简体   繁体   English

程序集堆栈指针AVR

[英]Assembly Stack Pointer AVR

Hello guys I have a quick question, but one I haven't been unable to answer yet. 大家好,我有一个简短的问题,但是我还无法回答。 I would appreciate some assistance with this: 在此我将提供一些帮助:

LDI R31, 0 

I'm not quite sure what this does, but before this I load the stack pointer HIGH equal to $08 and the low equal to $5F (I know this is the RAMEND definition for the end of the memory for my Arduino). 我不太确定这是做什么的,但是在此之前,我先加载等于$ 08的堆栈指针HIGH和等于$ 5F的低端指针(我知道这是Arduino内存末尾的RAMEND定义)。 Can someone please explain what this will do to the stack/ stack pointer? 有人可以向堆栈/堆栈指针解释这将做什么吗? I know that R31 is used as the high Byte, but I'm not sure what this will do to my current stack of values. 我知道R31用作高字节,但是我不确定这会对我当前的值堆栈有什么影响。

This IS a very small part of my homework, but I do feel it is essential to understand this. 这只是我家庭作业的一小部分,但我确实认为必须了解这一点。 Thanks! 谢谢!

R31 is part of the Z register, an alias for R31:R30. R31是Z寄存器的一部分,它是R31:R30的别名。 The X, Y, and Z registers are used by some assembly instructions for indirect addressing. X,Y和Z寄存器被某些汇编指令用于间接寻址。 See the AVR instruction Set. 请参阅AVR指令集。 LDI R31, 0 sets register 31 to 0. It has no effect on the stack or stack pointer. LDI R31, 0将寄存器31设置为0。它对堆栈或堆栈指针没有影响。

It looks like you are looking at some assembly code, especially near the beginning of the program. 您似乎正在查看一些汇编代码,尤其是在程序开始附近。 Typically, this is where the C runtime initializes the stack pointer and RAM, among other things. 通常,这是C运行时初始化栈指针和RAM的地方。 The variables in your program that are initialized in the source code will have their initial values copied from the data section near the end of the program code into RAM, where the variables actually reside. 在源代码中初始化的程序中的变量会将其初始值从程序代码末尾的数据部分复制到RAM实际所在的RAM中。 The Z register is useful for this purpose, as it makes it easy to loop through the program data. Z寄存器对于此目的很有用,因为它使循环访问程序数据变得容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM