Page 1 of 1

Some simple questions

Posted: Sun Oct 17, 2004 3:14 am
by ManOfSteel
Hello,
I have some simple questions:
What does the 'align' (pseudo) instruction do and what is it good for? I used it in a program and when I disassembled it, I didn't find any difference.
Can the user keyboard buffer (where the keys are sent), in the IRQ01 handler or in the keyboard handling software interruption, be only a byte long?
Thanks for any help.

Re:Some simple questions

Posted: Sun Oct 17, 2004 7:29 am
by Brendan
Hi,
ManOfSteel wrote: What does the 'align' (pseudo) instruction do and what is it good for? I used it in a program and when I disassembled it, I didn't find any difference.
The "align" pseudo-instruction aligns things :). For example, for best performance target addresses for "call", "jmp" and branches should be on a 4 byte boundary (or 8, or 16 depending on target CPU trace cache). Also data should be aligned on it's natural boundaries - 2 byte alignment for words, 4 byte alignment for dwords, 8 byte alignment for qwords, etc. To achieve this you can write things like this (for NASM):

Code: Select all

   align 4
subroutine:
   mov eax,[someData]
   fld qword [moreData]
   ret

   section .data
   align 4
someData:  dd 0
   section .bss
   alignb 8
moreData:  resq 1
   section .text
The reason it didn't appear to do anything is that your code/data may have already been aligned.
ManOfSteel wrote: Can the user keyboard buffer (where the keys are sent), in the IRQ01 handler or in the keyboard handling software interruption, be only a byte long?
Yes the keyboard buffer can be a byte long, but it wouldn't be much better than polling (which is IMHO a poor way of doing things for an OS intended for 80x86, and barely acceptable for embedded systems). Assuming there's a fast typist, how much time is there between the make code and the break code? Can you guarantee that all software running under your OS will be able to get the keyboard data out of the keyboard buffer (before it's overwritten) that quickly, even when the OS is overloaded with other work (including heaps of IRQs)?


Cheers,

Brendan