【发布时间】:2015-11-11 06:42:11
【问题描述】:
我有一个程序,我在其中一次添加 2 个数字。我从用户那里收到了 2 个数字,使用 ASCII -30 将它们转换为数字,将它们加到寄存器 0 中并输出总数。我现在确保将数字保持在 5 以下,所以我总共不会超过 9。但是我得到的总输出是......不确定名称。它就像一个浓密的时期,但在角色的中心而不是底部……就像一个要点。我的代码在下面,看着模拟器,当我通过程序并为两个数字输入 4 时......就在我输出总数(或我想要的总数)之前,寄存器是
R0 x0008 8
R1 x0004 4
R2 x0004 4
R3 x0008 8
ADTN LD R4 CONVERT ; Load -30 FFD0 into register 4
GETC ; Get charicter from user
ADD R1, R0, R4 ; store the number in R1 after adding the neg ascii 30
GETC ; Get 2nd charicter
ADD R2, R0, R4 ; Store number in R2 after adding neg ascii 30
LEA R0, ADDMSG ; Load into R0 message "The sum of the 2 numbers is "
PUTS ; Display message
ADD R0, R1, R2 ; Add R1 and R2 and store in R0
TRAP x21 ; Output total
一切看起来都不错,但出于某种原因,它提出了要点。我将 TRAP x21 更改为 PUTS,但也没有用
【问题讨论】: