[OS]Assembly in Linux Kernel
2010-03-26 18:16
363 查看
AT&T与Intel汇编的区别
在Linux内核中使用了AT&T格式的汇编指令而非Intel的格式,它们之间的区别1. common
(1)Intel一般用大小字母,而AT&T一般用小写
(2)寄存器:AT&T的寄存器要加%前缀,而Intel不需要。
(3)立即数:AT&T的立即数要加前缀$,而Intel不需要。
AT&T: pushl $4
Intel: PUSH 4
(4)指令的源和目标操作数顺序
AT&T: movl %ecx,%eax ;%ecx—>%eax
Intel: MOV EAX,ECX ;ecx—>eax
(5)操作码
AT&T: “l”表示长整数(32位),"w”表示字(16位),“b”表示字节(8位)。
Intel的语法中,则要在内存单元操作数的前面加上byte ptr,word ptr和dword ptr,"dword”对应“long”。
(6) jmp && call && ret
2. 内存寻址
Intel语法 | AT&T语法 |
segreg:[base+index*scale+disp] | %segreg:disp(base,index,scale) |
mov eax,[ebx+20h] | movl 0x20(%ebx),%eax |
add eax,[ebx+ecx*2h] | addl (%ebx,%ecx,0x2),%eax |
lea eax,[ebx+ecx] | leal (%ebx,%ecx),%eax |
sub eax,[ebx+ecx*4h-20h] | subl -0x20(%ebx,%ecx,0x4),%eax |
嵌入c的汇编
1. 单条指令__asm__表示是一条汇编指令。
Question: __volatile__这里表示什么意思呢?
2. 多条指令用"\n"来分隔
这里代码会展开成如下所示:
要说明一下的是1f是什么意思呢?这里f表示forward,就是向前跳转。如果是b就是backward向后跳转。
3. Quite Difficult Example
相关文章推荐
- Install a new Linux Kernel (3.10.56) in Guest OS (Dom U)
- 【Linux学习笔记】Linux C中内联汇编的语法格式及使用方法(Inline Assembly in Linux C)
- Linux C中内联汇编的语法格式及使用方法(Inline Assembly in Linux C)【转】
- 30 Linux Kernel Developers in 30 Weeks: Dave Jones
- 30 Linux Kernel Developers in 30 Weeks: Alan Cox
- Linux Kernel in a Nutshel
- Install Mysql in Linux OS
- High Memory In The Linux Kernel(Cited)
- Berkeley DB in kernel for linux-3.13
- Linux C中内联汇编的语法格式及使用方法(Inline Assembly in Linux C)
- Basic Data Structures and Algorithms in the Linux kernel
- How to install multi OS(Windows/Linux) in one PC box and boot them easily
- Memory Allocation API In Linux Kernel && Linux Userspace、kmalloc vmalloc Difference、Kernel Large Section Memory Allocation
- How should we learn configure software in linux OS
- Linux Device Drivers 3rd Edition Data Types in the Kernel
- os引导程序boot从扇区拷贝os加载程序loader文件到内存(boot copy kernel to mem in the same method)
- Interrupt Handling Internals in Linux Kernel
- Using Assembly Language in Linux
- Linux Kernel Developement process base on debian OS
- Install Linux Kernel 4.10 In CentOS and Ubuntu