News:

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

Main Menu

Rewritten "rcall" macro

Started by hutch--, November 07, 2022, 07:57:49 AM

Previous topic - Next topic

hutch--

Nothing wrong with the old one but this one should be a bit more efficient.

  ; |||||||||||||||||||||||||||||||||||||||||||||||||||

    register_call MACRO procedure:REQ,acnt,args:VARARG

      IF acnt eq 4
        goto lbl4
      ELSEIF acnt eq 3
        goto lbl3
      ELSEIF acnt eq 2
        goto lbl2
      ELSEIF acnt eq 1
        goto lbl1
      ELSEIF acnt eq 0
        goto lbl0
      ENDIF

      :lbl4
        mov r9, reparg(getarg(4,args))

      :lbl3
        mov r8, reparg(getarg(3,args))

      :lbl2
        mov rdx, reparg(getarg(2,args))

      :lbl1
        mov rcx, reparg(getarg(1,args))

      :lbl0
        call procedure

    ENDM

  ; ----------------------------------------------

    rcall MACRO procedure:REQ,args:VARARG
      LOCAL acnt
      acnt = argcount(args)
      IF acnt gt 4
        .err
        %echo
        %echo    ***********************************************************
        %echo
        %echo    ERROR WITH THIS COMMAND => procedure,args
        %echo    The statement form of direct register loads has a 4 argument
        %echo    limit. Use the 'invoke' notation for more that 4 arguments
        %echo
        %echo    ***********************************************************
        %echo
        goto bye
      ENDIF
      register_call procedure,acnt,args
      :bye
    ENDM

  ; ----------------------------------------------

    rvcall MACRO procedure:REQ,args:VARARG
      LOCAL acnt
      acnt = argcount(args)
      IF acnt gt 4
        .err
        %echo
        %echo    ***********************************************************
        %echo
        %echo    ERROR WITH THIS FUNCTION => (procedure,args)
        %echo    The function form of direct register loads has a 4 argument
        %echo    limit. Use the "rv()" notation for more that 4 arguments
        %echo
        %echo    ***********************************************************
        %echo
        goto bye
      ENDIF
      register_call procedure,acnt,args
      EXITM <rax>
      :bye
    ENDM

  ; |||||||||||||||||||||||||||||||||||||||||||||||||||