Gas trouble

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
Beastie
Posts: 14
Joined: Sun Jan 21, 2007 6:31 pm

Gas trouble

Post 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
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post 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.
Every good solution is obvious once you've found it.
Beastie
Posts: 14
Joined: Sun Jan 21, 2007 6:31 pm

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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]
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

IIRC, constants do not have the $ sign prepended to them.
Post Reply