I will provide you disassembly from a computer game that runs in MS-DOS. The game was…
- User
I will provide you disassembly from a computer game that runs in MS-DOS. The game was written in C with a Watcom compiler. Explain the functions I give to you and suggest names and C-language function signatures for them, including which parameters map to which registers or stack values. Also suggest names for global values when you have enough context to do so.
FUN_00082750 PUSH EBP MOV EBP,ESP PUSH EBX PUSH ECX PUSH EDX PUSH ESI PUSH EDI SUB ESP,0x14 MOV dword ptr [EBP + local_2c],EAX MOV dword ptr [EBP + local_20],0x1 MOV EAX,dword ptr [EBP + local_2c] CALL FUN_00082657 MOV dword ptr [EBP + local_28],EAX CMP dword ptr [EBP + local_28],0x0 JNZ LAB_00082782 MOV dword ptr [EBP + local_1c],0xffffffff JMP LAB_000827b6 LAB_00082782 MOV EAX,dword ptr [EBP + local_28] CALL FUN_0008269b MOV dword ptr [EBP + local_24],EAX LAB_0008278d MOV EAX,dword ptr [EBP + local_28] CMP EAX,dword ptr [EBP + local_2c] JZ LAB_000827b0 MOV EAX,dword ptr [EBP + local_28] DEC dword ptr [EBP + local_28] SHL dword ptr [EBP + local_20],0x4 MOV EAX,dword ptr [EBP + local_28] CALL FUN_0008269b IMUL EAX,dword ptr [EBP + local_20] ADD dword ptr [EBP + local_24],EAX JMP LAB_0008278d LAB_000827b0 MOV EAX,dword ptr [EBP + local_24] MOV dword ptr [EBP + local_1c],EAX LAB_000827b6 MOV EAX,dword ptr [EBP + local_1c] LEA ESP=>local_18,[EBP + -0x14] POP EDI POP ESI POP EDX POP ECX POP EBX POP EBP RET
FUN_00082657 PUSH EBP MOV EBP,ESP PUSH EBX PUSH ECX PUSH EDX PUSH ESI PUSH EDI SUB ESP,0x10 MOV dword ptr [EBP + local_28],EAX MOV EAX,dword ptr [EBP + local_28] MOV dword ptr [EBP + local_24],EAX MOV dword ptr [EBP + local_20],0x0 LAB_00082675 MOV EAX,dword ptr [EBP + local_24] CMP byte ptr [EAX],0x0 JZ LAB_00082688 MOV EAX,dword ptr [EBP + local_24] INC dword ptr [EBP + local_24] MOV dword ptr [EBP + local_20],EAX JMP LAB_00082675 LAB_00082688 MOV EAX,dword ptr [EBP + local_20] MOV dword ptr [EBP + local_1c],EAX MOV EAX,dword ptr [EBP + local_1c] LEA ESP=>local_18,[EBP + -0x14] POP EDI POP ESI POP EDX POP ECX POP EBX POP EBP RET
FUN_0008269b PUSH EBP MOV EBP,ESP PUSH EBX PUSH ECX PUSH EDX PUSH ESI PUSH EDI SUB ESP,0x8 MOV dword ptr [EBP + local_20],EAX MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] AND EAX,0xff CMP EAX,0x30 JL LAB_000826ca MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] AND EAX,0xff CMP EAX,0x39 JLE LAB_000826cc LAB_000826ca JMP LAB_000826de LAB_000826cc MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] XOR AH,AH SUB EAX,0x30 MOV dword ptr [EBP + local_1c],EAX JMP LAB_00082743 LAB_000826de MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] AND EAX,0xff CMP EAX,0x41 JL LAB_000826fc MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] AND EAX,0xff CMP EAX,0x5a JLE LAB_000826fe LAB_000826fc JMP LAB_0008270d LAB_000826fe MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] XOR AH,AH SUB EAX,0x37 MOV dword ptr [EBP + local_1c],EAX JMP LAB_00082743 LAB_0008270d MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] AND EAX,0xff CMP EAX,0x61 JL LAB_0008272b MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] AND EAX,0xff CMP EAX,0x61 JLE LAB_0008272d LAB_0008272b JMP LAB_0008273c LAB_0008272d MOV EAX,dword ptr [EBP + local_20] MOV AL,byte ptr [EAX] XOR AH,AH SUB EAX,0x57 MOV dword ptr [EBP + local_1c],EAX JMP LAB_00082743 LAB_0008273c MOV dword ptr [EBP + local_1c],0x0 LAB_00082743 MOV EAX,dword ptr [EBP + local_1c] LEA ESP=>local_18,[EBP + -0x14] POP EDI POP ESI POP EDX POP ECX POP EBX POP EBP RET
- Assistant
The first function, FUN_00082750, appears to calculate the numeric value of a hexadecimal string.
C-Language function signature:
uint32_t parse_hexadecimal_string(const char *hex_string);Name Suggestions: parse_hexadecimal_string or hex_to_int
Parameter mapping:
- EAX maps to the address of the input hex string (const char *hex_string).
The second function, FUN_00082657, calculates the length of a null-terminated input string.
C-Language function signature:
uint32_t get_string_length(const char *input_string);Name Suggestions: get_string_length or string_length
Parameter mapping:
- EAX maps to the address of the input string (const char *input_string).
The third function, FUN_0008269b, converts a single character (byte) to its corresponding hexadecimal value.
C-Language function signature:
uint8_t char_to_hex_value(char input_char);Name Suggestions: char_to_hex_value or hex_char_to_int
Parameter mapping:
- EAX maps to the input character (char input_char).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.