;This program converts three ASCII decimal nums into a single byte 0-255
;Input loc 400h-401h-402h
;Output location 403h
;Second output location 404h - 405 - 406 recreated decimal ascii using 
;  location 403h as input
        mov     al, byte ptr 400h       ;grab 100s digit
        sub     al, '0'                 ;de-ascii-fy it  '0' ->0  or '9' -> 9
;mult result by 10.  Later, it will be multiplied by 10 again, resulting in * 100
        add     al, al                  ;mult by 2
        mov     bl, al                  ;hold result
        add     bl, bl                  
        add     bl, bl                  ;original digit * 8
        add     bl, al                  ;original digit * 10
;do the same for second digit (10s)

        mov     al, byte ptr 401h       ;grab 10s
        sub     al, '0'                 ;de ascii fy
        add     al, bl                  ;add 100s digit (*10)plus tens digit
; multiply two digits by 10
        add     al, al                  ;times 2
        mov     bl, al
        add     bl, bl
        add     bl, bl                  ;times 8
        add     bl, al                  ;100 * digit1 + 10 * digit2

; get the 1s digit
        mov     al, byte ptr 402h       ;get 1s digit
        sub     al, '0'                 ;convert from ascii
        add     al, bl                  ;the converted number
        mov     byte ptr 403h, al       ;whew!

;Now, reverse the process, using 403h as the input
        mov     dh, byte ptr 403h       ; bring it back in
        mov     cl, '0'                 ;start counter at ascii zero
hun:    cmp     dh,  100
        jb      tens
        sub     dh, 100
        add     cl, 1                   ;cut 100 off and count it!
        jmp     hun
tens:   mov     byte ptr 404h, cl       ;move out 100s answer
        mov     cl, '0'                 ;count of 10s in ascii
tenlp:  cmp     dh, 10  
        jb      ones
        sub     dh, 10
        add     cl, 1                   ;cut 10off and count it!
        jmp     tenlp
ones:   mov     byte ptr 405h, cl       ;move out 10s answer
        add     dh, '0'                 ;asciify 1s
        mov     byte ptr 406h, dh       ;move out 1s answer
        int     20h