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. unigui的session【1】

    目前是1394. 明白session如何使用管理,看demo Session List和SessionTimeout unit Main; interface uses Windows, Messag ...

  2. CentOS 7.3降低内核版本为7.2

    查看当前内核版本: [root@nineep ~]# uname -r 2.3.10.0-514.2.2.el7.x86_64  查看当前发行版本: [root@nineep ~]# cat /etc ...

  3. 关于Linux的本地回环路由lo [127.0.0.1 ]

    最近 打算配开发板的socket通讯,打印环境变量发现却没有 127.0.0.1 / # ifconfig -a eth0 Link encap:Ethernet HWaddr 86:43:C9:A1 ...

  4. 移动端 javascript 计算html font-size

    直接上代码  (function(doc, win) {             var docEl = doc.documentElement,                 resizeEvt ...

  5. python 执行环境

    一些函数 执行其它非python程序 1 一些函数 callable callable()是一个布尔函数,确定一个对象是否可以通过函数操作符(())来调用.如果函数可调用便返回True,否则便是Fal ...

  6. 为什么要阅读——兼分享《首先,打破一切常规》[中译文]:世界顶级管理者的成功秘诀/(美)马库斯·白金汉,(美)柯特·科夫曼 著

    <ctrlno=255632">首先,打破一切常规>[中译文]:世界顶级管理者的成功秘诀/(美)马库斯·白金汉,(美)柯特·科夫曼 著:鲍世修 等译 下载地址:http:/ ...

  7. css3中 弹性盒模型布局之box-flex

    box-flex:也就是让子容器针对父容器的宽高属性依照一定的规则来划分 Eg: html代码: <div class="wrap"> <div class=&q ...

  8. hdu1542 线段树+扫描线+离散化

    仅仅想说题目给的欲实际不服     还是这类型的水题吧   建议看之前我写的那个 #include<stdio.h> #include<string.h> #include&l ...

  9. CreateWindowEx和CreateWindow的区别

    CreateWindowEx 函数功能:该函数创建一个具有扩展风格的重叠式窗口.弹出式窗口或子窗口,其他与 CreateWindow函数相同.关于创建窗口和其他参数的内容,请参看CreateWindo ...

  10. ubuntu 关机命令

    ubuntu 关机命令 关机命令 shutdown ubuntu的终端中默认的是当前用户的命令,只是普通用户,因此在终端器中可以使用sudo -sh 转换到管理员root用户下执行命令. 1)shut ...