Ten slotte zijn hier nog enkele voorbeelden waarmee het instructie geheugen geïnitialiseerd kan worden. Let er op dat je de generic map zo aanpast dat de simulator een geldig pad heeft naar deze files op jouw computer/laptop.
// predefined symbols
// A: Address Register.
// D: Data Register.
// M: Refers to the register in Main Memory whose address is currently stored in A.
// SP: RAM address 0.
// LCL: RAM address 1.
// ARG: RAM address 2.
// THIS: RAM address 3.
// THAT: RAM address 4.
// R0-R15: Addresses of 16 RAM Registers, mapped from 0 to 15.
// SCREEN: Base address of the Screen Map in Main Memory, which is equal to 16384.
// KBD: Keyboard Register address in Main Memory, which is equal to 24576.
//
// set the maximum value to which the sequence has to go
@10000
D=A
@R15
M=D
// init
@R1
M=0
@R2
M=1
(START_L)
// start loop phase 1
D=0
@R1
D=D+M
@R2
D=D+M
@R3
M=D
// check if MAX is reached
@R15
D=D-M
@INFINITE_LOOP
D;JGE
// start loop phase 2
D=0
@R2
D=D+M
@R3
D=D+M
@R1
M=D
// check if MAX is reached
@R15
D=D-M
@INFINITE_LOOP
D;JGE
// start loop phase 3
D=0
@R3
D=D+M
@R1
D=D+M
@R2
M=D
// check if MAX is reached
@R15
D=D-M
@INFINITE_LOOP
D;JGE
@START_L
0;JMP
// infinite loop to catch end
(INFINITE_LOOP)
@INFINITE_LOOP
0;JMP
0010011100010000 - 0x2710
1110110000010000 - 0xEC10
0000000000001111 - 0x000F
1110001100001000 - 0xE308
0000000000000001 - 0x0001
1110101010001000 - 0xEA88
0000000000000010 - 0x0002
1110111111001000 - 0xEFC8
1110101010010000 - 0xEA90
0000000000000001 - 0x0001
1111000010010000 - 0xF090
0000000000000010 - 0x0002
1111000010010000 - 0xF090
0000000000000011 - 0x0003
1110001100001000 - 0xE308
0000000000001111 - 0x000F
1111010011010000 - 0xF4D0
0000000000101011 - 0x002B
1110001100000011 - 0xE303
1110101010010000 - 0xEA90
0000000000000010 - 0x0002
1111000010010000 - 0xF090
0000000000000011 - 0x0003
1111000010010000 - 0xF090
0000000000000001 - 0x0001
1110001100001000 - 0xE308
0000000000001111 - 0x000F
1111010011010000 - 0xF4D0
0000000000101011 - 0x002B
1110001100000011 - 0xE303
1110101010010000 - 0xEA90
0000000000000011 - 0x0003
1111000010010000 - 0xF090
0000000000000001 - 0x0001
1111000010010000 - 0xF090
0000000000000010 - 0x0002
1110001100001000 - 0xE308
0000000000001111 - 0x000F
1111010011010000 - 0xF4D0
0000000000101011 - 0x002B
1110001100000011 - 0xE303
0000000000001000 - 0x0008
1110101010000111 - 0xEA87
0000000000101011 - 0x002B
1110101010000111 - 0xEA87