Vote count:
0
I have this code:
;bootloader
[bits 16]
[org 0x7c00]
jmp main
print_char:
mov ah,0x0e
mov bh,0x00
mov al,65
int 0x10
ret
main:
call print_char
times 510-($-$$) db 0
dw 0xAA55
So, it should jump to main and call print_char to print a letter A on the screen, but it doesn't work! I'am using a qemu+gdb for testing. I set sevreal breakpoints in gdb one at the begining, anouther one at call print_char and last one on ret. I found that print_char is not called in this code. What is wrong with my code?
My debug session:
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x0000fff0 in ?? ()
(gdb) br *0x7c00
Breakpoint 1 at 0x7c00
(gdb) br *0x7c00+0x3
Breakpoint 2 at 0x7c03
(gdb) br *0x7c00+0xb
Breakpoint 3 at 0x7c0b
(gdb) br *0x7c00+0xc
Breakpoint 4 at 0x7c0c
(gdb) stepi
0x0000e05b in ?? ()
(gdb) c
Continuing.
Breakpoint 1, 0x00007c00 in ?? ()
(gdb) stepi
Breakpoint 4, 0x00007c0c in ?? ()
(gdb) stepi
0x00007c0e in ?? ()
(gdb) stepi
0x00007c10 in ?? ()
(gdb) stepi
0x00007c12 in ?? ()
(gdb) stepi
0x00007c15 in ?? ()
(gdb)
lst file:
1 ;bootloader
2 [bits 16]
3 [org 0x7c00]
4
5
6 00000000 E90900 jmp main
7
8 print_char:
9 00000003 B40E mov ah,0x0e
10 00000005 B700 mov bh,0x00
11 00000007 B041 mov al,65
12 00000009 CD10 int 0x10
13 0000000B C3 ret
14
15 main:
16 0000000C E8F4FF call print_char
17
18
19 0000000F 00<rept> times 510-($-$$) db 0
20
21 000001FE 55AA dw 0xAA55
asked 54 secs ago
Nasm simple bootloader. Call and ret do not work properly
Aucun commentaire:
Enregistrer un commentaire