Presentation is loading. Please wait.

Presentation is loading. Please wait.

SSST: CS130 F. Hadziomerovic

Similar presentations


Presentation on theme: "SSST: CS130 F. Hadziomerovic"— Presentation transcript:

1 SSST: CS130 F. Hadziomerovic
Von Neumann Concept (cont.): Instructions (ISA): format, addressing modes Addressing modes: immediate (operand in instruction), register (reg in instruction, operand in register) Memory (memory address/offset in instruction, operand in memory): PC-relative, Base+offset, indirect. 11/22/2005 SSST: CS130 F. Hadziomerovic

2 SSST: CS130 F. Hadziomerovic
Computer Architecture: Computer Architecture (Data Path) around single bus, signals Ass#2 Question 3 Data Path: assume very simple computer with two registers A and B, that can perform operations below. A <- M[IR], B <- M[IR], A <- A + B, A <- A – B, M[IR] <- A Draw the necessary data path (around single bus architecture) to carry these operations by showing registers (including PC,IR, MAR, and MDR), adders, gates, etc. , data paths and control signals (with arrowheads not filled in). (25 points) r Memory w LDMAR MAR MDR LDMDR MDRon bus PCon IRon Aon PC LDIR IR LDA A B LDB inv invert ALU +1 11/22/2005 SSST: CS130 F. Hadziomerovic

3 Programming Machine language programming: LC-3 editor, LC-3 simulator
Midterm Question 5: Consider the program below: Translate the program to binary form (10 points). Interpret instructions in mnemonic form (10 points). What does the program do? (5 points) Address Content a. Binary b. Mnemonic x x54A AND R2, R2, #0 x3001 x14AA ADD R2, R2, #10 x3002 xE2FD LEA R1, x3100 x3003 xF TRAP IN x3004 x STR R0, R1, #0 x3005 x ADD R1, R1, #1 x3006 x14BF ADD R2, R2, # -1 x3007 x03FB BRp x3003 x3008 xF TRAP HALT c. Program stores 10 input characters into 10 memory locations starting with x3100. Question 5: Consider the program below: Translate the program to binary form (10 points). Interpret instructions in mnemonic form (10 points). What does the program do? (5 points) Address Content a. Binary b. Mnemonic x3000 x AND R1, R1, #0 x3001 x126A ADD R1, R1, #10 x3002 xE40D LEA R2, x3010 x3003 x LDR R0, R2, #0 x3004 xF TRAP OUT x3005 x14A ADD R2, R2, #1 x3006 x127F ADD R1, R1, #-1 x3007 x0BFB BRnp x3003 x3008 xF TRAP HALT c. Prints the ASCII content of 10 consecutive memory locations starting with x3010. 11/22/2005 SSST: CS130 F. Hadziomerovic

4 SSST: CS130 F. Hadziomerovic
Programming (cont.): Problem solving and structured programming: Example page 139 Common bugs and debugging Number of occurences (count): R2 <- 0 Input char from keyboard into R0: trap 23 Initialize pointer: R3 <- starting file address Get char from file: R1 <- M[R3] yes Prepare output: R0 <- R2 + x30 R1 ?= EOT no yes R0 ?= R1 Display char: trap 21 Incr.count R2<-R2+1 no halt: trap 25 Incr.point R3<-R3+1 11/22/2005 SSST: CS130 F. Hadziomerovic

5 SSST: CS130 F. Hadziomerovic
Mnemonic program that displays how many times the keyed character shows in a file X3000 AND R2,R2,#0 ; R2 < x x54A0 x3001 Trap x23 ; input char x xF023 x3002 LD R3, start file x x460E X3003 LDR R1,R3,#0 ; get char x x62C0 X3004 ADD R4, R1, #-4 ; ‘eot’ = 4 x x187C X3005 BRz x300D x x0407 X3006 NOT R1 x x927F X3007 ADD R1,R1,#1 x x1261 X3008 ADD R1, R1, R0 x x1240 x3009 BRnp, x300B x x0A01 x300A ADD R2,R2,#1 x300A x14A1 x300B ADD R3, R3,#1 x300B x16E1 x300C BRnzp x x300C x0FF6 x300D LD R0, x x300D x2004 x300E ADD R0, R0, R2 ; ASCII count x300E x1002 X300F TRAP x21 ; display R0 x300F xF021 X3010 TRAP x25 ; halt x xF025 X3011 start address of a file x x3013 X ; ASCII_offset x x0030 11/22/2005 SSST: CS130 F. Hadziomerovic


Download ppt "SSST: CS130 F. Hadziomerovic"

Similar presentations


Ads by Google