checksheet
https://cs.brown.edu/courses/cs033/docs/guides/x64_cheatsheet.pdf
汇编迅速测试环境
- https://0xax.github.io/categories/assembler/
- https://godbolt.org/
- https://en.wikibooks.org/wiki/X86_Disassembly/Calling_Conventions
- https://jameshfisher.com/2018/03/10/linux-assembly-hello-world/
- 补充一个 nasm 的小例子
问题:
- nasm 处理的 .s 和 kernel 中使用的 .S 似乎语法不一样
- .S 的语法在定义在哪里
工具
intel 指令 fzf : https://hikalium.github.io/opv86/
ASM
- 教程 : https://www.xorpd.net/pages/x86_adventures.html
- https://github.com/tenderlove/asmrepl
- asmrepl 函数
- asmtutor : 从 hello world 讲解到网络 io 操作
记录如何书写 .S 文件,记录在 entry.S 的遇到的任何问题
- 这是绝对的核心
-
https://fgiesen.wordpress.com/2016/08/25/how-many-x86-instructions-are-there/ : 来看看 x86 到底有复杂
- 可以用来学习一下各种 SIMD 指令的写法吧 : https://github.com/pigirons/cpufp
as(GNU Assembler)
https://en.wikipedia.org/wiki/X86_assembly_language https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax#Additional_GAS_reading 入门教程 https://sourceware.org/binutils/docs/as/ 完整文档 https://cs.lmu.edu/~ray/notes/gasexamples/ 最佳入门内容
gas 关键语法
code16
- .code32 && .code16
https://stackoverflow.com/questions/32395542/objdump-of-code16-and-code32-x86-assembly https://stackoverflow.com/questions/26539603/why-bootloaders-for-x86-use-16bit-code-first/31528128
.code 16 tells the assembler to assume the code will be run in 16bit mode
macro
- http://web.mit.edu/rhel-doc/3/rhel-as-en-3/irp.html
.irp param,1,2,3
move d\param,sp@-
.endr
is equivalent to assembling
move d1,sp@-
move d2,sp@-
move d3,sp@-
- How to concatenate GNU GAS macro arguments with other tokens to make single label?
使用
\(), 具体例子 https://github.com/cirosantilli/x86-bare-metal-examples/blob/master/bios_initial_state.S
global
- 应该是让一个 label 或者变量是全局的吧!
问题
include
- include 源文件
https://stackoverflow.com/questions/39457263/include-assembly-file-in-another-assembly-file
# include "test.S"
- include C header
https://stackoverflow.com/questions/4928238/include-header-with-c-declarations-in-an-assembly-file-without-errors
TODO
- 可以参考的资源:
- The NASM Manual
- Compiler Explorer
- System V Application Binary Interface
- The Intel Processor Manuals
- The AMD Processor Manuals
- Agner Fog’s optimization guides
- x86 and amd64 instruction reference
-
https://asmjit.com/ : 神奇的内联汇编
-
exit.c:do_exit 的 set_fs
-
check code in uaccess.c
- for example, understand
get_fs
- for example, understand
- https://www.kernel.org/doc/html/latest/x86/index.html
- http://infophysics.net/att0.pdf
- https://docs.oracle.com/cd/E19253-01/817-5477/817-5477.pdf
syntax
配合答案使用: https://github.com/0xAX/asm
需要回答的问题:
- global 是否存在对称的关键字
-
定义 static 变量的方法
- 宏
- inlcude
- section 的定义
TODO
https://github.com/nemasu/asmttpd : 终极实战项目
资源
- 缓冲区溢出试验
- https://stackoverflow.com/questions/1345670/stack-smashing-detected 有一个缓冲区溢出的试验 main maybe is not a function
https://www.nasm.us/doc/nasmdoc0.html : nasm 的教程,nasm 和 gcc 的关系是什么 ? gcc 会调用 nasm 吗 ? ,似乎 linux 使用的是 as 作为汇编器,从 Makefile 中间可以找到证据吗 ?
- 内联汇编彻底搞懂,出一个 examble based 的教程。
https://github.com/cirosantilli/x86-assembly-cheat : 看来如何编译这些代码都是不简单的
https://github.com/cirosantilli/x86-bare-metal-examples
- https://stackoverflow.com/questions/22054578/how-to-run-a-program-without-an-operating-system/32483545#32483545
https://news.ycombinator.com/item?id=22279051 : 学习 amd64 的最佳教程
https://blog.stephenmarz.com/2020/05/20/assemblys-perspective : 汇编 blog
https://blog.yossarian.net/2020/06/13/How-x86_64-addresses-memory : 终于看到总结 x86 寻址的总结了
https://news.ycombinator.com/item?id=24195627 : win 下的汇编
目标
- gdb disassembly 中间的汇编代码和源代码之间可以看的懂
- context switch 的代码可以阅读
- 各种内联汇编可以看懂
利用 https://godbolt.org/ 实现 routing 的查看
有没有 vim 插件啊 ?
看指令手册的长度: https://sandpile.org/
https://news.ycombinator.com/item?id=34241907
https://software.intel.com/en-us/articles/introduction-to-x64-assembly intel 入学手册,感觉没有必要。
本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。