Assembly in Linux (Stack, External Procedure)
来源:互联网 发布:阿城 知乎 编辑:程序博客网 时间:2024/06/11 04:31
Main Program:
call LoadBuffmov eax,edx
Procedure:
LoadBuff: push eax ; Save caller's EAX push ebx ; Save caller's EBX push edx ; Save caller's EDX mov eax,3 ; Specify sys_read call mov ebx,0 ; Specify File Descriptor 0: Standard Input mov ecx,Buff ; Pass offset of the buffer to read to mov edx,BUFFLEN ; Pass number of bytes to read at one pass int 80h ; Call sys_read to fill the buffer mov ebp,eax ; Save # of bytes read from file for later xor ecx,ecx ; Clear buffer pointer ECX to 0 pop edx ; Restore caller's EDX pop ebx ; Restore caller's EBX pop eax ; Restore caller's EAX ret ; And return to caller
Here the RET exits from the external procedure and return to the next line after call. More than one RET can be used in a procedure
Procedure must:
1. begin with a label
2. must have at least ret
3. may call another proc (*recursion problem)
*every call push 32bit(4byte) to stack, which could hold at most 1MB
step-by-step:
1. push address of next line of code to stack ( address of mov eax,edx)
2. go to procedure label and start running
3. follow the address on the stack and return to where it was interrupted by the call
- Assembly in Linux (Stack, External Procedure)
- Using Assembly Language in Linux
- Using Assembly Language in Linux
- Using Assembly Language in Linux
- Guide to Assembly Language Programming in Linux
- Hello Gtk+ in Linux Assembly Language
- linux arm programming in assembly language
- Scaling in the Linux Networking Stack
- Queueing in the Linux Network Stack
- Enabling Stack Dumping in Linux Kernel
- network tcpip stack in linux kernel
- QUEUEING IN THE LINUX NETWORK STACK
- Enabling Stack Dumping in Linux Kernel
- How to check the external public IP in linux
- some functions in assembly
- Implementing a Recursive Procedure with IA32 and Y86 Assembly Code
- RDO Stack:VMs cannot access external network.
- Linux C中内联汇编的语法格式及使用方法(Inline Assembly in Linux C)
- 有意思
- java获取路径
- 数据结构C语言动态分配实现串
- poj1860
- hdu4027 Can you answer these queries?
- Assembly in Linux (Stack, External Procedure)
- 我看好的移动应用
- HDU 1686 最基础的KMP
- 四舍五入的实现
- set容器的常用方法
- 正则表达式
- EHCI和OHCI,UHCI的比较和区别
- 杂记连载之20120719
- 闲话一二