Some simple questions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ManOfSteel

Some simple questions

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Some simple questions

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply