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 LOADI X A 1 2 D STOREI X E INPUT OUTPUT JUMP X SKIPCOND C 5 6 9 8 Subroutine JNS X call and return JUMPI X HALT 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 Load Indirect: Use the value of X as the actural address of the data operand to load into the AC Store Indirect: Use the value of X as the actural address where the AC value is stored. 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: C = 00016: skip if AC is negative (b11b10 = 002) 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 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 AC IR InREG OutREG address 2 3 MBR Memory 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 “HELLO WORLD” 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 1E 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 LOADI 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 13 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 201016 101216 301016 201116 D01116 840016 900916 900E16 600016 101016 300F16 201016 900216 700016 000116 000016 000016 001316 004816 004516 004C16 004C16 004F16 000D16 005716 004F16 005216 004C16 004416 000016