Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/23/11 12:25
Read: times


 
#182994 - bcdtohex code in assembly
Responding to: ???'s previous message
Here is your code

;routine for bcd to binary conversion in assembly
;answer in R0(Lower byte),R1(middle byte),R2(Higherbyte)

.equ unit,030h
.equ ten,031h
.equ hund,032h
.equ thous,033h
.equ tenthous,034h
.equ lacs,035h
.equ tmp_carry,039h
.equ addingreg,03ah

.org 0000
ljmp main


.org 0070h
main: mov SP,#060h

mov unit,#06h ;as for example
mov ten,#01h
mov hund,#04h
mov thous,#08h
mov tenthous,#02h
mov lacs,#09h

mov R0,lacs
mov R1,#0
mov R2,#0

lcall mulroutine

mov addingreg,tenthous

lcall sumroutine

lcall mulroutine

mov addingreg,thous

lcall sumroutine

lcall mulroutine

mov addingreg,hund

lcall sumroutine

lcall mulroutine

mov addingreg,ten

lcall sumroutine

lcall mulroutine

mov addingreg,unit

lcall sumroutine

main1: sjmp main1





mulroutine: mov a,R0
mov b,#0ah
mul ab

mov tmp_carry,b
mov R0,a

mov a,R1
mov b,#0ah
mul ab

clr c
add a,tmp_carry
mov R1,a

mov a,b
addc a,#00h
mov tmp_carry,a

mov a,R2
mov b,#0ah
mul ab

add a,tmp_carry
mov R2,a

ret



sumroutine:
clr c
mov a,R0
addc a,addingreg
mov R0,a

mov a,R1
addc a,#0h
mov R1,a

mov a,R2
addc a,#0h
mov R2,a

ret


List of 10 messages in thread
TopicAuthorDate
BCD TO HEXA IN ASSEMBLY            01/01/70 00:00      
   Think about it            01/01/70 00:00      
   School task            01/01/70 00:00      
      RE: Do you think you would even understand the code?            01/01/70 00:00      
   Fundamental Issue Here            01/01/70 00:00      
      Conversion vs Representation - and meaning of "BCD"            01/01/70 00:00      
   bcdtohex code in assembly            01/01/70 00:00      
      hardly            01/01/70 00:00      
         How to *usefully* post code            01/01/70 00:00      
   1 month later, and an identical post appears on Keil            01/01/70 00:00      

Back to Subject List