Function at 0x403130
Capabilities:
Read file on windows
Write file on windows

Disassembly:
push ebp
mov ebp, esp
push edi
push esi
push ebx
and esp, 0xfffffff0
sub esp, 0x440
call dbg.__main
mov eax, dword [ebp + 0xc]
mov dword [esp + 4], 0x408000
mov eax, dword [eax + 4]
mov dword [esp], eax
call sym._fopen
mov dword [esp + 8], 2
mov ebx, eax
mov dword [esp + 4], 0
mov dword [esp], eax
call sym._fseek
mov dword [esp], ebx
call sym._ftell
mov dword [esp + 8], 0
mov edi, eax
mov dword [esp + 4], 0
mov dword [esp], ebx
mov dword [esp + 0x20], eax
call sym._fseek
mov dword [esp], edi
call sym._malloc
mov dword [esp + 0xc], ebx
mov dword [esp + 8], edi
mov dword [esp + 4], 1
mov dword [esp], eax
mov dword [esp + 0x1c], eax
call sym._fread
mov dword [esp], ebx
call sym._fclose
cmp dword [ebp + 8], 2
jle 0x4036ff
mov edi, 2
xor ecx, ecx
mov dword [esp + 0x2c], 0
mov word [esp + 0x24], cx
mov ebx, edi
mov edi, dword [ebp + 0xc]
movzx eax, bl
mov eax, dword [edi + eax*4]
lea edi, [ebx + 1]
mov ecx, edi
cmp byte [eax], 0x2d
movzx esi, cl
jne 0x40345c
movzx eax, byte [eax + 1]
sub eax, 0x61
cmp al, 0x12
ja case.0x403212.1
movzx eax, al
jmp dword [eax*4 + 0x408094]
cmp dword [ebp + 8], esi
jle 0x4037c0
mov eax, dword [ebp + 0xc]
mov dword [esp + 8], 0x10
add ebx, 2
mov dword [esp + 4], 0
mov eax, dword [eax + esi*4]
movzx esi, bl
mov dword [esp], eax
call sym._strtol
mov word [esp + 0x24], ax
cmp dword [ebp + 8], esi
jg 0x4031e6
mov edx, dword [esp + 0x2c]
test edx, edx
je 0x403706
cmp byte [0x40901c], 0
jne 0x403289
movzx edi, word [esp + 0x24]
mov eax, 1
mov ecx, edi
shr di, 3
and ecx, 7
movzx edx, di
shl eax, cl
test byte [edx + 0x4093e0], al
je 0x403730
movzx eax, word [esp + 0x24]
mov dword [esp + 0x28], eax
jmp 0x4032c5
mov eax, dword [esp + 0x2c]
movzx edi, bx
mov esi, edi
sub esi, dword [esp + 0x28]
add esi, dword [esp + 0x1c]
mov dword [esp], eax
call sym._free
mov eax, dword [esp + 0x18]
test eax, eax
je 0x4034a6
test esi, esi
jne 0x4034a6
mov dword [esp + 0x2c], eax
mov eax, dword [esp + 0x2c]
mov edi, 1
movzx ebx, word [eax]
mov eax, dword [eax + 4]
mov dword [esp + 0x18], eax
mov edx, ebx
mov ecx, ebx
and ecx, 7
shr dx, 3
shl edi, cl
movzx edx, dx
mov ecx, edi
test byte [edx + 0x4093e0], cl
je 0x403294
mov eax, dword [esp + 0x2c]
mov dword [esp], eax
call sym._free
mov eax, dword [esp + 0x18]
test eax, eax
jne 0x4032c1
cmp byte [0x40901e], 0
jne 0x4035ba
mov edx, dword [esp + 0x28]
mov eax, dword [esp + 0x20]
lea edi, [esp + 0x38]
movzx esi, word [esp + 0x24]
add eax, edx
mov ebx, edx
cmp eax, edx
mov dword [esp + 0x2c], eax
jg 0x403341
jmp 0x4033ba
add esi, 1
movzx ebx, si
cmp ebx, dword [esp + 0x2c]
jge 0x4033ba
mov eax, esi
mov ecx, esi
mov edx, 1
shr ax, 3
and ecx, 7
movzx eax, ax
shl edx, cl
test byte [eax + 0x4093e0], dl
je 0x403335
movzx eax, si
sub eax, dword [esp + 0x28]
mov dword [esp + 4], edi
add eax, dword [esp + 0x1c]
mov dword [esp], eax
call sym._z80_decode
cmp byte [0x40901e], 0
jne 0x403335
lea edx, [esp + 0x40]
mov dword [esp + 8], ebx
mov dword [esp], edi
add esi, 1
mov dword [esp + 4], edx
mov dword [esp + 0x24], edx
call sym._z80_disasm
mov edx, dword [esp + 0x24]
mov dword [esp + 4], ebx
movzx ebx, si
mov dword [esp], str._X:__s_n
mov dword [esp + 8], edx
call sym._printf
cmp ebx, dword [esp + 0x2c]
jl 0x403341
lea esp, [ebp - 0xc]
xor eax, eax
pop ebx
pop esi
pop edi
pop ebp
ret
mov byte [0x40901c], 1
mov ebx, edi
jmp 0x40324b
mov byte [0x40901e], 1
mov ebx, edi
jmp 0x40324b
cmp dword [ebp + 8], esi
jle 0x40378c
mov eax, dword [ebp + 0xc]
mov dword [esp + 4], 0x408027
lea esi, [eax + esi*4]
mov eax, dword [esi]
mov dword [esp], eax
call sym._fopen
test eax, eax
mov edi, eax
je 0x403762
lea esi, [esp + 0x40]
jmp 0x40341c
cmp byte [esp + 0x40], 0
jne 0x403681
mov dword [esp + 8], edi
mov dword [esp + 4], 0x400
mov dword [esp], esi
call sym._fgets
test eax, eax
jne 0x403411
mov dword [esp], edi
add ebx, 2
call sym._fclose
movzx esi, bl
jmp 0x40324b
mov byte [0x40901d], 1
mov ebx, edi
jmp 0x40324b
mov ebx, edi
jmp 0x40324b
mov dword [esp + 8], 0x10
mov dword [esp + 4], 0
mov dword [esp], eax
call sym._strtol
mov ebx, eax
mov ecx, eax
mov edx, eax
shr bx, 3
and ecx, 7
mov eax, 1
movzx ebx, bx
shl eax, cl
test byte [ebx + 0x4093e0], al
mov ecx, eax
je 0x403648
or byte [ebx + 0x40b3e0], cl
mov ebx, edi
jmp 0x40324b
test esi, esi
je 0x403306
mov dword [esp + 0x2c], eax
sub edi, dword [esp + 0x28]
cmp edi, dword [esp + 0x20]
jg 0x4035a1
mov eax, ebx
mov ecx, ebx
mov edi, 1
shr ax, 3
and ecx, 7
movzx eax, ax
shl edi, cl
movzx edx, byte [eax + 0x4093e0]
mov ecx, edi
test dl, cl
jne 0x4035a1
cmp bx, word [esp + 0x24]
jb 0x4035a1
or edx, edi
mov dword [esp], esi
mov byte [eax + 0x4093e0], dl
lea eax, [esp + 0x38]
mov dword [esp + 4], eax
call sym._z80_decode
mov edi, eax
sub eax, esi
add ebx, eax
movzx eax, byte [esp + 0x38]
sub eax, 0x2e
cmp al, 0xb
ja case.0x403522.4
movzx eax, al
jmp dword [eax*4 + 0x4080e0]
movzx esi, word [esp + 0x3c]
add esi, ebx
mov eax, esi
mov ecx, esi
mov edx, 1
shr ax, 3
and ecx, 7
mov word [esp + 0x18], si
movzx eax, ax
shl edx, cl
mov esi, edi
or byte [eax + 0x40b3e0], dl
test byte [eax + 0x4093e0], dl
movzx edi, bx
jne 0x4034b2
mov dword [esp], 8
call sym._malloc
movzx ecx, word [esp + 0x18]
mov edx, dword [esp + 0x2c]
mov dword [eax + 4], edx
mov word [eax], cx
jmp 0x4034ae
add bx, word [esp + 0x3c]
movzx edi, bx
mov esi, edi
sub edi, dword [esp + 0x28]
sub esi, dword [esp + 0x28]
add esi, dword [esp + 0x1c]
cmp edi, dword [esp + 0x20]
jle 0x4034c0
mov eax, dword [esp + 0x2c]
test eax, eax
jne 0x4032c5
cmp byte [0x40901e], 0
je 0x403313
movzx ebx, word [esp + 0x20]
mov esi, 1
jmp 0x4035d3
add ebx, 1
mov eax, ebx
mov ecx, ebx
mov edx, esi
shr ax, 3
and ecx, 7
movzx eax, ax
shl edx, cl
test byte [eax + 0x40b3e0], dl
je 0x4035d0
movzx eax, bx
mov dword [esp], str.ADR__X_equ___X_n
mov dword [esp + 8], eax
mov dword [esp + 4], eax
call sym._printf
jmp 0x4035d0
movzx esi, word [esp + 0x3c]
jmp 0x403530
movzx edi, word [esp + 0x3c]
mov esi, edi
sub esi, dword [esp + 0x28]
mov ebx, edi
add esi, dword [esp + 0x1c]
jmp 0x4034b2
lea eax, [esp + 0x38]
mov dword [esp], eax
call sym._z80_is_terminal
test al, al
je 0x403677
movzx eax, word [esp + 0x20]
mov esi, edi
lea ebx, [eax + 1]
movzx edi, bx
jmp 0x4034b2
mov dword [esp], 8
mov dword [esp + 0x28], edx
mov dword [esp + 0x18], eax
call sym._malloc
mov edx, dword [esp + 0x28]
mov ecx, dword [esp + 0x18]
mov word [eax], dx
mov edx, dword [esp + 0x2c]
mov dword [esp + 0x2c], eax
mov dword [eax + 4], edx
jmp 0x403499
mov esi, edi
movzx edi, bx
jmp 0x4034b2
mov dword [esp + 8], 0x10
mov dword [esp + 4], 0
mov dword [esp], esi
call sym._strtol
test ax, ax
mov ecx, eax
mov dword [esp + 0x28], eax
je 0x40341c
mov edx, eax
and ecx, 7
mov eax, 1
shr dx, 3
shl eax, cl
movzx edx, dx
mov ecx, eax
test byte [edx + 0x4093e0], al
jne 0x4036f4
mov dword [esp], 8
mov dword [esp + 0x18], edx
mov dword [esp + 0x14], eax
call sym._malloc
movzx ecx, word [esp + 0x28]
mov edx, dword [esp + 0x18]
mov word [eax], cx
mov ecx, dword [esp + 0x2c]
mov dword [esp + 0x2c], eax
mov dword [eax + 4], ecx
mov ecx, dword [esp + 0x14]
or byte [edx + 0x40b3e0], cl
jmp 0x40341c
mov word [esp + 0x24], 0
movzx eax, word [esp + 0x24]
mov edx, eax
mov ecx, eax
mov eax, 1
shr dx, 3
and ecx, 7
movzx edx, dx
shl eax, cl
test byte [edx + 0x4093e0], al
jne 0x403754
mov dword [esp + 0x2c], 0
mov dword [esp], 8
call sym._malloc
movzx edi, word [esp + 0x24]
mov word [eax], di
mov edi, dword [esp + 0x2c]
mov dword [esp + 0x2c], eax
mov dword [eax + 4], edi
jmp 0x403289
movzx eax, word [esp + 0x24]
mov dword [esp + 0x28], eax
jmp 0x403306
mov eax, dword [esi]
mov dword [esp + 4], str.Failed_to_open__s_for_reading_n
mov dword [esp + 8], eax
mov eax, dword [sym.imp.msvcrt.dll__iob]
add eax, 0x40
mov dword [esp], eax
call sym._fprintf
mov dword [esp], 1
call sym._exit
mov eax, dword [sym.imp.msvcrt.dll__iob]
mov dword [esp + 8], 0x22
mov dword [esp + 4], 1
mov dword [esp], str._f_must_be_followed_by_a_filename_n
add eax, 0x40
mov dword [esp + 0xc], eax
call sym._fwrite
mov dword [esp], 1
call sym._exit
mov eax, dword [sym.imp.msvcrt.dll__iob]
mov dword [esp + 8], 0x2d
mov dword [esp + 4], 1
mov dword [esp], str._s_must_be_followed_by_a_start_offset_in_hex_n
add eax, 0x40
mov dword [esp + 0xc], eax
call sym._fwrite
mov dword [esp], 1
call sym._exit
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop