News:

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

Main Menu

Next update for macros64.inc 10-11-2022

Started by hutch--, November 10, 2022, 09:34:06 AM

Previous topic - Next topic

hutch--

A number of things have been updated as well as added to the macros file.

1. The .switch macro has been updated to a more efficient form.
2. The .switch$ macro from MASM32 has been ported to MASM64.
3. The .switchi$ macro from MASM32 has been ported to MASM64.

The new help format based on RTF files has had the "switch" page updated to include the two new string versions.
  03_SwitchBlock.rtf

macros64.inc is a replacement for the earlier version.

The file 03_SwitchBlock.rtf should replace the earlier one in the "RtfHelp" directory.

The two ported macros for string comparison.

  ; ======================
  ; case sensitive version
  ; ======================

    .switch$ arg                ; arg is the address of a zero terminated string

      .case$ "alpha"
        conout "alpha selected",lf

      .case$ "beta"
        conout "beta selected",lf

      .case$ "gamma"
        conout "gamma selected",lf

      .case$ "delta"
        conout "delta selected",lf

      .case$ "epsilon"
        conout "epsilon selected",lf

      .else$
        conout "No matching string",lf

    .endsw$

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

  ; ========================
  ; case insensitive version
  ; ========================

    .switchi$ arg               ; arg is the address of a zero terminated string

      .casei$ "JeSt"
        conout "jest selected",lf

      .casei$ "tEsT"
        conout "test selected",lf

      .casei$ "BeSt"
        conout "best selected",lf

      .casei$ "wEsT"
        conout "west selected",lf

      .elsei$
        conout "No matching string",lf

    .endswi$

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

hutch--

A simple demo of the case sensitive ".switch$" macro in use.

hutch--

 A console example of the case insensitive .switchi$ macros. Zip file attached.

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

    include \masm64\include64\masm64rt.inc

    .data
      alpha db "alpha",0
      beta db "beta",0
      gamma db "gamma",0
      delta db "delta",0
      epsilon db "epsilon",0
      zeta db "zeta",0
      eta db "eta",0
      theta db "theta",0
      iota db "iota",0
      kappa db "kappa",0

    .code

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

entry_point proc

    LOCAL iwrd :QWORD

    conout "-------------------------------------",lf
    conout "    64 bit MASM .switchi$ example",lf
    conout "  Format = Input word - output word",lf
    conout "-------------------------------------",lf,lf

    rcall switchitst,OFFSET alpha
    rcall switchitst,OFFSET beta
    rcall switchitst,OFFSET gamma
    rcall switchitst,OFFSET delta
    rcall switchitst,OFFSET epsilon
    rcall switchitst,OFFSET zeta
    rcall switchitst,OFFSET eta
    rcall switchitst,OFFSET theta
    rcall switchitst,OFFSET iota
    rcall switchitst,OFFSET kappa

    conout lf
    waitkey

    .exit

entry_point endp

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

switchitst proc iwrd:QWORD

    .switchi$ iwrd
      .casei$ "ALPHA"
        conout iwrd," ","ALPHA",lf

      .casei$ "BETA"
        conout iwrd," ","BETA",lf

      .casei$ "GAMMA"
        conout iwrd," ","GAMMA",lf

      .casei$ "DELTA"
        conout iwrd," ","DELTA",lf

      .casei$ "EPSILON"
        conout iwrd," ","GAMMA",lf

      .casei$ "ZETA"
        conout iwrd," ","EPSILON",lf

      .casei$ "ETA"
        conout iwrd," ","ETA",lf

      .casei$ "THETA"
        conout iwrd," ","THETA",lf

      .casei$ "IOTA"
        conout iwrd," ","IOTA",lf

      .casei$ "KAPPA"
        conout iwrd," ","KAPPA",lf

      .elsei$
        conout "No word here",lf

    .endswi$

    ret

switchitst endp

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

    end