Author Topic: Always moving signed dword  (Read 4224 times)

Jordi

  • Guest
Always moving signed dword
« 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.

Code: [Select]
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.

Farabi

  • Member
  • ****
  • Posts: 969
  • Neuroscience Fans
Re: Always moving signed dword
« Reply #1 on: December 07, 2012, 09:36:30 AM »
Dword and signed dword is treated the same. It is the instruction that make it difference.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Jordi

  • Guest
Re: Always moving signed dword
« Reply #2 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: [Select]
.code
start:
mov ebx, 1
add ebx, 2
mov t1, ebx
mov var5, t1

end start

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: Always moving signed dword
« Reply #3 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
Code: [Select]
mov var5, t1is illegal
Code: [Select]
push t1
pop var5
or
Code: [Select]
mov eax,t1
mov var5,eax
are legal

Jordi

  • Guest
Re: Always moving signed dword
« Reply #4 on: December 07, 2012, 09:57:42 AM »
Code: [Select]
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?

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: Always moving signed dword
« Reply #5 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

Code: [Select]
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