The MASM Forum

General => The Campus => Topic started by: Jordi on December 07, 2012, 09:14:59 AM

Title: Always moving signed dword
Post by: Jordi on December 07, 2012, 09:14:59 AM
Hello,

I was gone for a while. Now I am back and the forum has been changed. Great work  :greenclp:

I would like to know how I could move a signed dword. I have searched on the forum, the internet and Intel manual. Unfortunatly al what I found was  a instruction called movsx. This function does not allow me to move sdword to sdword. According to the manual you cannot move sdwords with a normal mov instruction.

My goal is to always move signed dwords. I would not like to move an unsigned dword.


include \masm32\include\masm32rt.inc
includelib \masm32\lib\msvcrt.lib

.DATA?

t1  SDWORD ?
var5  SDWORD ?

.code
start:
mov ebx, 1
add ebx, 2
mov t1, ebx
movsx var5, t1

end start


Could someone explain me how it works? Also is there something that I could use a reference like a C++ reference? Because in the masm reference I could not find something, nor in the tutorials. I am also interested  in procs/routines/functions to write messages and digits to the console. I don't want the answer what that procs are but could somebody point me in the right direction so I could find it myself. That is I think the best way to learn it  ::)

Thank you very much in advance.
Title: Re: Always moving signed dword
Post by: Farabi on December 07, 2012, 09:36:30 AM
Dword and signed dword is treated the same. It is the instruction that make it difference.
Title: Re: Always moving signed dword
Post by: Jordi on December 07, 2012, 09:45:25 AM
thank you for the reply. You mean I should use the normal mov instruction? if I do this I will get an error. error A2000: memory operand not allowed in context

.code
start:
mov ebx, 1
add ebx, 2
mov t1, ebx
mov var5, t1

end start
Title: Re: Always moving signed dword
Post by: dedndave on December 07, 2012, 09:51:17 AM
we cannot see how you have defined "t1" and "var5"   :P

what you cannot do is move content from one memory operand to another, at least not with MOV
mov var5, t1
is illegal
push t1
pop var5

or
mov eax,t1
mov var5,eax

are legal
Title: Re: Always moving signed dword
Post by: Jordi on December 07, 2012, 09:57:42 AM
include \masm32\include\masm32rt.inc
includelib \masm32\lib\msvcrt.lib

.DATA?

t1  SDWORD ?
var5  SDWORD ?

.code
start:
mov ebx, 1
add ebx, 2
mov t1, ebx
mov var5, t1

end start


this is all the code. Thank you very much for your response. I really appreciate that.

I don not want to bother you with simple questions. Is there a reference besides the reference in the masm folder? I would like to use functions so I could message floats en digits to the console. Could you point me in a direction so I could find the answer myself?
Title: Re: Always moving signed dword
Post by: dedndave on December 07, 2012, 10:06:08 AM
there are numerous sources of information
for instructions, the intel/amd manuals are probably best

you are missing an ExitProcess at the end of the program
that is a "ms windows" thing, though - not intel/amd
i use MSDN - but there are other sources

another type of issue might be specific to the assembler you are using

the help files in \masm32\help can give you a lot of info
also - the \masm32\examples folder can show you a lot of common techniques

the includelib you have is already taken care of in masm32rt.inc
it is a plain text file - open it with notepad to see what it does

include \masm32\include\masm32rt.inc

.DATA?

t1  SDWORD ?
var5  SDWORD ?

.code
start:
mov ebx, 1
add ebx, 2
mov t1, ebx
mov var5, ebx
invoke ExitProcess,0

end start


EDIT - oops, i copied your mistake - lol
it should work, now   :P