My NASM problem
Posted: Sun Apr 07, 2002 11:28 pm
The following NASM code doesn't want to work and I can't figure out why:
[tt][BITS 32]
[SECTION .text]
_kbd_isr: ; just "kbd_isr" in C
cli
mov esi, pKbdRawIn ;pointer to the raw kbd buffer
xor eax, eax ;zero eax
in al, 60h ;get 1 byte from the keyboard
mov ebx, KbdRawCnt ;check if the raw buffer is full
cmp ebx, 20h
je kbd_isr_finish ;if it is, exit
mov byte esi, al ;store al(byte from the kbd) in the raw buffer
inc dword [KbdRawCnt]
inc esi
cmp esi, KbdRawBuf+20h ;are we past the end of the buffer?
jb kbd_isr_finish
mov esi, KbdRawBuf
kbd_isr_finish:
mov pKbdRawIn, [esi]
out 0x20, 0x20
sti
ret
[SECTION .data]
KbdRawBuf:
times 32 DB 0 ;32-byte raw buffer
KbdRawCnt:
DD 0
pKbdRawIn:
DD KbdRawBuf
pKbdRawOut:
DD KbdRawBuf
KbdBuffer:
times 64 DD 0 ;64 DWords for the translated kbd buffer
KbdCnt:
DD 0
pKbdIn:
DD KbdBuffer
pKbdOut:
DD KbdBuffer[/tt]
I compile like this:
[tt]nasm -f aout kbd.asm[/tt]
and get these errors:
kbd.asm:13: warning: register size specification ignored
kbd.asm:13: invalid combination of opcode and operands
kbd.asm:21: invalid combination of opcode and operands
kbd.asm:22: invalid combination of opcode and operands
Thanks in advance,
K.J.
[tt][BITS 32]
[SECTION .text]
_kbd_isr: ; just "kbd_isr" in C
cli
mov esi, pKbdRawIn ;pointer to the raw kbd buffer
xor eax, eax ;zero eax
in al, 60h ;get 1 byte from the keyboard
mov ebx, KbdRawCnt ;check if the raw buffer is full
cmp ebx, 20h
je kbd_isr_finish ;if it is, exit
mov byte esi, al ;store al(byte from the kbd) in the raw buffer
inc dword [KbdRawCnt]
inc esi
cmp esi, KbdRawBuf+20h ;are we past the end of the buffer?
jb kbd_isr_finish
mov esi, KbdRawBuf
kbd_isr_finish:
mov pKbdRawIn, [esi]
out 0x20, 0x20
sti
ret
[SECTION .data]
KbdRawBuf:
times 32 DB 0 ;32-byte raw buffer
KbdRawCnt:
DD 0
pKbdRawIn:
DD KbdRawBuf
pKbdRawOut:
DD KbdRawBuf
KbdBuffer:
times 64 DD 0 ;64 DWords for the translated kbd buffer
KbdCnt:
DD 0
pKbdIn:
DD KbdBuffer
pKbdOut:
DD KbdBuffer[/tt]
I compile like this:
[tt]nasm -f aout kbd.asm[/tt]
and get these errors:
kbd.asm:13: warning: register size specification ignored
kbd.asm:13: invalid combination of opcode and operands
kbd.asm:21: invalid combination of opcode and operands
kbd.asm:22: invalid combination of opcode and operands
Thanks in advance,
K.J.