* HEX_BCD subroutine * This S/R converts from Hex to BCD the number in accA HEX_BCD PSHX ; save X in the stack PSHB ; save B in the stack TAB ; transfer info from A into low D CLRA ; clear A LDX #10 ; load 10 into X IDIV ; divide info by 10. Quotient ends ; in X, reminder stays in low D TBA ; transfer reminder (1st decimal ; digit) from low D into A PSHA ; save 1st digit in the stack XGDX ; exchange D and X. Quotient ; (i.e., 2nd digit) is now in low D ; i.e, in B PULA ; retrieve A from the stack. ; 1st digit is now in A LSLB ; shift B to the left 4 times to get LSLB ; 2nd digit to the left of B LSLB ; LSLB ; ABA ; add A and B, results stays in A ; now we have both digits in A, ; in the proper order. PULB ; retrieve original B from stack PULX ; retrieve original X from stack RTS ; return