4. Assembler WS 1
Assignments Only
-
D=D+23
-
RAM[100] <- 0
-
RAM[100] <- 17
-
RAM[100] <- RAM[200]
-
RAM[3] <- RAM[3] - 15
-
RAM[3] <- RAM[4] + 1
-
A=A+3
-
RAM[2] <- RAM[0] + RAM[1] + 17
-
After this code runs, what is D? What values are in RAM?
@74 D=A @19 M=D M=M+1 @18 M=A A=A+1 D=M+A
-
Suppose at the start we have RAM[0]=10 and RAM[1]=20. After executing the code below, what valus are in A? RAM?
@0 M=M+1 @1 M=M+1
Jumps and Symbolic Labels
- goto 50
- if D==0, then goto 112
- if D<9, then goto 507
- if RAM[12]>0 then goto 50
- goto FINI
- if sum>0 goto END
- Write an infinite loop that works anywhere in your program.
Variables
A variable is a lowercase symbolic label. Variables are assigned to consecutive memory locations in the order the variables appear in the program. The first variable is assigned to RAM[16].
-
Give the memory location and value for each variable in this code.
@1 D=A @w M=D M=M+1 @19 D=A-1 @y M=D
-
What memory locations are represented by x, y, and z in this code? What values do they have after the code is executed?
@120 D=A @x M=D @10 D=D+A @z M=D @70 A=-A D=D+A @y M=D
Further problems
-
Write code that fills in every memory location from 256 through 511 with the number 15.
-
Write code that keeps checking 0x6000 (KBD) until the value is 128 (representing the enter key). Set memory location 50 to 0 before your first check and set memory location 50 to -1 after the enter key is pressed.