为何存在低级与高级汇编?汇编入门的底层学习困惑
汇编学习中的两类教程与核心疑问
我在学习汇编语言时,接触到两类截然不同的教程:
- 高级汇编教程:直接从64位(或32位)汇编入手,无需编写任何底层前置代码就能实现功能。比如下面这个经典的x86 32位Hello World程序,直接使用
eax/ebx等寄存器,通过int 0x80调用内核系统调用完成输出和退出:
section .data hello: db 'Hello world!',10 ; 'Hello world!' plus a linefeed character helloLen: equ $-hello ; Length of the 'Hello world!' string section .text global _start _start: mov eax,4 ; The system call for write (sys_write) mov ebx,1 ; File descriptor 1 - standard output mov ecx,hello ; Put the offset of hello in ecx mov edx,helloLen ; helloLen is a constant, so we don't need to say int 0x80 ; Call the kernel mov eax,1 ; The system call for exit (sys_exit) mov ebx,0 ; Exit with return "code" of 0 (no error) int 80h; num_to_string: push ebp mov ebp, esp mov esp, ebp pop ebp
- 底层裸机汇编教程:这类教程需要从最基础的硬件启动流程入手,比如编写引导加载程序时,必须手动完成从16位实模式切换到32位保护模式,再进入64位长模式的全部流程,每一步都要直接和硬件架构的底层规则打交道。
我明白汇编语法会随架构不同而变化,但裸机汇编和高级汇编的差异远不止语法,而是编码方式的本质区别。我想请教:为什么会存在这种“低级/裸机汇编”与“高级汇编”的区分?
内容的提问来源于stack exchange,提问作者Gajej
相关产品推荐
相关产品推荐

