当前位置:网站首页>[assembly language] understand "stack" from the lowest point of view
[assembly language] understand "stack" from the lowest point of view
2022-04-23 02:03:00 【Strange &】
Catalog :
Preface
How do you do , I am a “ blame & ”, I'm a college student .
Home link : blame & My personal blog home page
️ The main direction of the blog is : Course learning knowledge 、 Homework problem solving 、 Final exam preparation . With the deepening of specialty, it will become more and more extensive … Look forward to .
️ One “ I don't want what I didn't do well to be your regret ” Bloggers .
Nice to meet you , Come on together !
One 、 What is a stack ?
A stack is a specific storage area or register , One end of it is fixed , The other end is floating . The data stored in this storage area of the heap , It's a special data structure . All data is stored or taken out , Only at the floating end ( Stack top ) Conduct , Strictly in accordance with “ First in, then out ” The principle of access , The element in between , Must be on top of its stack ( Latecomers ) The elements can only be taken out after being removed one by one . In memory ( Ram ) Open up an area in the stack , It's called software stack ; A stack of registers , It's called hardware stack .
brief introduction :
- A data structure
- The elements in and out of the stack follow :“ First in, then out ” principle
You must be using high-level languages , for example :java,c,c++,python And so on have used the stack , Its operation mechanism is generally clear , But the details are still vague .
This article will start from 《 assembly language 》 That is, the lowest point of view of the computer allows you to re understand the stack .
Two 、 Foreword knowledge of stack
mention 《 assembly language 》, It is inevitable to say 14 A register , Pictured ( be based on 8086CPU Of course )
It is said in the world that :“ Put this 14 Learn to understand , I graduated from assembly language ” The legend of .
That is, this article talks about stack , Then we need to understand :
- SS: Stack segment register
- SP: Stack pointer register group
8086CPU The operation of entering and leaving the stack is based on the word (word) In units . One word (word) Is two bytes (byte).
Anytime ,SS:SP Point to the top element of the stack
Stack is empty ,SS:SP Points to the next unit of the highest address unit in stack space .( because “ Anytime ,SS:SP Point to the top element of the stack ”, So when the stack is empty, there is no stack top element , therefore SS:SP You can only point to the cell below the bottom cell of the stack .)
3、 ... and 、 Stack operation
1、 Initialization of stack
mov ax,1000H
mov ss,ax ; Set the segment address of the stack ss=1000H, You cannot directly write to the segment register SS Send data , So use ax transit
mov sp,0010H
2、 Push
mov ax,1234
push ax
Push ax
Actually, two operations are performed :
- SP=SP-2
- take ax Content feed SS:SP In the memory unit pointed to ,SS:SP Now point to the top of the new stack
Storage , follow “ High storage high , Low save low ” Principles .
3、 Out of the stack
Pop bx
pop bx
Actually, two operations are performed :
- take SS:SP The data at the memory unit pointed to is sent to BX in
- SP=SP+2,SS:SP Point to the cell below the top of the current stack ( The new top of the stack )
3、 ... and 、 matters needing attention
- Assembly language is not case sensitive
- When programming, be careful that the top of the stack exceeds the limit : prevent “ When the stack is full, continue to enter the stack ” and “ When the stack is empty, continue to exit the stack ” The unbounded phenomenon of .
- Stack space is also part of memory space
️️️ Don't forget the romantic duck when you are busy Typing Code !
版权声明
本文为[Strange &]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230159363299.html
边栏推荐
- 有哪些常见的代理ip问题?
- Shardingsphere read write separation
- Redis memory recycling strategy
- 我国科学家揭示突破水稻产量瓶颈新机制
- What categories do you need to know before using proxy IP?
- 动态代理ip的测试步骤有哪些?
- 011_RedisTemplate操作Hash
- openstack 服务的启动
- How can e-procurement become a value-added function in the supply chain?
- 今天终于会写System.out.println()了
猜你喜欢
How to write the resume of Software Test Engineer so that HR can see it?
揭秘被Arm编译器所隐藏的浮点运算
How can e-procurement become a value-added function in the supply chain?
搭建网站是用物理机还是云主机好?
[hands on learning] network depth v2.1 Sequence model
Micro build low code zero foundation introductory course
Campus transfer second-hand market source code
批处理多个文件合成一个HEX
Encrypted compressed backup bat script
Longest common subsequence (record path version)
随机推荐
如何选择一台好的拨号服务器?
What businesses use physical servers?
postman里面使用 xdebug 断点调试
007_Redis_Jedis连接池
【dpdk】10. Dpdk DNS learning notes
揭秘被Arm编译器所隐藏的浮点运算
Micro build low code zero foundation introductory course
Campus transfer second-hand market source code
Thinkphp内核开发盲盒商城源码v2.0 对接易支付/阿里云短信/七牛云存储
Heap overflow of kernel PWN basic tutorial
2018 China Collegiate Programming Contest - Guilin Site J. stone game
搭建个人主页保姆级教程(二)
2022 Saison 6 perfect Kid Model IPA national race Leading the Meta - Universe Track
ESP32蓝牙Bluetooth Controller API介绍
About how to import C4d animation into lumion
Is the availability of proxy IP equal to the efficiency of proxy IP?
今天终于会写System.out.println()了
Dimension C China helping farmers in rural areas warms people's hearts the third stop is jiabaoguo farm
Implementation of Base64 encoding / decoding in C language
PHP & laravel & master several ways of generating token by API and some precautions (PIT)