I'm reading the book: "The Essential of Computer Organization and Architecture, Linda Null and Julia Lobur". On chapter 4 page 172 it is a example how the assembly language work with instruction but I cannot understand it. I cannot understand because there is not a good explanation for the number on the image.
Here is the image: http://postimg.org/image/6imlsa3t9/
Can anyone help me?
The chapter deals with the MARIE Assembler and its instructions. Look at the program in table 4.3. Assembly syntax:
Load 104
Add 105
Store 106
Halt
0023
FFE9
0000
and the opcodes in hexadecimal (7 16-bit values):
0x1104
0x3105
0x2106
0x7000
0x0023
0xFFE9
0x0000
The question is: how to translate assembly to opcodes.
1) We have an instruction Load X
which is number 1. This is the first hexadecimal number in the term or the first 4 bits of the 16-bit value. The rest (12 bits - 3 hexnumbers) contains the 'X' - in this case '104'. The whole term is 1104
.
2) For the second line we have to search anything appropriate with ADD in the instruction set and find ADD X
(hexnumber 3). '3' & X => 3105
.
3) For the third line we connect STORE X
(2) with '106' and get 2106
.
4) The fourth line stops the program with HALT
(7). Nothing else, so the 16-bit-value is 7000. After the HALT there is no program left, but data.
HTH