News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

First PROC

Started by Magnum, December 07, 2012, 01:08:21 PM

Previous topic - Next topic

Magnum

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

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

qWord

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 ;-)
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

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