From ba5ececab9a2af0620330c30ebca9de89b801eef Mon Sep 17 00:00:00 2001 From: nickysn Date: Wed, 25 Jun 2014 16:46:58 +0000 Subject: [PATCH] * i8086 far data memory model fixes in the int 0 (div by zero) handler git-svn-id: trunk@28062 - --- rtl/msdos/prt0comn.asm | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/rtl/msdos/prt0comn.asm b/rtl/msdos/prt0comn.asm index 9e18cd783c..08f0282584 100644 --- a/rtl/msdos/prt0comn.asm +++ b/rtl/msdos/prt0comn.asm @@ -259,39 +259,43 @@ error_msg: FPC_INT00_HANDLER: sub sp, 4 ; reserve space on the stack for the retf - push bx push cx push ds + push bp ; init ds %ifdef __TINY__ - mov bx, cs + mov bp, cs %else - mov bx, dgroup + mov bp, dgroup %endif - mov ds, bx + mov ds, bp +%ifdef __NEAR_DATA__ + ; in memory models, where SS=DS, also ; check whether we're running on the same stack mov cx, ss - cmp bx, cx + cmp bp, cx jne .call_previous_handler +%endif %ifndef __FAR_CODE__ ; check whether we're coming from the same code segment - mov bx, sp - mov cx, [bx + 3*2 + 6] ; get caller segment - mov bx, cs - cmp bx, cx + mov bp, sp + mov cx, [bp + 3*2 + 6] ; get caller segment + mov bp, cs + cmp bp, cx jne .call_previous_handler %endif ; runerror 200 - mov bx, sp - mov cx, [bx + 3*2 + 4] ; get caller offset + mov bp, sp + mov cx, [bp + 3*2 + 4] ; get caller offset %ifdef __FAR_CODE__ - mov dx, [bx + 3*2 + 6] ; get caller segment + mov dx, [bp + 3*2 + 6] ; get caller segment %endif - add sp, 3*2 + 4 + 6 + pop bp + add sp, 2*2 + 4 + 6 xor ax, ax push ax mov ax, 200 @@ -308,14 +312,14 @@ FPC_INT00_HANDLER: %endif .call_previous_handler: - mov bx, sp + mov bp, sp mov cx, [__SaveInt00] - mov [ss:bx + 3*2], cx + mov [bp + 3*2], cx mov cx, [__SaveInt00+2] - mov [ss:bx + 3*2 + 2], cx + mov [bp + 3*2 + 2], cx + pop bp pop ds pop cx - pop bx retf ; jumps to the previous handler with all registers and stack intact