News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Just translated 2 more of Vasily's macros, .while and .repeat.

Started by hutch--, August 08, 2018, 04:47:14 PM

Previous topic - Next topic

hutch--

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

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

hutch--

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

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

jj2007

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...

hutch--

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.