im trying to count a number of 0nes in an XOR output of binary numbers and need a control structure that will enable a register to increment it content.

here is what i have so far

TITLE number of ones in an xor output (XorOutputNumberOfOnes.asm)

INCLUDE Irvine32.inc

.code

main PROC

mov eax,00110001b ;puts 00110001 binary to eax

mov edx,00011001b ;puts 00011001 binary to eax

XOR eax,edx ;sets the XOR output to eax

xor ebx,ebx ;set ebx equal to zero
mov ecx,8

shiftl: ;loop to shift to the left

shl eax,1 ;shift to the let by one position

;a control stament goes here for searchin that identifies a carry

inc ebx ; increment ebx whenever there is a carry

loop shiftl

exit

main ENDP

END main

Hi,

What you're after is:

adc ebx, 0

instead of

inc ebx

adc will add the value of the carry flag.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.