32-bit registers?

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
St8ic

32-bit registers?

Post by St8ic »

Hi,
I have quite the newbie assembler question. The CPUID function returns values in the EAX, EBX, ECX and EDX registers. Of course, any 16-bit compiler would **** it's self if it ran into these regs. So am I to assume that a 16-bit OS can't use CPUID?
Thanks alot!
GT

RE:32-bit registers?

Post by GT »

No, you can use them in a 16-bit OS just fine.  There's a prefix in Intel machine code to switch operand size, which allows you to use 32-bit registers in 16-bit mode or vice versa.  Assuming your assembler is new enough to know about the CPUID instruction, it should also have no difficulty generating instructions to access 32-bit registers from 16-bit code.
St8ic

RE:32-bit registers?

Post by St8ic »

Fair enough. But by code is a bit flawed in other parts. Does nasm expect AT&T syntax or something? It gives me a "comma or end of line expected" on lines like these:

cmp word ptr [si+36h],ax
cont:  mov ax,word ptr [si+bx]
mov word ptr [si+bx],ax
carbonBased

RE:32-bit registers?

Post by carbonBased »

Nasm uses intel syntax, but has no notion of 'ptr' as far as I can recal.

You should be able to write as:
cmp word [si+36h],ax
cont:  mov ax,word [si+bx]
mov word [si+bx],ax

Or you could check out the nasm docs... http://nasm.sourceforge.net/doc/html/nasmdoc0.html

--Jeff
Post Reply