Author Topic: Just translated 2 more of Vasily's macros, .while and .repeat.  (Read 455 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5850
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
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 at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5850
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Just translated 2 more of Vasily's macros, .while and .repeat.
« Reply #1 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

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 8772
  • Assembler is fun ;-)
    • MasmBasic
Re: Just translated 2 more of Vasily's macros, .while and .repeat.
« Reply #2 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...

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5850
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Just translated 2 more of Vasily's macros, .while and .repeat.
« Reply #3 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: