Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
MARIE Assembly Language Type of Instructions Arithmetic Data Transfer I/O Branch Mnemonic Hex Opcode 3 4 B ADD X SUBT X ADDI X CLEAR LOAD X STORE X INPUT OUTPUT JUMP X SKIPCOND C Description Add the contents of address X to AC Subtract the contents of address X from the AC Add Indirect: Use the value at X as the actual address of the data operand to add to AC Put all zeros in the AC Load the contents of address X into AC Store the contents of AC at address X Input a value from the keyboard into AC Output the value in AC to the display Unconditional branch to X by loading the value of X into PC Skip the next instruction based on the condition, C: (b11b10 = 002) C = 00016: skip if AC is negative C = 40016: skip if the AC = 0 (b11b10 = 012) C = 80016: skip if the AC is positive (b11b10 = 102) Jump-and-Store: Store the PC at address X and jump to X+1 Use the value at X as the address to jump to Terminate the program A 1 2 5 6 9 8 Subroutine JNS X call and return JUMPI X HALT 0 C 7 MARIE Instruction Format 15 12 11 10 Opcode 0 Address (or Condition) Revised Figure 4.9 Datapath in MARIE 1 MAR 2 PC 3 4 7 5 6 16 1 2 3 MBR AC IR InREG OutREG Memory address ALU data/instr. Address 0 1 2 3 16-bits 4 2 7 5 6 Input Device Output Device 12 -1 MARIE Assembly Language Example 1: RESULT = X + Y - Z Address Label Assembly Language Machine Language 0 LOAD X 100616 1 ADD Y 300716 2 SUBT Z 400816 3 STORE RESULT 200916 4 OUTPUT 600016 5 HALT 700016 6 X, DEC 10 000A16 7 Y, DEC 20 001416 8 Z, DEC 5 000516 9 RESULT, DEC 0 000016 MARIE Assembly Language Example 2: Print null terminated string to output HLL: index = 0 while str[index] != 0 do output str[index] index = index + 1 end while Address 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1 1F Label WHILE, DO, END_WHILE, ONE, INDEX, ADDR, STR_BASE, STR, NULL, Assembly Language CLEAR STORE INDEX LOAD STR_BASE ADD INDEX STORE ADDR CLEAR ADDI ADDR SKIPCOND 400 JUMP DO JUMP END_WHILE OUTPUT LOAD INDEX ADD ONE STORE INDEX JUMP WHILE HALT DEC 1 DEC 0 HEX 0 HEX 14 DEC 72 / H DEC 69 / E DEC 76 / L DEC 76 / L DEC 79 / O DEC 13 /carriage return DEC 87 / W DEC 79 / O DEC 82 / R DEC 76 / L DEC 68 / D DEC 0 / NULL CHAR Machine Language A00016 201116 101316 301116 201216 A00016 B01216 840016 900A16 900F16 600016 101116 301016 201116 900216 700016 000116 000016 000016 001416 004816 004516 004C16 004C16 004F16 000D16 005716 004F16 005216 004C16 004416 000016