Computer Systems Org I - Prof. Grishman

Using the LC-3 simulator

To do for Thursday (Sept. 20):  Download the LC-3 simulator and the LC-3 lab manual from the textbook web site

To enter and run an LC-3 program,
  1. write the program out in some easy-to-read form
  2. convert the progrma to binary
  3.  enter the program using LC3Edit
    note:  the first line specifies where in memory to start loading the programI
  4. save the program
  5. do 'convert base 2' operation in LC3Edit, producing an .obj file
  6. start the LC3 simulator
  7. load the program (the .obj file you just created)
  8. step through the program, observing the registers and memory change
A simple program for B = A + 7 (loaded starting at location 0)

0000000000000000  ; load program starting at 0
0101000000100000  ; AND  R0, R0, 0  -- R0 <- 0
0110001000000101  ; LDR  R1, R0, 5  -- R1 <- A
0001001001100111  ; ADD  R1, R1, 7  -- R1 <- R1 + 7
0111001000000110  ; STR  R1, R0, 6  -- B  <- R1
0000000000000000  ; --
0000000000000001  ; A
0000000000000000  ; B

A version (using LD and SR) which can load starting at location 3000

0011000000000000  ; load program starting at x3000
0101000000100000  ; AND  R0, R0, 0  -- R0 <- 0
0010001000000011  ; LD   R1, 3      -- R1 <- A
0001001001100111  ; ADD  R1, R1, 7  -- R1 <- R1 + 7
0011001000000010  ; ST   R1, 2      -- B  <- R1
0000000000000000  ; --
0000000000000001  ; A
0000000000000000  ; B