这看似相当愚蠢,但实际上几乎没有任何资源可以学习LC-3。我无法设法找到对主题进行适当的深入分析并解释事情是如何工作的,我的意思是,你可以找到简单的定义和某些op / pseudo-op代码所做的事情,但没有任何完整和完整的写法解释。
如果有人可以对以下内容进行全面分析:
; Hello name in LC-3 assembler
.orig x3000
lea r0, what
puts
lea r1, name
; typical assembly language hack coming up
add r1, r1, #-1
char getc
putc
add r2, r0, #-10
brz completed; was a newline
str r0, r1, #0
add r1, r1, #1
brnzp char
completed lea r0, hello
puts
halt
这可能会非常冗长,但也非常感激。 (也许这是对LC-3代码资源进行全面分析的第一篇文章?) p.s我不希望回答的人解释每个操作/伪操作代码的作用,但至少要非常具体地说明操作员执行和完成其工作
答案 0 :(得分:1)
我主要了解LC3如何通过插入代码并逐步完成代码。虽然我会在书中提到Appendix A很多。
; Hello name in LC-3 assembler
.orig x3000 ; Starting place in memory for our code
lea r0, what ; Load the memory address of variable what
puts ; Print the string who's memory address is stored in R0
lea r1, name ; Load the memory address of the variable name into R1
; typical assembly language hack coming up
add r1, r1, #-1 ; Subtract 1 from R1, then store into R1
char getc ; Get a single char from the user, store into R0
putc ; Print that same char to the console
add r2, r0, #-10 ; R2 = R0 - 10
brz completed ; If the user presses ENTER (Ascii 10)
; and we've subtracted 10 then we'll get a 0, exit program
str r0, r1, #0 ; Store the value of R0 into memory[R1 + 0]
add r1, r1, #1 ; R1 = R1 + 1
brnzp char ; Jump to Clear no matter what
completed lea r0, hello ; Load the memory address of variable hello into R0
puts ; Print the string stored in hello
halt ; Stop the program