主题:诚心求教
程序功能:将c语言中的以下语句转成功能相同的汇编语句
for(i=1,j=0;i<100;i++){
if(i%2==0) j+=i;
并按十进制字符串的形式输出结果.
我写了如下程序,但72以内可以输出,但大于72时就不能输出了.
请问是什么原因呢?
.model small
.stack 256
.data
output_buff db 5 dup(' '),0dh,0ah,"$"
.code
;宏功能:按十进制ascii码显示数字
;入口:bx,_output(存放要输出的字符)
dispbx macro _output
local _dispbx_1,_dispbx_2
push ax
push bx
push cx
push dx
push ds
mov ax,seg _output
mov ds,ax
cmp bx,0
jge _dispbx_1
mov dl,'-'
mov ah,02h
int 21h
neg bx
_dispbx_1:
mov ax,bx
mov cx,10d
mov bx,4
_dispbx_2:
xor dx,dx
div cx
add dl,30h
mov _output[bx],dl
dec bx
cmp al,0
jg _dispbx_2
lea dx,_output
mov ah,09h
int 21h
pop ds
pop dx
pop cx
pop bx
pop ax
endm
.startup
mov cx,1
xor bx,bx
part_1:
mov ax,cx
and ax,1
jnz part_2
add bx,cx
part_2:
inc cx
cmp cx,74
jb part_1
dispbx output_buff
.exit
end
for(i=1,j=0;i<100;i++){
if(i%2==0) j+=i;
并按十进制字符串的形式输出结果.
我写了如下程序,但72以内可以输出,但大于72时就不能输出了.
请问是什么原因呢?
.model small
.stack 256
.data
output_buff db 5 dup(' '),0dh,0ah,"$"
.code
;宏功能:按十进制ascii码显示数字
;入口:bx,_output(存放要输出的字符)
dispbx macro _output
local _dispbx_1,_dispbx_2
push ax
push bx
push cx
push dx
push ds
mov ax,seg _output
mov ds,ax
cmp bx,0
jge _dispbx_1
mov dl,'-'
mov ah,02h
int 21h
neg bx
_dispbx_1:
mov ax,bx
mov cx,10d
mov bx,4
_dispbx_2:
xor dx,dx
div cx
add dl,30h
mov _output[bx],dl
dec bx
cmp al,0
jg _dispbx_2
lea dx,_output
mov ah,09h
int 21h
pop ds
pop dx
pop cx
pop bx
pop ax
endm
.startup
mov cx,1
xor bx,bx
part_1:
mov ax,cx
and ax,1
jnz part_2
add bx,cx
part_2:
inc cx
cmp cx,74
jb part_1
dispbx output_buff
.exit
end