11/7/04
A student writes:
I got to thinking about a specific subject you touched on in class. You mentioned that there were three kinds of "errors" that could occur during assembly of a program: assembly time, link time, and run time. The reference for the run-time error was that of an infinite loop. What I was wondering is, will the ISA/assembler (whichever sends you the run-time error) allow you to have an infinite loop, if that was the intention? Thank you for you time. << name withheld to protect the thinker >>
Yup, errors can be detected at assemble time (like
compile time), link time, and run time.
Assemble time (also compile time) errors are those wherein the computer
can not make sense out of what you are saying. Like ADD R3,R3,#50. You
are asking the assembler to code the decimal integer 50 with 5 bits. The
assembler knows that with the 5 bits it has available, it can only use
integers as high as +15 or as low as -16. Or, if instead of ADD, you said
ADND. No such opcode! Assembler does not know what you mean. In
English, suppose you said to someone, "The cup of steak breadbasket
broken, please." What do you expect the person to do? Each word is fine,
but the collection makes no sense as a sentence. Similarly with assembly
time errors. Something in the collection prevents the Assembler from
translating into legitimate LC-3 0s and 1s.
Link time errors are those that get picked up by the linker when it
combines different modules into one executable image. the most common
example is a symbol identified as .EXTERNAL in the module where it is used
but there is no label with that symbol in the module. The assembler says,
"Fine, the address of that symbol will be easy to see at link time when
the linker has all the modules that it is combining in one executable
image. An example is one module:
and another module:
As long as the second module is present, the Linker can figure out
bits[8:0] of the ST instruction. If the second module was not there, the
Linker would not know what offset is required to bridge the distance from
the ST to wherever HORSE is.
The third type of error, which the < A one-instruction infinite loop! The Assembler sees that there is no
reason it can't assemble it, so it does:
At run time, if PC ever contains the address of this instruction, you
are dead. ...Infinite loop! Do you see why?
But there are less obvious ones. And some of you have written to me
already about programs that assemble correctly but don't produce the right
answer.
Suppose you wanted to increment R2, and you told the assembler ADD
R2,R2,#-1.
The assembler would assemble this instruction into:
Perfectly good instruction ----> perfectly good 0s and 1s. But at run
time, the computer would subtract 1 rather than add 1. So much for that
algorithm being carried out correctly.
OK?
Yale Patt .EXTERNAL HORSE
...
...
ST R3, HORSE
...
...
...
HORSE .BLKW #1
ADNAUSEUM BRnzp ADNAUSEUM
0000 111 111111111
0001 010 010 1 11111