| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Assembly Questions and Answers for Assembly here! |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Will this code set and clear zero and sign flags
I'm a beginning and am having problems with this code. I think my problem is with my data statement. Please provide help. Here's the code:
.data .386 .model flat, stdcall option casemap :none ; case sensitive .code main PROC mov cl,1 ; CL=1 sub cl,1 ; CL=0, SF=0, ZF=1 call DumpRegs sub cl,1 ; CL=-1, SF=1, ZF=0 call DumpRegs add ch,1 ; CH=0, SF=0, ZF=1 call DumpRegs add ch,1 ; CH=1, SF=0, ZF=0 call DumpRegs exit main ENDP END main |
|
#2
|
||||
|
||||
|
Re: Will this code set and clear zero and sign flags
To manipulate the CPU flags you can use the pushf and popf functions. The push and pop the flag register onto the stack. With that you can retrieve the flags modify them and set them back.
Code:
pushf pop ax ; Now modify them, they are in ax push ax popf
__________________
I am not offering technical guidiance via email or IM Come on share your photo with us! CG members photo album! Use the Code Tags! Last edited by NoHero; January 30th, 2005 at 09:18 AM. |
|
#3
|
|||
|
|||
|
Re: Will this code set and clear zero and sign flags
Thanks for the response. I see that you used an alternative method, which is good to know. However, I was wondering if the code I wrote could be used, and if so, what am I doing wrong to make it execute properly?
Thanks in advance for your help. |
|
#4
|
|||
|
|||
|
Re: Will this code set and clear zero and sign flags
Quote:
Code:
add ch,1 ; CH=0, SF=0, ZF=1 call DumpRegs I'm guessing you wanted to use CL instead of CH. You can also manipulate set flags via - SAHF (sotre AH into flags). This will only modify the lower 8 bits of the flags. 'extended' 32bit flags won't be changed. Direction, interupt enable, Carry flags can be set/cleared directly via CLD/STD, CLI/STI, CLC/STC |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|