Please fix this code it is supposed to display CS 220 with pixels at the center of the screen for the CPU Emulator in Nand2Tetris: CS220.ASM===================================================================================== @16640 // Load value 16640 into A register- starting pointD=A // Store value of A register (16640) in D register@address // Access memory location of address registerM=D // Store value of D into address register@count // load count memory locationM=0 // Initialize count value to 0 (LOOP) @6 // Load value 6 into A register ( total number of characters to write)D=A // Store value of A register (6) in D register@count // Access count memory locationD=M-D // Subtract current count value from 6@ENDLOOP // Jump to ENDLOOP if count >= 6D;JGE // If D >= 0 (count is greater than or equal to 6), jump to ENDLOOP @67 // load the ASCII code for 'C' (67) into the A registerD=A // store the ASCII value for 'C' in D register@address // Access memory location of addressA=M // Access the address memory locationM=D // Store value of D (ASCII of 'C') into screen memory location@address // Access memory location of address registerM=M+1 // Increment address register to next memory location @83 // Load ASCII code for 'S' (83) into A registerD=A // Store ASCII value for 'S' in D register@address // Access memory location of addressA=M // Access address memory locationM=D // Store value of D (ASCII of 'S') into the screen memory location@address // Accessmemory location of address registerM=M+1 // Increment address register to the next memory location @32 // Load ASCII code for space (32) into the A registerD=A // Store ASCII value for space in D register@address // Access memory location of addressA=M // Acces address memory locationM=D // Store the value of D (ASCII of space) into the screen memory location@address // Access the memory location of address registerM=M+1 // Increment the address register to the next memory location @50 // Load the ASCII code for '2' (50) into the A registerD=A // Store ASCII value for '2' in D register@address // Access memory location of addressA=M // Access address memory locationM=D // Store value of D (ASCII of '2') into screen memory location@address // Access memory location of address registerM=M+1 // Increment address register to the next memory location @50 // Load ASCII code for '2' ( 50) into the A registerD=A // Store ASCII value for '2 in D register@address // access memory location of addressA=M // Access address memory locationM=D // Store value of D (ASCII of '2') into the screen memory location@address // Access memory location of address registerM=M+1 // Increment address register to the next memory location @48 // Load ASCII code for '0' (48) into the A registerD=A // Store ASCII value for '0' in D register@address // Access memory location of addressA=M // Access address memory locationM=D // Store value of D (ASCII of '0') into the screen memory location@address // Access the memory location of address registerM=M+1 // Increment address register to the next memory location @END // Jump to th END label0;JMP // Infinite loop to stop program execution (END) // End of the program
Please fix this code it is supposed to display CS 220 with pixels at the center of the screen for the CPU Emulator in Nand2Tetris:
CS220.ASM
=====================================================================================
@16640 // Load value 16640 into A register- starting point
D=A // Store value of A register (16640) in D register
@address // Access memory location of address register
M=D // Store value of D into address register
@count // load count memory location
M=0 // Initialize count value to 0
(LOOP)
@6 // Load value 6 into A register ( total number of characters to write)
D=A // Store value of A register (6) in D register
@count // Access count memory location
D=M-D // Subtract current count value from 6
@ENDLOOP // Jump to ENDLOOP if count >= 6
D;JGE // If D >= 0 (count is greater than or equal to 6), jump to ENDLOOP
@67 // load the ASCII code for 'C' (67) into the A register
D=A // store the ASCII value for 'C' in D register
@address // Access memory location of address
A=M // Access the address memory location
M=D // Store value of D (ASCII of 'C') into screen memory location
@address // Access memory location of address register
M=M+1 // Increment address register to next memory location
@83 // Load ASCII code for 'S' (83) into A register
D=A // Store ASCII value for 'S' in D register
@address // Access memory location of address
A=M // Access address memory location
M=D // Store value of D (ASCII of 'S') into the screen memory location
@address // Accessmemory location of address register
M=M+1 // Increment address register to the next memory location
@32 // Load ASCII code for space (32) into the A register
D=A // Store ASCII value for space in D register
@address // Access memory location of address
A=M // Acces address memory location
M=D // Store the value of D (ASCII of space) into the screen memory location
@address // Access the memory location of address register
M=M+1 // Increment the address register to the next memory location
@50 // Load the ASCII code for '2' (50) into the A register
D=A // Store ASCII value for '2' in D register
@address // Access memory location of address
A=M // Access address memory location
M=D // Store value of D (ASCII of '2') into screen memory location
@address // Access memory location of address register
M=M+1 // Increment address register to the next memory location
@50 // Load ASCII code for '2' ( 50) into the A register
D=A // Store ASCII value for '2 in D register
@address // access memory location of address
A=M // Access address memory location
M=D // Store value of D (ASCII of '2') into the screen memory location
@address // Access memory location of address register
M=M+1 // Increment address register to the next memory location
@48 // Load ASCII code for '0' (48) into the A register
D=A // Store ASCII value for '0' in D register
@address // Access memory location of address
A=M // Access address memory location
M=D // Store value of D (ASCII of '0') into the screen memory location
@address // Access the memory location of address register
M=M+1 // Increment address register to the next memory location
@END // Jump to th END label
0;JMP // Infinite loop to stop program execution
(END) // End of the program
Step by step
Solved in 2 steps