原文 Assembler / なぜx86ではMBRが"0x7C00"にロードされるのか?(完全版)
感謝 descent 大大分享本文,隨便看隨便譯。本文不是逐句譯,同時也不是這方面的專家 (不管是語言或技術),用語不一或缺漏錯誤在所難免,歡迎自行 fork 修正指教
誰適合看本文?
對 x86 架構與組合語言有基礎認識,以及從 MBR 到載入 OS 這一段過程有興趣的人 (還有談到中斷向量或 INT xxx 時不會一臉茫然的人)
| #include <cstdio> | |
| using namespace std; | |
| int main(int argc, char *argv[]) | |
| { | |
| int x=5; | |
| int y=7; | |
| x=2; | |
| auto func = [=] (const char *n, const char *s) |
| [34749.042174] Modules linked in: | |
| [34749.042178] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.4.41-rt161-hgb61895a2463c-dirty #30 | |
| [34749.042179] Hardware name: Rockchip (Device Tree) | |
| [34749.042193] [<c0111210>] (unwind_backtrace) from [<c010c54c>] (show_stack+0x20/0x24) | |
| [34749.042200] [<c010c54c>] (show_stack) from [<c03715a4>] (dump_stack+0x8c/0xa0) | |
| [34749.042207] [<c03715a4>] (dump_stack) from [<c0144678>] (__schedule_bug+0x5c/0x6c) | |
| [34749.042212] [<c0144678>] (__schedule_bug) from [<c06d4df4>] (__schedule+0x3e0/0x428) | |
| [34749.042216] [<c06d4df4>] (__schedule) from [<c06d4ea4>] (schedule+0x68/0x104) | |
| [34749.042220] [<c06d4ea4>] (schedule) from [<c06d678c>] (rt_spin_lock_slowlock+0x170/0x25c) | |
| [34749.042225] [<c06d678c>] (rt_spin_lock_slowlock) from [<c06d8160>] (rt_spin_lock+0x64/0x68) |
| m: file format elf64-x86-64 | |
| Disassembly of section .interp: | |
| 00000000000002a8 <.interp>: | |
| 2a8: 2f (bad) | |
| 2a9: 6c insb (%dx),%es:(%rdi) | |
| 2aa: 69 62 36 34 2f 6c 64 imul $0x646c2f34,0x36(%rdx),%esp |
| ;Made by FeDOS (FeDOS SubSystems) | |
| ;All Rights Reserved | |
| ;FeDOS (ICQ 313-997-813) | |
| [BITS 16] | |
| [ORG 0x0000] | |
| __start: | |
| ; mov cx, 0xB800 | |
| ; mov es, cx | |
| ; mov bx, 0h | |
| ; mov cx, cs |
| /* | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| */ | |
| #include <arpa/inet.h> | |
| #include <linux/if_packet.h> | |
| #include <stdio.h> |
| descent@debian64:simple_compiler$ cat f1 | |
| int i,j; | |
| int func(int x, char dd) | |
| { | |
| char a,b; | |
| 1+2; | |
| 9+5*6; | |
| if (a>1) | |
| { |
原文 Assembler / なぜx86ではMBRが"0x7C00"にロードされるのか?(完全版)
感謝 descent 大大分享本文,隨便看隨便譯。本文不是逐句譯,同時也不是這方面的專家 (不管是語言或技術),用語不一或缺漏錯誤在所難免,歡迎自行 fork 修正指教
誰適合看本文?
對 x86 架構與組合語言有基礎認識,以及從 MBR 到載入 OS 這一段過程有興趣的人 (還有談到中斷向量或 INT xxx 時不會一臉茫然的人)
| main.out: main.o map.o | |
| g++ main.o map.o -o main.out | |
| main.o: main.c | |
| gcc -c main.c -o main.o | |
| map.o: map.cpp | |
| g++ -c map.cpp -o map.o | |
| clean: |