Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Convert Hex. to Decimal

Convert Hex. to Decimal

Convert Hex. to Decimal

I am studying computing science at university and i am having problems with the following homework
I'm hoping someone will be able to help me out.

Develop an emmbedded intel 8086 assembler program in stages to solve the following problem

Convert a string containing an unsigned integer as a sequence of hexidecimal character digits to another string containing the corresponding decimal character digits within the assembler, without using any logical operations (AND,OR,XOR,shift), without using multiplication or division operations and without using a straight sequence of simple 4 repeated ADD operations to achieve multiplication.
The Pascal section will only input the original string and print the result.
(assume that the maximum hex. input number is 7FFF. use only 8-bit and 16-bit registers, except for the 32-bit string address register.)

You may find it helpful to use internal procedure calls in the assembler, which jump to a section of code with a label and which returns to the assembler statment after the call

    CALL  @POINT  {call procedure POINT}
    @POINT NOP    {start of procedure}
    RET           {return from procedure}

I have 3 days left before I have to hand it in.
Cheers Steve

RE: Convert Hex. to Decimal

Ok. I don't have time to think of a better solution (Any solution is better than this one), but it is better than nothing, so here it is:

MOV     CX,0FFFFh        ;the number to turn to Decimal
MOV     AX,0
MOV     BX,0
MOV     DL,0
INC     AL               ;AL is the first digit
CMP     AL,0Ah           ;Has it reached 10 yet?
JNE     CONTINUE         ;No, continue.
MOV     AL,0             ;Yes, empty it
INC     AH               ;AH is the second digit
CMP     AH,0Ah           ;Has it reached 10 yet?
JNE     CONTINUE         ;No, continue ...
MOV     AH,0
INC     BL               ;BL is the third digit
CMP     BL,0Ah
MOV     BL,0
INC     BH               ;BH is the forth digit
CMP     BH,0Ah
MOV     BH,0
INC     DL               ;DL is the fifth digit

Now you will have every Decimal digit in a different 8-bit register. Making the string from here shouldn't be a problem.

Hope you find a better solution, and if you do, or if your teacher shows you one, please tell me about it.

RE: Convert Hex. to Decimal

I would suggest to use this algorithm:
- Check how many 10 thousands your number has

@loop_TT :
CMP Number, 3e8h
JMP @loop_TT

; {Now you have to display value of CX, if it is more than Ah, then display '1', then SUB CX,0Ah , display the rest}

and this algo should do the same for thousands,hundreds, tens and the last display as it appears.

Best Regards,

aphrodita@mail.krovatka.ru     {uiuc rules}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close