[英]How to develop an intuition to code in LC-3 Assembly?
I read about how LC-3 works, but I can't for the life of me figure out how to code in LC-3 assembly.我读到了 LC-3 是如何工作的,但我一生都无法弄清楚如何在 LC-3 程序集中进行编码。 My goal is to be able to write simple programs like generating Fibonacci numbers or sorting an array.
我的目标是能够编写简单的程序,例如生成斐波那契数或对数组进行排序。
Can someone point to me to resources to learn this?有人可以指点我的资源来学习这个吗? I'm fluent in Python and Java, so the underlying logic behind those problems is clear to me.
我精通 Python 和 Java,所以这些问题背后的基本逻辑对我来说很清楚。
There are several aspects to learning assembly language, which is the human readable version of the machine code of the processor.学习汇编语言有几个方面,它是处理器机器代码的人类可读版本。
Basically other languages are at a logical level, whereas machine code is very much at a physical level基本上其他语言处于逻辑级别,而机器代码非常处于物理级别
For one, this goes particularly to the difference in the notions of storage:一方面,这尤其体现在存储概念上的差异:
So, when we write assembly language, we translate our pseudo code: logical code with lots of typed variables of limited lifetime, in part by mapping logical variables onto the fixed physical resources.因此,当我们编写汇编语言时,我们翻译了我们的伪代码:具有许多生命周期有限的类型变量的逻辑代码,部分是通过将逻辑变量映射到固定的物理资源上。 There are often more variables than CPU registers, especially when some of the registers have dedicated purpose, like stack or return address.
变量通常比 CPU 寄存器多,尤其是当某些寄存器具有专用用途时,例如堆栈或返回地址。
For another, today's other languages generally employ structured programming, whereas in assembly language/machine code we have if-goto-label.另一方面,今天的其他语言通常采用结构化编程,而在汇编语言/机器代码中,我们有 if-goto-label。
All structured statements have translation in if-goto-label.所有结构化语句在 if-goto-label 中都有翻译。 Each translation is a transformation of a pattern in structured form to a pattern in if-goto-label form.
每个翻译都是将结构化形式的模式转换为 if-goto-label 形式的模式。 Follow the patterns properly and you'll reproduce the control flow of your pseudo code — very easy to take short cuts here and make confusing mistakes, so I encourage a methodical approach here.
正确地遵循模式,您将重现伪代码的控制流——在这里很容易走捷径并犯令人困惑的错误,因此我鼓励在这里采用有条不紊的方法。
Other languages have rich expressions: having operators of many levels of precedence, and as complex as you like using ()
's.其他语言有丰富的表达式:具有许多优先级的运算符,并且可以使用
()
的复杂性。 Machine code has instructions that take (usually) at most 3 operands.机器代码的指令(通常)最多需要 3 个操作数。
Function calls, stack frames, parameter passing, return values are a fairly deep subject, function prologue & epilogue. Function 调用、堆栈帧、参数传递、返回值是一个相当深的主题,function 序言和结语。
For more information, see some of following resources:有关详细信息,请参阅以下一些资源:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.