简体   繁体   中英

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

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, 在此处输入图片说明

  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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM