The MASM Forum

Projects => Rarely Used Projects => Archival JWASM postings => Topic started by: habran on October 12, 2014, 06:27:37 AM

Title: Signed Flags
Post by: habran on October 12, 2014, 06:27:37 AM
Hi there,

I have added these signed flags to JWasm:
  SCARRY?           JGE    Sign flag = overflow flag               
  !SCARRY?            JL     Sign flag != overflow flag             
  SZERO?             JLE    Zero flag is set or sign != overflow   
  !SZERO?            JG     Zero flag is clear and sign = overflow 


I have encountered this C source:

  //Align to 16 pixel
  ptScale.x+=ptScale.x % 16;


it is compiled to this:

mov edx, DWORD PTR ptScale
mov ecx, edx
and ecx, -2147483633 ; ffffffff8000000fH
jge SHORT $LN10
dec ecx
or ecx, -16
inc ecx
$LN10:
add edx, ecx
  mov DWORD PTR ptScale, edx


we can write it like this:

  mov eax,ptScale.x                                   
and eax,8000000Fh
jge @F
dec eax               
or eax, -16                                 
inc eax
@@:
add ptScale.x, eax


assembled to:

  mov eax,ptScale.x                                   
000000013F8411C7 8B 84 24 90 00 00 00 mov         eax,dword ptr [ptScale] 
and eax,8000000Fh
000000013F8411CE 25 0F 00 00 80       and         eax,8000000Fh 
jge @F
000000013F8411D3 7D 07                jge         main+1Dh (013F8411DCh) 
dec eax               
000000013F8411D5 FF C8                dec         eax 
or eax, -16                                 
000000013F8411D7 83 C8 F0             or          eax,0FFFFFFF0h 
inc eax
000000013F8411DA FF C0                inc         eax 
@@:
add ptScale.x, eax
000000013F8411DC 01 84 24 90 00 00 00 add         dword ptr [ptScale],eax 

it would look better if we write it like this:

    mov eax,ptScale.x
    and eax, 8000000fH
    .if (SCARRY?)
      dec eax
      or eax, -16
      inc eax
    .endif
    add ptScale.x, eax

assembled to:

    mov eax,ptScale.x
000000013FCB11E3 8B 84 24 90 00 00 00 mov         eax,dword ptr [ptScale] 
    and eax, 8000000fH
000000013FCB11EA 25 0F 00 00 80       and         eax,8000000Fh 
    .if (SCARRY?)
000000013FCB11EF 7D 07                jge         main+39h (013FCB11F8h) 
      dec eax
000000013FCB11F1 FF C8                dec         eax 
      or eax, -16
000000013FCB11F3 83 C8 F0             or          eax,0FFFFFFF0h 
      inc eax
000000013FCB11F6 FF C0                inc         eax 
    .endif
    add ptScale.x, eax
000000013FCB11F8 01 84 24 90 00 00 00 add         dword ptr [ptScale],eax

your comments would be appreciated :biggrin:

if you agree about it I will post both 32bit and 64bit JWasm.exe here
Title: Re: Signed Flags
Post by: dedndave on October 12, 2014, 11:26:53 AM
these are the flag operators supported by MASM:
ZERO?
OVERFLOW?
SIGN?
CARRY?
PARITY?


these are the x86 conditional branch instructions (not including LOOPxx instructions):
------------------------------------------------------------------------
Group     Instruction  Description               Condition       Aliases
------------------------------------------------------------------------
Equality  JZ           Jump if equal             ZF=1            JE
          JNZ          Jump if not equal         ZF=0            JNE

Unsigned  JA           Jump if above             CF=0 and ZF=0   JNBE
          JAE          Jump if above or equal    CF=0            JNC JNB
          JB           Jump if below             CF=1            JC JNAE
          JBE          Jump if below or equal    CF=1 or ZF=1    JNA

