What is the difference between a JMP (“jump”) instruction and a CALL (“call”) instruction? Where might each type of branching command be used? Hint: one of these is used to execute a subroutine.
A JMP instruction simply tells the microprocessor to “jump” to a specified address. A CALL instruction similarly redirects program flow to a specified address, but remembers its place so the program may “return” where it left off.
Discuss the concept of a subroutine with your students, and how subroutines economize program size.
An important feature of microprocessors is the use of flag registers. What, exactly, is a “flag”, and what are they used for in microprocessor programming? Identify some common machine-language commands that set flags, and some common commands that read flags.
Flags are single-bit registers in a microprocessor set according to the results of an operation. Arithmetic and logical operations are common examples of commands that set flags. Conditional operations such as “Jump if Zero” are based on flag status: that is, the status of certain flags dictate what a conditional operation will do.
When I began learning microprocessor programming, I wondered how conditional operations such as JZ “knew” whether to jump or not. It was apparent from inspection of various programs that these conditional operations based their “decision” on the command immediately preceding, but I had no idea how this communicative link was made. Once I researched flags, though, it all made sense.
Published under the terms and conditions of the Creative Commons Attribution License
In Partnership with NXP Semiconductors
by Jeff Child
by Jake Hertz