flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > New hll .on

Author
Thread Post new topic Reply to topic
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges 22 Dec 2005, 17:26
Hi! Very Happy

new hll .on

.on v1 cond v2, instruction
.on cond, instruction

If condition is TRUE, instruction after the comma IS executed
And program continues in the following line

If condition is FALSE, instruction after the comma is NOT executed
Program continues in the following line

" .on " replace on a single line the macro ".if / .endif" on three lines:
.if v1 cond v2
Instruction
.endif
Or
.if cond
Instruction
.endif
Code:
;==========================================================================
; Hll .on
; AsmGges @2005
; .on replace on a single line the macro .if/.endif on three lines:
;   
; If condition is true, instruction after the comma IS executed
; And program continues in the following line
;
; If condition is false, instruction after the comma is NOT executed
; Program continues in the following line
;
; instruction: instruction op1,op2
;              instruction op
;              stdcall proc,param1,param2,....
;              call ....
;              invoke .....
;              ect.....
;Example:
;
;  invoke CreateWindowEx,0,ClassName,WinCaption,WS_POPUP+WS_VISIBLE,\
;                        0,0,0,0,0,0,[hinstance],0
;  .on eax = 0, stdcall ErrorProgram,MsgCreateWinError
;   mov [hWnd],eax
;
;==========================================================================
; UNSIGNED
; .on v1 = v2,   instruction
; .on v1 <> v2,  instruction
; .on v1 > v2,   instruction
; .on v1 >= v2,  instruction
; .on v1 < v2,   instruction
; .on v1 <= v2,  instruction

; SIGNED
; .on v1 s< v2,  instruction
; .on v1 s<= v2, instruction
; .on v1 s> v2,  instruction
; .on v1 s>= v2, instruction

; REGISTER
; .on reg,   instruction
; .on [reg], instruction

; VARIABLE
; .on [var], instruction
;==========================================================================
macro .on [args]
{   common
    local ..on
    __ON equ ..on
    match =ARGS v1=s>==v2 =, inst, ARGS args  ; .on v1 s>= v2, instruction
    \{  cmp v1,v2
        jl __ON
        inst
        ARGS equ  \}
    match =ARGS v1=s<==v2 =, inst, ARGS args  ; .on v1 s<= v2, instruction
    \{  cmp v1,v2
        jg __ON
        inst
        ARGS equ  \}
    match =ARGS v1=s<v2 =, inst, ARGS args    ; .on v1 s< v2, instruction
    \{  cmp v1,v2
        jge __ON
        inst
        ARGS equ  \}
    match =ARGS v1=s>v2 =, inst, ARGS args    ; .on v1 s> v2, instruction
    \{  cmp v1,v2
        jle __ON
        inst
        ARGS equ  \}
    match =ARGS v1>==v2 =, inst, ARGS args    ; .on v1 >= v2, instruction
    \{  cmp v1,v2
        jb __ON
        inst
        ARGS equ  \}
    match =ARGS v1<==v2 =, inst, ARGS args    ; .on v1 <= v2, instruction
    \{  cmp v1,v2
        ja __ON
        inst
        ARGS equ  \}
    match =ARGS v1==v2 =, inst, ARGS args     ; .on v1 = v2, instruction
     \{ cmp v1,v2
        jne __ON
        inst
        ARGS equ  \}
    match =ARGS v1<>v2 =, inst, ARGS args     ; .on v1 <> v2, instruction
    \{  cmp v1,v2
        je __ON
        inst
        ARGS equ
         \}
    match =ARGS v1>v2 =, inst, ARGS args      ; .on v1 > v2, instruction
    \{  cmp v1,v2
        jbe __ON
        inst
        ARGS equ  \}
    match =ARGS v1<v2 =, inst, ARGS args      ; .on v1 < v2, instruction
    \{  cmp v1,v2
        jae __ON
        inst
        ARGS equ  \}
    match =ARGS v =, inst, ARGS args  ; .on reg/var, instruction
   \{  if v eqtype 0
           if ~ v
              jmp __ON
           end if
        else if v eqtype eax
           test v,v
           jz __ON
        else
           cmp v,0
           je __ON
        end if
        inst
        ARGS equ  \}     
    __ON:
    restore __ON
    restore ARGS   }   
;==========================================================================
    

Friendly...AsmGges


Last edited by asmgges on 24 Dec 2005, 09:13; edited 2 times in total
Post 22 Dec 2005, 17:26
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 22 Dec 2005, 18:06
idea to improve it - think about:
Code:
on eax<=0, <<mov [error],1>, jmp error_handler>    

hint: irp
Wink
Post 22 Dec 2005, 18:06
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi 03 Jan 2006, 14:40
these "hll" macros does make life easier sometimes Smile
but code goes easily all spaghetti with these macros Neutral

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 03 Jan 2006, 14:40
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.