change hex0 comments to be ; instead of #

This commit is contained in:
janis 2026-06-05 02:45:33 +02:00
parent c2934ffd50
commit 0d6ed8a318
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8
2 changed files with 134 additions and 134 deletions

View file

@ -7,7 +7,7 @@ stage0: $(BUILD)/stage0
stage0-bootstrap: $(BUILD)/stage0-bootstrap stage0-bootstrap: $(BUILD)/stage0-bootstrap
$(BUILD)/stage0-bootstrap: hex0.in $(BUILD)/stage0-bootstrap: hex0.in
for x in `sed '/^#/d;s/#.*//;s/ *//' hex0.in`; do printf \\x$$x; done > $@ for x in `sed '/^;/d;s/;.*//;s/ *//' hex0.in`; do printf \\x$$x; done > $@
chmod +x $@ chmod +x $@
$(BUILD)/stage0: $(BUILD)/stage0-bootstrap $(BUILD)/stage0: $(BUILD)/stage0-bootstrap

View file

@ -1,221 +1,221 @@
# ELF header ; ELF header
# e_ident: u128 ; e_ident: u128
# Magic number: 0x7f454c46 = "\x7fELF" ; Magic number: 0x7f454c46 = "\x7fELF"
7f 45 4c 46 7f 45 4c 46
# EI_CLASS: u8 = ELFCLASS64 ; EI_CLASS: u8 = ELFCLASS64
02 02
# EI_DATA: u8 = ELFDATA2LSB ; EI_DATA: u8 = ELFDATA2LSB
01 01
# EI_VERSION: u8 = EV_CURRENT ; EI_VERSION: u8 = EV_CURRENT
01 01
# EI_OSABI: u8 = ELFOSABI_NONE ; EI_OSABI: u8 = ELFOSABI_NONE
00 00
# EI_ABIVERSION: u8 = 0 ; EI_ABIVERSION: u8 = 0
00 00
# EI_PAD: [u8; 7] ; EI_PAD: [u8; 7]
00 00 00 00 00 00 00 00 00 00 00 00 00 00
# e_type: u16 = E_EXEC ; e_type: u16 = E_EXEC
02 00 02 00
# e_machine: u16 = EM_X86_64 ; e_machine: u16 = EM_X86_64
3e 00 3e 00
# e_version: u32 = EV_CURRENT ; e_version: u32 = EV_CURRENT
01 00 00 00 01 00 00 00
# e_entry: u64 = 0x400078 ; e_entry: u64 = 0x400078
78 00 40 00 00 00 00 00 78 00 40 00 00 00 00 00
# e_phoff: u64 = 0x40 ; e_phoff: u64 = 0x40
40 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
# e_shoff: u64 = 0x0 ; e_shoff: u64 = 0x0
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# e_flags: u32 = 0 ; e_flags: u32 = 0
00 00 00 00 00 00 00 00
# e_ehsize: u16 = 64 ; e_ehsize: u16 = 64
40 00 40 00
# e_phentsize: u16 = 56 ; e_phentsize: u16 = 56
38 00 38 00
# e_phnum: u16 = 1 ; e_phnum: u16 = 1
01 00 01 00
# e_shentsize: u16 = 0 ; e_shentsize: u16 = 0
00 00 00 00
# e_shnum: u16 = 0 ; e_shnum: u16 = 0
00 00 00 00
# e_shstrndx: u16 = 0 ; e_shstrndx: u16 = 0
00 00 00 00
# End of ELF header ; End of ELF header
# ;
# Program header ; Program header
# p_type: u32 = PT_LOAD ; p_type: u32 = PT_LOAD
01 00 00 00 01 00 00 00
# p_flags: u32 = PF_R | PF_X ; p_flags: u32 = PF_R | PF_X
05 00 00 00 05 00 00 00
# p_offset: u64 = 0 ; p_offset: u64 = 0
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# p_vaddr: u64 = 0x400000 ; p_vaddr: u64 = 0x400000
00 00 40 00 00 00 00 00 00 00 40 00 00 00 00 00
# p_paddr: u64 = 0x0 ; p_paddr: u64 = 0x0
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# p_filesz: u64 = 0x167 ; p_filesz: u64 = 0x167
67 01 00 00 00 00 00 00 67 01 00 00 00 00 00 00
# p_memsz: u64 = 0x167 ; p_memsz: u64 = 0x167
67 01 00 00 00 00 00 00 67 01 00 00 00 00 00 00
# p_align: u64 = 0x1000 ; p_align: u64 = 0x1000
00 10 00 00 00 00 00 00 00 10 00 00 00 00 00 00
# End of program header ; End of program header
# ;
# Code segment (offset 0x40, virtual address 0x400000) ; Code segment (offset 0x40, virtual address 0x400000)
# ;
# _start=120: ; _start=120:
# ; alloca 0x1000 bytes on the stack ; ; alloca 0x1000 bytes on the stack
# mov rbp, rsp ; mov rbp, rsp
48 89 e5 48 89 e5
# sub rsp, 0x10000, increase this if you want to read more than 0x10000 bytes ; sub rsp, 0x10000, increase this if you want to read more than 0x10000 bytes
48 81 ec 00 00 01 00 48 81 ec 00 00 01 00
# ; read 0x10000 bytes from stdin into the stack ; ; read 0x10000 bytes from stdin into the stack
# .READ: (130) ; .READ: (130)
# xor rax, rax ; xor rax, rax
48 31 c0 48 31 c0
# mov edi, 0 (stdin) ; mov edi, 0 (stdin)
48 c7 c7 00 00 00 00 48 c7 c7 00 00 00 00
# mov rsi, rsp ; mov rsi, rsp
48 89 e6 48 89 e6
# mov rdx, 0x10000, increase this if you want to read more than 0x10000 bytes ; mov rdx, 0x10000, increase this if you want to read more than 0x10000 bytes
48 c7 c2 00 00 01 00 48 c7 c2 00 00 01 00
# syscall (sys_read) ; syscall (sys_read)
0f 05 0f 05
# cmp rax, 0 ; cmp rax, 0
48 83 f8 00 48 83 f8 00
# jle die ; jle die
0f 8e b3 00 00 00 0f 8e b3 00 00 00
## (162) ;# (162)
# ; end = r8 ; ; end = r8
# mov r8, rax ; mov r8, rax
49 89 c0 49 89 c0
# add r8, rsp ; add r8, rsp
49 01 e0 49 01 e0
# ; pos = r9 ; ; pos = r9
# mov r9, rsp ; mov r9, rsp
49 89 e1 49 89 e1
# ; dst = r10 ; ; dst = r10
# mov r10, rsp ; mov r10, rsp
49 89 e2 49 89 e2
# add r10, 0x0000 ; add r10, 0x0000
49 81 c2 00 00 00 00 49 81 c2 00 00 00 00
# ; while (pos < end) { ; ; while (pos < end) {
# ; .L0: (181) ; ; .L0: (181)
# cmp r9, r8 ; cmp r9, r8
4d 39 c1 4d 39 c1
# jge .L3 ; jge .L3
0f 8d 72 00 00 00 0f 8d 72 00 00 00
# (190) ; (190)
# ;
# ; if (*pos == '#') { ; ; if (*pos == ';') {
# mov al , byte [r9] ; mov al , byte [r9]
41 8a 41 00 41 8a 41 00
# cmp al, '\n' ; cmp al, '\n'
3c 0a 3c 0a
# je .L2.1: ; je .L2.1:
0f 84 15 00 00 00 0f 84 15 00 00 00
# (202) ; (202)
# cmp al, '#' ; cmp al, ';'
3c 23 3c 3b
# jne .L1 ; jne .L1
0f 85 15 00 00 00 0f 85 15 00 00 00
# ; while (*pos != '\n') pos++; ; ; while (*pos != '\n') pos++;
# ; .L2: (210) ; ; .L2: (210)
# inc r9 ; inc r9
49 ff c1 49 ff c1
# cmp byte [r9], '\n' ; cmp byte [r9], '\n'
41 80 39 0a 41 80 39 0a
# jne .L2 ; jne .L2
0f 85 f3 ff ff ff 0f 85 f3 ff ff ff
# .L2.1: (223) ; .L2.1: (223)
# inc r9 ; inc r9
49 ff c1 49 ff c1
# jmp .L0 ; jmp .L0
e9 ce ff ff ff e9 ce ff ff ff
# (231) ; (231)
# ; .L1: (231) ; ; .L1: (231)
# ; convert *pos to high word ; ; convert *pos to high word
# mov al, byte [r9] ; mov al, byte [r9]
41 8a 01 41 8a 01
# mov bl, al ; mov bl, al
88 c3 88 c3
# sub bl, 'a' ; sub bl, 'a'
80 eb 61 80 eb 61
# add bl, 10 ; add bl, 10
80 c3 0a 80 c3 0a
# sub al, '0' ; sub al, '0'
2c 30 2c 30
# cmp al, 10 ; cmp al, 10
3c 0a 3c 0a
# cmovge eax, ebx ; cmovge eax, ebx
0f 43 c3 0f 43 c3
# shl al, 4 ; shl al, 4
c0 e0 04 c0 e0 04
# ; pos++ ; ; pos++
# inc r9 ; inc r9
49 ff c1 49 ff c1
# ; convert *pos to low word ; ; convert *pos to low word
# mov bl, byte [r9] ; mov bl, byte [r9]
41 8a 19 41 8a 19
# mov cl, bl ; mov cl, bl
88 d9 88 d9
# sub cl, 'a' ; sub cl, 'a'
80 e9 61 80 e9 61
# add cl, 10 ; add cl, 10
80 c1 0a 80 c1 0a
# sub bl, '0' ; sub bl, '0'
80 eb 30 80 eb 30
# cmp bl, 10 ; cmp bl, 10
80 fb 0a 80 fb 0a
# cmovge ebx, ecx ; cmovge ebx, ecx
0f 4d d9 0f 4d d9
# ; combine high and low word ; ; combine high and low word
# or al, bl ; or al, bl
08 d8 08 d8
# ; write the byte to dst ; ; write the byte to dst
# mov byte [r10], al ; mov byte [r10], al
41 88 02 41 88 02
# inc r10 ; inc r10
49 ff c2 49 ff c2
# inc r9 ; inc r9
49 ff c1 49 ff c1
# ; if (*pos++ == '\n') goto .L1; ; ; if (*pos++ == '\n') goto .L1;
# cmp byte [r9], '\n' ; cmp byte [r9], '\n'
41 80 39 0a 41 80 39 0a
# je .L0 ; je .L0
0f 84 8d ff ff ff 0f 84 8d ff ff ff
## (296) ;# (296)
# inc r9 ; inc r9
49 ff c1 49 ff c1
# jmp .L1 ; ; jmp .L1 ;
e9 b7 ff ff ff e9 b7 ff ff ff
## (304) ;# (304)
# ; } ; ; }
# .L3: (304) ; .L3: (304)
# ; write the decoded bytes to stdout ; ; write the decoded bytes to stdout
# mov rax, 1 (sys_write) ; mov rax, 1 (sys_write)
48 c7 c0 01 00 00 00 48 c7 c0 01 00 00 00
# mov rdi, 1 (stdout) ; mov rdi, 1 (stdout)
48 c7 c7 01 00 00 00 48 c7 c7 01 00 00 00
# mov rsi, rsp ; mov rsi, rsp
48 89 e6 48 89 e6
# add rsi, 0x000 ; add rsi, 0x000
48 81 c6 00 00 00 00 48 81 c6 00 00 00 00
# mov rdx, r10 ; mov rdx, r10
4c 89 d2 4c 89 d2
# sub rdx, rsi ; sub rdx, rsi
48 29 f2 48 29 f2
# syscall ; syscall
0f 05 0f 05
# jmp .READ ; ; jmp .READ ;
e9 2d ff ff ff e9 2d ff ff ff
## (341) ;# (341)
# ;
# die: (341) ; die: (341)
# mov rax, 60 (sys_exit) ; mov rax, 60 (sys_exit)
48 c7 c0 3c 00 00 00 48 c7 c0 3c 00 00 00
# xor rdi, rdi ; xor rdi, rdi
48 31 ff 48 31 ff
# syscall ; syscall
0f 05 0f 05
# _start+215 ; _start+215