Signed    JG           Jump if greater           SF=OF or ZF=0   JNLE
          JGE          Jump if greater or equal  SF=OF           JNL
          JL           Jump if less              SF<>OF          JNGE
          JLE          Jump if less or equal     SF<>OF or ZF=1  JNG
          JO           Jump if overflow          OF=1
          JNO          Jump if no overflow       OF=0
          JS           Jump if sign              SF=1
          JNS          Jump if no sign           SF=0

Parity    JP           Jump if parity            PF=1            JPE
          JNP          Jump if no parity         PF=0            JPO


it would be nice if the assembler "examined" combinations to see if code reduction is possible
for example, the source:
    .repeat
        add     eax,dwTestVar
    .until !CARRY? && !ZERO?

would generate the code:
@@:     add     eax,dwTestVar
        jbe     @B


a couple of advantages:
1) The programmer doesn't have to consciously check flag conditions against branch instructions.
   If the statement allows the use of the shorter form, substitution takes place automatically.
2) No change in current list of reserved keywords.
   No need for SCARRY? or SZERO? operators.
Title: Re: Signed Flags
Post by: habran on October 12, 2014, 02:20:58 PM
Hi Dave,
Thanks for replaying

check this code:

    mov eax,ptScale.x
000000013FCF11F1 8B 84 24 90 00 00 00 mov         eax,dword ptr [ptScale] 
    and eax, 8000000fH
000000013FCF11F8 25 0F 00 00 80       and         eax,8000000Fh 
    .if (CARRY? && SIGN?)
000000013FCF11FD 73 09                jae         main+49h (013FCF1208h) 
000000013FCF11FF 79 07                jns         main+49h (013FCF1208h) 
      dec eax
000000013FCF1201 FF C8                dec         eax 
      or eax, -16
000000013FCF1203 83 C8 F0             or          eax,0FFFFFFF0h 
      inc eax
000000013FCF1206 FF C0                inc         eax 
    .endif
    add ptScale.x, eax
000000013FCF1208 01 84 24 90 00 00 00 add         dword ptr [ptScale],eax

now compare it with the above one with SCARRY?
Title: Re: Signed Flags
Post by: dedndave on October 12, 2014, 03:04:05 PM
yah - there is no Jcc for (carry=0 AND sign=0)  :P

typically, carry is used for unsigned operations and sign is used for signed operations
Title: Re: Signed Flags
Post by: habran on October 12, 2014, 05:50:50 PM
So you now do agree with me that SCARRY? is actually not so SCARY  ;)
Title: Re: Signed Flags
Post by: TouEnMasm on October 12, 2014, 06:34:02 PM
More sign are a good idea
Quote
ZERO?
OVERFLOW?
SIGN?
CARRY?
PARITY?
;-----------------------------------
SCARRY?           JGE    Sign flag = overflow flag               
  !SCARRY?            JL     Sign flag != overflow flag             
  SZERO?             JLE    Zero flag is set or sign != overflow   
  !SZERO?            JG     Zero flag is clear and sign = overflow 

Title: Re: Signed Flags
Post by: habran on October 12, 2014, 06:58:11 PM
ToutEnMasm MERCIE BEAUCOUP :t
Title: Re: Signed Flags
Post by: dedndave on October 13, 2014, 07:36:04 AM
;*****************************
; SIGNED OPERATIONS
;*****************************

;JG           Jump if greater           SF=OF or ZF=0
;JGE          Jump if greater or equal  SF=OF
;JL           Jump if less              SF<>OF
;JLE          Jump if less or equal     SF<>OF or ZF=1
;
;if this code were supported, then signed operations would be feasible:

;   .if SIGN?==OVERFLOW?        ;MASM generates error
;       nop
;   .endif

;the assembler would also need to code:
;"(SIGN?==OVERFLOW?) || (!ZERO?)" as a JG instruction
;and
;"(SIGN?!=OVERFLOW?) || (ZERO?)" as a JLE instruction

;other combinations form the inverted logic of the same instructions
;for instance, ".if xxx" performs code if xxx is true
;the inverse logic is used in ".until xxx", where the branch occurs if xxx is not true


;*****************************
; UNSIGNED OPERATIONS
;*****************************

