A
A
Alan Turing2020-05-21 02:14:55
assembler
Alan Turing, 2020-05-21 02:14:55

How can I change the program to count units in a 32-bit number?

Good day, gentlemen
, there is a program where the units are counted, I need to count the zeros
, I realized that a jnc transition is used to search for the unit, but I don’t know how to find all the zeros?

.data;
msg_title db "Title", 0
buffer db 256 dup(?)
format db "%d", 0
.code

start:
mov edx, 819 ;число, в котором будем считать единицы
mov ecx, 0
mov ebx, 1
loop_start: 
cmp ecx, 32 
jge loop_end 
rol edx, 0 
jnc bit0 
inc ebx 
bit0:
inc ecx 
jmp loop_start
loop_end: 

fn MessageBox,0,str$(ebx),"Result",MB_OK
invoke ExitProcess, 0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-05-21
@cryptaeser

I have no idea how to find all the zeros?

The number of zeros in a 32-bit number is 32 - (количество единиц). But if you really want to calculate - replace jncwith jc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question