; digl403 Lab3 ; Program to demo the stack by Doug Stewart May 2000 ; slightly modified by Mike Dawdy ;Program equ $c000 Program equ $2000 Stack equ Program+$0300 org $0000 asc1 rmb 1 ;result here ... asc2 rmb 1 ; ... and here ; input byte to data1 using BUFFALO [MM 02] command data1 rmb 1 org Program start lds #Stack ldx #$1000 ;not used ldaa data1 ;load input byte into A bsr hex2ascii ;convert [A] to 2 displayable bytes bsr asc2hex ;convert the 2 bytes back to A swi ;logical end of program ; A = hex number ; change each nybble to an ascii code ; the results will be found in asc1 and asc2 hex2ascii ;convert hex to ascii psha ;save [A] and do left nybble lsra lsra lsra lsra bsr asc ;change to ascii staa asc1 pula ;get [A] back and do right nybble anda #$0F bsr asc staa asc2 rts ; get 2 asc11 chars and put them together to make a byte ; the 2 chars are in asc1 and asc2 ; the result is returned in the A register asc2hex pshb ;protect B from destruction ldaa asc1 bsr hex1 asla asla asla asla ;multiply by 16 tab ;save in b ldaa asc2 bsr hex1 aba ;make one byte pulb ;restore B rts ; change a hex nybble to ascii and return it in the A mmregister asc cmpa #$a bhs aa1 adda #$30 bra aaend aa1 adda #$37 aaend rts ; take an ascii hex value and change to a number hex1 cmpa #$3A bhs hh1 suba #$30 bra hh1end hh1 suba #$37 hh1end rts