Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

(6) If E(X) = 1 and E(X2) = 2, then the variance is 2. Pg45

Answered: 1 week ago

Question

Describe three other types of visual aids.

Answered: 1 week ago