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. Django - 日志工作中常用配置

    工作中常用配置 # 日志配置 BASE_LOG_DIR = os.path.join(BASE_DIR, "log") LOGGING = { 'version': 1, # 保留 ...

  2. check_nrpe: ERROR - could not complete SSL handshake

    情景描述: 发现的问题是 在监控端执行 ./check_nrpe -H 被监控端ip 正常返回nrpe版本 在被监控端执行 ./check_nrpe -H 监控端ip 报错 check_nrpe: E ...

  3. JavaSE 学习笔记之Object对象(八)

    Object:所有类的直接或者间接父类,Java认为所有的对象都具备一些基本的共性内容,这些内容可以不断的向上抽取,最终就抽取到了一个最顶层的类中的,该类中定义的就是所有对象都具备的功能. 具体方法: ...

  4. JVM内存监控(五)

    频繁fullgc排查 jvm配置 -Xms200m -Xmx200m -Xmn50m -XX:PermSize=30m -XX:+HeapDumpBeforeFullGC -XX:+HeapDumpA ...

  5. 矩阵连乘 LRJ白书 p141 栈 解析表达式

    #include<iostream> #include<cstdio> #include<cstring> #include<sstream> #inc ...

  6. 洛谷——P2722 总分 Score Inflation

    https://www.luogu.org/problem/show?pid=2722 题目背景 学生在我们USACO的竞赛中的得分越多我们越高兴. 我们试着设计我们的竞赛以便人们能尽可能的多得分,这 ...

  7. 洛谷 P2195 HXY造公园

    P2195 HXY造公园 题目描述 现在有一个现成的公园,有n个休息点和m条双向边连接两个休息点.众所周知,HXY是一个SXBK的强迫症患者,所以她打算施展魔法来改造公园并即时了解改造情况.她可以进行 ...

  8. MVC.Net:Razor指定模板

    在MVC.Net开发中,我们通常会在_ViewStart.cshtml中指定一个默认的模板,在文件开头输入如下代码: @{ Layout = "~/Views/Shared/[自己定义的模板 ...

  9. ubuntu网卡ip的配置

    ifconfig 命令的结果 和 ip addr (或者查看具体网卡的是 ip addr show eth0) 看到的结果不一样, ip addr show eth0 可以看到eth0网卡上面的多个 ...

  10. java面向接口编程

    在oop中有一种设计原则是面向接口编程,面向接口编程有非常多优点,详细百度一大片.我来谈一下详细的使用中的一些不成熟的见解.! 首先面向接口编程能够消除类之间的依赖关系,使得业务仅仅依赖接口. 这样有 ...