Bochs Keyboard Input
Posted: Thu May 25, 2017 1:45 pm
Hello, i am trying to program 8259A in bochs. But there are problems that i cant solve by myself so i'd like to ask them here. My question is when we map Master 8259's interrupt vectors to 0x20-0x27 range, does it mean that i need correct IVT entries between the physical addresses 0x80-A0 (i am in real mode and ivt sits at 0x000-0x400 so i thought interrupt numbers 0x20-0x27 would map to 0x80-0xA0 physical address range)?
If i call int 0x21(i think this is keyboard interrupt after mapping?) from assembly it works(a string printed on screen). But when i press any key it doesn't work. I'd appreciate any help which enlightens my misunderstandings on subject.
If i call int 0x21(i think this is keyboard interrupt after mapping?) from assembly it works(a string printed on screen). But when i press any key it doesn't work. I'd appreciate any help which enlightens my misunderstandings on subject.
Code: Select all
cli
mov ax,0x7c0
mov ds,ax
mov ax,0x7000
mov sp,ax
xor ax,ax
mov es,ax
mov ax,0x84;0x21th interrupt address
mov di,ax
mov ax,[int_offset]
mov [es:di],ax
inc di
inc di
mov ax,[int_segment]
mov [es:di],ax
;ICW 1
mov al, 0x11
out 0x20, al
out 0xA0, al
;ICW 2
mov al, 0x20
out 0x21, al
mov al, 0x28
out 0xA1, al
;ICW 3
mov al, 0x4
out 0x21, al
mov al, 0x2
out 0xA1, al
;ICW 4
mov al, 1
out 0x21, al
out 0xA1, al
;OCW1 no mask
;mov al, 0
;out 0x21, al
;out 0xa1, al
sti
int 0x21
end:
jmp end
;prints string in [ds:si] to screen
printStr:
pusha;
push di
push es
cld;inc si after lodsb
loadchr:
lodsb;
cmp al,0x00;
je printStrFinish;
cmp al,0x0A;
je newline;
mov ah,0x4e;
mov di,[video_memory_index];
mov es,[video_memory_base];
mov [es:di],ax;
inc di;
inc di;
mov [video_memory_index],di;
jmp loadchr;
newline:
push dx;
push bx;
push ax;
mov bx,0x00A0;
add [video_memory_index],bx;
mov dx,0;
mov ax,[video_memory_index];
div bx;
sub [video_memory_index],dx;
pop ax;
pop bx;
pop dx;
jmp loadchr;
printStrFinish:
pop es
pop di
popa;
ret;
video_memory_base dw 0xb800;
video_memory_index dw 0x0000;
disk_drive_number_str db 'DiskDriveNumber:',0x00;
int_offset dw 0x7d00
int_segment dw 0x0000
times 256-($-$$) db 0
mov ax,disk_drive_number_str;My interrupt handler which sits at 0x7d00
mov si,ax
call printStr
mov al, 0x20;send EOI
out 0x20, al
iret
times 510-($-$$) db 0
db 0x55
db 0xAA