The MASM Forum

Microsoft 64 bit MASM => MASM64 SDK => Topic started by: hutch-- on August 08, 2018, 04:47:14 PM

Title: Just translated 2 more of Vasily's macros, .while and .repeat.
Post by: hutch-- on August 08, 2018, 04:47:14 PM
These are already available in Vasily's macro file, they have not been documented yet. Both macros will perform complex multiple evaluations as well using Vasily's character substitutions.

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

    mov r12, 25

    .while r12 {} 0
      conout str$(r12),lf
      sub r12, 1
    .endw

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

    mov r12, 25

    .repeat
      conout str$(r12),lf
      sub r12, 1
    .until r12 == 0

  ; ----------------------------------------
Title: Re: Just translated 2 more of Vasily's macros, .while and .repeat.
Post by: hutch-- on August 09, 2018, 04:54:00 PM
This is a message loop using .repeat - .until .

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

msgloop proc

    LOCAL msg :MSG

    movq mm0, r14
    movq mm1, r15

    xor r15, r15                                ; replace immediate 0 with register
    mov r14, ptr$(msg)                          ; get the msg structure address

    .repeat
      rcall TranslateMessage,r14
      rcall DispatchMessage,r14
    .until rvcall(GetMessage,r14,r15,r15,r15) == r15

    movq r14, mm0
    movq r15, mm1

    ret

msgloop endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Title: Re: Just translated 2 more of Vasily's macros, .while and .repeat.
Post by: jj2007 on August 09, 2018, 06:12:39 PM
Why do you need separate macros rv and rvcall for 1...4 vs more than 4 procs?

mov rcx, rv(CreateWindowEx, 0, wc.lpszClassName, chr$("Hello World"), wsStyle, 600, 127, 300, 200, NULL, rv(LoadMenu, wc.hInstance, 100), wc.hInstance, NULL)

Would this produce different code? Just curious...
Title: Re: Just translated 2 more of Vasily's macros, .while and .repeat.
Post by: hutch-- on August 09, 2018, 07:05:38 PM
rv uses the same base macro as invoke, rvcall is a direct register call. If a procedure or API has 4 or less arguments, it is more efficient to use the direct register call. The base macro used by invoke and rv can do any procedures call where the direct register calls can only do up to 4 arguments corresponding to the 4 registers used in the FASTCALL 64 bit convention.