【问题标题】:How to print multiple text lines in LC3如何在 LC3 中打印多行文本
【发布时间】:2015-09-09 09:29:38
【问题描述】:

我正在尝试在 lc3 中编写三行文本,并且我想使用 .stringz 将它们打印到控制台。这是我目前的代码。通过这种方式,我只能打印第一行。有什么建议吗?

; LC3 program that displays my name and id number to console
; then the user inputs two variables and they will be added 
; and the sum printed to the console
    .ORIG x3000
    LEA R0, NAME
    LEA R1, FIRST
    LEA R2, SECOND
    PUTS
    PUTS
    HALT
NAME    .STRINGZ "Thomas Collier"
FIRST   .STRINGZ "PLease enter first number between 0 and 9:"
SECOND  .STRINGZ "Please enter second number between 0 and 9:"  
    .END

【问题讨论】:

    标签: lc3


    【解决方案1】:

    它只打印存储在 NAME 中的字符串,因为 PUTs 例程只打印存储在 R0 中的指针指向的内容。您需要执行以下操作:

    LEA R0, NAME
    PUTS
    LEA R0, FIRST
    PUTS
    LEA R0, SECOND
    PUTS
    HALT
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-22
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 2014-11-10
      • 2020-12-12
      相关资源
      最近更新 更多