how to easily debug you code!
Posted: Fri Aug 09, 2002 6:57 pm
I was looking at the newsgroups link on the www.osdev.com website and summbled on to a sure fire way to easily debug your code. I though alot of people might want to know how to do this.
After every one or more lines of code, add a message to the code.
If you have ten messages, them you have ten numbers.
Put all ten messages in the code and then run it.
If you have ten messages and you only see 5 on the screen, then you know theres a problem between line 5 and the rest of your messages.
example:
[org 0x7c00]
start:
xor ax,ax
mov ax,cs
mov si,one
call print
mov es,ax
cli
mov ax,0
mov ss,ax
mov sp,0xffff
sti
mov si,two
call print
print:
lodsb
or al,al
jz return
int 10h
jmp print
return:
ret
one db '1',13,10,0
two db '2',13,10,0
times 510-($-$$) db 0
dw 0xAA55
If it displays only one out of the two messages, then you know you have a problem with message two area.
Got it!
After every one or more lines of code, add a message to the code.
If you have ten messages, them you have ten numbers.
Put all ten messages in the code and then run it.
If you have ten messages and you only see 5 on the screen, then you know theres a problem between line 5 and the rest of your messages.
example:
[org 0x7c00]
start:
xor ax,ax
mov ax,cs
mov si,one
call print
mov es,ax
cli
mov ax,0
mov ss,ax
mov sp,0xffff
sti
mov si,two
call print
print:
lodsb
or al,al
jz return
int 10h
jmp print
return:
ret
one db '1',13,10,0
two db '2',13,10,0
times 510-($-$$) db 0
dw 0xAA55
If it displays only one out of the two messages, then you know you have a problem with message two area.
Got it!