简体   繁体   中英

Value of Program Counter after jmp loop (Assembly)

I have this question in an assignment (quoted below), which I do not understand. I have tried Googling for more information on unconditional branches, goto's, jump loops, assembly language, but came with nothing.

Any type of help would be appreciated. I am still new to computer hardware. I know the answer shouldn't be too complicated. Thanks.

All instruction sets contain unconditional branches ("gotos"). The assembly-language syntax might be 'jmp loop', where 'loop' is the label on some instruction. When the program is running, each machine instruction is stored in memory, and hence has a machine address.

a) [8 marks] If the processor executes a 'jmp loop' instruction, and if the instruction that is labeled 'loop' lives at memory address 1,024, what is the value of PC after the 'jmp loop' instruction has completed but before the next instruction in program order has been fetched? In general, how do gotos alter program order?

The question pretty much gives itself away. From the text, the only memory address we know to even exist is 1,024, and that is indeed the answer.

More generally, a statement like

jmp loop

is conceptually the same as

mov ip, offset loop (not valid syntax, usually)

where ip is the instruction (or program) counter.

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