食野苹

计算1+...+100的结果

data segment
sum dw 0
data ends

code segment
assume cs:code,ds:data
main:
mov ax,data
mov ds,ax
mov cl,100
mov ax,0
again:
inc ax
add sum,ax
dec cl
 jnz again


mov  ax,sum
sub ax, 13bah
mov sum, ax
mov cl,4
shr ax,cl ;take middle 4 bits
and ax,000fh

add ax,30h

mov dl, al
mov ah, 2
int 21h

mov  ax,sum
and ax,000fh ;take upper 4 bits
add ax,30h

mov dl, al
mov ah, 2
int 21h

mov ah,4Ch;终止当前程序并返回调用程序
int 21h;

code ends
end main

 

posted on 2011-07-27 15:44  nyc1893  阅读(240)  评论(0编辑  收藏  举报