Page 1 of 1

Gas trouble

Posted: Tue Jan 29, 2008 12:29 pm
by Beastie
Hello,

I've a problem figuring out what is wrong with this code

Code: Select all

.set WHITE, 0x7
...
...
movb	WHITE, (%edx)                  # edx points to 0xb8000
This is imm to mem move, i don't know whats wrong it used to work under nasm with equ directive.

Thanks

Posted: Wed Jan 30, 2008 1:40 am
by Solar
1) You could use .equ with GAS just as well.

2) You are trying to move the value in memory address 0x7 to the memory address pointed to by %edx - that's a memory-to-memory move, doesn't work. If you want to move the value 0x7, use $WHITE.

Posted: Wed Jan 30, 2008 4:13 pm
by Beastie
Thank solar,
but can i :
(1) use

Code: Select all

.set COLOR, $0x7
...
movb COLOR, (%edx)
(2)

Code: Select all

.set STACKSIZE, 1024
movl	$STACK + STACKSIZE, %esp   # i can not use $ in the 2nd or 3rd number
.bss
.lcomm	STACK, STACKSIZE
If i typed it as $STACK+$STACKSIZE it will complains, i don't know why???

Thanks a lot Solar

Posted: Thu Jan 31, 2008 2:52 am
by AJ
Hi,

When compilation fails, please could you let us know the exact compiler error you get? I'm not familiar with AT&T syntax, but sometimes the compiler error will give enough clues to help sort it out.

Cheers,
Adam

[immature alert]PS for gas trouble, eating fewer baked beans can really help :D [/immature alert]

Posted: Thu Jan 31, 2008 2:59 am
by pcmattman
IIRC, constants do not have the $ sign prepended to them.