		move.l	#number,a0	; Address for number to split
		move.l	#string,a1	; Address for storing result
		bsr	Disassemble	; Split one byte into two

		move.l	#string,a0	; Address of number to convert
		move.l	#result,a1	; Address for result
		bsr	Convert		; Convert it to BCD
		rts

;------------------------------------------------------------------------
;
;                         Subroutine Convert
;
; PURPOSE:             Convert a disassembled byte in decimal format
;                      to a hexadecimal number.
;
; INITIAL CONDITIONS:  The address of the disassembled byte is in A0
;                      The address where to store the result is in A1
;
; FINAL CONDITIONS:    The address given in A1 contains the hexadecimal
;                      value of the decimal number.
;
; SAMPLE CASE:     Initial conditions:
;                      A0 contains the address $20000 
;                      The two first bytes beginning at $20000 is
;                       $05 and $07 (the disassembled number $57)
;                      A1 contains the address $30000
;                  Final conditions:
;                      The address $30000 contains $37
;
;------------------------------------------------------------------------

Convert:	movem.l	d0-d3/a0,-(sp)
		moveq	#1,d0		; Number of digits(-1) to process
		clr.l	d1		; Clear final result - D1
		clr.l	d2		; Clear digit register
		bra.s	nomult		; Skip multiply first time

loop:		add.w	d1,d1		; 2X
		move.w	d1,d3
		lsl.w	#2,d3		; 8X = 2X * 4
		add.w	d3,d1		; 10X = 8X + 2X

nomult:		move.b	(a0)+,d2	; Next BCD digit,(D2[15-8] unch.)
		add.b	d2,d1		; Add next digit
		dbra	d0,loop	    ; Continue processing if still digits
		move.b	d1,(a1)		; Store result
		movem.l	(sp)+,d0-d3/a0
		rts

;------------------------------------------------------------------------
;
;                      Subroutine disassemble
;
; PURPOSE: Split a byte value into two bytes (each containing one digit
;          from the byte).
;
; INITIAL CONDITIONS:  The address of the number to convert is in A0
;                      The address of where to store the result is in A1
;
; FINAL CONDITIONS:    The address given in A1 contains the disassembled
;                      value of the number from address A0
;
; SAMPLE CASE:     Initial conditions:
;                      A0 contains $20000
;                      The byte at $20000 contains $57
;                      A1 contains $30000
;                  Final conditions:
;                      The address $30000 contains $05,
;                      The address $30001 contains $07
;
;------------------------------------------------------------------------

Disassemble:	movem.l	d0/a0-a1,-(sp)
		moveq	#0,d0		; Clear D0
		move.b	(a0)+,d0	; Get byte to process
		rol.w	#4,d0		; Move byte to D0 (4-11)
		lsr.b	#4,d0		; Shift D0 (4-7) to D0 (0-3)

		move.b	d0,1(a1)	; Save least significant number
		lsr.w	#8,d0		; Get the most sign. number
		move.b	d0,(a1)		; and save it
		movem.l	(sp)+,d0/a0-a1
		rts

;------------------------------------------------------------------------

string:		blk.b	2,0
number:		blk.b	1,$57
result:		blk.b	1,0
		blk.b	16,0
