1  Intro

  When a program starts executing, a certain contiguous section of memory is set aside for the program called the stack.

   

  The stack pointer is usually a register that contains the top of the stack. The stack pointer contains the smallest address x such that any address smaller than x is considered garbage, and any address greater than or equal to x is considered valid.

  stack bottom The largest valid address of a stack. When a stack is initialized, the stack pointer points to the stack bottom.

  stack limit The smallest valid address of a stack. If the stack pointer gets smaller than this, then there's a stack overflow (this should not be confused with overflow from math operations).

2  Push

  There are two operations on the stack: push and pop.

  push You can push one or more registers, by setting the stack pointer to a smaller value (usually by subtracting 4 times the number of registers to be pushed on the stack) and copying the registers to the stack.

  

push:  addi $sp, $sp, -  # Decrement stack pointer by
sw $r3, ($sp) # Save $r3 to stack

  

  The diagram on the left shows the stack before the push operation.

  The diagram in the center shows the stack pointer being decremented by 4.

  The diagram on the right shows the stack after the 4 bytes from register 3 has been copied to address 0x000f fffc

3  Pop

  pop You can pop one or more registers, by copying the data from the stack to the registers, then to add a value to the stack pointer (usually adding 4 times the number of registers to be popped on the stack)

pop:  lw   $r3, ($sp)   # Copy from stack to $r3
addi $sp, $sp, # Increment stack pointer by

  The diagram on the left is the initial state of the stack.

  The data is copied from the stack to the register 3. Thus, the diagram in the center is the same as the one on the left. If I had drawn a picture of the contents of register 3, it would have been updated with the data from the stack.

  Then, the stack pointer is moved down (shown in the diagram on the right).

Embedded之Stack之一的更多相关文章

  1. Embedded之Stack之三

    Stack Overflow While stacks are generally large, they don't occupy all of memory. It is possible to ...

  2. Embedded之Stack之二

    1 Function Programming languages make functions easy to maintain and write by giving each function i ...

  3. 【转载】关于Embedded Linux启动的经典问题

    转载自:http://linux.chinaunix.net/techdoc/install/2009/04/13/1107608.shtml 发信人: armlinux (armlinux), 信区 ...

  4. 试验Windows Embedded Standard 7 Service Pack 1 Evaluation Edition

    =========================================== 是否支持再使用 RT 7 Lite 精简 ? ================================= ...

  5. Windows Embedded Compact 7新特性

    Windows® Embedded Compact 7是Windows Embedded CE的下一代产品,而Windows Embedded CE这款操作系统面向占用资源少的新颖设备.Windows ...

  6. Using QEMU for Embedded Systems Development

    http://www.opensourceforu.com/2011/06/qemu-for-embedded-systems-development-part-1/ http://www.opens ...

  7. Important Programming Concepts (Even on Embedded Systems) Part V: State Machines

    Earlier articles in this series: Part I: Idempotence Part II: Immutability Part III: Volatility Part ...

  8. Install LAMP Stack On Ubuntu 16.04

    原文:http://www.unixmen.com/how-to-install-lamp-stack-on-ubuntu-16-04/ LAMP is a combination of operat ...

  9. ELK Stack (2) —— ELK + Redis收集Nginx日志

    ELK Stack (2) -- ELK + Redis收集Nginx日志 摘要 使用Elasticsearch.Logstash.Kibana与Redis(作为缓冲区)对Nginx日志进行收集 版本 ...

随机推荐

  1. axios的基本概念和安装以及配置方法

    ajax:异步请求,是一种无需再重新加载整个网页的情况下,能够更新部分网页的技术 axios:用于浏览器和node.js的基于promise的HTTP客户端 1.从浏览器制作XMLHttpReques ...

  2. camera placement (paraview)

    # 'renderView1' is the view name# current camera placement for renderView1 renderView1.CameraPositio ...

  3. MySQL下做Master/Slave同步,延迟太大怎么办?

    slave的延迟是比较常见的,如果短暂的延迟后还能追上,一般就能接受了.   用innodb不是坏事,会减少一些slave中止的情况.如果是myisam的表,insert update delete操 ...

  4. Linux imooc learning

    https://www.imooc.com/video/3529 Windows Vs Linux Linux: (other linux overall   https://onedrive.liv ...

  5. ggplot画图笔记

    1.数据集相加符号 %+% 2.图形属性映射 aesc()函数 aes(x=mpg,y=wt)  把mpg属性映射为x,wt属性映射为y 图层图形属性可以添加.修改和删除映射. 如 3.位置调整参数 ...

  6. 有趣的linux shell 命令, 跑马车

    apt-get install sl

  7. [转]supervisor 安装、配置、常用命令

    原文: http://www.cnblogs.com/xueweihan/p/6195824.html ------------------------------------------------ ...

  8. [PWA] Optimize Assets Delivery using preload and prefetch

    By default, browsers load the assets in a render-blocking way. Modern browsers introduced prefetch a ...

  9. 重学C++ (十一) OOP面向对象编程(2)

    转换与继承 本节主要须要区分的是: 基类和派生类的转换: 引用(指针)的转换和对象的转换. 1.每一个派生类对象包括一个基类部分.因此.能够像使用基类对象一样在派生类对象上执行操作. 基于这一点,能够 ...

  10. wpf 样式的调用

    这个针对异地调用: 1.在主程序的项目中新建一个Skins的目录.然后再目录里新建一个BlackSkin.xaml的字典资源: <ResourceDictionary xmlns="h ...