;JA           Jump if above             CF=0 and ZF=0

    .if !CARRY? && !ZERO?
        nop
    .endif

;MASM assembles that code as:

        jb      label0
        jz      label0
        nop
label0:

;it would be nice if it was coded as:

        ja      label0
        nop
label0:

;-----------------------------

;JBE          Jump if below or equal    CF=1 or ZF=1

    .if CARRY? || ZERO?
        nop
    .endif

;MASM assembles that code as:

        jb      label1
        jnz     label2
label1: nop
label2:

;it would be nice if it was coded as:

        jbe     label1
        nop
label1:
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 09:54:30 AM
This is written in MASM Programmer's Guide:

Instruction Jumps if
JC/JB/JNAE   Carry flag is set
JNC/JNB/JAE Carry flag is clear
JBE/JNA        Either carry or zero flag is set
JA/JNBE        Carry and zero flag are clear
JE/JZ            Zero flag is set
JNE/JNZ        Zero flag is clear
JL/JNGE        Sign flag != overflow flag
JGE/JNL        Sign flag = overflow flag
JLE/JNG        Zero flag is set or sign != overflow
JG/JNLE        Zero flag is clear and sign = overflow
JS                Sign flag is set
JNS              Sign flag is clear
JO                Overflow flag is set
JNO              Overflow flag is clear
JP/JPE           Parity flag is set (even parity)
JNP/JPO        Parity flag is clear (odd parity)

I can make this happen in JWasm:
ZRORCRY?      jbe
!ZRORCRY?     ja

and instead of  SZERO?   and !SZERO? :


SZRORCRY?      jle
!SZRORCRY?     jg

Title: Re: Signed Flags
Post by: habran on October 13, 2014, 10:16:49 AM
here you are:

    mov eax,ptScale.x
000000013FB211F1 8B 84 24 90 00 00 00 mov         eax,dword ptr [ptScale] 
    and eax, 8000000fH
000000013FB211F8 25 0F 00 00 80       and         eax,8000000Fh 
    .if (SZRORCRY? )
000000013FB211FD 7E 07                jle         main+47h (013FB21206h) 
      dec eax
000000013FB211FF FF C8                dec         eax 
      or eax, -16
000000013FB21201 83 C8 F0             or          eax,0FFFFFFF0h 
      inc eax
000000013FB21204 FF C0                inc         eax 
    .endif
    add ptScale.x, eax
000000013FB21206 01 84 24 90 00 00 00 add         dword ptr [ptScale],eax 

    mov ecx, eax
000000013FB2120D 8B C8                mov         ecx,eax 
    and ecx, 8000000fH
000000013FB2120F 81 E1 0F 00 00 80    and         ecx,8000000Fh 
    .if (!SZRORCRY? )
000000013FB21215 7F 07                jg          main+5Fh (013FB2121Eh) 
    dec ecx
000000013FB21217 FF C9                dec         ecx 
    or ecx, -16
000000013FB21219 83 C9 F0             or          ecx,0FFFFFFF0h 
    inc ecx
000000013FB2121C FF C1                inc         ecx 
    .endif
    add eax, ecx
000000013FB2121E 03 C1                add         eax,ecx 
    mov eax, 16
000000013FB21220 B8 10 00 00 00       mov         eax,10h 
    mov ecx, eax
000000013FB21225 8B C8                mov         ecx,eax 
    and ecx, 8000000fH
000000013FB21227 81 E1 0F 00 00 80    and         ecx,8000000Fh 
    .if (!ZRORCRY? )
000000013FB2122D 77 07                ja          main+77h (013FB21236h) 
    dec ecx
000000013FB2122F FF C9                dec         ecx 
    or ecx, -16
000000013FB21231 83 C9 F0             or          ecx,0FFFFFFF0h 
    inc ecx
000000013FB21234 FF C1                inc         ecx 
    .endif
    add eax, ecx
000000013FB21236 03 C1                add         eax,ecx 
   
    mov ecx, eax
000000013FB21238 8B C8                mov         ecx,eax 
    and ecx, 8000000fH
