Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A made-up assembler turns each instruction into 8 bits: a 4-bit operation code followed by the address as a 4-bit binary number. The operation codes are LDA , ADD and STO .
The program is LDA 7, ADD 9, STO 10.
Machine code is binary and is the language of the processor. Assembly language is low level: it uses mnemonics such as ADD, and an assembler translates it into machine code. A high-level language is easier to read, write and debug and is machine independent. A low-level language can manipulate the hardware directly.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. LDA 7. then : 0001 0111.
Step 2. ADD 9. then : 0010 1001.
Step 3. STO 10. then : 0100 1010.
Step 4. ADD 9 in denary. has 1s in the places , and : .
Step 5. The bits. instructions of bits: bits.
Answer: (a) 0001 0111, 0010 1001, 0100 1010. (b) . (c) bits.
Check. The assembler does a fixed swap for each mnemonic. That is why each line of assembly language matches one machine code instruction.
Log in to join the discussion.
Loading…