Category : C Source Code
Archive   : TCINTFX1.ZIP
Filename : INTR.8

 
Output of file : INTR.8 contained in archive : TCINTFX1.ZIP
; A86 source code to fix Turbo C intr function bug
;
; NOTE: This file is not MASM or TASM compatible. It may be coerced to
; assemble in MASM or TASM.
;

; For small model and tiny model:
;
; assemble as follows:
;
; A86 =INTRS +C intr.8 to intrs.obj
;
; place into small library as follows:
;
; TLIB CS -intr
; TLIB CS +intrs.obj /E
;

; For large model and huge model:
;
; assemble as follows:
;
; A86 =INTRL +C intr.8 to intrl.obj
;
; place into large library as follows:
;
; TLIB CL -intr
; TLIB CL +intrl.obj /E
;
; For medium model:
;
; assemble as follows:
;
; A86 =INTRM +C intr.8 to intrm.obj
;
; place into medium library as follows:
;
; TLIB CM -intr
; TLIB CM +intrm.obj /E

; For compact model:
;
; assemble as follows:
;
; A86 =INTRC +C intr.8 to intrc.obj
;
; place into compact library as follows:
;
; TLIB CC -intr

; TLIB CC +intrc.obj /E


org 0
_intr:
push bp ; save bp
mov bp,sp ; make stack frame
sub sp, 18 ; allocate 18 bytes of space
push si, di, bp, ds ; save important regs
pushf ; and flags
lea cx, [bp-14] ; make far pointer to the code
mov [bp-18], cx ; we will build in the stack
mov [bp-16], ss ; code built:

;
; ATTENTION : The next two lines of uncommented source code are the fix
;
; These lines originally were:
; mov W[bp-14], 6E8BH
; mov B[bp-12], 0E2H
;
; Only the last source line of the group was in error, but together the
; two lines created a mov bp, [bp-1EH] instruction in the code generated
; in the stack. Aparently the code originally worked and then two additional
; pushes were added to the setup code which were not accounted for in the
; code created in the stack.
;
mov W[bp-14], 6E8BH ; mov bp, [bp-22H] ; retrieve BP
mov B[bp-12], 0DEH ;


mov B[bp-11], 0CDH ; int XX ; exec intrupt
#IF INTRL ; large (and huge) models
mov ax,[bp+6] ; get the selected interrupt number
#ELSEIF INTRC ; compact model
mov ax,[bp+4] ; get the selected interrupt number
#ELSEIF INTRS ; small (and tiny) models
mov ax, [bp+4] ; get the selected interrupt number
#ELSEIF INTRM ; medium model
mov ax, [bp+6] ; get the selected interrupt number
#ELSE ;
missing param error ; create assembler error if incorrect
; or missing conditional
#ENDIF ;
mov [bp-10], al ;
cmp al, 25H ; Q: absolute disk read or write?
jb >i1 ; N: skip
cmp al, 26H ; Q: absolute disk read or write?
ja >i1 ; N: skip
mov B[bp-9], 36H ; code built:
mov W[bp-8], 068FH ; ss pop [[cx]]; dump the nasty flags
; ; on no-longer used
; ; subroutine pointer
; ; in stack
mov [bp-6], cx ; retf 2 ; return, cleaning
mov B[bp-4], 0CAH ; ; bp from stack
mov W[bp-3], 0002H ;
jmp short i2
nop

i0:
iret ; dummy iret

i1:
mov B[bp-9], 0CAH ; code built:
mov W[bp-8], 0002 ; retf 2 ; return, cleaning
i2: ; bp from stack
#IF INTRL ; large (and huge) models
lds di,[bp+8] ; DS:DI --> allregs
#ELSEIF INTRC ; compact model
lds di,[bp+6] ; DS:DI --> allregs
#ELSEIF INTRS ; small (and tiny) models
mov di, [bp+6] ; our DS:DI --> allregs
#ELSEIF INTRM ; medium model
mov di, [bp+8] ; our DS:DI --> allregs
#ELSE ;
missing param error ; create assembler error if incorrect or
; missing conditional
#ENDIF
push ds, di ; save ds, di
mov ax, [di] ; ax <-- allregs.r_ax
mov bx, [di+2] ; bx <-- allregs.r_bx
mov cx, [di+4] ; cx <-- allregs.r_cx
mov dx, [di+6] ; dx <-- allregs.r_dx
push [di+8] ; save allregs.r_bp on stack
mov si, [di+10] ; si <-- allregs.r_si
mov es, [di+16] ; es <-- allregs.r_es
lds di, [di+12] ; ds <-- allregs.r_ds
; di <-- allregs.r_di
call D[bp-18] ; exec code on stack
push ds, di, bp ; save ds, di, bp
pushf ; save flags
mov bp,sp ; make a stack frame
lds di, [bp+8] ; ds:di-->allregs
mov [di], ax ; restore ax
mov [di+2], bx ; restore bx
mov [di+4], cx ; restore cx
mov [di+6], dx ; restore dx
mov [di+10], si ; restore si
mov [di+16], es ; restore ex
pop [di+18] ; restore flags
pop [di+8] ; restore bp
pop [di+12] ; restore di
pop [di+14] ; restore ds
add sp, 4 ; clear the temps
push cs ; dummy a call to an iret to restore the
call i0 ; flags pushed at the start of the routine
pop ds, bp, di, si ; restore important regs
mov sp, bp ; undo the stack frame
pop bp ; restore bp
#IF INTRL ; large (and huge) models
retf ; do a far return
#ELSEIF INTRM ; medium model
retf ; do a far return
#ELSEIF INTRS ; small (and tiny) models
ret ; do a near return
#ELSEIF INTRC ; compact model
ret ; do a near return
#ELSE
missing param error ; create assembler error if incorrect
; or missing conditional
#ENDIF




  3 Responses to “Category : C Source Code
Archive   : TCINTFX1.ZIP
Filename : INTR.8

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/