RT
以知有20个无符号数,存放在以A为首地址的内存单元中,试编制一个程序,完成以下功能:
求出所有奇数的和,偶数的和,能被3整除的数的个数,并依次存放在DDSVM、EVENSM和
COUNT单元中。
谢谢MM和GG帮忙说下
data segment
a dw 20 dup(?)
ddsvm dw ?
evensm dw ?
count db ?
data ends
stack segment
dw 40h dup(?)
stack ends
code segment
assume cs:code,ds:data,ss:stack
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
start:
mov ax,data
mov ds,ax
lea dx,a
mov ah,0ah
int 21h
lea si,a
mov cx,20
;push ax
;push dx
;push ds
again1:
mov bx,[si]
test bx,01h
;and bx,01h
jz l1
;mov dx,0
mov ddsvm,0
add ddsvm,bx
add si,2
loop again1
;mov ddsvm,dx
; mov ax,seg ddsvm
;mov ds,ax
;lea dx,ddsvm
mov ah,02h
int 21h
jmp bch
l1:
push dx
mov dx,0
add dx,bx
inc si
loop again1
mov evensm,dx
pop dx
mov ax,seg evensm
mov ds,ax
lea dx,evensm
mov ah ,09h
int 21h
jmp bch
call bg
mov ah,4ch
int 21h
bg proc near
push ax
push bx
push dx
push si
push cx
again2:
mov al,0
mov cx,20
mov ax,a
mov bl,3
div bl
cmp ah,0
je l2
jmp bch
l2:
inc al
loop again2
mov count,al
pop ax
pop bx
pop dx
pop si
pop cx
mov ah,9
mov bh,[count]
mov bl,7
mov cx,1
int 10h
bch:
mov ah,4ch
int 21h
ret
bg endp
code ends
end start
这个是我自己弄 的好象有好多错误 ,BB帮忙给改改