000000013FB2123A 81 E1 0F 00 00 80    and         ecx,8000000Fh 
    .if (ZRORCRY?)
000000013FB21240 76 07                jbe         main+8Ah (013FB21249h) 
    dec ecx
000000013FB21242 FF C9                dec         ecx 
    or ecx, -16
000000013FB21244 83 C9 F0             or          ecx,0FFFFFFF0h 
    inc ecx
000000013FB21247 FF C1                inc         ecx 
    .endif
    add eax, ecx
000000013FB21249 03 C1                add         eax,ecx 

Title: Re: Signed Flags
Post by: habran on October 13, 2014, 10:29:53 AM
if you can come with more clear notation I'll be happy to accept it
all I need is to have  JG, JGE, JL, JLE, JA, JBE  branches  without using CMP, TST, OR, AND
Title: Re: Signed Flags
Post by: dedndave on October 13, 2014, 10:43:20 AM
no - i see what you are trying to do - and it's good
there have been many times when i go back to the old branch label method to get what i want
sometimes because of the lack of Jcc support - sometimes due to complex branch construction

i can't state my case any clearer, i guess - lol
my thinking was that - one of the goals is to have JwAsm compatible with Masm
so - if i write a program for one, it should assemble with the other - minimal modification required
i don't know if that is really one of Andreas' primary goals or not
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 01:08:12 PM
JWasm CAN do anything what MASM can do but MASM is just a little brother to grown up JWasm
Why would we need a backward compatibility? There would be no point to develop it
JWasm is flexible and getting better and better   

I can not go back to MASM it would be the same as trying to wear shoes from my childhood :bgrin:

I found somewhere on this forum that jj2007  also pointed out these missing flags

IMO we can not let C or C++ or any other HLL to be more capable than ASM
there would be no point to do programming in ASM
That is why, when ever I stumble on something missing or not good enough in JWasm I try to make it better
(fortunately that source code is available)
remember THE BEATLES Lyrics:"Take a sad song and make it better" :biggrin:
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 02:07:09 PM
I can change SCARRY?  to SIGNEQUO? and !SCARRY? to !SIGNEQUO?
than we would have 6 new jumps:
Instruction Jumps if:
SIGNEQUO?     jge  Sign flag = overflow flag
!SIGNEQUO?    jl     Sign flag != overflow flag
SZRORCRY?     jle    Zero flag is set or sign != overflow
!SZRORCRY?    jg     Zero flag is clear and sign = overflow
ZERORCRY?     jbe    Either carry or zero flag is set
!ZERORCRY?    ja     Carry and zero flag are clear
Title: Re: Signed Flags
Post by: dedndave on October 13, 2014, 03:05:48 PM
the names you assign aren't critical - i would try to use something readable

Unsigned
JA           Jump if above             CF=0 and ZF=0
JBE          Jump if below or equal    CF=1 or ZF=1


Signed
JG           Jump if greater           SF=OF or ZF=0
JGE          Jump if greater or equal  SF=OF
JL           Jump if less              SF<>OF
JLE          Jump if less or equal     SF<>OF or ZF=1


for unsigned, ABOVE? should do the job
JA    !ABOVE?
JBE   ABOVE?


for signed, LESS? and GREATER?
JG    !GREATER?
JGE   LESS?
JL    !LESS?
JLE   GREATER?


notice that you branch if the case is false, so they seem backwards   :P
    .if A !GREATER? B
        ;do some code
    .endif

the branch is used to jump around the code, so a JG instruction is used in that case

GREATERTHAN and LESSTHAN would also be good choices

still, the info i posted in reply #7 is valid - i.e., both could be supported
go back and read that reply again - if it is not clear to you, i will try to make 6 code examples
Title: Re: Signed Flags
Post by: TouEnMasm on October 13, 2014, 07:15:05 PM
I prefered  also name without abreviations.
I find !ZEROANDCARRY?  better than !ZERORCRY?
Pseudo code is also better in the explain.
NOT (ZERO AND CARRY)
.if !ZEROANDCARRY?
.......
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 08:04:00 PM
Hey Dave, your suggestion is brilliant, it is simple and clear :t
I have to admit that I was also thinking about it but was not able to find proper words
Thank you :biggrin:
I will take it exactly as you suggested:
JGE   LESS?
JL    !LESS?   
JG    !GREATER?
JLE   GREATER?
JA    !ABOVE?
JBE   ABOVE?

