我有一个问题,希望用户输入名字和姓氏,然后打印出来。这个问题还希望我在名字和姓氏之间也打印一个空格,我无法弄清楚如何做到这一点。我也这样做了,如果用户输入“$”,程序将停止接受输入并继续打印子程序。到目前为止,这是我的代码。
/main program
FirstNameLoop, JnS SubInputFirstName
Load Name
Add One
Store Name
Jump FirstNameLoop
LastNameLoop, Jns SubInputLastName
Load Name
Add One
Store Name
Jump LastNameLoop
/subroutine for inputting firstname
SubInputFirstName, Hex 0
Input
Store Temp
Subt Comma
Skipcond 400
Jump StoreFirstName
Load Comma
Add One
StoreI Name
Jump LastNameLoop
StoreFirstName, Load Temp
StoreI Name
JumpI SubInputFirstName
End, JnS subPrintString
Load NamePrint
Add One
Store NamePrint
Jump End
Finish, Halt
/subroutine for entering last name
SubInputLastName, HEX 0
Input
Store Temp
Subt Dollar
Skipcond 400
Jump StoreLastName
Jump End
StoreLastName, Load Temp
StoreI Name
JumpI SubInputLastName
/subroutine for printing name
subPrintString, HEX 0
LoadI NamePrint
Store Temp
Subt Period
Skipcond 400
Jump PrintName
Jump Finish
PrintName, Load Temp
Output
JumpI subPrintString
NamePrint, HEX 300
Dollar, Dec 36
Name, HEX 300
One, DEC 1
Temp, DEC 0
Space, DEC 32
Comma, DEC 44
Period, DEC 46