flat assembler
Message board for the users of flat assembler.

Index > Main > $-label oddities

Author
Thread Post new topic Reply to topic
Marikallees



Joined: 21 Apr 2006
Posts: 4
Marikallees
Here's what I'm trying to do:
Code:
section '.data' data readable writable

string db  'Some string stuff'
length equ $-string
    

I expected the value of length to be the number of bytes in the string, but it seems the address given by $ and the address of the label are wildly different and the value of length is far too large. Can someone give me a hint as to what I'm doing wrong?
Post 25 Apr 2006, 14:54
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
use "length = $-string". With equ you make "length" to be "$-string" instead of the value of $-string.

With EQU "mov eax, length" gets assembled as mov eax, $-string

With = "mov eax, length" gets assembled as mov eax, length
Post 25 Apr 2006, 15:17
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
equ is for text while = is for numeric constants (or something like that). Here, read this, it should help explain it. Razz
Post 26 Apr 2006, 22:35
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.