Skip to content

Instantly share code, notes, and snippets.

View castleberrysam's full-sized avatar

Sam Castleberry castleberrysam

View GitHub Profile
All registers are 16 bits and are initialized to all zeros.
Registers: pc, sp, fp, ax, bx, cx, dx, ex
pc (000): program counter
sp (001): stack pointer
fp (010): frame pointer
ax (011): general purpose A
bx (100): general purpose B
cx (101): general purpose C
dx (110): general purpose D
ex (111): general purpose E
uint16_t fibonacci(uint16_t n)
{
uint16_t first = 1;
uint16_t second = 1;
while(n > 1) {
uint16_t tmp = first + second;
second = first;
first = tmp;
(movl %sp #xff)
(movh %sp #xff)
(movl %ax 7)
(movh %ax 0)
(mov (@+ %sp 0) %ax)
(add %sp -1)
(movl %ax 19)
(.macro movx)
(movl $1 (logand $2 #xff))
(movh $1 (ash $2 -8))
(.endmacro)
(.print "Testing the .print macro!\n")
(movx :sp #xffff)
(.macro push-reg)
What is I2C?
- Communication protocol
- Two wires (SDA, SCL) also needs GND
- Serial, data is transmitted one bit at a time
- Half duplex, one device talks at a time
- Synchronous, must receive response before moving on
- Master/slave, master controls clock and who can talk
- 1 byte word size, every ninth bit contains ACK or NACK
- 100kb/s baud rate, but it allows slave to stretch the clock by pulling SCL low
- SDA can only change when SCL is low (except start/stop)
Instruction Set:
PSH C push a constant onto the stack
POP N remove N values from the top of the stack
POP pop value N, POP N
STO N pop value, store into Nth slot down in the stack
STO pop value N, STO N
RCL N push value in Nth slot down in the stack
RCL pop value N, RCL N
AND C logical AND C with the top value
AND logical AND the top two values
acl 2.2.52-2
adwaita-icon-theme 3.18.0-1
alleyoop 0.9.8-3
alsa-lib 1.1.0-1
alsa-plugins 1.1.0-1
archlinux-keyring 20160123-1
at-spi2-atk 2.18.1-1
at-spi2-core 2.18.3-1
atk 2.18.0-1
attr 2.4.47-1