The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: drapaki on February 26, 2007, 11:02:45 PM

Title: are these right? quick and easy!
Post by: drapaki on February 26, 2007, 11:02:45 PM
just getting started in MASM (if you can't tell.. hehehe)
;use direct offse to move four values from Uarray to EAX
.386
.model flat,stdcall
.stack 100h
INCLUDE <c:\masm615\include\GraphWin.inc>

.data
Uarray WORD 1000h,2000h,3000h,4000h

.code
main PROC
mov EAX,Uarray ;put 1000h in register EAX
mov EBX,Uarray+4 ;go to offset of 2000h and put in register EBX
mov ECX,Uarray+8 ;go to offset of 3000h and put in register ECX
mov EDX,Uarray+12 ;go to offset of 4000h and put in register EDX

call DumpRegs ;show registers

main ENDP
end MAIN

and

;implement followint expression: EAX = -val2 + 7 – val3 + val1
.386
.model flat,stdcall
.stack 100h
INCLUDE <c:\masm615\include\GraphWin.inc>

.data
val1 SDWORD 8
val2 SDWORD -15
val3 SDWORD 20

.code
main PROC
mov EAX,val2 ;EAX = -Fh
neg EAX ;EAX = Fh
add EAX,7 ;EAX = 16h
sub EAX,val3 ;EAX = FFFFFFFFFFFFFFFF6h
add EAX,val1 ;EAX = FFFFFFFFFFFFFFFFEh

call DumpRegs

main ENDP
end MAIN
Title: Re: are these right? quick and easy!
Post by: PBrennick on February 26, 2007, 11:08:21 PM
drapaki,
I see you are using the masm615 package. Updates for that package are now in a package called GeneSys. masm615 has been withdrawn but if you have any problems with it, Vortex and I will still support it.

Paul
Title: Re: are these right? quick and easy!
Post by: drapaki on February 26, 2007, 11:10:50 PM
um.. teacher has us using this 615 version... guess he wants to keep it old school..  :dance:
Title: Re: are these right? quick and easy!
Post by: hutch-- on February 26, 2007, 11:16:34 PM
Remove the line,


.stack 100h


32 bit PE files set the stack limit if needed with the linker.

Your application will not exit correctly, it needs a call to ExitProcess().

Ensure that the "DumpRegs" procedure is available or you will get a linker error.