Thanks ToutEnMasm for your involvement, I appreciate it :t

I'll be back!
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 08:25:36 PM
done!

    mov eax, ptScale.x
000000013FC611F1 8B 84 24 90 00 00 00 mov         eax,dword ptr [ptScale] 
    and eax, 8000000fH
000000013FC611F8 25 0F 00 00 80       and         eax,8000000Fh 
    .if (LESS?)
000000013FC611FD 7D 07                jge         main+47h (013FC61206h) 
    dec eax
000000013FC611FF FF C8                dec         eax 
    or eax, -16
000000013FC61201 83 C8 F0             or          eax,0FFFFFFF0h 
    inc eax
000000013FC61204 FF C0                inc         eax 
    .endif
    add ptScale.x, eax
000000013FC61206 01 84 24 90 00 00 00 add         dword ptr [ptScale],eax 

    mov eax, ptScale.x
000000013FC6120D 8B 84 24 90 00 00 00 mov         eax,dword ptr [ptScale] 
    and eax, 8000000fH
000000013FC61214 25 0F 00 00 80       and         eax,8000000Fh 
    .if (!LESS?)
000000013FC61219 7C 07                jl          main+63h (013FC61222h) 
    dec eax
000000013FC6121B FF C8                dec         eax 
    or eax, -16
000000013FC6121D 83 C8 F0             or          eax,0FFFFFFF0h 
    inc eax
000000013FC61220 FF C0                inc         eax 
    .endif
    add ptScale.x, eax
000000013FC61222 01 84 24 90 00 00 00 add         dword ptr [ptScale],eax 

    mov eax,ptScale.x
000000013FC61229 8B 84 24 90 00 00 00 mov         eax,dword ptr [ptScale] 
    and eax, 8000000fH
000000013FC61230 25 0F 00 00 80       and         eax,8000000Fh 
    .if (GREATER? )
000000013FC61235 7E 07                jle         main+7Fh (013FC6123Eh) 
      dec eax
000000013FC61237 FF C8                dec         eax 
      or eax, -16
000000013FC61239 83 C8 F0             or          eax,0FFFFFFF0h 
      inc eax
000000013FC6123C FF C0                inc         eax 
    .endif
    add ptScale.x, eax
000000013FC6123E 01 84 24 90 00 00 00 add         dword ptr [ptScale],eax 

    mov ecx, eax
000000013FC61245 8B C8                mov         ecx,eax 
    and ecx, 8000000fH
000000013FC61247 81 E1 0F 00 00 80    and         ecx,8000000Fh 
    .if (!GREATER? )
000000013FC6124D 7F 07                jg          main+97h (013FC61256h) 
    dec ecx
000000013FC6124F FF C9                dec         ecx 
    or ecx, -16
000000013FC61251 83 C9 F0             or          ecx,0FFFFFFF0h 
    inc ecx
000000013FC61254 FF C1                inc         ecx 
    .endif
    add eax, ecx
000000013FC61256 03 C1                add         eax,ecx 

    mov eax, 16
000000013FC61258 B8 10 00 00 00       mov         eax,10h 
    mov ecx, eax
000000013FC6125D 8B C8                mov         ecx,eax 
    and ecx, 8000000fH
000000013FC6125F 81 E1 0F 00 00 80    and         ecx,8000000Fh 
    .if (ABOVE?)
000000013FC61265 76 07                jbe         main+0AFh (013FC6126Eh) 
    dec ecx
000000013FC61267 FF C9                dec         ecx 
    or ecx, -16
000000013FC61269 83 C9 F0             or          ecx,0FFFFFFF0h 
    inc ecx
000000013FC6126C FF C1                inc         ecx 
    .endif
    add eax, ecx
