
C
uefi_artisan
这个作者很懒,什么都没留下…
展开
-
一句话说清楚c代码中如何内嵌汇编
内嵌汇编语法如下:_asm_ _volatile_ ( 汇编语句模板: 输出部分: 输入部分: 破坏描述部分)下面通过一个简单的例子来熟悉内嵌汇编的语法规则。max@ubuntu:~$ cat add.c#include <stdio.h>int main(){原创 2021-03-28 20:21:50 · 3328 阅读 · 0 评论 -
C语言与汇编语言的对应关系,以递归调用为例
我们写一个C文件,包含如下代码:root@ubuntu:/home/max# cat rfact.clong rfact(long n){ long result; if (n <= 1) result = 1; else result = n * rfact(n-1); return result;}root@ubuntu:/home/max# 然后使用编译器生成汇编代码,这里我们需要用到-S选项。root@ubuntu:/home/max# gcc -..原创 2021-03-20 20:46:42 · 2512 阅读 · 1 评论 -
C语言本质
基本概念我们可以这样去声明一个数组 T A[N]; T 是某种类型,比如int, float, double, A是数组名, N是整型常数这句声明会产生两个动作,第1,它分配连续L x N byte 的长度,L 是类型T的大小(size). 我们用Xa.表示这段长度的起始地址,第2,A可以作为一个指针指向这个数组的最开始地方,它的值即为Xa,原创 2015-06-04 10:53:36 · 3333 阅读 · 0 评论 -
C/C++ 中volatile用法
当用volatile去修饰一个变量的时候,表明这个变量很可能被其他地方修改举个例子: volatile const long clock_register; // update by the hardware clockvolatile 就是告诉编译器,不要去试图优化看起多余的读或者写操作。auto t1{clock_register};// ...no use of clo原创 2015-09-20 09:46:41 · 1698 阅读 · 0 评论 -
C/C++里面const的用法
讲在最前, const 就是read-only 的意思int main(){ int y; f( &y); // f attempts illegal modification} // end main// xPtr cannot modify the value of constant variable to which it pointsvoid f(const原创 2015-09-20 10:08:22 · 1403 阅读 · 0 评论 -
Uefi hexedit 源码分析
我们最熟悉的软件应该就是记事本了,UEFI SHELL 下面也提供了一个类似的,叫edit 和 hexedit用于对文件,磁盘,或者内存 里面的内容进行编辑。接下来,我们就对它一些关键的函数和数据结构进行分析。/** Dispatch input to different handler @param[in] Key The原创 2017-11-25 17:35:28 · 1129 阅读 · 0 评论 -
uefi bios代码中如何找到函数的实现?
写在最前,摘自 K&R The only legal operations on a structure are copying it or assigning to it as a unit, taking its address with & (读作ampersand), and accessing its members, 翻译成中文是这样的,对于一个结构体而言,唯一合原创 2015-01-04 20:25:36 · 4882 阅读 · 0 评论 -
for(;;)的解释
通常死循环会这样写for(;;) 无限循环理论上讲,任何一个循环语句都可以达到死循环的目的,比如 (代码取自udk2014)/** Executes an infinite loop. Forces the CPU to execute an infinite loop. A debugger may be used to skip past the loop a原创 2015-01-01 18:52:47 · 1931 阅读 · 0 评论 -
怎么确认一台电脑是big-endian 还是little-endian?
假设我们使用的是一台32位机器。如果是little endian, 那么x在内存中是之样排列的 高内存 ----> +----+----+----+----+ |0x01|0x00|0x00|0x00| +----+----+----+----+ A | &x所以 (char*)(*x) == 1 如果是big endi翻译 2015-01-01 17:46:53 · 2767 阅读 · 0 评论 -
怎样阅读指针声明
How to Read a Declaration现在是时候推荐一种阅读指声明的方式,它可以使理解起来更简单,诀窍就是从后往前读,当然我们还没有讨论指向常量的情况,以下面例子作为说明:const int *pci;从后往前读可以使我们渐近的理解声明1 pci is a variable翻译 2014-03-19 11:46:43 · 1095 阅读 · 0 评论 -
写程序实现自己的strcpy() 函数
函数 mystrcpy() 实现了strcpy() ,复制源字符串到目的串,返回一个指向目的串的指针code#include char *mystrcpy(char *destination, const char *source){ char *destination_ptr; /* Store the starting position * of the des翻译 2014-03-21 18:38:50 · 2731 阅读 · 0 评论 -
external 的使用
外部变量以及其作用域main 里面的变量,像line, longest等,对main来说是私有的或者是局部(local)的,因为它们是在main里面声明的,别的函数中的变量也是一样的,比如说,getline中的的i和copy中的i 是没有任何关系的,只有当函数被调用的时候,变量才会存在于内存中,随着函数的退出而消失,这也就是为什么变量常常被称为automatic(自动变量)跟随别的语言中的叫法翻译 2014-03-25 15:23:15 · 2824 阅读 · 0 评论 -
再谈链表的使用
#include #include #include #define MAXCHARS 30#define DEBUG 0/* here is the declaration of a linked list structure */struct NameRec{ char name[MAXCHARS]; struct NameRec转载 2014-04-07 22:52:53 · 762 阅读 · 0 评论 -
使用冒泡排序讲解函数指针
冒泡排序,思路直观,函数指针是初学者常常想不明白的,这里利用冒泡排序,来深度讲解函数指针的由来。翻译 2014-04-07 02:59:13 · 4910 阅读 · 0 评论 -
动态内存分配
动态分配以及destroy内存的函数FU原创 2014-04-07 23:29:54 · 925 阅读 · 0 评论 -
字符数组 ( 台湾人翻译成矩阵)
#include #define MAXLINE 1000 /* maximum input line size */int getline(char line[], int maxline);void copy(char to[], char from[]);/* print longest input line */main(){ int len; /*翻译 2014-04-22 23:15:49 · 1066 阅读 · 0 评论 -
PPI Services
下面这些services 为PPI database 提供了翻译 2014-07-15 11:40:57 · 2576 阅读 · 0 评论 -
函数指针
#include #include void check(char *a, char *b, int (*cmp)(const char *, const char *));int main(void){ char s1[80], s2[80]; int (*p) (const char *, const char *); /* function pointer */翻译 2014-09-14 19:07:27 · 945 阅读 · 1 评论 -
Functions with Variable Argumet lists in C using va_list
Perhaps you would like to have a function that will accept any number of values and then return the average. You don't know how many arguments will be passed in to the function. One way you could mak转载 2013-05-17 13:48:48 · 882 阅读 · 0 评论