Author Topic: Signed Flags  (Read 14761 times)

ToutEnMasm

  • Member
  • *****
  • Posts: 1190
    • EditMasm
Re: Signed Flags
« Reply #15 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?
.......
Fa is a musical note to play with CL

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #16 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!
Cod-Father

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #17 on: October 13, 2014, 08:25:36 PM »
done!
Code: [Select]
    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 

Cod-Father

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Signed Flags
« Reply #18 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
« Last Edit: October 13, 2014, 11:23:25 PM by dedndave »

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #19 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   
Cod-Father

nidud

  • Member
  • *****
  • Posts: 1689
    • https://github.com/nidud/asmc
Re: Signed Flags
« Reply #20 on: October 13, 2014, 10:09:20 PM »
Code: [Select]
.data
val sdword -1
.code
.if sdword ptr eax < 0
    inc eax
.endif
.if val < eax
    inc eax
.endif
        end

Code: [Select]
00000000                        .if sdword ptr eax < 0
00000000  83F800            *   cmp sdword ptr eax , 0
00000003  7D01              *   jnl @C0001
00000005  40                    inc eax
00000006                        .endif
00000006                    *   @C0001:
00000006                        .if val < eax
00000006  390500000000      *   cmp val , eax
0000000C  7D01              *   jnl @C0002
0000000E  40                    inc eax
0000000F                        .endif
0000000F                    *   @C0002:

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Signed Flags
« Reply #21 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

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #22 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:
Cod-Father

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Signed Flags
« Reply #23 on: October 13, 2014, 11:25:25 PM »
British English is pretty strange, too - lol

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #24 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?
Cod-Father

ToutEnMasm

  • Member
  • *****
  • Posts: 1190
    • EditMasm
Re: Signed Flags
« Reply #25 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)
 
Fa is a musical note to play with CL

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #26 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
Cod-Father

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #27 on: October 13, 2014, 11:45:20 PM »
here is hll.c
replace former with this one
Cod-Father

nidud

  • Member
  • *****
  • Posts: 1689
    • https://github.com/nidud/asmc
Re: Signed Flags
« Reply #28 on: October 14, 2014, 12:01:53 AM »
Code: [Select]
.ifa
.ifb
        .ife
.ifg
.ifl
...
.ifae
.ifbe
.ifge
.ifle
...

habran

  • Member
  • *****
  • Posts: 1193
    • uasm
Re: Signed Flags
« Reply #29 on: October 14, 2014, 06:00:42 AM »
Hi nidud :biggrin:
which one looks better?
Code: [Select]
  .repeat 
    .if LESS?
      inc eax
    .endif
  .until  ABOVE?
 
  .repeat 
    .if .ifge
      inc eax
    .endif
  .until .ifa
Cod-Father