000000013FC6126E 03 C1                add         eax,ecx 
   
    mov ecx, eax
000000013FC61270 8B C8                mov         ecx,eax 
    and ecx, 8000000fH
000000013FC61272 81 E1 0F 00 00 80    and         ecx,8000000Fh 
    .if (!ABOVE?)
000000013FC61278 77 07                ja          main+0C2h (013FC61281h) 
    dec ecx
000000013FC6127A FF C9                dec         ecx 
    or ecx, -16
000000013FC6127C 83 C9 F0             or          ecx,0FFFFFFF0h 
    inc ecx
000000013FC6127F FF C1                inc         ecx 
    .endif
    add eax, ecx
000000013FC61281 03 C1                add         eax,ecx 

Title: Re: Signed Flags
Post by: dedndave on October 13, 2014, 09:08:12 PM
i guess some of those are not really necessary, come to think of it

Masm (and probably JwAsm) supports ">=", "<=", "<", and ">"
and, signed comparisons by using the SDWORD PTR specifier

later today, i'll play with some code to see what's missing
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 09:15:16 PM
Hey Dave SDWORD doesn't work in these cases that's why I went through all this

here are binaries   
Title: Re: Signed Flags
Post by: nidud on October 13, 2014, 10:09:20 PM
deleted
Title: Re: Signed Flags
Post by: dedndave on October 13, 2014, 11:02:23 PM
right - that was before my first cup of coffee - lol
ignore that post   :P

we are talking about pre-existing flag conditions - not compares
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 11:18:00 PM
Yes Dave, that is good wording pre-existing flag conditions
(reminds me on premature... something) ;)
your English is pretty good
Actually I am never sure if you Americans speak English or American
I know for sure that Australians speak Australian language because when I came here
they did not understand my 'English' (which we were taught in my school) :biggrin:
Title: Re: Signed Flags
Post by: dedndave on October 13, 2014, 11:25:25 PM
British English is pretty strange, too - lol
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 11:30:13 PM
Certainly!
If you want to learn nice smooth English watch the SBS news (here in OZ)
Do you also have SBS news in US?
Title: Re: Signed Flags
Post by: TouEnMasm on October 13, 2014, 11:34:23 PM

I had dowloaded the new JWASM
"JWASM isn't a valid WIN32 aplication"

Seems there is a problem ? (xp sp3)
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 11:40:56 PM
I have Window 7
If you want I can post here hll.c
the rest of source you take from my last post
and than build it with your favorite program
Title: Re: Signed Flags
Post by: habran on October 13, 2014, 11:45:20 PM
here is hll.c
replace former with this one
Title: Re: Signed Flags
Post by: nidud on October 14, 2014, 12:01:53 AM
deleted
Title: Re: Signed Flags
Post by: habran on October 14, 2014, 06:00:42 AM
Hi nidud :biggrin:
which one looks better?

  .repeat 
    .if LESS?
      inc eax
    .endif
  .until  ABOVE?

  .repeat 
    .if .ifge
      inc eax
    .endif
  .until .ifa
Title: Re: Signed Flags
Post by: habran on October 14, 2014, 06:03:04 AM
ToutEnMasm have you succeeded to build JWasm on your machine?
Title: Re: Signed Flags
Post by: TouEnMasm on October 14, 2014, 06:08:52 AM

That's a great question.I have a source code than I can compile with vc express 2010.
Question is :
Wich source code to download and wich file to add/modify ?
With an answer ,I can do it.
Title: Re: Signed Flags
Post by: nidud on October 14, 2014, 06:18:42 AM
deleted
Title: Re: Signed Flags
Post by: habran on October 14, 2014, 06:19:07 AM
It is JWasmHabran.zip this link http://masm32.com/board/index.php?topic=3149.0 (http://masm32.com/board/index.php?topic=3149.0)

