flat assembler
Message board for the users of flat assembler.

Index > Main > text to number

Author
Thread Post new topic Reply to topic
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude
sorry for this newbie question, but why doesnt this work?

Code:
mov dword[eax],<'rb',0,0>    
Post 23 Apr 2015, 14:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
If you want the constant "rb" you can use:
Code:
mov dword[eax],'rb'  ;'r','b',0,0    
If you want a pointer to a string 'rb' you can use:
Code:
my_string: db 'rb',0,0
;...
mov dword[eax],my_string    
Post 23 Apr 2015, 15:26
View user's profile Send private message Visit poster's website Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude
Code:
mov dword[eax],'rb'  ;'r','b',0,0    


oh, i didnt know it would fill the rest of the string with zeros. thanks Very Happy

but what if i wanted this instead?

Code:
mov dword[eax],<'rb',1,2>    
Post 23 Apr 2015, 15:41
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Code:
mov  dword [eax], 'rb' or $02010000    

But I would use the following:
Code:
mov dword [eax], $02016272   ; 'rb', 1, 2    

The assembly programmer must know the ASCII table after all. Cool
Post 23 Apr 2015, 16:09
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude
lol, really fasm doesnt have a proper way to do it without hardcoding? Sad
Post 23 Apr 2015, 17:38
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
randomdude wrote:
lol, really fasm doesnt have a proper way to do it without hardcoding? Sad


It can by using macro. But it really doesn't worths the effort. Of course, everything is relative. If you need hundreds of such definitions, the macro is a good solution.

P.S. In fact, "<'rd', 1, 2>" is "hardcoding" as well.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 23 Apr 2015, 18:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
You can actually type character 1 and 2 into the string (ALT+001/2 on windows)
Code:
mov dword [eax],'rb'     
Razz
Post 23 Apr 2015, 21:17
View user's profile Send private message Reply with quote
El Tangas



Joined: 11 Oct 2003
Posts: 120
Location: Sunset Empire
El Tangas
randomdude wrote:
lol, really fasm doesnt have a proper way to do it without hardcoding? Sad


Or you can hardcode the mov instruction instead Confused

Code:
db 0B8h ;mov eax, immediate
db 'rb',1,2     


Ad, err, sorry for answering with 1 month delay.
Post 24 May 2015, 21:00
View user's profile Send private message 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. Also on YouTube, Twitter.

Website powered by rwasa.