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.
My NASM problem
Re:My NASM problem
What lines do these warnings/errors point to? I think I have an idea what's wrong.
Re:My NASM problem
Line 13:
Replace with: mov esi,eax
(you already have the rest of eax zeroed out, so this will work fine.)
Line 21:
Replace with:
mov eax, [esi] (or any other available register)
mov [pKbdRawIn], eax
(mov [pKbdRawIn],[esi] might work)
Line 22:
Replace with:
mov dx,0x20
mov al,0x20
out dx,al
Replace with: mov esi,eax
(you already have the rest of eax zeroed out, so this will work fine.)
Line 21:
Replace with:
mov eax, [esi] (or any other available register)
mov [pKbdRawIn], eax
(mov [pKbdRawIn],[esi] might work)
Line 22:
Replace with:
mov dx,0x20
mov al,0x20
out dx,al
Re:My NASM problem
>> Replace with: mov esi,eax <<
Why? I don't understand this. I DO understand that the error was because he was trying to go from 4bit to 32bit, but I don't understand why you changed it to this.
Why? I don't understand this. I DO understand that the error was because he was trying to go from 4bit to 32bit, but I don't understand why you changed it to this.
Re:My NASM problem
I just realized (by reading his comments) what he was trying to do. It should have been:Tommy wrote: >> Replace with: mov esi,eax <<
Why? I don't understand this. I DO understand that the error was because he was trying to go from 4bit to 32bit, but I don't understand why you changed it to this.
mov [esi],al
Silly me.
Re:My NASM problem
>Line 22:
>
>Replace with:
> mov dx,0x20
> mov al,0x20
> out dx,al
Just for clarity... this can also be written as:
mov al,0x20
out 0x20,al
as long as the port # fits into one byte
BC
>
>Replace with:
> mov dx,0x20
> mov al,0x20
> out dx,al
Just for clarity... this can also be written as:
mov al,0x20
out 0x20,al
as long as the port # fits into one byte
BC
Re:My NASM problem
What would you mov the value of register AL into what is at the address of esi? Can you please explain this in some detail? Thanks!Dave_Hunt wrote:I just realized (by reading his comments) what he was trying to do. It should have been:Tommy wrote: >> Replace with: mov esi,eax <<
Why? I don't understand this. I DO understand that the error was because he was trying to go from 4bit to 32bit, but I don't understand why you changed it to this.
mov [esi],al
Silly me.
Re:My NASM problem
Thanks Dave_Hunt and bchadwick01.
I got my code working thanks to your suggestions.
Thanks,
K.J.
I got my code working thanks to your suggestions.
Thanks,
K.J.
Re:My NASM problem
K.J.,
Glad to help!
Tommy,
esi is pointing to his keyboard buffer (pKbdRawIn). So, the "mov [esi],al" would move the byte entered at the keyboard (retrived via "in al,60h") into the buffer.
Glad to help!
Tommy,
esi is pointing to his keyboard buffer (pKbdRawIn). So, the "mov [esi],al" would move the byte entered at the keyboard (retrived via "in al,60h") into the buffer.