用汇编,编写程序计算1+2+3+4+........+100并将结果显示在屏幕上

来源:百度知道 编辑:UC知道 时间:2024/06/17 08:50:07
急啊

code segment
assume cs:code
start:
mov ax,code
mov ds,ax
lea dx,mes
mov ah,9
int 21h
xor ax,ax
mov cx,100
add ax,cx
loop $-2;当前地址减去2就是上一条指令
xor cx,cx
mov bx,10
Q0:
xor dx,dx
div bx
or dx,0e30h
inc cx
push dx
cmp ax,0
jnz Q0
Q1:pop ax
int 10h
loop Q1
mov ah,1
int 21h
mov ah,4ch
int 21h
mes db '1+2+3+4+...+100=$'
code ends
end start

code segment
assume cs:code
start:
mov ax,code
mov ds,ax
xor ax,ax
mov cx,100
add ax,cx
loop $-2//当前地址减去2就是上一条指令
mov ax,4c00h
int 21h
code ends
end start
这是我认为的最简单的一种方式,其实还有其它的做法,这也是我在网上看到的,你看看吧!