Author Topic: First PROC  (Read 2079 times)

Magnum

  • Member
  • *****
  • Posts: 2309
First PROC
« 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: [Select]

.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

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: First PROC
« Reply #1 on: December 07, 2012, 01:19:55 PM »
use the ASSUME directive to remove the error:
Code: [Select]
assume fs:nothing
...
Also, when using PROC/ENDP the stack frame is automatically created.

Compiler did one of those ASSUME errors.
Assembler != Compiler ;-)
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: First PROC
« Reply #2 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
Code: [Select]
        ASSUME  FS:Nothing, DS:Nothing, SS:Nothing