Posted by traxx on Sunday, November 14, 2010 at 8:21am.
Write a procedure BCD to convert a hexadecimal number in RA into its BCD (binary-coded decimal) representation and place it in RB. The return address should be placed in RF. For example, if RA=0x0024 before the call, RB=0x0036 after the all.
// can someone tell me how to write that//
- Computer/assembly language - MathMate, Sunday, November 14, 2010 at 3:08pm
0x0024 is 2*16+4=36, which is what is required in RB 0x0036.
Basically, the hex value is converted into decimal, and each decimal digit is stored as a byte in RB.
The algorithm to do this is to divide the hex number by 10 (decimal), store the integer quotient in a register, and the remainder is the first byte in RB.
Repeat the process, i.e. divide the quotient by 10(dec.). However, the remainder must be shifted 8 bits to the left before adding to RB to get the next digit.
Repeat, if necessary, until the quotient is zero.
RA = 0x0024
RB = 0x0000
Divide by 0x000A to get
RA = 0x0003 (quotient)
RC = 0x0006 (remainder)
RB = 0x0006
if RA≠0, Repeat division
RA = 0x0000
RC = 0x0003 (remainder)
shift left 8 bits
RC = 0x0030
RB = 0x0036
You will have to do some register management to put the quotient and remainder in the right places.
Answer this Question
More Related Questions
- Computer Sceince - Convert the following binary numbers to decimal (6 points): ...
- computer science - What is the binary representation of the following ...
- trig - Given BC = 53 cm, BD = 62 cm, CD = 80 cm, ABC = 53°, and ACB = 66°, find ...
- computer science /use java language - write the program that inputs a string ...
- computer science (Assembly language) - Hello, i am new at assembly language and...
- C++ - A c++ program which convert from decimal, octal & hexadecimal to binary ...
- Converting decimal(floating point) to octal/hex - Hi everybody, Can anybody show...
- computers - All Processing and storage of data inside a computer is done in ...
- COMPUTER DATA NETWORKS - A firm is assigned the network part 128.171. It selects...
- electronic logic - write from 0- 1000 in binary hexadecimal octal and decimal