Add32							Sub32	

00	LD a0, address low		[0x010000]
01	LD a1, address high		[0x010001]
02	LD a2, address low		[0x010002]
03	LD a3, address high		[0x010003]
04	ADD a0,a2					SUB a0,a2
05	ADDC a1,a3					SUBC a1,a3
06	ST a0, address low		[0x010004]
07	ST a1, address high		[0x010005]


Mul8

00	LDS a0	[0x10]	5010	# load multiplicand
01	LDS a1	[0x11]	5111	# load multiplier
02	OR a3, 8	cb08	# set counter to 8
03	SUB a3, 1	9b01	# subtract 1 from counter
04	JMPPN 	[0x0c]	2a0c	# if counter < 0, go to output
05	SHR a1		a112	# shift multiplier to the right
06	JMPPC	[0x09]	2c09	# if carry == 1, go to Add()
07	SHL a0		a010	# else shift left multiplicand
08	JMPP	[0x03]	2803	# and go decrement the counter
09	ADD a2, a0	8200	# Add(): add multiplicand to running sum
0a	SHL a0		a010	# and shift left multiplicand
0b	JMPP	[0x03]	2803	# and go decrement the counter
0c	MOV Out, a2	1b40	# output: move a2 contents to the output register
0d	HLT		0000	# stop the clock
0e
0f
10	multiplicand
11	multiplier



squares256

00	AND a4, 0 	ac00	# START, load 0 to a4
01	LDi a7	(0x0100)4700	# load immediate constant 0x0100 for memoffset
02		0x0100	0100	# immediate constant
03	MOV a0, a4	1080	# MUL a4,a4
04	MOV a1, a4	1180
05	ZERO a3		8310
06	OR a3, 8	cb08
07	SUB a3, 1	9b01
08	JMPPN	[0x0f]	2a10	# if counter < 0, go to save to mem
09	SHR a1		a112
0a	JMPPC	[0x0d]	2c0d	# if carry == 1, go to Add()
0b	SHL a0		a010
0c	JMPP	[0x07]	2807	# shl multiplicand
0d	ADD a2, a0	8200
0e	SHL a0		a010
0f	JMPP	[0x07]	2807	# MUL end
10	MOV a5, a4	1580	# copy i to a5 reg
11	ADD a5, a7	85e0	# calculating memoffset
12	ST a2	[a5]	7aa0	# store to address with memoffset in a5
13	MOV a5,a4	1580	# copy i value
14	SUB a5, 0xff	9dff	# check if bigger
15	JMPPZ	[0x19]	2919	# if i is bigger than 255, jump to displaying
16	ADD a4, 1	8c01	# else increment i
17	ZERO a2		8210	# clear a2 register
18	JMPP	[0x03]	2803	# and calculate next i*i
19	AND a4, 0	ac00	# Displaying cycle start, clearing i
1a	LDi a6	(0x0100)4600	# load immediate constant 0x0100 for memoffset
1b		0x0100	0100	# immediate constant
1c	MOV a5, a4	1580	# 
1d	ADD a5, a6	85c0
1e	LD a0	[a5]	70a0	# load a0 register from memory address in reg a5
1f	MOV Out, a0	1b00	# copy a0 register to output register
20	MOV a5, a4	1580
21	SUB a5, 0xff	9dff
22	JMPPZ	[0x25]	2925	# if i is bigger than 255, go to end
23	ADD a4, 1	8c01	# else increment i
24	JMPP	[0x1c]	281c	# and go to display the next value
25	HLT		0000	# End


Load/store testing

00	OR a0, 0xf3			c8f3	# placing value 0xf3 into a0 register
01	ST a0		[0x000100]	6800	# store value a0 at address 0x000100	
			0x0100		0100	# low 16 bit of address
03	OR a1, 0xf			c90f	# placing value 0xf into a1 register	
04	ADD a1, a0			8100	# adding a0 to a1, save to a1
05	ST a1		[a1]		7920	# store the value in a1 to the address with low bits in a1
06	LDi a4				4400	# load immediate value into a4 register
07			0xf731		f731	# immediate value for a4
08	LDs a5		[0x10]		5510	# load a5 with value at address with low 8 bits set to 0x10
09	LDadd a6	[0x000100]	6600	# load a6 with value at address 0x000102 (where a1 was stored)	
0a			0x0100		0100	# low 16 bits of address
0b	LD a7		[a1]		7720	# load value from memory at address with low 16 bits in a1 register
0c					0000
0d					0000	
0e					0000
0f					0000
10	0x6666				6666	# value for load to a5	


00	OR a0, 0x07	c807
01	OR a1, 0x0f	c90f
02	OR a2, 0x1f	ca1f
03	OR a3, 0x3f	cb3f
04	OR a7, 0xff	cfff
05	ADDi a7, 0x01	8f01
06	ST a0	[a7]	78e0
07	ADDi a7, 0x01	8f01
08	ST a1	[a7]	79e0
09	ADDi a7, 0x01	8f01
0a	ST a2	[a7]	7ae0
0b	ADDi a7, 0x01	8f01
0c	ST a3	[a7]	7be0
0d	LD a0	[a7]	70e0
0e	SUBi a7, 1	9f01
0f	LD a1	[a7]	71e0
10	SUBi a7, 1	9f01
11	LD a2	[a7]	72e0
12	SUBi a7, 1	9f01
13	LD a3	[a7]	73e0
14	HLT		0000


SP test

00	ORi a0, 0xff	c8ff	# SP initial value calculation
01	ADDi a0, 0xff	88ff
02	ADDi a0, 0x00	8800
03	PUSH a7		0f00	# initializing SP, calculated value discarded, empty push to point SP to 0xffffff
04	ZERO a0		8010	# start of pushing
05	OR a0, 0x0f	c80f
06	PUSH a0		0800
07	SUBi a0, 0x01	9801
08	JPPZ	[0x0a]	290a	# if a0 = 0, jump to popping and showing	
09	JPP	[0x06]	2806	# else push next
0a	ORi a1, 0x0f	c90f
0b	POP a0 		0810	# start of popping and showing
0c	MOV Out, a0	1b00	# showing stack contents
0d	SUBi a1, 0x01	9901
0e	JPPZ	[0x10]	2910	# if a1 = 0, jump to end
0f	JPP	[0x0b]	280b	# else pop the next
10	HLT		0000









