0
$\begingroup$

Some ISA's have instructions that are multiple words, such as the MOV instruction in x86. How does the program counter behave in that case, if the instruction loaded is more than one word? For example, the 5 byte MOV eax, 0x11223344 in x86, encoded as B8 44 33 22 11. In the case of that example, I would assume PC (EPI register in x86 if I understand right) is incremented by two (4 byte + 4 byte, two words, assuming word size is 4 byte. ) I tried to test it myself in this emulator , but it only increments by one. I assume emulator wrong. I ask broadly here because people here would likely know: How does the program counter behave (generally, across specific ISA's) if the instruction loaded is more than one word?

$\endgroup$
16
  • $\begingroup$ I'm not sure this is on-topic here. Any community votes? It might be appropriate for Stack Overflow. $\endgroup$
    – D.W.
    Commented Jul 18, 2022 at 22:56
  • $\begingroup$ Why would it not be on topic? $\endgroup$
    – user52174
    Commented Jul 18, 2022 at 23:49
  • $\begingroup$ Programming questions are off-topic here. See our help center. $\endgroup$
    – D.W.
    Commented Jul 18, 2022 at 23:50
  • $\begingroup$ Labelling this a "programming" question is a bit of a stretch, is it not? $\endgroup$
    – user52174
    Commented Jul 18, 2022 at 23:51
  • $\begingroup$ That's up to the community to vote on, but my understanding is that questions about the details of a specific programming language or assembly language are generally considered out of scope here. Such questions can be asked on Stack Overflow. $\endgroup$
    – D.W.
    Commented Jul 19, 2022 at 5:35

1 Answer 1

1
$\begingroup$

You have an instruction that is five bytes in size. After executing that instruction, what do you think where the next instruction is stored? Since the word size on a modern processor is 8 bytes, assume we have an instruction that is 11 bytes in size. Where do you think the next instruction is stored?

$\endgroup$
2
  • $\begingroup$ I assumed that the next was stored (if the instruction was larger than the word size) after the slots the instruction required. If it required two words, then after two. I state this in my question (I state where I think the next instruction is stored. ) But, now a user commented that the memory for instructions is addressed per-byte. And that the program counter would be incremented 5 times for 5 bytes. $\endgroup$
    – user52174
    Commented Jul 19, 2022 at 11:28
  • $\begingroup$ Think about it: If you increased the PC by 8 bytes, what good would a 5 byte instruction do you? You might as well fill it with 3 more bytes of information. $\endgroup$
    – gnasher729
    Commented Aug 18, 2022 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.