Skip to content

Instantly share code, notes, and snippets.

View humberto-ortiz's full-sized avatar

Humberto Ortiz-Zuazaga humberto-ortiz

View GitHub Profile
@humberto-ortiz
humberto-ortiz / 16-bit-fib.bin
Created November 14, 2013 14:04
Machine language for 16-bit Fibonacci program for simple CPU.
v2.0 raw
100 200 8209 0300 83fe 0400 8401 3410 8101 3410
8101 2413 8301 2513 0645 3610 83ff 710 87f7 b7f7
@humberto-ortiz
humberto-ortiz / 16-bit-fib.asm
Last active December 28, 2015 07:49
Fibonacci for simple 16 bit CPU
# Compute 10 elements of fibonacci sequence
# Copyright 2011, 2013 - Humberto Ortiz-Zuazaga <humberto.ortiz@upr.edu>
# Released under the GNU General Public Licence v3 or later
# See http://www.gnu.org/licenses/gpl.html
# Uses the 16-bit assembly we made up for our less broken cpu.
# http://www.hpcf.upr.edu/~humberto/courses/arch2013/less-broken-cpu.html
add $1, $0, $0 # $1 is base
add $2, $0, $0
@humberto-ortiz
humberto-ortiz / repr.py
Created September 17, 2012 20:50
Functions to read and write numbers represented in various bases
# bases.py - Copyright 2010, Humberto Ortiz-Zuazaga humberto.ortiz@upr.edu
# Functions to read and write numbers represented in various bases
digits = "0123456789ABCDEF" # digits for bases 2 - 16
def readnum(numstring, base):
"Read a string of digits in base BASE, and compute the correct decimal value"
value = 0
for i in range(len(numstring)):
value = value * base
@humberto-ortiz
humberto-ortiz / simple.asm
Last active October 10, 2015 16:08
A full program for QtSPIM, adds two integers, prints the result, and returns.
# simple sum - add a and b, store in c, print c, then return
# Copyright 2011, 2013 - Humberto Ortiz-Zuazaga <humberto.ortiz@upr.edu>
# Released under the GNU General Public Licence v3 or later
# See http://www.gnu.org/licenses/gpl.html
.data
vara: .word 0
varb: .word 0
varc: .word 0
.text