AT&T Assembly on Linux
2016-09-24 22:18
281 查看
je
if equal then jmp
jg
if the second gt the first, then jmp
jge
if the second ge the first, then jmp
jl
if the second lt the first, then jmp
jle
if the second le the first, then jmp
AT&T 64-bit assembly
how to call library like printf?
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161004100638817-826050129.png)
The code shows the AT&T assembly on 64-bit Linux.
We use syscall instead of int 0x80.
We save parameters in registers before calling printf, instead of pushing the parameters on the stack.
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161004103535926-1595189933.png)
This is the key:
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161004090831614-1334958973.png)
How to debug assembly program on Linux ?
using gdb
as xx.s -gstabs -o xx.o -gstabs is necessary,otherwise
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161003095725598-150709891.png)
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161003095919410-1217021153.png)
commands:
run, next, info registers, break num(line number), quit
how to exit program rightly:
movq 1,%rax
int $0x80
if equal then jmp
jg
if the second gt the first, then jmp
jge
if the second ge the first, then jmp
jl
if the second lt the first, then jmp
jle
if the second le the first, then jmp
AT&T 64-bit assembly
how to call library like printf?
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161004100638817-826050129.png)
The code shows the AT&T assembly on 64-bit Linux.
We use syscall instead of int 0x80.
We save parameters in registers before calling printf, instead of pushing the parameters on the stack.
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161004103535926-1595189933.png)
This is the key:
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161004090831614-1334958973.png)
How to debug assembly program on Linux ?
using gdb
as xx.s -gstabs -o xx.o -gstabs is necessary,otherwise
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161003095725598-150709891.png)
![](https://images2015.cnblogs.com/blog/726249/201610/726249-20161003095919410-1217021153.png)
commands:
run, next, info registers, break num(line number), quit
how to exit program rightly:
movq 1,%rax
int $0x80
相关文章推荐
- AT&T Assembly for Linux and Mac (sys_exit)
- linux AT &T Assembly
- AT&T Assembly for Linux and Mac (sys_write)
- AT&T ASSEMBLY FOR LINUX AND MAC (SYS_FORK)
- linux汇编工具之GAS(AT&T 语法)和NASM(Intel 语法)比较
- Linux 下AT&T汇编语法格式简介02
- Linux 汇编语言开发指南(AT&T)
- 关于Linux AT&T Asm的零星小结
- Linux下AT&T汇编语法格式简介
- Linux USB "On-The-Go" (OTG) on OMAP H2
- [转贴]AT&T ASM Syntax,帮大家了解linux代码中的AT&T汇编
- Linux 下AT&T汇编语法格式简介01
- Linux 0.11内核bootsect.s和loader.s的移植为AT&T汇编
- Real10 & Xpdf installation on Linux Box
- AT&T汇编---第一个linux汇编程序
- Linux Assembly "Hello World" Tutorial, CS 200
- Linux 下AT&T汇编语法格式简介03
- 一本Linux下AT&T汇编语言与GCC内嵌汇编入门的中文书籍
- 关于Linux AT&T Asm的零星小结
- 关于Linux AT&T Asm的零星小结