Hi,
does the x86 ISA pport an instruction to read the
carry flag and move it to a register?
Something like this:
mov ecx, 32
move edx, 0
loopL:
shl eax, 1
XXX ebx ; load carry flag into ebx (zero extended)
add edx, edx, ebx
loop loopL
Is there any instrtuction for XXX?
Regards,
Chris
|
|
0
|
|
|
|
Reply
|
Christian
|
5/24/2006 12:32:42 PM |
|
Christian Christmann wrote:
> mov ecx, 32
> move edx, 0
> loopL:
> shl eax, 1
> XXX ebx ; load carry flag into ebx (zero extended)
> add edx, edx, ebx
> loop loopL
>
>
> Is there any instrtuction for XXX?
Well, why don't you change the add to an adc? Are you going to use the
carry flag in ebx for anything else?
Bjarni
--
INFORMATION WANTS TO BE FREE
|
|
0
|
|
|
|
Reply
|
Bjarni
|
5/24/2006 6:48:50 PM
|
|
Christian Christmann wrote:
> Hi,
>
> does the x86 ISA pport an instruction to read the
> carry flag and move it to a register?
>
> Something like this:
>
> mov ecx, 32
> move edx, 0
> loopL:
> shl eax, 1
> XXX ebx ; load carry flag into ebx (zero extended)
> add edx, edx, ebx
> loop loopL
>
>
> Is there any instrtuction for XXX?
>
> Regards,
> Chris
Well, there is LAHF and SAHF (load/store AH / flags).
Of course,you can also use
mov 0, ebx
rcl ebx, 1
Cheers,
Randy Hyde
|
|
0
|
|
|
|
Reply
|
randyhyde
|
5/24/2006 7:59:20 PM
|
|
Christian Christmann wrote:
> Hi,
>
> does the x86 ISA pport an instruction to read the
> carry flag and move it to a register?
>
> Something like this:
>
> mov ecx, 32
> move edx, 0
> loopL:
> shl eax, 1
> XXX ebx ; load carry flag into ebx (zero extended)
> add edx, edx, ebx
> loop loopL
>
>
> Is there any instrtuction for XXX?
There's not a single instruction to do exactly what you want, but if
the destination is cleared first, an adc or rcl will do the trick, a
setc will set an entire byte (but not all of ebx), and then you can
lahf or pushf/pop and extract the bit manually.
|
|
0
|
|
|
|
Reply
|
robertwessel2
|
5/24/2006 9:55:19 PM
|
|
robertwessel2@yahoo.com <spamtrap@crayne.org> wrote in part:
> Christian Christmann wrote:
>> does the x86 ISA pport an instruction to read the
>> carry flag and move it to a register?
>>
> There's not a single instruction to do exactly what you want,
What about `sbb eax,eax` ? This will set EAX=0 if CF=0,
and EAX=0FFFFFFFFh if CF=1.
-- Robert
|
|
0
|
|
|
|
Reply
|
Robert
|
5/24/2006 10:56:52 PM
|
|
Robert Redelmeier wrote:
> robertwessel2@yahoo.com <spamtrap@crayne.org> wrote in part:
> > Christian Christmann wrote:
> >> does the x86 ISA pport an instruction to read the
> >> carry flag and move it to a register?
> >>
> > There's not a single instruction to do exactly what you want,
>
> What about `sbb eax,eax` ? This will set EAX=0 if CF=0,
> and EAX=0FFFFFFFFh if CF=1.
That's good, I hadn't thought of that, but the OP did specify zero
extension.
|
|
0
|
|
|
|
Reply
|
robertwessel2
|
5/25/2006 1:00:05 AM
|
|
Robert Redelmeier wrote:
> robertwessel2@yahoo.com <spamtrap@crayne.org> wrote in part:
>> Christian Christmann wrote:
>>> does the x86 ISA pport an instruction to read the
>>> carry flag and move it to a register?
>>>
>> There's not a single instruction to do exactly what you want,
>
> What about `sbb eax,eax` ? This will set EAX=0 if CF=0,
> and EAX=0FFFFFFFFh if CF=1.
Then he'll still have to and it with 1 to make it 1.
Bjarni
--
INFORMATION WANTS TO BE FREE
|
|
0
|
|
|
|
Reply
|
Bjarni
|
5/25/2006 1:10:36 AM
|
|
|
6 Replies
480 Views
(page loaded in 0.076 seconds)
Similiar Articles: Read carry flag - comp.lang.asm.x86Hi, does the x86 ISA pport an instruction to read the carry flag and move it to a register? Something like this: mov ecx, 32 move edx, 0 loopL: s... Trick with SBB instruction - comp.lang.asm.x86Read carry flag - comp.lang.asm.x86 Trick with SBB instruction - comp.lang.asm.x86... or subtract (-1 + 1) = 0 from -1. > > I.e. the idiom seems to turn a carry flag into ... Bit-Shifting in ASM - comp.lang.asm.x86Read carry flag - comp.lang.asm.x86 bit shifting - comp.lang.c How to Use Bit Shifting in Cryptography | eHow ... MOVZX has stall register - comp.lang.asm.x86 Modifying a ... CPUID and number of cores - comp.lang.asm.x86Read carry flag - comp.lang.asm.x86 CPUID and number of cores - comp.lang.asm.x86... xor edx, edx cpuid mov edi, a mov [edi], eax mov edi, b mov [edi], ebx mov edi, c mov ... Major differences between MIPS and ARM - comp.archRead carry flag - comp.lang.asm.x86 Major differences between MIPS and ARM - comp.arch - ARM has a carry flag that makes multi-word integers easy to handle. Interrupted system calls (socket read) , EINTR and SIGTERM - comp ...I have a code snippet like this while(1) { while((n = read(connection->sock ... This what I thought, set a global flag in the signal handler, check that flag in the ... improve strlen - comp.lang.asm.x86hi all i have read some manual pent opt; i have tried write my pesonal routine ... the first 2 bytes add eax, 2 @@: shl cl, 1 ; use carry flag ... reading a .csv file with a space after negative sign - comp.soft ...Is there any way to read a .csv file with the contents ... was that the ...negative sign... was more of a dash/flag ... Take the N x 2 numeric array that is output, and ... use of W&Z reg in 8085 - comp.dsp... What do you call a christian who accidently read the bible with his brain turned on? ... The 8085 flags are S-Sign flag, Z-Zero flag, AC-Auxiliary carry flag, P-Parity flag ... Reading a Line from a file - comp.soft-sys.matlab> > > I'm not at MATLAB right now, but does it really take so long to read through 500k lines when ... However the matlab part isn't right, it's > actually: > > [theline,flag ... Carry flag - Wikipedia, the free encyclopediaIn computer processors the carry flag (usually indicated as the C flag) is a single bit in a ... Read; Edit; View history Read carry flag - comp.lang.asm.x86 | Computer GroupHi, does the x86 ISA pport an instruction to read the carry flag and move it to a register? Something like this: mov ecx, 32 move edx, 0 loopL: s... 7/24/2012 8:33:26 AM
|