Last active
December 14, 2024 04:49
-
-
Save Uristqwerty/15a0c6f163e6c92f941e907f091ee944 to your computer and use it in GitHub Desktop.
Uristqwerty's bootstrap seed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Supported syntax: | |
// /<anything> Ignored until newline. | |
// For forwards compatibility, always written // | |
// "String literal" | |
// #> <address> set output position to <address> | |
// #: <address> write 4-byte offset from <current_pos>+4 to <address> | |
// <address> is a variable-length hex constant, may have leading spaces | |
// Everything else is expected to be hex digit pairs and whitespace | |
// DOS "MZ" header | |
"MZ" 60 00 01 00 00 00 04 00 00 00 10 00 00 00 | |
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 00 00 00 00 60 00 00 00 | |
#> 0040 // DOS stub | |
b4 09 0e 1f ba 0e 00 cd 21 b8 01 4c cd 21 | |
"Can't run in dos.$" | |
#> 0060 // Windows "PE" header | |
"PE" 0000 // Magic number | |
6486 // Machine type x86-64 | |
0300 // 3 Sections | |
00000000 // Timestamp | |
00000000 // COFF symbol table, NULL for exes. | |
00000000 // Symbol count | |
f000 // Size of optional header | |
2302 // Characteristics flags: | |
// 0001 No relocatons | |
// 0002 Executable Image | |
// 0020 Large address aware | |
// 0200 No debugging information | |
// "Optional" header | |
0b02 // Magic number for PE-32+ | |
00 00 // Linker version 0.0 | |
00100000 // Code section sum: 0x1000 | |
00100000 // Data section sum: 0x1000 | |
00003000 // BSS section sum: 0x300000 | |
00200000 // Entry point address | |
00200000 // Code section start address | |
0000400000000000// Image base | |
00100000 // Section alignment | |
00020000 // File alignment | |
0100 0000 // OS version 1.0 | |
0100 0100 // Image version 1.1 | |
0600 0000 // Subsystem version 6.0 | |
0000 0000 // Win32 version; reserved field | |
00303000 // Image size. IMPORTANT | |
00040000 // Total header size | |
00000000 // Checksum | |
0300 // Subsystem | |
0000 // DLL Characteristics | |
0000010000000000// Stack reservation | |
0010000000000000// Stack commit | |
0000010000000000// Heap reservation | |
0010000000000000// Heap commit | |
00000000 // Loader flags; reserved field | |
10000000 // RVA count | |
00000000 00000000 // 00 Export table | |
00100000 28000000 // 01 Import table | |
00000000 00000000 // 02 Resource table | |
00000000 00000000 // 03 Exception table | |
00000000 00000000 // 04 Certificate table | |
00000000 00000000 // 05 Base Relocation table | |
00000000 00000000 // 06 Debug | |
00000000 00000000 // 07 Architecture | |
00000000 00000000 // 08 Global Pointer | |
00000000 00000000 // 09 TLS Table | |
00000000 00000000 // 0A Load Config Table | |
00000000 00000000 // 0B Bound Import table | |
00000000 00000000 // 0C Import Address Table | |
00000000 00000000 // 0D Delay Import descriptor | |
00000000 00000000 // 0E CLR Runtime Header | |
00000000 00000000 // 0F reserved | |
// Sections | |
".idata" 0000 | |
00100000 // Virtual size | |
00100000 // Virtual Address | |
00100000 // Raw data size | |
00040000 // File position | |
00000000 // Relocation pointer | |
00000000 // Line number pointr | |
0000 // Relocation count | |
0000 // Line number count | |
400000c0 // Characteristics | |
// 00000040 Initialized data | |
// 40000000 Readable | |
// 80000000 Writable | |
".code" 000000 | |
00100000 00200000 | |
00040000 00140000 | |
00000000 00000000 0000 0000 | |
20000060 // 00000020 Code | |
// 20000000 Executable | |
// 40000000 Readable | |
".bss" 00000000 | |
00003000 00300000 | |
00000000 00000000 | |
00000000 00000000 0000 0000 | |
800000c0 // 00000080 Uninitialized data | |
// 40000000 Readable | |
// 80000000 Writable | |
#> 0400 // .idat section | |
80100000 // Table Address. 0x1080 virtual, 0x480 file pos | |
00000000 // Timestamp, not bound | |
00000000 // Forwarder chain | |
06110000 // Name address. 0x1106 virt, 0x506 file | |
40100000 // Thunk table. 0x1040 virt, 0x440 file | |
// Null entry | |
00000000 00000000 00000000 00000000 00000000 | |
#> 0440 // Thunk table, replaced with real function addresses at runtime | |
c010000000000000 // GetStdHandle | |
d010000000000000 // WriteFile | |
dc10000000000000 // ExitProcess | |
ea10000000000000 // ReadFile | |
f610000000000000 // GetLastError | |
0000000000000000 // Null entry | |
#> 0480 // Name table, left intact | |
c010000000000000 | |
d010000000000000 | |
dc10000000000000 | |
ea10000000000000 | |
f610000000000000 | |
0000000000000000 | |
#>04c0 0000 "GetStdHandle" 00 | |
#>04d0 0000 "WriteFile" 00 | |
#>04dc 0000 "ExitProcess" 00 | |
#>04ea 0000 "ReadFile" 00 | |
#>04f6 0000 "GetLastError" 00 | |
#>0506 "kernel32.dll" | |
#> 1400 // .code section | |
6a 00 // Push 0 Argument 5 for Read/WriteFile, NULL | |
48 83 ec 20 // rsp -= 20 4 stack slots | |
48 b9 f6ffffffffffffff // rcx = -10 Stdin | |
ff 15 #:0440 // call import: GetStdHandle | |
48 89 c1 // rcx = rax, copy returned handle to Arg1 | |
48 8d 15 #:201400 // rdx = .code + 0x200000, input buffer | |
49 b8 0000100000000000 // r8 = 0x100000, buffer length | |
4c 8d 0d #:2400 // r9 = .code + 0x1000, position to write bytes read | |
ff 15 #:0458 // call import: ReadFile | |
e8 #:14c0 // call Compile | |
48 b9 f5ffffffffffffff // rcx = -11 Stdout | |
ff 15 #:0440 // call import: GetStdHandle | |
48 89 c1 // rcx = rax, copy returned handle to Arg1 | |
48 8d 15 #:101400 // rdx = .code + 0x100000, output buffer | |
49 89 f8 // r8 = rdi length from Compile | |
4c 8d 0d #:2400 // r9 = .code + 0x1000 | |
ff 15 #:0448 // call import: WriteFile | |
48 31 c9 // rcx = 0 (via xor) | |
ff 15 #:0450 // call import: ExitProcess | |
#> 1480 // NextChar | |
e8 #:1490 // call PeekChar | |
e8 #:14a0 // call IncReadPos | |
c3 // Ret | |
#> 1490 // PeekChar | |
8a 06 // al = *rsi | |
85 ed // test ebp remaining chars | |
75 05 // jne +05 if zero | |
b8 ffffffff // eax = -1 | |
c3 // Ret | |
#> 14a0 // IncReadPos | |
85 ed // test ebp remaining chars | |
74 05 // jeq +05 if not zero | |
ff cd // ebp-- decrement count | |
48 ff c6 // rsi++ advance read pointer | |
c3 // Ret | |
#> 14c0 // Compile | |
8b 2d #:2400 // ebp = *.code + 0x1000, bytes read | |
48 8d 35 #:201400 // rsi = .code + 0x200000, input buffer | |
48 8d 3d #:101400 // rdi = .code + 0x100000, output buffer | |
e9 #:1500 // jump to Loop | |
#> 14e0 // Loop_Eof | |
48 8d 35 #:101400 // rsi = .code + 0x100000, output buffer | |
48 2b fe // rdi -= rsi | |
c3 // Ret | |
#> 1500 // Loop | |
31 c0 // eax = 0 (via xor) | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 09 0f 84 #:1500 // if \t, Loop | |
3c 0a 0f 84 #:1500 // if \n, Loop | |
3c 0d 0f 84 #:1500 // if \r, Loop | |
3c 20 0f 84 #:1500 // if space, Loop | |
3c 22 0f 84 #:15e0 // if ", StringLiteral | |
3c 23 0f 84 #:1620 // if #, Directive | |
3c 2f 0f 84 #:1600 // if /, Comment | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1500 // test eax, if <0 Loop | |
8b c8 // ecx = eax | |
c1 e1 04 // ecx <<= 4 shift to high nybble | |
e8 #:1480 | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1500 // test eax, if <0 Loop | |
03 c1 // eax += ecx add high nybble | |
88 07 // *rdi = al | |
48 ff c7 // rdi++ | |
e9 #:1500 // Loop | |
#> 15e0 // StringLiteral | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 22 0f 84 #:1500 // if ", return to main Loop | |
88 07 // *rdi = al | |
48 ff c7 // rdi++ | |
e9 #:15e0 // StringLiteral loop | |
#> 1600 // Comment | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 0a 0f 84 #:1500 // if \n, return to main Loop | |
e9 #:1600 // Comment loop | |
#> 1620 // Directive | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 3a 0f 84 #:1680 // if #:, RelativeAddress | |
3c 3e 0f 84 #:1660 // if #>, SetOutPosition | |
e9 #:1500 // jump back to main Loop | |
#> 1660 // SetOutPosition | |
e8 #:16c0 // call HexAddr | |
48 8d 3d #:101400 // rdi = .code + 0x100000, output buffer | |
48 03 f8 // rdi += rax | |
e9 #:1500 // jump back to main Loop | |
#> 1680 // RelativeAddress | |
e8 #:16c0 // call HexAddr | |
48 8d 0d #:101400 // rcx = .code + 0x100000, output buffer | |
48 2b cf // rcx -= rdi | |
48 f7 d9 // rcx = -rcx (NEG rcx) | |
48 83 c1 04 // rcx += 4 | |
48 2b c1 // rax -= rcx | |
89 07 // *rdi = eax | |
48 83 c7 04 // rdi += 4 | |
e9 #:1500 // jump back to main Loop | |
#> 16c0 // HexAddr | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 20 0f 84 #:16c0 // if space, jump back to the start of HexAddr | |
31 c9 // rcx = 0 (xor ecx ecx) | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1740 // test eax, if <0 .._End, character wasn't in [0-9a-fA-F] | |
e9 #:1700 // jump back to main Loop | |
#> 1700 // HexAddr_Loop | |
48 c1 e1 04 // rcx <<= 4 | |
48 03 c8 // rcx += rax | |
e8 #:1490 // call PeekChar | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1740 // test eax, if <0 Loop_Eof | |
e8 #:14a0 // call IncReadPos | |
e9 #:1700 // jump .._Loop | |
#> 1740 // HexAddr_End | |
48 8b c1 // rax = rcx | |
c3 // return | |
#> 1760 // Hex2Num | |
2c 30 0f 82 #:17a0 // -= '0', if below .._NotHex | |
3c 0a 0f 82 #:17c0 // <= '9', .._Ret | |
2c 11 0f 82 #:17a0 // -= 'A', if below .._NotHex | |
3c 06 0f 82 #:17b0 // <= 'F', .._Alpha | |
2c 20 0f 82 #:17a0 // -= 'a', if below .._NotHex | |
3c 06 0f 82 #:17b0 // <= 'f', .._Alpha | |
e9 #:17a0 // > 'f' .._NotHex | |
#> 17a0 // Hex2Num_NotHex | |
b8 ffffffff // eax = -1 | |
e9 #:17c0 // jump to .._Ret | |
#> 17b0 // Hex2Num_Alpha | |
04 0a // += 10 | |
e9 #:17c0 // jump to .._Ret | |
#> 17c0 // Hex2Num_Ret | |
c3 // return | |
#> 1800 // Pad to next multiple of 0x200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Supported syntax: | |
// /<anything> Ignored until newline. | |
// For forwards compatibility, always written // | |
// "String literal" | |
// #> <address> set output position to <address> | |
// #: <address> write 4-byte offset from <current_pos>+4 to <address> | |
// <address> is a variable-length hex constant, may have leading spaces | |
// Everything else is expected to be hex digit pairs and whitespace | |
// +names extensions: | |
// #v <address> Set virtual address offset to <address> minus output position | |
// #@ <name> Define named address | |
// #& <name> write 4-byte offset from <current_pos>+4 to <name>d address | |
// <name> is [a-zA-Z0-9_]{1,12} | |
// Note: Names must be defined before use. Mildly inconvenient, but | |
// it's possible to "#v 5000 #@ Name" if you know the virtual address | |
// or even write actual contents out-of-order with "#>". | |
// Still, good enough for leaf functions and data. | |
// Keeps the implementation and data structures small. | |
// DOS "MZ" header | |
"MZ" 60 00 01 00 00 00 04 00 00 00 10 00 00 00 | |
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 00 00 00 00 60 00 00 00 | |
#> 0040 // DOS stub | |
b4 09 0e 1f ba 0e 00 cd 21 b8 01 4c cd 21 | |
"Can't run in dos.$" | |
#> 0060 // Windows "PE" header | |
"PE" 0000 // Magic number | |
6486 // Machine type x86-64 | |
0300 // 3 Sections | |
00000000 // Timestamp | |
00000000 // COFF symbol table, NULL for exes. | |
00000000 // Symbol count | |
f000 // Size of optional header | |
2302 // Characteristics flags: | |
// 0001 No relocatons | |
// 0002 Executable Image | |
// 0020 Large address aware | |
// 0200 No debugging information | |
// "Optional" header | |
0b02 // Magic number for PE-32+ | |
00 00 // Linker version 0.0 | |
00100000 // Code section sum: 0x1000 | |
00100000 // Data section sum: 0x1000 | |
00005000 // BSS section sum: 0x400000 | |
00200000 // Entry point address | |
00200000 // Code section start address | |
0000400000000000// Image base | |
00100000 // Section alignment | |
00020000 // File alignment | |
0100 0000 // OS version 1.0 | |
0100 0100 // Image version 1.1 | |
0600 0000 // Subsystem version 6.0 | |
0000 0000 // Win32 version; reserved field | |
00305000 // Image size. IMPORTANT | |
00040000 // Total header size | |
00000000 // Checksum | |
0300 // Subsystem | |
0000 // DLL Characteristics | |
0000010000000000// Stack reservation | |
0010000000000000// Stack commit | |
0000010000000000// Heap reservation | |
0010000000000000// Heap commit | |
00000000 // Loader flags; reserved field | |
10000000 // RVA count | |
00000000 00000000 // 00 Export table | |
00100000 28000000 // 01 Import table | |
00000000 00000000 // 02 Resource table | |
00000000 00000000 // 03 Exception table | |
00000000 00000000 // 04 Certificate table | |
00000000 00000000 // 05 Base Relocation table | |
00000000 00000000 // 06 Debug | |
00000000 00000000 // 07 Architecture | |
00000000 00000000 // 08 Global Pointer | |
00000000 00000000 // 09 TLS Table | |
00000000 00000000 // 0A Load Config Table | |
00000000 00000000 // 0B Bound Import table | |
00000000 00000000 // 0C Import Address Table | |
00000000 00000000 // 0D Delay Import descriptor | |
00000000 00000000 // 0E CLR Runtime Header | |
00000000 00000000 // 0F reserved | |
// Sections | |
".idata" 0000 | |
00100000 // Virtual size | |
00100000 // Virtual Address | |
00100000 // Raw data size | |
00040000 // File position | |
00000000 // Relocation pointer | |
00000000 // Line number pointr | |
0000 // Relocation count | |
0000 // Line number count | |
40000040 // Characteristics | |
// 00000040 Initialized data | |
// 40000000 Readable | |
".code" 000000 | |
00100000 00200000 | |
00060000 00140000 | |
00000000 00000000 0000 0000 | |
20000060 // 00000020 Code | |
// 20000000 Executable | |
// 40000000 Readable | |
".bss" 00000000 | |
00005000 00300000 | |
00000000 00000000 | |
00000000 00000000 0000 0000 | |
800000c0 // 00000080 Uninitialized data | |
// 40000000 Readable | |
// 80000000 Writable | |
#> 0400 // .idat section | |
80100000 // Table Address. 0x1080 virtual, 0x480 file pos | |
00000000 // Timestamp, not bound | |
00000000 // Forwarder chain | |
06110000 // Name address. 0x1106 virt, 0x506 file | |
40100000 // Thunk table. 0x1040 virt, 0x440 file | |
// Null entry | |
00000000 00000000 00000000 00000000 00000000 | |
#> 0440 // Thunk table, replaced with real function addresses at runtime | |
c010000000000000 // GetStdHandle | |
d010000000000000 // WriteFile | |
dc10000000000000 // ExitProcess | |
ea10000000000000 // ReadFile | |
f610000000000000 // GetLastError | |
0000000000000000 // Null entry | |
#> 0480 // Name table, left intact | |
c010000000000000 | |
d010000000000000 | |
dc10000000000000 | |
ea10000000000000 | |
f610000000000000 | |
0000000000000000 | |
#>04c0 0000 "GetStdHandle" 00 | |
#>04d0 0000 "WriteFile" 00 | |
#>04dc 0000 "ExitProcess" 00 | |
#>04ea 0000 "ReadFile" 00 | |
#>04f6 0000 "GetLastError" 00 | |
#>0506 "kernel32.dll" | |
#> 1400 // .code section | |
6a 00 // Push 0 Argument 5 for Read/WriteFile, NULL | |
48 83 ec 20 // rsp -= 20 4 stack slots | |
48 b9 f6ffffffffffffff // rcx = -10 Stdin | |
ff 15 #:0440 // call import: GetStdHandle | |
48 89 c1 // rcx = rax, copy returned handle to Arg1 | |
48 8d 15 #:301400 // rdx = .code + 0x300000, input buffer | |
49 b8 0000200000000000 // r8 = 0x200000, buffer length | |
4c 8d 0d #:2400 // r9 = .code + 0x1000, position to write bytes read | |
ff 15 #:0458 // call import: ReadFile | |
e8 #:14c0 // call Compile | |
48 b9 f5ffffffffffffff // rcx = -11 Stdout | |
ff 15 #:0440 // call import: GetStdHandle | |
48 89 c1 // rcx = rax, copy returned handle to Arg1 | |
48 8d 15 #:101400 // rdx = .code + 0x100000, output buffer | |
49 89 f8 // r8 = rdi length from Compile | |
4c 8d 0d #:2400 // r9 = .code + 0x1000 | |
ff 15 #:0448 // call import: WriteFile | |
48 31 c9 // rcx = 0 (via xor) | |
ff 15 #:0450 // call import: ExitProcess | |
#> 1480 // NextChar | |
e8 #:1490 // call PeekChar | |
e8 #:14a0 // call IncReadPos | |
c3 // Ret | |
#> 1490 // PeekChar | |
8a 06 // al = *rsi | |
85 ed // test ebp remaining chars | |
75 05 // jne +05 if zero | |
b8 ffffffff // eax = -1 | |
c3 // Ret | |
#> 14a0 // IncReadPos | |
85 ed // test ebp remaining chars | |
74 05 // jeq +05 if not zero | |
ff cd // ebp-- decrement count | |
48 ff c6 // rsi++ advance read pointer | |
c3 // Ret | |
#> 14c0 // Compile | |
45 31 d2 // r10 = 0 via xor, virtual address offset | |
8b 2d #:2400 // ebp = *.code + 0x1000, bytes read | |
48 8d 35 #:301400 // rsi = .code + 0x300000, input buffer | |
48 8d 3d #:101400 // rdi = .code + 0x100000, output buffer | |
e9 #:1500 // jump to Loop | |
#> 14e0 // Loop_Eof | |
48 8d 35 #:101400 // rsi = .code + 0x100000, output buffer | |
48 2b fe // rdi -= rsi | |
c3 // Ret | |
#> 1500 // Loop | |
31 c0 // eax = 0 (via xor) | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 09 0f 84 #:1500 // if \t, Loop | |
3c 0a 0f 84 #:1500 // if \n, Loop | |
3c 0d 0f 84 #:1500 // if \r, Loop | |
3c 20 0f 84 #:1500 // if space, Loop | |
3c 22 0f 84 #:15e0 // if ", StringLiteral | |
3c 23 0f 84 #:1620 // if #, Directive | |
3c 2f 0f 84 #:1600 // if /, Comment | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1500 // test eax, if <0 Loop | |
8b c8 // ecx = eax | |
c1 e1 04 // ecx <<= 4 shift to high nybble | |
e8 #:1480 | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1500 // test eax, if <0 Loop | |
03 c1 // eax += ecx add high nybble | |
88 07 // *rdi = al | |
48 ff c7 // rdi++ | |
e9 #:1500 // Loop | |
#> 15e0 // StringLiteral | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 22 0f 84 #:1500 // if ", return to main Loop | |
88 07 // *rdi = al | |
48 ff c7 // rdi++ | |
e9 #:15e0 // StringLiteral loop | |
#> 1600 // Comment | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 0a 0f 84 #:1500 // if \n, return to main Loop | |
e9 #:1600 // Comment loop | |
#> 1620 // Directive | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 3a 0f 84 #:1680 // if #:, RelativeAddress | |
3c 3e 0f 84 #:1660 // if #>, SetOutPosition | |
e9 #:1800 // jump to +names directives | |
#> 1660 // SetOutPosition | |
e8 #:16c0 // call HexAddr | |
48 8d 3d #:101400 // rdi = .code + 0x100000, output buffer | |
48 03 f8 // rdi += rax | |
e9 #:1500 // jump back to main Loop | |
#> 1680 // RelativeAddress | |
e8 #:16c0 // call HexAddr | |
48 8d 0d #:101400 // rcx = .code + 0x100000, output buffer | |
48 2b cf // rcx -= rdi | |
48 f7 d9 // rcx = -rcx (NEG rcx) | |
48 83 c1 04 // rcx += 4 | |
48 2b c1 // rax -= rcx | |
89 07 // *rdi = eax | |
48 83 c7 04 // rdi += 4 | |
e9 #:1500 // jump back to main Loop | |
#> 16c0 // HexAddr | |
e8 #:1480 // call NextChar | |
85 c0 0f 88 #:14e0 // test eax, if <0 Loop_Eof | |
3c 20 0f 84 #:16c0 // if space, jump back to the start of HexAddr | |
31 c9 // rcx = 0 (xor ecx ecx) | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1740 // test eax, if <0 .._End, character wasn't in [0-9a-fA-F] | |
e9 #:1700 // jump into _Loop | |
#> 1700 // HexAddr_Loop | |
48 c1 e1 04 // rcx <<= 4 | |
48 03 c8 // rcx += rax | |
e8 #:1490 // call PeekChar | |
e8 #:1760 // call Hex2Num | |
85 c0 0f 88 #:1740 // test eax, if <0 Loop_Eof | |
e8 #:14a0 // call IncReadPos | |
e9 #:1700 // jump .._Loop | |
#> 1740 // HexAddr_End | |
48 8b c1 // rax = rcx | |
c3 // return | |
#> 1760 // Hex2Num | |
2c 30 0f 82 #:17a0 // -= '0', if below .._NotHex | |
3c 0a 0f 82 #:17c0 // <= '9', .._Ret | |
2c 11 0f 82 #:17a0 // -= 'A', if below .._NotHex | |
3c 06 0f 82 #:17b0 // <= 'F', .._Alpha | |
2c 20 0f 82 #:17a0 // -= 'a', if below .._NotHex | |
3c 06 0f 82 #:17b0 // <= 'f', .._Alpha | |
e9 #:17a0 // > 'f' .._NotHex | |
#> 17a0 // Hex2Num_NotHex | |
b8 ffffffff // eax = -1 | |
e9 #:17c0 // jump to .._Ret | |
#> 17b0 // Hex2Num_Alpha | |
04 0a // += 10 | |
e9 #:17c0 // jump to .._Ret | |
#> 17c0 // Hex2Num_Ret | |
c3 // return | |
#> 1800 // +names Directives extension | |
3c "v" 0f 84 #:1820 // if #v, TODO: virtual addr | |
3c "@" 0f 84 #:1960 // if #@, TODO: define name | |
3c "&" 0f 84 #:19a0 // if #&, TODO: named addr | |
e9 #:1500 // jump back to main Loop | |
#> 1820 // #v <addr> | |
e8 #:16c0 // call HexAddr | |
48 8d 0d #:101400 // rcx = .code + 0x100000, output buffer | |
48 2b cf // rcx -= rdi, -<file_pos> | |
03 c8 // ecx += eax | |
41 89 ca // r10 = ecx, when added to <file_pos>, get <virtual_addr> | |
e9 #:1500 // jump back to main Loop | |
#> 1840 // IsNameChar: Zero eax unless al in [a-zA-Z0-9_] | |
3c "_" 0f 84 #:1882 // == '_', good | |
3c 30 0f 82 #:1880 // < '0', bad | |
3c 3a 0f 82 #:1882 // <= '9', good | |
3c 41 0f 82 #:1880 // < 'A', bad | |
3c 5b 0f 82 #:1882 // <= 'Z', good | |
3c 61 0f 82 #:1880 // < 'a', bad | |
3c 7b 0f 82 #:1882 // <= 'z', good | |
e9 #:1880 // else bad | |
#> 1880 // IsNameChar_bad | |
31 c0 // zero eax via xor | |
#> 1882 // IsNameChar_good | |
c3 // return | |
#> 18a0 // ReadName: Shifts 0-12 chars of [a-zA-Z0-9_] in r8 & r9. If r8 is zero, something went wrong. | |
e8 #:1490 // call PeekChar | |
45 31 c0 // Clear r8 | |
45 31 c9 // Clear r9 | |
3c 20 0f 85 #:18c0 // if not space, jump into _Loop | |
e8 #:14a0 // call IncReadPos | |
e9 #:18a0 // Repeat from ReadName | |
#> 18c0 // ReadName_Loop | |
e8 #:1840 // call IsNameChar | |
3c 00 0f 84 #:18f0 // If 0, either EOF or end of ident, jump to _End | |
4d 0f a4 c1 08 // r9 <<= 8 and |= r8 >> 56, (Shift Left Double) | |
49 c1 e0 08 // r8 <<= 8 | |
41 88 c0 // r8b = al | |
e8 #:14a0 // call IncReadPos | |
e8 #:1490 // call PeekChar | |
e9 #:18c0 // next _Loop iteration | |
#> 18f0 // ReadName_End | |
c3 // return | |
#> 1900 // LookupName: Advance rcx until it points to a name entry matching r8 & r9, or a blank. virtual addr in eax | |
48 8d 0d #:9400 // rcx = .code + 0x8000, name table | |
e9 #:1910 // enter _Loop | |
#> 1910 // LookupName_Loop | |
83 39 00 // compare *rcx to 0, blank entry? | |
0f 84 #:1950 // then break to _End | |
4c 39 01 // compare *rcx to r8 | |
0f 85 #:1940 // Different? _Next | |
44 39 49 08 // compare *rcx+8 to r9d | |
0f 85 #:1940 // Different? _Next | |
e9 #:1950 // matches. _End | |
#> 1940 LookupName_Next | |
48 83 c1 10 // rcx += 0x10, next entry | |
e9 #:1910 // next _Loop | |
#> 1950 LookupName_End | |
8b 41 0c // eax = *rcx+0xc, virtual addr field | |
c3 // return | |
#> 1960 // DefineName | |
e8 #:18a0 // call ReadName | |
45 85 c0 0f 84 #:14e0 // test r8, if 0 Loop_Eof | |
e8 #:1900 // call LookupName | |
48 8d 15 #:101400 // rdx = .code + 0x100000, output buffer | |
48 2b d7 // rdx -= rdi, edx now contains -<out_pos> | |
f7 da // neg edx, <out_pos> | |
41 03 d2 // edx += r10 | |
4c 89 01 // *rcx = r8 | |
44 89 49 08 // *rcx+0x8 = r9d | |
89 51 0c // *rcx+0xc = edx | |
e9 #:1500 // jump back to main Loop | |
#> 19a0 // NameAddr | |
e8 #:18a0 // call ReadName | |
45 85 c0 0f 84 #:14e0 // test r8, if 0 Loop_Eof | |
e8 #:1900 // call LookupName | |
48 8d 15 #:101400 // rdx = .code + 0x100000, output buffer | |
48 2b d7 // rdx -= rdi, edx now contains -<out_pos> | |
03 c2 // eax += edx | |
41 2b c2 // eax -= r10 | |
83 e8 04 // eax -= 4 | |
89 07 // *rdi = eax | |
48 83 c7 04 // rdi += 4 | |
e9 #:1500 // jump back to main Loop | |
#> 1a00 // Pad to next multiple of 0x200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment