Computer/assembly language

posted by .

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 -

    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)
    Add rb,rc
    RB = 0x0006

    if RA≠0, Repeat division
    RA = 0x0000
    RC = 0x0003 (remainder)
    shift left 8 bits
    RC = 0x0030
    add rb,rc
    RB = 0x0036


    You will have to do some register management to put the quotient and remainder in the right places.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Converting decimal(floating point) to octal/hex

    Hi everybody, Can anybody show me how to convert 0.59375(decimal) to Octal and Hexadecimal?
  2. computers

    All Processing and storage of data inside a computer is done in _____ Form. A)binary B)hexadecimal C)decimal D)character
  3. computer science /use java language

    write the program that inputs a string representing a binary number(0s and 1s). First, your program should veerify that it is indeed a binary number, that is, the number contains only 0s and 1s . if that is not the case, your program …
  4. computer science (Assembly language)

    Hello, i am new at assembly language and i just got started with this stuff. I have this assignment which doesn't make any sense to me. Can someone please help?
  5. computer science

    What is the binary representation of the following hexadecimal number?
  6. trig

    Given BC = 53 cm, BD = 62 cm, CD = 80 cm, ABC = 53°, and ACB = 66°, find the following. (Round your answers to the nearest whole number.) (a) the length of the chainstay, AC AC = cm (b) BCD BCD = °
  7. electronic logic

    write from 0- 1000 in binary hexadecimal octal and decimal

    A firm is assigned the network part 128.171. It selects a 10-bit subnet part. a) Draw the bits for the four octets of the IP address of the first host on the first subnet. (Hint: Use Windows Calculator.) b) Convert this answer into …
  9. C++

    A c++ program which convert from decimal, octal & hexadecimal to binary equivalent with array concept.
  10. Computer Science

    Convert the following binary numbers to decimal (6 points): 11111 101011 1101011 Convert the following decimal numbers to binary (6 points): 49 367 1023 Convert the following hex numbers to decimal (4 points): ACE 800 Convert the following …

More Similar Questions