Reputation: 218
Could someone please explain to me why the following program won't show anything on screen? So what I tried to do is calculate the sum of a vector like so:
.model small
.stack 100h
.data
vector db 1,2,3,4,5,6,7,8,9
suma db 0
count db 9
msg db 10,13,"Sum is:$"
.code
mov ax,@data
mov ds,ax
mov si,0
xor si,si
xor cx,cx
mov cl,count
repeta:
mov al,vector[si]
add suma,al
inc si
loop repeta
mov bx,ax
mov ah,09
lea dx,msg
int 21h
mov ah,2
mov dl,bl
int 21h
mov ah,2
mov dl,bl
int 21h
mov ah,4ch
int 21h
end
Upvotes: 2
Views: 2250
Reputation: 39556
mov bx,ax
There's nothing meaningful in AX
at this point in the program. The value that you're after is in the suma variable.
Next code will show results provided the sum stays below 100.
mov ah, 09h
lea dx, msg
int 21h
mov al, suma ;Result happens to be 55
aam ;Tens go to AH, units go to AL
or ax, "00" ;Make ASCII characters
mov bx, ax ;Move to safe place
mov ah, 02h
mov dl, BH ;Display tens
int 21h
mov ah, 02h
mov dl, BL ;Display units
int 21h
mov ah, 00h
int 16h ;Wait for a key
Upvotes: 7