|
|
Common Errors
Got a bug? This is a list of common errors that might help solve your problem
- Pushes and Pops don't match or are in the incorrect sequence.
I cannot even begin to count the number of times I have seen this
push ax
push bx
...
then the programmer does a cut and paste, then rename push to pop resulting in
pop ax
pop bx
...
You need to reverse the order as well!
of course a simple error is easy to miss like the following
...
push ax
push bx
cmp ax, bx
je next
pop ax
jmp done
next:
pop bx
pop ax
done:
ret
Notice that if we branch we will pop both ax and bx, but if we don't branch then one pop is missed. When we return, think about what is on the stack. If you need to, draw a picture showing the stack as you enter this procedure and as you execute through it. I will be doing an example like this on the board in class.
- A fairly common error that occurs more often the night before a project is due is the following.
mov ah, 09
mov bx, SEG myString
mov dx, bx
mov dx, OFFSET myString
int 21h
What's wrong with this block of code to print a string? Well, the use of DX twice in a row should look a little suspicious. What we meant to type was mov ds, bx NOT DX! Reading though the code is usually the fastest way to catch errors like this. Take a break if you have been working for a while and come back to your code - usually you will catch it quickly. Sometimes an extra pair of eyes will be necessary. Drop by my office hours or ask a friend to look over your code if you are really stuck.
If you have a common error you think might benefit the class, please let me know - write up the description and email it to me. I will post it for everyone else.
Last Modified: January 22nd, 1999 - Barry E. Mapen
|