flat assembler
Message board for the users of flat assembler.

Index > Main > invert ZF

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
whats the difference among CF and OF ? and after all when CF is set or cleared?
Post 28 Sep 2011, 19:58
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
Overflow happens when signed number maximum/minimum is reached.
1a) CF is set when eax=0, sub eax,1
1b) CF is set when eax=4294967296, add eax,1
2a) OF is set when eax=-2147483648, sub eax,1
(after sub instruction eax=2147483647
2b) OF is set when eax=2147483647, add eax,1
(after add instruction eax=-2147483648 (signed) 2147483648 (unsigned)

Basically on a scale from 0 to 2^32 CF/OF are sentinels here:
CF________________OF________________CF
Post 30 Sep 2011, 16:45
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
so basicaly OF for signed and CF for unsigned?
Post 30 Sep 2011, 20:14
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
bitRAKE wrote:
Of course, there is the bitmap method, too. Only uses 32 bytes of data (single cacheline). Only uses a single register.
Code:
    xor eax,eax
    lodsb
    bt [_alphanum],eax
; carry flag is result
    ret    
...might want to inline it.

How does that method works, bitRAKE? can you give me a small full example?

_________________
Sorry if bad english.
Post 05 Oct 2011, 16:12
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
Teehee wrote:
bitRAKE wrote:
Of course, there is the bitmap method, too. Only uses 32 bytes of data (single cacheline). Only uses a single register.
Code:
    xor eax,eax
    lodsb
    bt [_alphanum],eax
; carry flag is result
    ret    
...might want to inline it.

How does that method works, bitRAKE? can you give me a small full example?
Teehee, I described this method with some examples here: http://board.flatassembler.net/topic.php?p=109261#109261
Post 05 Oct 2011, 16:25
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
i think i got it. For example, for decimal number (0-9) you set (1) all the bits number 48 till 57 (0 to 9 char ascii table correspondency) so BT will look for the bit at that possition and put it in CF. Thats it?

Code:
; table to decimal 0-9 
0000000000000000 0000000000000000 0000000000000001 1111111110000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000    

?

_________________
Sorry if bad english.
Post 05 Oct 2011, 17:06
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
You should get something like that (written as dwords):
Code:
CharFunction dd 0x00000000, 0x03FF0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000    
(you have to remember that we number bits starting from 0 not 1, so in your table you have to shift all '1' one position to the right):
Code:
; table to decimal 0-9 
0000000000000000 0000000000000000 0000000000000000 1111111111000000

0000000000000000 0000000000000000 0000000000000000 0000000000000000

0000000000000000 0000000000000000 0000000000000000 0000000000000000

0000000000000000 0000000000000000 0000000000000000 0000000000000000    
Post 05 Oct 2011, 17:20
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
weird... 0x03FF0000 != 11111111110000000000000000000000.

[edit] eh, i forgot the endian thing.. Razz
Post 05 Oct 2011, 18:55
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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 GitHub, YouTube, Twitter.

Website powered by rwasa.