From 399e6e3098247ef0498e86f4c40ab53d7950e037 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Wed, 1 Oct 2014 15:51:50 +0200 Subject: [PATCH] [Reduction] #517-518: int86 --- libs/BorlandC/int86.asm | 117 ++++++++++++++++++++++++++++++++++ th01_fuuin.asm | 134 +-------------------------------------- th01_op.asm | 134 +-------------------------------------- th01_reiiden.asm | 136 +--------------------------------------- 4 files changed, 120 insertions(+), 401 deletions(-) create mode 100644 libs/BorlandC/int86.asm diff --git a/libs/BorlandC/int86.asm b/libs/BorlandC/int86.asm new file mode 100644 index 00000000..aac7b0ec --- /dev/null +++ b/libs/BorlandC/int86.asm @@ -0,0 +1,117 @@ +; int __cdecl int86(int intno, union REGS *inregs, union REGS *outregs) +_int86 proc DIST +@@segp = SREGS ptr -(size SREGS) +@@intno = word ptr (dPtrSize + 2) +@@inregs = DPTR_ (dPtrSize + 4) +@@outregs = DPTR_ (dPtrSize + 4 + dPtrSize) + + push bp + mov bp, sp + sub sp, size SREGS + push si + push di + push ss + lea ax, [bp+@@segp] + push ax + nopcall _segread + pop cx + pop cx + push ss + lea ax, [bp+@@segp] + push ax + push word ptr [bp+@@outregs+2] + push word ptr [bp+@@outregs] + push word ptr [bp+@@inregs+2] + push word ptr [bp+@@inregs] + push [bp+@@intno] + call _int86x + add sp, (dPtrSize * 2) + 6 + pop di + pop si + mov sp, bp + pop bp + ret +_int86 endp + +; int __cdecl int86x(int intno, union REGS *inregs, union REGS *outregs, struct SREGS *segregs) +_int86x proc DIST +@@Code = byte ptr -(4 + 10) +@@Vector = dword ptr -4 +@@intno = word ptr (dPtrSize + 2) +@@inregs = DPTR_ (dPtrSize + 4) +@@outregs = DPTR_ (dPtrSize + 4 + dPtrSize) +@@segregs = DPTR_ (dPtrSize + 4 + dPtrSize + dPtrSize) + + push bp + mov bp, sp + sub sp, (4 + 10) + push si + push di + push ds + lea cx, [bp+@@Code] + mov word ptr [bp+@@Vector], cx + mov word ptr [bp+@@Vector+2], ss + mov [bp+@@Code], 55h + mov [bp+@@Code+1], 0CDh + mov ax, [bp+@@intno] + mov [bp+@@Code+2], al + mov word ptr [bp+@@Code+3], 0CB5Dh + cmp al, 25h + jb short @@SetRegs + cmp al, 26h + ja short @@SetRegs + mov [bp+@@Code+3], 36h + mov word ptr [bp+@@Code+4], 68Fh + mov word ptr [bp+@@Code+6], cx + mov word ptr [bp+@@Code+8], 0CB5Dh + +@@SetRegs: + LDS_ si, [bp+@@segregs] + push [si+SREGS._es] + push [si+SREGS._ds] + LDS_ si, [bp+@@inregs] + mov ax, [si+WORDREGS._ax] + mov bx, [si+WORDREGS._bx] + mov cx, [si+WORDREGS._cx] + mov dx, [si+WORDREGS._dx] + mov di, [si+WORDREGS._di] + mov si, [si+WORDREGS._si] + pop ds + pop es + clc + call [bp+@@Vector] + pushf + pushf + push si + push ds + push es +ife LDATA + mov ds, [bp-20] +endif + LDS_ si, [bp+@@segregs] + pop [si+SREGS._es] + pop [si+SREGS._ds] + LDS_ si, [bp+@@outregs] + pop [si+WORDREGS._si] + pop [si+WORDREGS._flags] + pop [si+WORDREGS._cflags] + and [si+WORDREGS._cflags], 1 + mov [si+WORDREGS._di], di + mov [si+WORDREGS._dx], dx + mov [si+WORDREGS._cx], cx + mov [si+WORDREGS._bx], bx + mov [si+WORDREGS._ax], ax + pop ds + jz short @@int86Ok + push ax + push ax + call __IOERROR + pop ax + +@@int86Ok: + pop di + pop si + mov sp, bp + pop bp + ret +_int86x endp diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 076f0426..68281cec 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -4147,139 +4147,7 @@ include libs/BorlandC/xxv.asm include libs/BorlandC/cputype.asm include libs/BorlandC/FARHEAP.ASM include libs/BorlandC/fbrk.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl int86(int intno, union REGS *inregs, union REGS *outregs) -_int86 proc far - -segp = SREGS ptr -8 -intno = word ptr 6 -inregs = dword ptr 8 -outregs = dword ptr 0Ch - - push bp - mov bp, sp - sub sp, 8 - push si - push di - push ss - lea ax, [bp+segp] - push ax ; segp - nopcall _segread - pop cx - pop cx - push ss - lea ax, [bp+segp] - push ax ; segregs - push word ptr [bp+outregs+2] - push word ptr [bp+outregs] ; outregs - push word ptr [bp+inregs+2] - push word ptr [bp+inregs] ; inregs - push [bp+intno] ; intno - push cs - call near ptr _int86x - add sp, 0Eh - pop di - pop si - mov sp, bp - pop bp - retf -_int86 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl int86x(int intno, union REGS *inregs, union REGS *outregs, struct SREGS *segregs) -_int86x proc far - -var_E = byte ptr -0Eh -var_D = byte ptr -0Dh -var_C = byte ptr -0Ch -var_B = word ptr -0Bh -var_8 = word ptr -8 -var_6 = word ptr -6 -var_4 = dword ptr -4 -intno = word ptr 6 -inregs = dword ptr 8 -outregs = dword ptr 0Ch -segregs = dword ptr 10h - - push bp - mov bp, sp - sub sp, 0Eh - push si - push di - push ds - lea cx, [bp+var_E] - mov word ptr [bp+var_4], cx - mov word ptr [bp+var_4+2], ss - mov [bp+var_E], 55h ; 'U' - mov [bp+var_D], 0CDh ; 'Í' - mov ax, [bp+intno] - mov [bp+var_C], al - mov [bp+var_B], 0CB5Dh - cmp al, 25h ; '%' - jb short loc_3614 - cmp al, 26h ; '&' - ja short loc_3614 - mov byte ptr [bp+var_B], 36h ; '6' - mov [bp+var_B+1], 68Fh - mov [bp+var_8], cx - mov [bp+var_6], 0CB5Dh - -loc_3614: - lds si, [bp+segregs] - push word ptr [si] - push word ptr [si+6] - lds si, [bp+inregs] - mov ax, [si] - mov bx, [si+2] - mov cx, [si+4] - mov dx, [si+6] - mov di, [si+0Ah] - mov si, [si+8] - pop ds - pop es - clc - call [bp+var_4] - pushf - pushf - push si - push ds - push es - lds si, [bp+segregs] - pop word ptr [si] - pop word ptr [si+6] - lds si, [bp+outregs] - pop word ptr [si+8] - pop word ptr [si+0Eh] - pop word ptr [si+0Ch] - and word ptr [si+0Ch], 1 - mov [si+0Ah], di - mov [si+6], dx - mov [si+4], cx - mov [si+2], bx - mov [si], ax - pop ds - jz short loc_366A - push ax - push ax - call __IOERROR - pop ax - -loc_366A: - pop di - pop si - mov sp, bp - pop bp - retf -_int86x endp - +include libs/BorlandC/int86.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th01_op.asm b/th01_op.asm index d62908f1..fb10a498 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -3849,139 +3849,7 @@ include libs/BorlandC/xxv.asm include libs/BorlandC/cputype.asm include libs/BorlandC/FARHEAP.ASM include libs/BorlandC/fbrk.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl int86(int intno, union REGS *inregs, union REGS *outregs) -_int86 proc far - -segp = SREGS ptr -8 -intno = word ptr 6 -inregs = dword ptr 8 -outregs = dword ptr 0Ch - - push bp - mov bp, sp - sub sp, 8 - push si - push di - push ss - lea ax, [bp+segp] - push ax ; segp - nopcall _segread - pop cx - pop cx - push ss - lea ax, [bp+segp] - push ax ; segregs - push word ptr [bp+outregs+2] - push word ptr [bp+outregs] ; outregs - push word ptr [bp+inregs+2] - push word ptr [bp+inregs] ; inregs - push [bp+intno] ; intno - push cs - call near ptr _int86x - add sp, 0Eh - pop di - pop si - mov sp, bp - pop bp - retf -_int86 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl int86x(int intno, union REGS *inregs, union REGS *outregs, struct SREGS *segregs) -_int86x proc far - -var_E = byte ptr -0Eh -var_D = byte ptr -0Dh -var_C = byte ptr -0Ch -var_B = word ptr -0Bh -var_8 = word ptr -8 -var_6 = word ptr -6 -var_4 = dword ptr -4 -intno = word ptr 6 -inregs = dword ptr 8 -outregs = dword ptr 0Ch -segregs = dword ptr 10h - - push bp - mov bp, sp - sub sp, 0Eh - push si - push di - push ds - lea cx, [bp+var_E] - mov word ptr [bp+var_4], cx - mov word ptr [bp+var_4+2], ss - mov [bp+var_E], 55h ; 'U' - mov [bp+var_D], 0CDh - mov ax, [bp+intno] - mov [bp+var_C], al - mov [bp+var_B], 0CB5Dh - cmp al, 25h ; '%' - jb short loc_367C - cmp al, 26h ; '&' - ja short loc_367C - mov byte ptr [bp+var_B], 36h ; '6' - mov [bp+var_B+1], 68Fh - mov [bp+var_8], cx - mov [bp+var_6], 0CB5Dh - -loc_367C: - lds si, [bp+segregs] - push word ptr [si] - push word ptr [si+6] - lds si, [bp+inregs] - mov ax, [si] - mov bx, [si+2] - mov cx, [si+4] - mov dx, [si+6] - mov di, [si+0Ah] - mov si, [si+8] - pop ds - pop es - clc - call [bp+var_4] - pushf - pushf - push si - push ds - push es - lds si, [bp+segregs] - pop word ptr [si] - pop word ptr [si+6] - lds si, [bp+outregs] - pop word ptr [si+8] - pop word ptr [si+0Eh] - pop word ptr [si+0Ch] - and word ptr [si+0Ch], 1 - mov [si+0Ah], di - mov [si+6], dx - mov [si+4], cx - mov [si+2], bx - mov [si], ax - pop ds - jz short loc_36D2 - push ax - push ax - call __IOERROR - pop ax - -loc_36D2: - pop di - pop si - mov sp, bp - pop bp - retf -_int86x endp - +include libs/BorlandC/int86.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th01_reiiden.asm b/th01_reiiden.asm index d302bc6c..dfea1c9b 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -7224,141 +7224,7 @@ loc_496A: _farcoreleft endp ; sp-analysis failed include libs/BorlandC/FHEAPCHK.ASM - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl int86(int intno, union REGS *inregs, union REGS *outregs) -_int86 proc far - -segp = SREGS ptr -8 -intno = word ptr 6 -inregs = dword ptr 8 -outregs = dword ptr 0Ch - - push bp - mov bp, sp - sub sp, 8 - push si - push di - push ss - lea ax, [bp+segp] - push ax ; segp - nopcall _segread - pop cx - pop cx - push ss - lea ax, [bp+segp] - push ax ; segregs - push word ptr [bp+outregs+2] ; segregs - push word ptr [bp+outregs] ; outregs - push word ptr [bp+inregs+2] ; outregs - push word ptr [bp+inregs] ; inregs - push [bp+intno] ; intno - push cs ; intno - call near ptr _int86x - add sp, 0Eh - pop di - pop si - mov sp, bp - pop bp - retf -_int86 endp ; sp-analysis failed - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl int86x(int intno, union REGS *inregs, union REGS *outregs, struct SREGS *segregs) -_int86x proc far - -var_E = byte ptr -0Eh -var_D = byte ptr -0Dh -var_C = byte ptr -0Ch -var_B = word ptr -0Bh -var_8 = word ptr -8 -var_6 = word ptr -6 -var_4 = dword ptr -4 -intno = word ptr 4 -inregs = dword ptr 6 -outregs = dword ptr 0Ah -segregs = dword ptr 0Eh - - push bp - mov bp, sp - -loc_4C4B: - sub sp, 0Eh - push si - push di - push ds - lea cx, [bp+var_E] - mov word ptr [bp+var_4], cx - mov word ptr [bp+var_4+2], ss - mov [bp+var_E], 55h ; 'U' - mov [bp+var_D], 0CDh ; 'Í' - mov ax, word ptr [bp+inregs] - mov [bp+var_C], al - mov [bp+var_B], 0CB5Dh - cmp al, 25h ; '%' - jb short loc_4C86 - cmp al, 26h ; '&' - ja short loc_4C86 - mov byte ptr [bp+var_B], 36h ; '6' - mov [bp+var_B+1], 68Fh - mov [bp+var_8], cx - mov [bp+var_6], 0CB5Dh - -loc_4C86: - lds si, [bp+segregs+2] - push word ptr [si] - push word ptr [si+6] - lds si, [bp+inregs+2] - mov ax, [si] - mov bx, [si+2] - mov cx, [si+4] - mov dx, [si+6] - mov di, [si+0Ah] - mov si, [si+8] - pop ds - pop es - clc - call [bp+var_4] - pushf - pushf - push si - push ds - push es - lds si, [bp+segregs+2] - pop word ptr [si] - pop word ptr [si+6] - lds si, [bp+outregs+2] - pop word ptr [si+8] - pop word ptr [si+0Eh] - pop word ptr [si+0Ch] - and word ptr [si+0Ch], 1 - mov [si+0Ah], di - mov [si+6], dx - mov [si+4], cx - mov [si+2], bx - mov [si], ax - pop ds - jz short loc_4CDC - push ax - push ax - call __IOERROR - pop ax - -loc_4CDC: - pop di - pop si - mov sp, bp - pop bp - retf -_int86x endp - +include libs/BorlandC/int86.asm ; =============== S U B R O U T I N E =======================================