Skip to the content.

checksheet

https://cs.brown.edu/courses/cs033/docs/guides/x64_cheatsheet.pdf

汇编迅速测试环境

问题:

  1. nasm 处理的 .s 和 kernel 中使用的 .S 似乎语法不一样
    • .S 的语法在定义在哪里

工具

intel 指令 fzf : https://hikalium.github.io/opv86/

ASM

记录如何书写 .S 文件,记录在 entry.S 的遇到的任何问题

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

  1. .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

.irp    param,1,2,3
move    d\param,sp@-
.endr

is equivalent to assembling

move    d1,sp@-
move    d2,sp@-
move    d3,sp@-

global

问题

include

  1. include 源文件

https://stackoverflow.com/questions/39457263/include-assembly-file-in-another-assembly-file

# include "test.S"
  1. include C header

https://stackoverflow.com/questions/4928238/include-header-with-c-declarations-in-an-assembly-file-without-errors

TODO

  1. 可以参考的资源:
  1. https://asmjit.com/ : 神奇的内联汇编

  2. exit.c:do_exit 的 set_fs

  3. check code in uaccess.c

    • for example, understand get_fs

syntax

配合答案使用: https://github.com/0xAX/asm

需要回答的问题:

  1. global 是否存在对称的关键字
  2. 定义 static 变量的方法

  3. inlcude
  4. section 的定义

TODO

https://github.com/nemasu/asmttpd : 终极实战项目

资源

  1. 缓冲区溢出试验
    1. 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 中间可以找到证据吗 ?

  1. 内联汇编彻底搞懂,出一个 examble based 的教程。

https://github.com/cirosantilli/x86-assembly-cheat : 看来如何编译这些代码都是不简单的

https://github.com/cirosantilli/x86-bare-metal-examples

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 下的汇编

目标

  1. gdb disassembly 中间的汇编代码和源代码之间可以看的懂
  2. context switch 的代码可以阅读
  3. 各种内联汇编可以看懂

利用 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 将按侵权追究法律责任,其它情况随意。