No Address Implied Mode

Instructions such as I NX (increment X), BRK (break), and TflY (transfer A to Y) need no address; they make no memory reference and are complete in themselves. Such instructions occupy one byte of memory.

We might say that such instructions have "no address." The precise term is "implied address," which seems to say that there is in fact an address but we do not need to state it.

Perhaps the word "implied" is used in this manner: an instruction such as I NX implies the use of the address register; and an instruction such as BRK implies the address of the machine language monitor. If so, there's an instruction that still defies this definition: NOP.

The Do-Nothing Instruction: NOP

NOP (no operation) is an instruction that does nothing. It affects no data registers or flags. When a NOP instruction is given, nothing happens and the processor continues to the next instruction. It seems inappropriate to me that we say that NOP has an implied address. It doesn't do anything; it doesn't have an address at all On the other hand, I suppose that logicians might say, "Yes, but it does nothing to the X register."

The NOP instruction, whose op code is $EA, is surprisingly useful. It's not simply that if you're a contract programmer getting paid by the byte you might be tempted to put a large number of NOP instructions into your program. NOP can serve two important program testing functions: taking out unwanted instructions, or leaving space for extra instructions.

It's not as easy to change a machine language program as it is to change a BASIC program. As you have seen, the instructions are placed in specific locations. If we wish to eliminate an instruction, we must either move all the following instructions down or fill in the space with NOP instructions If we move the instructions, we may need to correct some of the addresses.

Examine the following code:

If we decide to eliminate the instruction at 0352 (STA $1234), we must remove all three bytes. So we place code $E A in locations D352, D353, and 0354

Suppose we are testing a moderately large program Most programs will break into distinct "modules," each of which does a specific job. One module might clear a portion of memory to zero, another might do a calculation, and so on. When we are checking out this program, it might be wise to look at each module as it runs

In this case, we might deliberately code a BRK (break) command between each program module. The program will start to run, and then it will break to the machine language monitor. Within the monitor, we can examine memory to ensure that this module has done the job as we planned it. When we are satisfied, we can start the next module using the . G command. In this way, we can have tight testing control over our program.

That's all very well, but when we have finished testing our program and are satisfied that it runs correctly, we don't want the BRK instructions there That's easy to fix. We replace the BRK codes ($□□) with NOP's ($E A), and the program will run through to the end

If we are writing a program and suspect that we may need to insert one or two extra instructions within a certain area of the code, we can put a number of NOP instructions there The space will be available for use when we need it.

0 0

Post a comment

  • Receive news updates via email from this site