Assembly language, don't understand the instruction codes and memory locations

258 views Asked by At

I'm studying for a test in my digital design class and I don't understand some things. Here is the worksheet with the answers on it,enter image description here

  1. I understand the PC address for each instruction. What I don't understand is on b, where it says where does the branch jump to, which instruction does the 68hc12 fetch and execute after the branch. I see 080B 20 F8, but what does that mean exactly, like 080B is the slot in memory where the instruction is held but what does the 20 F8 after mean? also I don't quite understand A in part C, any help would be awesome.
1

There are 1 answers

5
Peter Cordes On

A) explains that 20 F8 is the raw machine code for bra loop, and that it's not shown for the other instructions.

Apparently you're supposed to know enough about the machine-code format to figure out where that branches to.

I don't know 68HC12, but from experience with other ISAs (like x86), I assume 0x20 is the opcode and 0xF8 is a signed 2's complement relative displacement, probably relative to the end of the branch instruction.

Oh, yes the solution written in for part C confirms that. But 0x080D + 0xF8 only works if there's no carry from the low byte to high byte. Unless 68hc12 displacements are weird or there's segmentation, you have to sign extend that before adding, so it's 0x080D + 0xFFF8.