the folder contains JWasm binaries and MVS13 Expres solution
it also contains changed sources
because of forum limitation I couldn't upload complete sources
so if someone wants to build it, must download it from Japheth site and than add missing sources
headers are all there so you don't need to touch the H folder
Title: Re: Signed Flags
Post by: habran on October 14, 2014, 06:29:58 AM
great job nidud :t
Title: Re: Signed Flags
Post by: nidud on October 14, 2014, 07:38:17 AM
deleted
Title: Re: Signed Flags
Post by: habran on October 14, 2014, 09:51:28 AM
Hey nidud :biggrin:
that is remarkable how your brains work :eusa_clap:
However, with only a few changes in original source code we can get all of this
this is hll.c
here I added last 3 characters

/* items in table below must match order COP_ZERO - COP_OVERFLOW */
static const char flaginstr[] = { 'z', 'c', 's', 'p', 'o', 'l', 'g', 'a'};


enum c_bop {
  COP_NONE,
  COP_EQ,   /* == */
  COP_NE,   /* != */
  COP_GT,   /* >  */
  COP_LT,   /* <  */
  COP_GE,   /* >= */
  COP_LE,   /* <= */
  COP_AND,  /* && */
  COP_OR,   /* || */
  COP_ANDB, /* &  */
  COP_NEG,  /* !  */
  COP_ZERO, /* ZERO?   not really a valid C operator */
  COP_CARRY,/* CARRY?  not really a valid C operator */
  COP_SIGN, /* SIGN?   not really a valid C operator */
  COP_PARITY,  /* PARITY?   not really a valid C operator */
  COP_OVERFLOW, /* OVERFLOW? not really a valid C operator */
  //added by habran
  COP_LESS,/* SIGN=OVERFLOW  not really a valid C operator */
  COP_GREATER, /* SIGNED ZERO OR CARRY   not really a valid C operator */
  COP_ABOVE  /* ZERO OR CARRY  not really a valid C operator */
};



  else {
    if (item->token != T_ID)
      return(COP_NONE);
    /* a valid "flag" string must end with a question mark */
    size = strlen(p);
    if (*(p + size - 1) != '?')
      return(COP_NONE);
    if (size == 5 && (0 == _memicmp(p, "ZERO", 4)))
      rc = COP_ZERO;
    else if (size == 6 && (0 == _memicmp(p, "CARRY", 5)))
      rc = COP_CARRY;
    else if (size == 5 && (0 == _memicmp(p, "SIGN", 4)))
      rc = COP_SIGN;
    else if (size == 7 && (0 == _memicmp(p, "PARITY", 6)))
      rc = COP_PARITY;
    else if (size == 9 && (0 == _memicmp(p, "OVERFLOW", 8)))
      rc = COP_OVERFLOW;
    //added by habran
    else if (size == 5 && (0 == _memicmp(p, "LESS", 4)))
      rc = COP_LESS;
    else if (size == 8 && (0 == _memicmp(p, "GREATER", 7)))
      rc = COP_GREATER;
    else if (size == 6 && (0 == _memicmp(p, "ABOVE", 5)))
      rc = COP_ABOVE;
    else
      return(COP_NONE);
  }



Title: Re: Signed Flags
Post by: habran on October 14, 2014, 10:20:57 AM
I have uploaded the C source in the post 1 of this thread and headers post 3 because they are together greater than 512K
Title: Re: Signed Flags
Post by: nidud on October 16, 2014, 10:29:11 PM
deleted
Title: Re: Signed Flags
Post by: habran on October 17, 2014, 06:34:03 AM
Hi nidud :biggrin:
I admire your intellect, enthusiasm and programming skills 8)
I also came to this idea but I realized that it would be to complex and confusing :dazzled:
Whatever changes I have done to JWasm is because of my needs, and I find this solution simple and clear:
signed jumps
   LESS?             JGE skip
   !LESS?            JL   skip
   GREATER?       JLE skip
  !GREATER?      JG   skip
unsigned missing jumps
   ABOVE?         JBE skip
   !ABOVE?        JA   skip
As we can see only Dave and ToutEnMasm are interested in this matter and they both agree with above flags,
so I decided to keep them
Thank you for your interest and time spent on this matter, I appreciate it :t