MACRO for alternative high level syntax in MASM 32

Started by Mur, September 03, 2006, 06:45:39 PM

Previous topic - Next topic

Mur

MACRO for alternative high level syntax in MASM 32  :boohoo:
MACRO is support additional flags of the processor (list see below).
@IF, @ELSEIF allows to use the additional commands for calculation of the conditions
Hope that in following version MASM 32 supports of these possibilities will be built-in .IF, .UNTIL, ...
-------------------------------------------------------------------------------------------------
Formats of alternative high level syntax [unessential parameters]:
  @IF [<<command>>, ...], flags
    ...
  [@ELSEIF [<<command>>, ...], flags]     ; (see example below)
    ...
  [@ELSE]
    ...
  @ENDIF
Note: in << >> essential introduced only command, included comma (for example: <<mov EAX, 5>>)
  - - - - - - - - - - - - - - - -
  @REPEAT
    ...
    [@BREAK]
    [@BREAK [@IF] flags]
    [@BREAK [.IF] flags]
    ...
  @UNTIL [flags]
  - - - - - - - - - - - - - - - -
  @WHILE [flags]
    ...
    [@BREAK]
    [@BREAK [@IF] flags]
    [@BREAK [.IF] flags]
    ...
  @ENDW
-------------------------------------------------------------------------------------------------
List supported flag and their combination:
  CARRY?,  OVERFLOW?,  PARITY?,  SIGN?,  ZERO?,  EQUAL?,  ABOVE?,  ABOVE?||EQUAL?, 
  BELOW?,  BELOW?||EQUAL?,  GREATER?,  GREATER?||EQUAL?,  LESS?,  LESS?||EQUAL?,
  NOCARRY?,  NOOVERFLOW?,  NOPARITY?,  NOSIGN?,  NOZERO?,  NOEQUAL?,  NOABOVE?,
  NOBELOW?,  NOGREATER?,  NOLESS?
--------------------------------------------------------------------------------------------------
                                           FOR EXAMPLES:
include Alt_IF_en.mac
.data?
iVAR_1   dd ?
iVAR_2   dd ?
qVAR_3   dq ?
.code
- - - - - - - - - -
  ...
  @IF <<or EDX, EDX>>, SIGN?   ; register EDX < 0
    ...
  @ELSEIF <<mov EAX, [iVAR_1]>>, <<cmp EAX, [iVAR_2]>>, GREATER?||EQUAL?  ; iVAR_1 >= iVAR_2 (signed)
    ...
  @ELSEIF FLD [qVAR_3], FICOMP [iVAR_2], FSTSW AX, SAHF, ABOVE?||EQUAL?    ; qVAR_3 >= iVAR_2 (signed!)
    ...       ; ATTENTION: at FPU compare use only UNSIGHED flags (ABOVE?, BELOW?)
    ...       ;            although FPU compare ALWAYS signed !!!
  @ENDIF
; Note: in << >> essential introduced only command, included comma (for example: <<mov EAX, 5>>)
; - - - - - - - - - -
  mov ECX, 15
  @REPEAT
    ...
    cmp EAX, -5
    @BREAK @IF LESS? || EQUAL? ; early exit if EAX <= -5
    ...
    cmp [iVAR_1], 10
  @UNTILCXZ ABOVE?||EQUAL?   ; exit from loop if [iVAR_1] >= 10 (unsigned) or ECX == 0

[attachment deleted by admin]

Mur

New version 2.0
Added MACRO for defined and undefined local labels:
call  jmp @LABEL(имя_метки) possible use both before, and after DEFLABEL label_name[:]
    DEFLABEL label_name[:]   ; Define local label
    @LABEL(label_name)   ; Reference to local label
    UNDEFLABEL label_name   ; Close area define local label
after UNDEFLABEL possible define new label with same name!!!

All condition macro support of added command.
Remove limitation of nesting levels.
Fixed error in @WHILE.


[attachment deleted by admin]