I recently came across an old post in a forum
which is about an assembly patching of a 'divide overflow' error.
I quote
the program pcxdump.exe will 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 ****tion of the PCXDUMP program attempts
to go resident
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
****tion 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
;*******************************************************************************************
Now, I'm afraid I don't get in what way
and dx, 09c3h
should make the trick.
Actually, I don't even see where the overflow should come from in the
original unpatched code...
Can someone help me ?
Are those snippets meaningful to you ?
If you wish, I can post the link to that post
Thx for reading.


|