我正在尝试在LC3中创建一个程序,要求用户输入一个字符串并继续将其打印出来。我的程序只能打印出用户输入的字符串中的第一个字母。例如,我输入" Hello"它只打印出来" H"。有没有办法来解决这个问题?感谢
.orig x3000
Lea r1, storeString
Lea r0, EnterText
puts
LOOP
getc
str r0, r1, 0
add r1, r0, -10
brz OUTSIDE
out
brnzp LOOP
OUTSIDE
Lea r0, UserEnter
puts
Lea r0, storeString
puts
Halt
EnterText .stringz "\nPlease enter a text: "
UserEnter .stringz "\nThe text you have typed is: "
storeString .BLKW 99
.end
答案 0 :(得分:0)
学习使用调试器。你在行检查结束时覆盖LOOP
getc
str r0, r1, 0
add r1, r1, 1 ; next character
add r0, r0, -10 ; just subtract in place
brz OUTSIDE
out
brnzp LOOP
(这是你的指针),实际上你应该将它递增1,因此它指向下一个字符的位置。你很幸运,这不只是爆炸。
这样的事情会更好:
create or replace TRIGGER addPhoneLine
AFTER INSERT ON phoneNumber
REFERENCING NEW AS NEW
FOR EACH ROW
DECLARE
primNum varchar(12);
acctNum numeric(5);
NEWusageID_new varchar(5);
BEGIN
if :new.primaryNumber is not NULL then
select acctID, primaryNumber into acctNum, primNum
from account A
where A.primaryNumber = :new.primaryNumber;
select to_char(round(dbms_random.value(10000, 99999),0)) into
NEWusageID_new from dual
minus
select usageID from usage;
INSERT INTO acct_num VALUES
(acctNum, primNum, :new.phonenumber);
INSERT INTO phone_usage VALUES
(NEWusageID_new, :new.phonenumber);
end if;
END;