LINUX The following code can be imported intothe ebe assembler IDE. Whileit's mostly correct, it's missing something.
Question:
LINUX
The following code can be imported intothe ebe assembler IDE. Whileit's mostly correct, it's missing something. You'llneed to fix it up and then make sure it assembles correctly
segment .text
global main
main: mov rax, [data] ; rax holds the data
xor ebx, ebx ; clear since setc will fill in bl
xor ecx, ecx ; i = 0;
xor edx, edx ; sum = 0;
while: cmp rcx, 64 ; while ( i < 64 ) {
jnl end_while ; requires testing on opposite
bt rax, 0 ; data & 1
setc bl ; move result of test to bl
add edx, ebx ; sum += data & 1;
shr rax, 1 ; data = data >> 1;
inc rcx ; i++;
jmp while ; end of the while loop
end_while:
mov [sum], rdx ; save result in memory
xor eax, eax ; return 0 from main
ret
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe