4. Assembler WS 1

Assignments Only

  1. D=D+23

  2. RAM[100] <- 0

  3. RAM[100] <- 17

  4. RAM[100] <- RAM[200]

  5. RAM[3] <- RAM[3] - 15

  6. RAM[3] <- RAM[4] + 1

  7. A=A+3

  8. RAM[2] <- RAM[0] + RAM[1] + 17

  9. 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
    
  10. 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

  1. goto 50
  2. if D==0, then goto 112
  3. if D<9, then goto 507
  4. if RAM[12]>0 then goto 50
  5. goto FINI
  6. if sum>0 goto END
  7. 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].

  1. 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
    
  2. 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

  1. Write code that fills in every memory location from 256 through 511 with the number 15.

  2. 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.

Last modified September 24, 2024: Added material for ch3,4. (3b2d093)