汇编语言输出sum,和n的值到屏幕上,老鸟们教教啊!!!问题如下
从自然数1开始累加,直到累加和大于1000为止,统计被累加的自然数的个数,并把统计的个数送入n单元,把累加和送入sum单元帮忙写个输出程序,能够将结果显示在左面上,十六进...
从自然数1开始累加,直到累加和大于1000为止,统计被累加的自然数的个数,并把统计的个数送入n单元,把累加和送入sum单元
帮忙写个输出程序,能够将结果显示在左面上,十六进制结果,小弟不胜感激!高手们帮帮忙。。。谢谢谢谢谢,先谢谢了
DATAS SEGMENT
n DW ?
sum DW ?
DATAS ENDS
STACK SEGMENT PARA STACK' STACK'
DW 200 DUP (?)
STACK ENDS
CODES SEGMENT
MAIN PROC FAR
ASSUME CS:CODES,DS:DATAS,SS:STACK
START: PUSH DS
MOV AX,0
PUSH AX
MOV AX,DATAS
MOV DS,AX
MOV AX,0
MOV BX,0
MOV CX,0
LOOPT: INC BX
ADD AX,BX
INC CX
CMP AX,1000
JBE LOOPT
MOV n, CX
MOV sum, AX
RET
MAIN ENDP
CODES ENDS
END START 展开
帮忙写个输出程序,能够将结果显示在左面上,十六进制结果,小弟不胜感激!高手们帮帮忙。。。谢谢谢谢谢,先谢谢了
DATAS SEGMENT
n DW ?
sum DW ?
DATAS ENDS
STACK SEGMENT PARA STACK' STACK'
DW 200 DUP (?)
STACK ENDS
CODES SEGMENT
MAIN PROC FAR
ASSUME CS:CODES,DS:DATAS,SS:STACK
START: PUSH DS
MOV AX,0
PUSH AX
MOV AX,DATAS
MOV DS,AX
MOV AX,0
MOV BX,0
MOV CX,0
LOOPT: INC BX
ADD AX,BX
INC CX
CMP AX,1000
JBE LOOPT
MOV n, CX
MOV sum, AX
RET
MAIN ENDP
CODES ENDS
END START 展开
展开全部
DATAS SEGMENT
n DW ?
sum DW ?
DISP DB 5 DUP('$')
MSG0 DB 'N=','$'
MSG1 DB 'SUM=','$'
DATAS ENDS
STACK SEGMENT PARA STACK 'STACK'
DW 200 DUP (?)
STACK ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACK
START:
MOV AX,STACK
MOV SS,AX
MOV SP,400
MOV AX,DATAS
MOV DS,AX
MOV AX,0
MOV BX,0
MOV CX,0
LOOPT: INC BX
ADD AX,BX
INC CX
CMP AX,1000
JBE LOOPT
MOV n, CX
MOV sum, AX
MOV AH,09H
LEA DX,MSG0
INT 21H
LEA SI,DISP
MOV BX,N
CALL OUTPUT
LEA DX,DISP
MOV AH,09H
INT 21H
CALL CRLF
MOV AH,09H
LEA DX,MSG1
INT 21H
LEA SI,DISP
MOV BX,SUM
CALL OUTPUT
LEA DX,DISP
MOV AH,09H
INT 21H
MOV AX,4C00H
INT 21H
crlf:
mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
output:
mov ch,4
mov cl,4
s0:
rol bx,cl ;每4位二进制数对应一位十六进制数,分别取出来转化就好
mov dx,bx
and dl,0fh
cmp dl,9
jbe d0_9
add dl,07h
d0_9:
add dl,30h
mov [si],dl
inc si
dec ch
jnz s0
ret
CODES ENDS
END START
n DW ?
sum DW ?
DISP DB 5 DUP('$')
MSG0 DB 'N=','$'
MSG1 DB 'SUM=','$'
DATAS ENDS
STACK SEGMENT PARA STACK 'STACK'
DW 200 DUP (?)
STACK ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACK
START:
MOV AX,STACK
MOV SS,AX
MOV SP,400
MOV AX,DATAS
MOV DS,AX
MOV AX,0
MOV BX,0
MOV CX,0
LOOPT: INC BX
ADD AX,BX
INC CX
CMP AX,1000
JBE LOOPT
MOV n, CX
MOV sum, AX
MOV AH,09H
LEA DX,MSG0
INT 21H
LEA SI,DISP
MOV BX,N
CALL OUTPUT
LEA DX,DISP
MOV AH,09H
INT 21H
CALL CRLF
MOV AH,09H
LEA DX,MSG1
INT 21H
LEA SI,DISP
MOV BX,SUM
CALL OUTPUT
LEA DX,DISP
MOV AH,09H
INT 21H
MOV AX,4C00H
INT 21H
crlf:
mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
output:
mov ch,4
mov cl,4
s0:
rol bx,cl ;每4位二进制数对应一位十六进制数,分别取出来转化就好
mov dx,bx
and dl,0fh
cmp dl,9
jbe d0_9
add dl,07h
d0_9:
add dl,30h
mov [si],dl
inc si
dec ch
jnz s0
ret
CODES ENDS
END START
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询