Computer Science 210 Computer Organization Machine Language Instructions

  • Slides: 12
Download presentation
Computer Science 210 Computer Organization Machine Language Instructions: Computation

Computer Science 210 Computer Organization Machine Language Instructions: Computation

Types of Instructions • Operate (computation): NOT, AND, ADD • Data movement: LD, LDR,

Types of Instructions • Operate (computation): NOT, AND, ADD • Data movement: LD, LDR, LDI, LEA, STR, STI • Control: BR, JMP, JSRR, RET, RTI, TRAP

Bitwise NOT 15 14 13 12 11 10 NOT 9 8 Dst 7 6

Bitwise NOT 15 14 13 12 11 10 NOT 9 8 Dst 7 6 Src 5 4 3 2 1 0 1 1 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 1 1 1 1 0 0 1 RDst NOT RSrc R 3 NOT R 5

Data Path for NOT 15 14 13 12 11 10 NOT Dst 9 8

Data Path for NOT 15 14 13 12 11 10 NOT Dst 9 8 7 Src 6 5 4 3 2 1 0 1 1 1 RDst NOT RSrc

Bitwise AND (2 flavors) 15 14 13 12 11 10 AND 9 8 Dst

Bitwise AND (2 flavors) 15 14 13 12 11 10 AND 9 8 Dst 15 14 13 12 11 10 AND 7 6 Src 1 9 8 Dst 7 6 Src 1 5 4 3 0 0 0 5 4 3 1 2 1 0 RDst RSrc 1 AND RSrc 2 2 1 0 RDst RSrc 1 AND Data imm 5 Data is the sign-extend of imm 5 15 14 13 12 11 10 0 1 0 0 9 8 7 6 5 4 3 2 1 0 0 1 1 0 0 0 Clear R 1

ADD (2 flavors) 15 14 13 12 11 10 ADD 9 8 Dst 15

ADD (2 flavors) 15 14 13 12 11 10 ADD 9 8 Dst 15 14 13 12 11 10 ADD 7 6 Src 1 9 8 Dst 7 6 Src 1 5 4 3 0 0 0 5 4 3 1 2 1 0 RDst RSrc 1 ADD RSrc 2 2 1 0 RDst RSrc 1 ADD Data imm 5 Data is the sign-extend of imm 5 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 0 0 Increment R 1

Data Path for AND/ADD (register mode) 15 14 13 12 11 10 AND 8

Data Path for AND/ADD (register mode) 15 14 13 12 11 10 AND 8 Dst 15 14 13 12 11 10 ADD 9 Dst 7 6 Src 1 9 8 7 Src 1 RDst RSrc 1 AND RSrc 2 RDst RSrc 1 ADD RSrc 2 6 5 4 3 0 0 0 2 1 0 Src 2 2 1 Src 2 0 bit means register mode 0

Data Path for AND/ADD (immediate mode) 15 14 13 12 11 10 AND 8

Data Path for AND/ADD (immediate mode) 15 14 13 12 11 10 AND 8 Dst 15 14 13 12 11 10 ADD 9 Dst 7 6 Src 1 9 8 7 Src 1 RDst RSrc 1 AND Data RDst RSrc 1 ADD Data 5 4 3 1 6 5 1 2 1 0 imm 5 4 3 2 imm 5 1 bit means immediate mode

Other Useful Operations • Decrement the contents of a given register • Copy the

Other Useful Operations • Decrement the contents of a given register • Copy the contents of RA to RB • Subtract RB from RA and store the result in RC

The LC-3 Simulator • Various versions, ours comes from U Texas • Supports assembly,

The LC-3 Simulator • Various versions, ours comes from U Texas • Supports assembly, loading of object files, and visualized execution • Next, Step, Finish, Continue, Stop • Can edit PC, registers, and memory

Using the Simulator • Run /opt/lc 3 tools/lc 3 sim-tk • Enter instructions starting

Using the Simulator • Run /opt/lc 3 tools/lc 3 sim-tk • Enter instructions starting at x 3000 • Set PC to x 3000, then Next or Continue

For Wednesday Memory access: load and store instructions

For Wednesday Memory access: load and store instructions