Please examine the following assembly code from an MS-DOS program. assume CS = 0x1000…
- User
Please examine the following assembly code from an MS-DOS program.
assume CS = 0x1000 assume SP = 0x800 assume SS = 0x15f7 Entry Point JMP FUN_1000_1c15
FUN_1000_1c15 STI MOV CX,0x1465 MOV ES,CX MOV BX,0x191a ADD BX,0xf AND BL,0xf0 MOV word ptr ES:[DAT_1465_0afc],BX MOV word ptr ES:[DAT_1465_0af6],DS ADD BX,SP ADD BX,0xf AND BL,0xf0 MOV SS,CX MOV SP,BX MOV word ptr ES:[DAT_1465_0afe],BX MOV DX,BX SHR DX,0x1 SHR DX,0x1 SHR DX,0x1 SHR DX,0x1 CMP byte ptr ES:[DAT_1465_0afa],0x0 JNZ LAB_1000_1c8f MOV CX,word ptr [0x2] MOV AX,ES SUB CX,AX CMP DX,CX JC LAB_1000_1c69 MOV BX,0x1 MOV AX,0x1bfb MOV DX,CS CALL FUN_1000_1dcf LAB_1000_1c69 MOV AX,ES MOV BX,DX SHL BX,0x1 SHL BX,0x1 SHL BX,0x1 SHL BX,0x1 JNZ LAB_1000_1c7a MOV BX,0xfffe LAB_1000_1c7a MOV word ptr ES:[DAT_1465_0af4],BX MOV BX,DX ADD BX,AX MOV AX,ES:[DAT_1465_0af6] MOV ES,AX SUB BX,AX MOV AH,0x4a INT 0x21 LAB_1000_1c8f MOV DI,DS MOV ES,DI MOV DI,0x81 MOV CL,byte ptr [DI + -0x1] MOV CH,0x0 CLD MOV AL,0x20 SCASB.REPE ES:DI LEA SI,[DI + -0x1] MOV DX,0x1465 MOV ES,DX MOV DI,word ptr ES:[DAT_1465_0afc] MOV word ptr ES:[DAT_1465_0b16],DI MOV word ptr ES:[DAT_1465_0b18],ES JZ LAB_1000_1cbc INC CX MOVSB.REP ES:DI=>DATA:DAT_1465_1920,SI LAB_1000_1cbc: SUB AL,AL STOSB ES:DI=>DATA:DAT_1465_1920 MOV AL,0x0 STOSB ES:DI=>DATA:DAT_1465_1921 DEC DI MOV AH,0x30 INT 0x21 MOV ES:[DAT_1465_0af8],AL MOV byte ptr ES:[DAT_1465_0af9],AH MOV CX,DI CMP AL,0x3 JC LAB_1000_1d05 MOV DS,word ptr [0x2c] SUB SI,SI XOR BP,BP LAB_1000_1cde: MOV AX,word ptr [SI] OR AX,0x2020 CMP AX,0x6f6e JNZ LAB_1000_1cf1 MOV AX,word ptr [SI + 0x2] CMP AX,0x3738 JNZ LAB_1000_1cf1 INC BP LAB_1000_1cf1: CMP byte ptr [SI],0x0 LODSB SI JNZ LAB_1000_1cf1 CMP byte ptr [SI],0x0 JNZ LAB_1000_1cde LODSB SI INC SI INC SI LAB_1000_1cff: CMP byte ptr [SI],0x0 MOVSB ES:DI=>DATA:DAT_1465_1921,SI JNZ LAB_1000_1cff LAB_1000_1d05: MOV SI,CX MOV word ptr ES:[DAT_1465_0b1a],SI MOV word ptr ES:[DAT_1465_0b1c],ES MOV AX,ES:[DAT_1465_0af6] MOV ES,AX MOV BX,SP MOV DX,0x1465 MOV DS,DX MOV ES,DX MOV word ptr [DAT_1465_0b04],BP MOV word ptr [DAT_1465_0afc],DI MOV CX,0x191a MOV DI,0xbca SUB CX,DI MOV AL,0x0 STOSB.REP ES:DI=>DATA:DAT_1465_0bca CMP word ptr [DAT_1465_0b06],0x0 JNZ LAB_1000_1d55 MOV AX,0x1dcb MOV [DAT_1465_0b06],AX MOV word ptr [DAT_1465_0b08],CS MOV [DAT_1465_0b0a],AX MOV word ptr [DAT_1465_0b0c],CS MOV [DAT_1465_0b0e],AX MOV word ptr [DAT_1465_0b10],CS LAB_1000_1d55: XOR BP,BP MOV AX,0x1dca MOV [DAT_1465_0b12],AX MOV word ptr [DAT_1465_0b14],CS MOV AX,0xff CALL FUN_1000_3754 CALL FUN_1000_36e7 LAB_1000_1d6a: PUSH AX MOV DX,0x1465 MOV DS,DX CLD LEA DI,[0x0] MOV ES,DX MOV CX,0x10 MOV AX,0x101 SCASW.REPE ES:DI=>DAT_1465_0000 POP AX JZ LAB_1000_1db3 MOV BX,AX MOV AX,0x1bda MOV DX,CS
FUN_1000_1dcf PUSH CX PUSH SI MOV CX,AX MOV SI,DX CALL FUN_1000_3910 TEST AX,AX JNZ LAB_1000_1de3 MOV AX,CX MOV DX,SI CALL FUN_1000_1d89 LAB_1000_1de3 POP SI POP CX RET
FUN_1000_3910 CMP byte ptr [0xb36],0x0 JZ LAB_1000_3929 PUSH DX PUSH AX INT3 JMP LAB_1000_3922 ; This instruction is followed by the string "WVIDEO" LAB_1000_3922 MOV AX,0x1 ADD SP,0x4 RET LAB_1000_3929 XOR AX,AX RET
- Assistant
The given code is an extracted segment from an MS-DOS program. It is written in x86 assembly language, and it performs several tasks including:
- Setting up the stack (memory segments, stack pointer, etc.)
- Manipulating and comparing memory contents by using various bitwise operations, arithmetic operations, and string operations.
- Performing conditional jumps and loops based on the comparison results.
- Calling interrupt services and internal functions.
Here's a high-level overview of the code operations:
- At the entry point, it jumps to the function FUN_1000_1c15.
- In the FUN_1000_1c15 function, it performs tasks such as setting up and adjusting the stack, and manipulating and comparing memory contents.