阅读赵炯博士的Linux内核分析0.12完全注释笔记(A heavily Commented Linux Kernel Source Code Linux Version 0.11)...

Read the fucking source code  -Linus Bendict Torvalds

基础:

  具备一些基本的 C 语言知识和 Intel CPU 汇编语言知识 有关 C 语言最佳

  参考资料仍是 Brain W. Kernighan 先生和 Dennis M. Ritchie 先生合著的《The C Programming Language》
一书。而汇编语言的资料则可以参考任意一本讲解与 Intel CPU 相关的汇编语言教材。另外还需要一些
嵌入式汇编语言的资料。有关嵌入式汇编的权威信息都包含在 GNU gcc 编译器手册中。

源码下载链接:http://www.oldlinux.org/Linux.old/Linux-0.12/sources/

 

80x86汇编语言程序设计教程 : https://pan.baidu.com/s/1kTC4Ldd

 I/O 端口寻址和访问控制方式:统一编址和独立编址

 

在普通 Linux 系统下通过查看/proc/ioports 文件可以得到相关控制器或设置使用的 I/O 地址范围,见如下所示。

 

 C编译的过程

 

 

如何在C语言中嵌入汇编代码

基本格式如下:

asm(“汇编语句”

: 输出寄存器

: 输入寄存器

: 会被修改的寄存器);

 

  除第 1 行以外,后面带冒号的行若不使用就都可以省略。其中,“asm”是内联汇编语句关键词;“汇
编语句”是你写汇编指令的地方;“输出寄存器”表示当这段嵌入汇编执行完之后,哪些寄存器用于存放
输出数据。此地,这些寄存器会分别对应一 C 语言表达式值或一个内存地址;“输入寄存器”表示在开始
执行汇编代码时,这里指定的一些寄存器中应存放的输入值,它们也分别对应着一 C 变量或常数值。“会
被修改的寄存器”表示你已对其中列出的寄存器中的值进行了改动,gcc 编译器不能再依赖于它原先对这些
寄存器加载的值。如果必要的话,gcc 需要重新加载这些寄存器。因此我们需要把那些没有在输出/输入寄
存器部分列出,但是在汇编语句中明确使用到或隐含使用到的寄存器名列在这个部分中。示例如下:

 

说明:

1. 干什么的 ? 嵌入一个汇编语言宏函数 

2.怎么写?  写在({})中   __asm__ 表示开始   __res 表示 表达式输出的值  斜杠"\" 表示连成一行

 

 

 

转载于:https://www.cnblogs.com/wpgraceii/p/10749676.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This book provides detailed and comprehensive comments and explanations on all source code of the early Linux kernel (V0.12), aiming to enable readers to gain a comprehensive and profound understanding of the working mechanism of Linux in a shortest possible time and to lay a solid foundation for further study of modern Linux systems. Although the version of the analysis is very low, the kernel has been able to compile and run, and it already includes the essence of the working principle of Linux. The book first briefly introduced the development history of the Linux kernel, explained the main differences between the various kernel versions and improvements, and gave the reasons for choosing the 0.12 kernel source code as the study object. Then it gives the basic knowledge needed to read the source code, outlines the hardware structure of the PC running the Linux system, the assembly language used by the kernel, the extends of C language, and focuses on the 80X86 processor in protected mode. Then we introduced the kernel code overview, given the kernel source directory tree structure, and according to the organizational structure of all kernel, programs and files are described in detail. In order to deepen the reader's understanding of the working principle of the kernel, the last chapter gives a number of related operational debugging tests. All relevant information in the book can be downloaded from the website www.oldlinux.org. This book suits as the assistant and practical teaching material of university computer major student study operating system course, also suitable for self-study reference book of Linux lovers as learning kernel operating principle, also can be used as the reference book that the general technical personnel develops the embedded system

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值