Problem: Write a Nios II program that converts an n-digit decimal integer into a binary Example B.12 number. The decimal number is given as n ASCII-encoded characters, as would be the case if the number is entered by typing it on a keyboard Solution: Consider a four-digit decimal number, D-dzd2dido. The value of this number is ((d3 x 10 + d2) x 10 + di) x 10 + do. This representation of the number is the basis for the conversion technique used in the program in Figure B.17. Note that each ASCII encoded character is converted into a Binary Coded Decimal (BCD) digit before it is used in the computation 히 r2 is a counter, initialize it with n movia r2, N ldw 2. (r2) movia r3, DECIMAL /* r3 points to the ASCII digits. / add r4, r0, r0 1 r4 will hold the binary number. *! /* Get the next ASCII digit. LOOP:ldbr5. (r3) andi r5, r5, OxOF Form the BCD digit add addir3. r3. 1 r4, r4, r5 Add to the intermediate result. / Decrement the counter Multiply by 10 /* Increment the digit pointer 히 ge beq muli br r2, r2, 1 r2, rO, DONE r4, r4, 10 LOOP 히 히 Loop back if not done DONE: movia r5, BINARY Store the result in stw r4, (r5) memory location BINARY. 히
HOW OUR WEBSITE WORKS
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of
HIGH QUALITY & PLAGIARISM FREE.
To make an Order you only need to click PLACE ORDER on top of this page and we will direct you to our Order Page at WriteDen. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Deadline range from 6 hours to 30 days.
Once done with writing your paper we will upload it to your account on our website and also forward a copy to your email.
Upon receiving your paper, review it and if any changes are needed contact us immediately. We offer unlimited revisions at no extra cost.
Is it Safe to use our services?
We never resell papers on this site. Meaning after your purchase you will get an original copy of your assignment and you have all the rights to use the paper.
Our price ranges from $8-$14 per page. If you are short of Budget, contact our Live Support for a Discount Code. All new clients are eligible for 15% off in their first Order. Our payment method is safe and secure.
Please note we do not have prewritten answers. We need some time to prepare a perfect essay for you.
Interested in purchasing an essay from us? Click PLACE ORDER on top of this page