flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > hlls addition

Author
Thread Post new topic Reply to topic
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges
Hi ! Very Happy

I added processor flags state for .if / .until and premature exit of loops

If useful for somebody ...good... Cool
Otherwise useful for me. Wink

Friendly...AsmGges

Code:
;===========================================================================================
; .if / .elseif / .else / .endif
; .if [.elseif] v1 condition v2
;        condition non signée  =   <>   <   <=   >   >=
; .if [.elseif] v1, condition, v2
;        condition non signée  ,e,(égal) ,ne,(différent) ,b,(inférieur) ,be,(inférieurégal)
;                              ,a,(supérieur) ,ae,(supérieurégal)
;
;        condition signée      ,l,(inférieur) ,le,(inférieurégal) ,g,(supérieur)
;                              ,ge,(supérieurégal)
;
; .if [.elseif] cond   ; cond = flag or reg or var
;     flag  z(zéro)  nz(nonzéro)  s(signé)  ns(nonsigné)  p(pair)  np(nonpair)
;           o(débordement)  no(nondébordement  c(retenue)  nc(nonretenue)
;
macro .if [arg]
{   common
    __IF equ
    local ..endif
    __ENDIF equ ..endif
    local ..else
    __ELSE equ ..else
    JCOND __ELSE,arg   }

macro .else
{   jmp __ENDIF
    __ELSE:
    restore __IF
    __IF equ ,   }

macro .elseif [arg]
{   common
    jmp __ENDIF
    __ELSE:
    restore __ELSE
    local ..else
    __ELSE equ ..else
    JCOND __ELSE,arg   }

macro .endif
{   if __IF eq
     __ELSE:
    end if
    __ENDIF:
    restore __ELSE
    restore __ENDIF
    restore __IF  }
;-------------------------------------------------------------------------------------------
; .while / .endw / .exitwhile
; .while v1 condition v2
;        condition non signée  =  <>  <  <=  >  >=
; .while v1, condition, v2
;        condition non signée  ,e,(égal) ,ne,(différent) ,b,(inférieur) ,be,(inférieurégal)
;                              ,a,(supérieur) ,ae,(supérieurégal)
;
;        condition signée      ,l,(inférieur) ,le,(inférieurégal) ,g,(supérieur)
;                              ,ge,(supérieurégal)
;
; .while cond   ; cond = reg or var
;
macro .while [arg]         ; boucle tant que
{   common
    local ..while
    __WHILE equ ..while
    local ..endw
    __ENDW equ ..endw
    __WHILE:
    JCOND __ENDW,arg   }

macro .endw
{   jmp __WHILE
    __ENDW:
    restore __ENDW
    restore __WHILE   }

macro .exitwhile
{   jmp __ENDW  }
;-------------------------------------------------------------------------------------------
; .repeat / .until / .exitrepeat
; .until v1 condition v2
;        condition non signée  =  <>  <  <=  >  >=
; .until v1, condition, v2
;        condition non signée  ,e,(égal) ,ne,(différent) ,b,(inférieur) ,be,(inférieurégal)
;                              ,a,(supérieur) ,ae,(supérieurégal)
;
;        condition signée      ,l,(inférieur) ,le,(inférieurégal) ,g,(supérieur)
;                              ,ge,(supérieurégal)
;
; .until cond   ; cond = flag or reg or var
;        flag  z(zéro)  nz(nonzéro)  s(signé)  ns(nonsigné)  p(pair)  np(nonpair)
;              o(débordement)  no(nondébordement  c(retenue)  nc(nonretenue)
;
macro .repeat
{   local ..repeat
    __REPEAT equ ..repeat
    local ..until
    __UNTIL equ ..until
    __REPEAT:   }

macro .until [arg]       ;boucle .repeat jusqu'à ce que ...
{   common
    JCOND __REPEAT,arg
    __UNTIL:
    restore __REPEAT
    restore __UNTIL   }

macro .exitrepeat
{   jmp __UNTIL   }

macro JCOND label,[cond]
{   common
    match =COND v1>==v2, COND cond
    \{
        cmp v1,v2
        jb label
        COND equ
    \}
    match =COND v1<==v2, COND cond
    \{
        cmp v1,v2
        ja label
        COND equ
    \}
    match =COND v1==v2, COND cond
    \{
        cmp v1,v2
        jne label
        COND equ
    \}
    match =COND v1<>v2, COND cond
    \{
        cmp v1,v2
        je label
        COND equ
    \}
    match =COND v1>v2, COND cond
    \{
        cmp v1,v2
        jbe label
        COND equ
    \}
    match =COND v1<v2, COND cond
    \{
        cmp v1,v2
        jae label
        COND equ
    \}
    match =COND v1=,c=,v2, COND cond
    \{
        cmp v1,v2
        jn\#c label
        COND equ
    \}
    match =COND v, COND cond
    \{
        if v in <z,nz,s,ns,p,np,o,no,c,nc>  ;pour flags processeur  .if / .until
           jn\#v label
        else
           cmp v,0
           if __IF eq
              je label                      ;pour variable ou registre .if
           else
              jne label                     ;pour variable ou registre .until / .while
           end if
        end if
        COND equ
    \}
    restore COND   }
;===========================================================================================
; .do / .exitloop / .loop
macro .do
{   local ..do
    __DO equ ..do
    local ..loop
    __LOOP equ ..loop
    __DO:   }

macro .loop
{   jmp __DO
    __LOOP:
    restore __LOOP
    restore __DO   }

macro .exitloop
{   jmp __LOOP   }

;===========================================================================================
 jnnz equ jz     ;zéro
 jnns equ js     ;signé
 jnnp equ jp     ;parité
 jnno equ jo     ;débordement
 jnnc equ jc     ;retenue

 jnne equ je     ;égal
 jnna equ ja     ;supérieur
 jnnb equ jb     ;inférieur
 jnnae equ jae   ;supérieur ou égal
 jnnbe equ jbe   ;inférieur ou égal

 jnng equ jg     ;supérieur signé
 jnnl equ jl     ;inférieur signé
 jnnge equ jge   ;supérieur ou égal signé
 jnnle equ jle   ;inférieur ou égal signé
;===========================================================================================
    
Post 10 Dec 2005, 13:08
View user's profile Send private message Visit poster's website Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 02:06; edited 1 time in total
Post 10 Dec 2005, 15:05
View user's profile Send private message Reply with quote
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges
Hi! Yardman Very Happy

As punishment, this small program "french" work eternally on my computer
Code:
Msg_For_Me db "Excusez moi d'avoir offensé votre grande intelligence",13,10
           db "par mes macros idiotes, ô Dieu de l'assembleur ",13,10
           db "je me prosterne devant vous en vous embrassant les pieds",13,10
           db " et en vous suppliant de me pardonner.",0

macro One_thousand_forgivenesses val
{  
    Yardman:
    mov ecx, val
    .repeat
         Display_on_my_computer Msg_For_Me
         dec ecx
    .until z
    jmp Yardman
}

One_thousand_forgivenesses 0FFFFFFFFh
    

Friendly...AsmGges
Post 10 Dec 2005, 19:35
View user's profile Send private message Visit poster's website Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]
Post 10 Dec 2005, 21:13
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.