flat assembler
Message board for the users of flat assembler.

 Index > Main > invert ZF Goto page Previous  1, 2
Author
Teehee

Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 28 Sep 2011, 19:58
whats the difference among CF and OF ? and after all when CF is set or cleared?
28 Sep 2011, 19:58

Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 30 Sep 2011, 16:45
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
30 Sep 2011, 16:45
Teehee

Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 30 Sep 2011, 20:14
so basicaly OF for signed and CF for unsigned?
30 Sep 2011, 20:14
Teehee

Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 05 Oct 2011, 16:12
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.
05 Oct 2011, 16:12
MHajduk

Joined: 30 Mar 2006
Posts: 6094
Location: Poland
MHajduk 05 Oct 2011, 16:25
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
05 Oct 2011, 16:25
Teehee

Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 05 Oct 2011, 17:06
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.
05 Oct 2011, 17:06
MHajduk

Joined: 30 Mar 2006
Posts: 6094
Location: Poland
MHajduk 05 Oct 2011, 17:20
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    ```
05 Oct 2011, 17:20
Teehee

Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 05 Oct 2011, 18:55
weird... 0x03FF0000 != 11111111110000000000000000000000.

 eh, i forgot the endian thing..
05 Oct 2011, 18:55
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area
Goto page Previous  1, 2

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum