The MASM Forum

General => The Campus => Topic started by: Magnum on December 07, 2012, 01:08:21 PM

Title: First PROC
Post by: Magnum on December 07, 2012, 01:08:21 PM
This is my attempt at writing my first procedure.
Compiler did one of those ASSUME errors.

Andy



.code

start:

call Custom

invoke ExitProcess,0

;Custom I.D.P. api ??

Custom proc
             PUSH EBP
               MOV EBP,ESP
              PUSH ECX
              PUSH EAX
               PUSH ECX
   MOV EAX,DWORD PTR FS:[18]
        MOV EAX,DWORD PTR DS:[EAX+30]
           MOV ECX,DWORD PTR DS:[EAX]
        MOV DWORD PTR SS:[EBP-4],ECX
              POP ECX
           POP EAX
         MOV EAX,DWORD PTR SS:[EBP-4]
         SHR EAX,10
        AND EAX,1
             MOV ESP,EBP
          POP EBP
            RETN

Custom endp

end     start

Title: Re: First PROC
Post by: qWord on December 07, 2012, 01:19:55 PM
use the ASSUME directive to remove the error:
assume fs:nothing
...

Also, when using PROC/ENDP the stack frame is automatically created.

Quote from: Magnum on December 07, 2012, 01:08:21 PM
Compiler did one of those ASSUME errors.
Assembler != Compiler ;-)
Title: Re: First PROC
Post by: dedndave on December 07, 2012, 01:28:52 PM
it is automatically created if you have PROC line parameters or LOCAL variables
also - you don't want to use RETN if it does - just RET

in this case, you may be better off to create your own stack frame, as you are

you can put several registers in one ASSUME
        ASSUME  FS:Nothing, DS:Nothing, SS:Nothing