Problem with INT in real mode
Posted: Fri Aug 15, 2003 11:00 pm
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
[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