Hi,
I want to know how the 6 digit bcd is converted into hex value Ex: 123456 to 1E240. Please help me by providing the assembly code for 8051.
Homework?
Ya i did it for 5 digit BCD that is till 65535 i am able to convert, but now i want to do it for next counts as well as for 6 digits so please help me in this case...
Sharath
BCD_TO_BIN 01E240h
Hi,macro
I am not getting what you posted here
Thanks
Why don't you simply ask a question - surely, you have encountered problems trying (have you?) - instead of asking for the whole thing really for shipment?
So what's the problem with extending that to the next digit??
Or is the real problem that you didn't actually understand your 5-digit code - therefore you don't understand how to extend it?
See your cross-post here: www.8052.com/.../182709
Hi macro
This is what i have did...
BCD2BIN:
; Input B R0R1 ; (B msd & R1 lsd)
; Output R2R3 ; (r2 msb)
MOV B,#5H
MOV R0,#10H
MOV R1,#20H
clr A
mov R2,A
mov R3,A ; release B reg to use in mul intruction
mov a,b ; speed up if B (ms digits are 0)
jz bb_230
mov r4,a
CALL DO_ONE_DIGIT
bb_230:
mov A,R0
mov R4,A
call DO_ONE_DIGIT
mov a,R1
Call DO_ONE_DIGIT
ret
DO_ONE_DIGIT:
call BIN_MUL_10
jc dod_10
mov A,R4
swap A
anl A,#0fh
add A,R3
mov R3,A
addc a,r2
mov r2,a
dod_10:
BIN_MUL_10:
mov B,#10
mov A,R3
mul AB
mov A,B
xch A,R2
add A,R2
jc BM_10
jz BM_10
cpl C
BM_10: ret
END
If you know how to do for the higher values please let me know....
JOHN: PUSH IE CLR EA LCALL EMANAL MOV DPH,#JENIFER MOV DPL,#WD2 MOVX A,@DPTR ANL A,#06H CJNE A,#06H,NATT1 MOV A,TNIPPLEL MOV DPH,#JENIFER MOV DPL,#TSADDL MOVX @DPTR,A MOV A,TNIPPLEH MOV DPH,#JENIFER MOV DPL,#TSADDH MOVX @DPTR,A ANDY1: MOV A,TNIPPLEL MOV DPH,#JENIFER MOV DPL,#TEADDL MOVX @DPTR,A MOV DPL,#TEADDH MOV A,TNIPPLEH MOVX @DPTR,A POP IE MOV DPH,#JENIFER MOV DPL,#WD2 MOVX A,@DPTR JB ACC.1,NITJP CLR IJSTAT LJMP ITER2 ANDY2: JB ACC.2,NIJMP3 JNB ITJMP,NIJMP1 ERIK1: SETB IJSTAT MOV DPH,#JENIFER MOV DPL,#ITJUMP MOVX A,@DPTR ANL A,#0FH MOV R1,A JZ NIJMP1 MOV DPH,#JENIFER MOV DPL,#APPTR+1 MOVX A,@DPTR ERIK2: CLR C SUBB A,#4 DJNZ R1,DECAP1 MOVX @DPTR,A DEATH: LCALL TNBFAV LCALL PANIC JNB FULANAL,ONL58 MOV DPH,#JENIFER MOV DPL,#QNIPPLEL MOVX A,@DPTR MOV DPL,#TSADDL MOVX @DPTR,A MOV DPL,#TEADDL MOVX @DPTR,A MOV TNIPPLEL,A MOV DPL,#QNIPPLEH MOVX A,@DPTR MOV DPL,#TSADDH MOVX @DPTR,A MOV DPL,#TEADDH MOVX @DPTR,A MOV TNIPPLEH,A LCALL MANALMT JB NODATA,NOWEM2 LJMP OL458 NOWEM2: CLR FULANAL LJMP OL458A ONL58: POP IE NIJMP2: LJMP TURD NIJMP3: SETB TRANST SJMP NIJMP6 NIJMP5: JB LOWCH,NIJMP8 SETB DAT2TX POP IE LJMP SUPERV NIJMP6: MOV DPL,TNIPPLEL MOV DPH,TNIPPLEH MOV DCRAP0,DPL MOV DCRAP1,DPH MOV A,#ATTDEL MOVX @DPTR,A LCALL PTRINC MOV TNIPPLEL,DPL MOV TNIPPLEH,DPH MOV DPH,#JENIFER MOV DPL,#QNIPPLEL MOV A,TNIPPLEL MOVX @DPTR,A MOV DPL,#TSADDL MOVX @DPTR,A MOV DPL,#QNIPPLEH MOV A,TNIPPLEH MOVX @DPTR,A MOV DPL,#TSADDH MOVX @DPTR,A LCALL ANALFUL LCALL PANIC JNB FULANAL,NIJMPC LIPGLOSS: MOV DPH,DCRAP1 MOV DPL,DCRAP0 MOV A,#DELIMT MOVX @DPTR,A CLR TRANST LJMP OL458
@macro micro,
Why isn't my name labelled?!
hi macro,
I am not getting any thing in what you have posted.. and I think this is not a code for bcd to hex conversion...
@ Andrew Neil,
Till 65535 only 2 registers are enough but for the next digit i need to take one more register for the converted out put and i am finding difficult there..
You didn't follow the instructions for posting source code, did you?
Look at the picture - it tells you clearly what to do: www.danlhenry.com/.../keil_code.png
Your code is also devoid of any meaningful comments.
Your first step to understanding what that code does should be to comment what it is doing.
Again, if you understand what your code is doing, you should easily be able to extend it to extra digits...
BTW: Are you sure you are dealing with BCD here...?
@Tamir Michael,
Sorry. I didn't mean to offend with my omission.
TAMIR: LCALL DO_TAMIR_TYPE_THINGS LCALL IS_DUMB_OP_QUESTION_PENDING JZ TAMIR LCALL ANSWER_DUMB_OP_QUESTION SJMP TAMIR
Again, you already have code that deals with multiple registers - look at how that works, and extend it.
And again: Your first step, of course, must be to understand the code that you have.
This thread is about BCD: http://www.keil.com/forum/19104/
Do you really mean BCD ?
en.wikipedia.org/.../Binary-coded_decimal