Page 1 of 1

32-bit registers?

Posted: Thu Jul 01, 2004 11:00 pm
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!

RE:32-bit registers?

Posted: Fri Jul 02, 2004 11:00 pm
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.

RE:32-bit registers?

Posted: Fri Jul 02, 2004 11:00 pm
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

RE:32-bit registers?

Posted: Sat Jul 03, 2004 11:00 pm
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