Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

hexadecimal to decimal conversion code in assembly

Status
Not open for further replies.

jit_singh_tara

Full Member level 6
Joined
Dec 22, 2006
Messages
325
Helped
9
Reputation
18
Reaction score
4
Trophy points
1,298
Location
Delhi , India
Activity points
4,293
0a hexadecimal to decimal

hi therr,
can any one tell me how to convert hexadecimal value in decimal in 8051 assembly programming.

wat i m doing is making a circuit 0 to 99 counter on two seven segments.
i want to read external interrupt , store it in a register say r2 and increment it on every interrupt , now obviously the value incremented or stored in r2 will b in hex.for example after 9 it will b incremented to 0A(hex) instead of 10(decimal) .
i want to use r2 to break it into two nibbles and send them to two 7 segments.
so that i can have 0 on lower 7segment and 1 on upper 7segment.

plz plz help.
 

hex to decimal conversion code

Here is your code (for demo purpose):
Code:
Decimal2:     
     MOV   A,R2
     MOV   B,#10
     DIV   A,B
     MOV   P1,A   ; Upper 7 segment LED display with 7447
     MOV   P2,B   ; Lower 7 segment LED display with 7447
     RET
 
hexadecimal to decimal 8051

here is the code...
its in asm 8051...
this programs assume the hex value is in acc...

;-------------------------------------------------------------------------------
hex_to_dec:
mov b,#100d
div ab
mov hun,a ;hundreds place is copied in say 30h(hun)
mov a,b ;remender is copied in acc
mov b,#10d ;
div ab
mov tens,a ;tens place is copied in say 31h(tens)
mov units,a ;units place is copied in say 32h(units)
ret
;----------------------------------------------------------------------------------
 
hexadecimal to decimal conversion assembly

You can also count directly in decimal. Then you will need to use de decimal adjust instrucction.
It will be faster than the division required to convert from hexadecimal and you can also look at the value in memory when you simulate
 
Re: hexadecimal to decimal conversion code in C

can any one help me on how to convert hex values to decimal using C (8051)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top