ADDR B1 B2 B3 B4 thrass11.tmp PAGE 1 * Standard equates CODE EQU $E000 ; Start code in EEPROM DATA EQU $0000 ; Start data in page 0 internal RAM STACK EQU $ff ; Start stack at top of external RAM. EOS EQU $FF ; Well use hex $FF to mark end-of- . string of BCD bytes. ORG DATA ; Begin data segment. 0000 01 23 45 67 array FCB $01,$23,$45,$67,$89,EOS ; Array of packed BCD . 0004 89 FF bytes result RMB 10 ; We'll put the . result here ORG CODE ; Begin code segment. E000 8E 00 FF Main: LDS #STACK ; Load stack pointer E003 CE 00 00 LDX #array ; Load address of data array E006 18 CE 00 06 LDY #result ; Ditto for result array E00A A6 00 Loop: LDAA 0,X ; Get byte to convert E00C 81 FF CMPA #EOS ; Compare byte with end of string E00E 27 0D BEQ Done ; If end of string, then stop E010 BD E0 20 JSR BCD2ASC ; Call subroutine to do conversion E013 18 ED 00 STD 0,Y ; Store D in result array E016 08 INX ; Go to the next input byte E017 18 08 INY ; Go to next output word E019 18 08 INY E01B 20 ED BRA Loop ; Do it all again E01D 3E Done: WAI ; End of main program, wait for . interrupts E01E 20 FE Infloop: BRA Infloop ; If we ever get here, stay here ************************* * Subroutine Name: Bcd2Asc * Input parameter list: A * Output parameter list: A,B **************************** * This routine converts a Packed BCD byte in A * into a pair of ASCII characters in A,B. ************************************************** LOWER EQU $0F ; Mask for low nybble UPPER EQU $F0 ; Mask for high nybble ASCII EQU $30 ; ASCII code for numeral 0 E020 16 Bcd2Asc: TAB ; Copy A register to B E021 C4 0F ANDB #LOWER ; Mask lower nybble of B E023 CB 30 ADDB #ASCII ; Convert B to ASCII code E025 84 F0 ANDA #UPPER ; Mask upper nybble of A E027 44 LSRA ; Logical shift right 4 positions E028 44 LSRA E029 44 LSRA E02A 44 LSRA E02B 8B 30 ADDA #ASCII ; Convert A to ASCII E02D 39 RTS ; Return result in A,B Symbol Table DONE E01D LOWER 000F RESULT 0006 CODE E000 BCD2ASC E020 MAIN E000 STACK 00FF INFLOOP E01E EOS 00FF ASCII 0030 ARRAY 0000 Symbol Table thrass11.tmp PAGE 2 LOOP E00A UPPER 00F0 DATA 0000