First post, by dvwjr
After spending about three months learning about the initial levels of Intel assembly language as my New Year's resolution - I thought that I would post a patch I wrote for the old DOS SVGA/VESA screen-capture program PCXDUMP which has problems with the faster CPUs of today. It appears that this former shareware program is now abandonware and has had no code updates since the 1996 release of version 9.31 of the program.
The PCXDUMP program requires that the registered name and serial number be input while the DOS clock is set to some date/time in 1996. After that registration action is performed the actual date/time do not matter but the program will then NOT function properly on the faster CPUs of today because of a 'divide overflow' error - but a fairly simple patch can correct the 'divide overflow' error that occurs when the TSR portion of the PCXDUMP program attempts to go resident.
The PCXDUMP author used a home-grown EXE packer to compress his program, so the CODE patch listed below will only function after the program is successfully UNPACKED. Use Google to find the unpack utility CUP386 and use the code fragments listed below to UNPACK version 9.31 of PCXDUMP.EXE so that the patch listed below may be used. Once the PCXDUMP program is patched no further CPU speed increases will cause the same 'divide overflow' failure.
PCXDUMP version 9.31 (abandonware?)
(as an example)
Name: mxxxxxx xx [uCF]
S/N: MDSxxxxxxxxxxxxxx
The PCXDUMP.EXE version 9.31 has a home-grown DOS EXE packer. Can be unpacked with CUP386 version 3.4 which can be found somewhere on the Internet...
To unpack PCXDUMP v9.31 properly with CUP386, the code line "MOV AX, CS" shown below should be the REAL entry point for the program after the in-memory UNPACK. Use this information with CUP386 to UNPACK the PCXDUMP.EXE properly.
0001:B1FD 8C C8 mov ax,cs ;start Unpack HERE
0001:B1FF 8E D8 mov ds,ax
0001:B201 2E: 8C 06 15CF mov cs:[data_284],es ; (0001:15CF=369Dh)
0001:B206 2E: C7 06 47C7 38D3 mov cs:[data_446],38D3h ; (0001:47C7=0)
0001:B20D 2E: 81 06 47C7 00A0 add cs:[data_446],0A0h ; (0001:47C7=0)
0001:B214 E8 E4C2 call sub_204 ; (96D9)
0001:B217 E8 D723 call sub_180 ; (893D)
0001:B21A E8 DE22 call sub_187 ; (903F) Sub does not return here
Now here is the old PCXDUMP.EXE code which caused the problem:
; OLD CODE: FILE OFFSET at byte: 0x982C of the UNPACKED version of PCXDUMP.EXE v 9.31
;**********************************************************************************************************************
; This original code will cause an Intel 'divide overflow' error on FAST CPUs...
0001:914C B8 0000 mov ax,0
0001:914F BA 0000 mov dx,0 ; DX start at ZERO too much for fast CPUs
0001:9152 2E: C7 06 9184 0000 mov cs:[data_588],0 ; (0001:9184=0)
0001:9159 loc_821: ; xref 0001:9166
0001:9159 40 inc ax
0001:915A 3D 0000 cmp ax,0
0001:915D 75 01 jne short loc_822 ; Jump if not equal
0001:915F 42 inc dx ; the DX portion of DX:AX too BIG!
0001:9160 loc_822: ; xref 0001:915D
0001:9160 2E: 83 3E 9184 09 cmp cs:[data_588],9 ; (0001:9184=0)
0001:9166 72 F1 jb loc_821 ; Jump if below
;**********************************************************************************************************************
Code Patch for today's FASTER Intel/AMD CPUs:
; NEW CODE: FILE OFFSET at byte: 0x982C of the UNPACKED version of PCXDUMP.EXE v 9.31
;**********************************************************************************************************************
; Below is new Patch to prevent DIVIDE OVERFLOW with a Timer Counter on FAST CPUs...
0001:914C 31 C0 xor ax, ax
0001:914E 31 D2 xor dx, dx
0001:9150 2E A3 9184 mov cs:[data_588], ax
0001:9154 loc_821:
0001:9154 40 inc ax
0001:9155 3D 0000 cmp ax, 0
0001:9158 75 01 jne short loc_822
0001:915A 42 inc dx
0001:915B loc_822:
0001:915B 2E: 83 3E 9184 09 cmp cs:[data_588], 09
0001:9161 72 F1 jb loc_821
0001:9163 81 E2 09C3 and dx, 09C3h ; prevent the DIVIDE OVERFLOW in DX
0001:9167 90 nop
;**********************************************************************************************************************
Hope this helps,
dvwjr