I just wanted to set and test a interrupt in my bootimage code. But something seems to be wrong. Can someone help and find whats wrong ?
[BITS 16]
[ORG 0x7C0]
jmp loadOS
loadOS:
cli ;Clear Interrupt
mov ax,0x07C0
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,0x0000
mov ss,ax
mov sp,0xFFFF ;Maximum Limit for the Stack Pointer in 16bit mode
;i.e. 64kb = 2^16
sti
push dx
push es
xor ax,ax
mov es,ax
cli
mov word [es:0x21*4], _int0x21
mov [es:0x21*4+2], cs
sti ;Set Interrupt
pop es
pop dx
int 0x16
mov si, msgBoot
mov al,0x01
int 0x21
jmp $
_int0x21:
_int0x21_ser0x01:
cmp al,0x01
jne _int0x21_end
_int0x21_ser0x01_start:
lodsb
or al,al
jz _int0x21_ser0x01_end
mov ah,0x0E
mov bh,0x00
mov bl,0x07
int 0x10
jmp _int0x21_ser0x01_start
_int0x21_ser0x01_end:
_int0x21_end:
iret ; return from INT 0x21
msgBoot db 0x0D,0x0A,"OS Booting ....",0x00
times 510-($-$$) db 0
dw 0xAA55
Problem with INT in real mode
RE:Problem with INT in real mode
the mistake is in the 2nd line, your code is loaded to 0000:7c00 but you have [org 0x7c0]
greets, hartyl
greets, hartyl
Thanks hartyl
hi hartyl,
yea u were right. My code worked after I changed that and a related 'mov ax,0x07C' code. As planned it prints the code when I hit a key. But after that Bochs reports a fatal error saying
"FATAL: KBD: dropped key scan=1F, ascii=73"
The corrected code:
-------------------
[BITS 16]
[ORG 0x7C00]
jmp loadOS
loadOS:
cli ;Clear Interrupt
push cs
pop ax
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,0x0000
mov ss,ax
mov sp,0xFFFF ;Maximum Limit for the Stack Pointer in 16bit mode
;i.e. 64kb = 2^16
sti
push dx
push es
xor ax,ax
mov es,ax
cli
mov word [es:0x21*4], _int0x21
mov [es:0x21*4+2], cs
sti ;Set Interrupt
pop es
pop dx
int 0x16
mov si, msgBoot
mov al,0x01
int 0x21
jmp $
_int0x21:
_int0x21_ser0x01:
cmp al,0x01
jne _int0x21_end
_int0x21_ser0x01_start:
lodsb
or al,al
jz _int0x21_ser0x01_end
mov ah,0x0E
mov bh,0x00
mov bl,0x07
int 0x10
jmp _int0x21_ser0x01_start
_int0x21_ser0x01_end:
_int0x21_end:
iret ; return from INT 0x21
msgBoot db 0x0D,0x0A,"OS Booting ....",0x00
times 510-($-$$) db 0
dw 0xAA55
yea u were right. My code worked after I changed that and a related 'mov ax,0x07C' code. As planned it prints the code when I hit a key. But after that Bochs reports a fatal error saying
"FATAL: KBD: dropped key scan=1F, ascii=73"
The corrected code:
-------------------
[BITS 16]
[ORG 0x7C00]
jmp loadOS
loadOS:
cli ;Clear Interrupt
push cs
pop ax
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,0x0000
mov ss,ax
mov sp,0xFFFF ;Maximum Limit for the Stack Pointer in 16bit mode
;i.e. 64kb = 2^16
sti
push dx
push es
xor ax,ax
mov es,ax
cli
mov word [es:0x21*4], _int0x21
mov [es:0x21*4+2], cs
sti ;Set Interrupt
pop es
pop dx
int 0x16
mov si, msgBoot
mov al,0x01
int 0x21
jmp $
_int0x21:
_int0x21_ser0x01:
cmp al,0x01
jne _int0x21_end
_int0x21_ser0x01_start:
lodsb
or al,al
jz _int0x21_ser0x01_end
mov ah,0x0E
mov bh,0x00
mov bl,0x07
int 0x10
jmp _int0x21_ser0x01_start
_int0x21_ser0x01_end:
_int0x21_end:
iret ; return from INT 0x21
msgBoot db 0x0D,0x0A,"OS Booting ....",0x00
times 510-($-$$) db 0
dw 0xAA55