Loops in Assembly

Problem #197

Tags: assembly if-else loops special binary c-1 c-0

Who solved this?

No translations... yet

Try this problem after Mul Two if you have troubles with Fibonacci Randomizer. Here we are going to learn how simple conditions and loops are used.

The task is very simple. You will be given an integer (in range 0..15) in the R1. You should count how many bits it have raised (equal to 1) and put the result in R0.

Note that your answer should be a valid source for running in Intel 4004 emulator.

Input on program start R1 is initialized with some value.
Result should be count of bits stored in R0 after program finishes.

Examples:

input:    0 0 ...
result:   0 ...

input:    0 1 ...
result:   1 ...

input:    0 2 ...
result:   1 ...

input:    0 3 ...
result:   2 ...

input:    0 f ...
result:   4 ...
You need to login to get test data and submit solution.