I wrote up an NASM source with similar functions to your
own code. A function for reversing the array, for
adding the two arrays as unpacked BCS, and for entering
values are here. Call to array reversal is commented out.
After three characters have been read in either a + or =
sign is displayed, numbers are added, result is printed.
bits 16
org 100h
jmp Ldead_stag
glass times 0x3 db 0x0
neck times 0x3 db 0x0
withme times 0x4 db 0x0
Ldead_stag:
mov bx, glass ; our first sequence of
; arbitrary digits from user
mov dl, '+' ; a maltese cross character, plus
call stolen_dec
mov bx, neck ; our second array
mov dl, '=' ; equality symbol
call stolen_dec
;mov bx, glass
;call permutate
call sum_dumb
call flashed_sum
ret
stolen_dec: ; DL-A + or = with
; permission BX-points to array
push dx
mov cx, 3
stolen_dec_talks:
mov ah, 0x1
int 0x21
and al, 0xf
mov [bx], al
inc bx
dec cx
jnz stolen_dec_talks
pop dx
mov ah, 0x2
int 0x21
ret
sum_dumb:
mov bx, glass+2
mov si, neck+2
mov di, withme+3
xor ah, ah
mov cx, 3
sum_dumb_l:
mov al, [bx]
add al, [si]
aaa
cmp ah, 0
jnz sum_dumb_addend
sum_dumb_imback:
add al, [di]
mov [di], al
dec bx
dec si
dec di
dec cx
jnz sum_dumb_l
ret
sum_dumb_addend:
mov [di-1], ah
xor ah, ah
jmp sum_dumb_imback
flashed_sum:
mov bx, withme
mov cx, 4
flashed_sum_again:
mov dl, [bx]
add dl, 0x30
mov ah, 2
int 0x21
inc bx
dec cx
jnz flashed_sum_again
ret
permutate: ; a array reversal BX=array
; assumes 3 byte array
mov di, bx
add bx, 2
mov cx, 2
permutate_again:
mov al, [di]
mov dl, [bx]
mov [bx], al
mov [di], dl
inc di
dec bx
dec cx
jnz permutate_again
ret