更新时间 2021-07-16

hello world 相信大多数人的第一个程序,都是下面的这段代码。或者差不多是这样。不过编译器最终生成的汇编代码是怎样的,是一个比较有趣的事情,那么这里我们分析一下。 #include <stdio.h> int main() { printf("hello world!!!\n"); return 0; } 我们可以用下面的命令生成汇编代码: gcc -S hello.c .file "hello.c" .text .section .rodat

下面是一个 hello world!!! 程序使用 nasm 汇编,调用 32位系统调用,然后退出的程序。过程简单,但是存在一个问题 …… [bits 32] section .text global main main: mov eax, 4; write mov ebx, 1; stdout mov ecx, message; buffer mov edx, message_end - message int 0x80 mov eax, 1; exi

更新时间 2021-04-27

-x language 指定文件语言 -c 编译或汇编源文件,但不链接 -S 输出汇编代码 -E 输出预处理代码 -o file 指定输出文件 –version 打印版本号 -pipe 在编译的不同阶段使用管道代替临时文件 -std= 指定语言标准 -fno-builtin -fno-builtin-function 不识别 gcc 内置函数,gcc 可能将 c 标准函数用内置函数代替 -fno-stack-protector 禁用堆栈保护 -fno-stack-

更新时间 2021-03-11

C #include <stdio.h> int main() { printf("hello world\n"); return 0; } C++ #include <iostream> int main() { std::cout << "hello world" << std::endl; return 0; } Python print('hello world') Java public class Hello{ public static voi

更新时间 2019-07-30

一般来说,网上绝大多数的关于C++生成随机数的文章,写的都是使用C语言的 rand() 来生成的,比如像下面这样: #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { srand(time(NULL)); // use current time as seed for random generator int random_variable = rand(); printf("Rando