flat assembler
Message board for the users of flat assembler.

Index > Main > Data Conversions

Author
Thread Post new topic Reply to topic
NanoBytes



Joined: 02 Jun 2011
Posts: 57
Location: Iowa, United States
NanoBytes 11 Jun 2011, 08:37
Ok, I'm not sure whether or not the question I have is difficult or not. Ok I have two variables:
Code:
X DW 5
Y DD 10
    

The psudocode for what i want is:
Code:
Y=X
or
DOUBLE=WORD
    

This in and of itself is not difficult, my problem is that I need a kill all for the following problem:
I only have the names of the two variables, and the data type of the seconed. So the kill all would work just as well for A=B as it would for Y=X (all I need to do is plug the names in and then the seconed would be moved to the first.
so:
Code:
Var1 = conversion(Var2_Type, Var2)
    

So back to the X,Y example. Y will equal X no matter what type Y actualy is. For example, if this "kill all" is a procedure, I will pass the location of Var1,and 2 and the type of Var 2,
For the type passing, I was planning to use a character for that:
'B' = byte
'W' = word
'D' = double
ect...
Code:
something like:
LEA EAX,[Var1]
PUSH EAX
LEA EAX,[Var2]
PUSH EAX
call ConvertAndAssign 
    

_________________
He is no fool who gives what he cannot
keep to gain what he cannot loose.
Post 11 Jun 2011, 08:37
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20357
Location: In your JS exploiting you and your system
revolution 11 Jun 2011, 08:50
I think it goes a little bit further than that. You might need to consider signed and unsigned:
Code:
movzx eax,[X] ;is it this?
movsx eax,[X] ;or this?
mov [Y],eax    
Post 11 Jun 2011, 08:50
View user's profile Send private message Visit poster's website Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 11 Jun 2011, 18:45
aren't there instructions for this like cwd & cbw (convert word to doubleword and convert byte to word)?
Post 11 Jun 2011, 18:45
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.