Question: Can you converty the C-style pseudocode into Assembly language please. Collatz Conjecture receives an 8-bit HEX number through command line parameter outputs a sequence of

Can you converty the C-style pseudocode into Assembly language please.

Collatz Conjecture receives an 8-bit HEX number through command line parameter outputs a sequence of numbers according to Collatz Conjecture

From https://en.wikipedia.org/wiki/Collatz_conjecture

The conjecture is that no matter what value of n, the sequence will always reach 1.

In modular arithmetic notation, define the function f as follows: f(n+1) = n/2, if n==0 (mod 2) f(n+1) = 3n+1, if n==1 (mod 2)

this corresponds to the following C style pseudocode: printf("number = %d ",number) while(number != 1) { step++ if(number % 2) number = 3*number + 1 else number /= 2 printf("number = %d ",number) } printf("Total Steps: %d ",steps)

where number = n and steps counts the number of steps for the sequence to converge to 1 ___________________________________________ Using the compilation command: nasm -f elf *.asm; ld -m elf_i386 -s -o demo *.o; demo 0x13

The following output should be produced BEGIN PROGRAM

number = 0x13

number = 0x3A

number = 0x1D

number = 0x58

number = 0x2C

number = 0x16

number = 0x0B

number = 0x22

number = 0x11

number = 0x34

number = 0x1A

number = 0x0D

number = 0x28

number = 0x14

number = 0x0A

number = 0x05

number = 0x10

number = 0x08

number = 0x04

number = 0x02

number = 0x01

Steps = 0x14

END PROGRAM

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!