【发布时间】:2014-03-16 15:58:46
【问题描述】:
我有一个非常简单的程序集 8086 用于大学用途。主要组件正在工作,但是当我想显示 2 个或更多字符串时,我有一些特殊字符,无法理解输出。这是我第一次尝试组装,所以可能会出现很多错误,但我无法弄清楚。
程序非常简单:首先显示消息“欢迎使用我的三角形面积计算器!”然后显示“你想再试一次吗?y-yes n-no”,根据按下的键,你可以重试或完成程序。这是我的代码:
DATA SEGMENT PARA PUBLIC 'DATA'
WELCOME DB "Welcome to my triangle area calculator!$";welcome message
CONTINUE DB "Do you want another try? y-yes n-no$";other message
DATA ENDS
CODE SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODE, DS:DATA
MAIN PROC FAR
MOV DX,OFFSET WELCOME;load the address of the welcome message in dx
MOV AH,09H; instruction for display
INT 21H; interrupt for display
XOR DX,DX; putting dx back to 0
XOR AX,AX; the same for ax
START:;loop label
MOV DX,OFFSET CONTINUE;loads the address of the other message into dx
MOV AH,09H; display intruction
INT 21H; interrupt for display
MOV AH,01H; character input instruction
INT 21H; interrupt for input
CMP AL,79H; comparison if the inputted character is y
JZ START; jump zero if it is
CMP AL,6EH; comparison if the inputted character is n
JZ FINISHPROGRAM; jump zero to finish the program
FINISHPROGRAM:
MOV AH,4CH; dos program ending
INT 21H
RET
MAIN ENDP
CODE ENDS
END MAIN
【问题讨论】:
-
也许你应该描述错误是什么??
-
如果您添加 cmets 来说明每个系统调用是什么,您会帮助您自己和我们 - 几十年前,我们中的许多人都没有看到这种东西。
-
没有编译错误,什么都没有,当程序运行时会显示一堆特殊字符,然后欢迎消息并代替其他消息再次显示欢迎消息。
-
编辑完成,现在有 cmets。
-
你说
assume ds:data,但你没有做到。