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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/05/05 09:14
Read: times


 
#104685 - The source with comments !
Responding to: ???'s previous message
; 8 BCD digits are placed in 4 addresses, highest 2 (D1-D2) are first. Convert
; them to 4 byte binary and place them to R5-R4-R3-R2 (R5 highest)


X008a:	mov	a,@r0		; Take first (highest) pair BCD digits (D1-D2)
	inc	r0
	lcall	BCD2BI

	mov	b,#64h		; Mply by 100
	mul	ab
	mov	r2,a		; Lower
	mov	r3,b		; Higher

	mov	a,@r0		; Next pair (D3-D4)
	inc	r0
	lcall	BCD2BI

	add	a,r2		; Add first mplied pair
	jnc	X009f
	inc	r3		; Now (D1-D2-D3-D4) is converted to R3-R2 (max 9999)

X009f:	mov	b,#64h		; Mply lower byte by 100
	mul	ab
	mov	r2,a		; Lower
	mov	a,b
	xch	a,r3		; Save Higher temporary, take prev Higher ...

	mov	b,#64h		; ... to mply by 100
	mul	ab
	add	a,r3
	mov	r3,a
	clr	a
	addc	a,b
	mov	r4,a		; 100*(D1-D2-D3-D4) converted to R4-R3-R2 (max 999900)

	mov	a,@r0		; Next pair (D5-D6) should be added to this
	inc	r0
	lcall	BCD2BI

	add	a,r2		; Add to lowest, and update higher bytes
	jnc	X00be
	inc	r3
	cjne	r3,#0,X00be
	inc	r4		; (D1-D2-D3-D4-D5-D6) converted to R4-R3-R2 (max 10to6-1)

X00be:	mov	b,#64h		; Mply by 100
	mul	ab
	mov	r2,a
	mov	a,b
	xch	a,r3
	mov	b,#64h		; Mply by 100
	mul	ab
	add	a,r3
	mov	r3,a
	clr	a
	addc	a,b
	xch	a,r4
	mov	b,#64h		; Mply by 100
	mul	ab
	add	a,r4
	mov	r4,a
	clr	a
	addc	a,b
	mov	r5,a		; 100*(D1-D2-D3-D4-D5-D6) converted to R5-R4-R3-R2

	mov	a,@r0		; Add D7-D8
	inc	r0
	lcall	BCD2BI
	add	a,r2
	jnc	X00eb		; Update higher bytes
	inc	r3
	cjne	r3,#0,X00eb
	inc	r4
	cjne	r4,#0,X00eb
	inc	r5
X00eb:	mov	r2,a
	ret

;


BCD2BI:	xrl	a,#0f0h		; Complement only higher nibble
	jbc	acc.4,X00f4	; If 0, add 10, else only clear it
	add	a,#0ah		; add 10
X00f4:	jbc	acc.5,X00f9
	add	a,#14h		; add 20
X00f9:	jbc	acc.6,X00fe
	add	a,#28h		; add 40
X00fe:	jbc	acc.7,X0103
	add	a,#50h		; add 80
X0103:	ret	
;


Regards, Slobodan


List of 30 messages in thread
TopicAuthorDate
week puzzle V            01/01/70 00:00      
   that would be intersating only to codebr            01/01/70 00:00      
      codebreakers            01/01/70 00:00      
         busted            01/01/70 00:00      
   having a guess            01/01/70 00:00      
   Hmm,isn't it demotivating to reengineer?            01/01/70 00:00      
      Cool algorithm            01/01/70 00:00      
      maybe            01/01/70 00:00      
   Looks like BCD to binary routine            01/01/70 00:00      
   My assumption            01/01/70 00:00      
   The source with comments !            01/01/70 00:00      
      thanks            01/01/70 00:00      
         Seems more elegant ...            01/01/70 00:00      
            optimized=ugly            01/01/70 00:00      
         why "xrl a,#0F0h" ?            01/01/70 00:00      
            Wow!            01/01/70 00:00      
         A bit shorter ...            01/01/70 00:00      
            za Slobodana Mandarica            01/01/70 00:00      
      another approach            01/01/70 00:00      
         optimizing further            01/01/70 00:00      
            packed bcd            01/01/70 00:00      
               packed bcd... by specification :-)            01/01/70 00:00      
      that is not comments, that is "explanati            01/01/70 00:00      
         true if            01/01/70 00:00      
         Yes they are Comments            01/01/70 00:00      
            Exactly !            01/01/70 00:00      
            I have seen such called "comments" way t            01/01/70 00:00      
               more on comments            01/01/70 00:00      
                  the point            01/01/70 00:00      
                     "anyone" and the point            01/01/70 00:00      

Back to Subject List