diff --git a/libs/BorlandC/eof.asm b/libs/BorlandC/eof.asm new file mode 100644 index 00000000..00d7ede0 --- /dev/null +++ b/libs/BorlandC/eof.asm @@ -0,0 +1,78 @@ +; int __cdecl __far eof(int handle) +_eof proc DIST +@@endPosn = DPTR_ -(dPtrSize) +@@handle = word ptr 2 + dPtrSize + + push bp + mov bp, sp + sub sp, dPtrSize + push si + push di + mov ax, [bp+@@handle] + cmp ax, __nfile + jb short @@eofSeen? + mov ax, 6 + push ax + jmp short @@IOError + +@@eofSeen?: + mov bx, [bp+@@handle] + add bx, bx + test byte ptr (_openfd+1)[bx], 2 + jz short @@check + mov ax, 1 + jmp short @@ret + +@@check: + mov ax, 4400h + mov bx, [bp+@@handle] + int 21h + jb short @@eofFailed + test dl, 80h + jnz short @@NotEof + mov ax, 4201h + xor cx, cx + mov dx, cx + int 21h + jb short @@eofFailed + push dx + push ax + mov ax, 4202h + xor cx, cx + mov dx, cx + int 21h + mov word ptr [bp+@@endPosn], ax + mov word ptr [bp+@@endPosn+2], dx + pop dx + pop cx + jb short @@eofFailed + mov ax, 4200h + int 21h + jb short @@eofFailed + cmp dx, word ptr [bp+@@endPosn+2] + jb short @@NotEof + ja short @@IsEof + cmp ax, word ptr [bp+@@endPosn] + jb short @@NotEof + +@@IsEof: + mov ax, 1 + jmp short @@ret + +@@NotEof: + xor ax, ax + jmp short @@ret + +@@eofFailed: + push ax + +@@IOError: + call __IOERROR + +@@ret: + pop di + pop si + mov sp, bp + pop bp + ret +_eof endp diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 2e489e68..554ea5c8 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -4550,100 +4550,7 @@ handle = word ptr 6 retf __close endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl eof(int handle) -_eof proc far - -var_4 = word ptr -4 -var_2 = word ptr -2 -handle = word ptr 6 - - push bp - mov bp, sp - sub sp, 4 - push si - push di - mov ax, [bp+handle] - cmp ax, __nfile - jb short loc_3BEC - mov ax, 6 - push ax - jmp short loc_3C49 -; --------------------------------------------------------------------------- - -loc_3BEC: - mov bx, [bp+handle] - add bx, bx - test byte ptr [bx+0E3Dh], 2 - jz short loc_3BFD - mov ax, 1 - jmp short loc_3C4C -; --------------------------------------------------------------------------- - -loc_3BFD: - mov ax, 4400h - mov bx, [bp+handle] - int 21h ; DOS - 2+ - IOCTL - GET DEVICE INFORMATION - ; BX = file or device handle - jb short loc_3C48 - test dl, 80h - jnz short loc_3C44 - mov ax, 4201h - xor cx, cx - mov dx, cx - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from present location - jb short loc_3C48 - push dx - push ax - mov ax, 4202h - xor cx, cx - mov dx, cx - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from end of file - mov [bp+var_4], ax - mov [bp+var_2], dx - pop dx - pop cx - jb short loc_3C48 - mov ax, 4200h - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from beginning of file - jb short loc_3C48 - cmp dx, [bp+var_2] - jb short loc_3C44 - ja short loc_3C3F - cmp ax, [bp+var_4] - jb short loc_3C44 - -loc_3C3F: - mov ax, 1 - jmp short loc_3C4C -; --------------------------------------------------------------------------- - -loc_3C44: - xor ax, ax - jmp short loc_3C4C -; --------------------------------------------------------------------------- - -loc_3C48: - push ax - -loc_3C49: - call __IOERROR - -loc_3C4C: - pop di - pop si - mov sp, bp - pop bp - retf -_eof endp - +include libs/BorlandC/eof.asm include libs/BorlandC/fclose.asm include libs/BorlandC/fflush.asm include libs/BorlandC/flength.asm @@ -5270,9 +5177,7 @@ loc_474F: mov al, es:[bx+4] cbw push ax ; handle - nop - push cs - call near ptr _eof + nopcall _eof pop cx cmp ax, 1 jz short loc_478B diff --git a/th01_op.asm b/th01_op.asm index eda57dc4..079d7587 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -4227,100 +4227,7 @@ handle = word ptr 6 retf __close endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl eof(int handle) -_eof proc far - -var_4 = word ptr -4 -var_2 = word ptr -2 -handle = word ptr 6 - - push bp - mov bp, sp - sub sp, 4 - push si - push di - mov ax, [bp+handle] - cmp ax, __nfile - jb short loc_3CC4 - mov ax, 6 - push ax - jmp short loc_3D21 -; --------------------------------------------------------------------------- - -loc_3CC4: - mov bx, [bp+handle] - add bx, bx - test byte ptr [bx+0B8Dh], 2 - jz short loc_3CD5 - mov ax, 1 - jmp short loc_3D24 -; --------------------------------------------------------------------------- - -loc_3CD5: - mov ax, 4400h - mov bx, [bp+handle] - int 21h ; DOS - 2+ - IOCTL - GET DEVICE INFORMATION - ; BX = file or device handle - jb short loc_3D20 - test dl, 80h - jnz short loc_3D1C - mov ax, 4201h - xor cx, cx - mov dx, cx - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from present location - jb short loc_3D20 - push dx - push ax - mov ax, 4202h - xor cx, cx - mov dx, cx - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from end of file - mov [bp+var_4], ax - mov [bp+var_2], dx - pop dx - pop cx - jb short loc_3D20 - mov ax, 4200h - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from beginning of file - jb short loc_3D20 - cmp dx, [bp+var_2] - jb short loc_3D1C - ja short loc_3D17 - cmp ax, [bp+var_4] - jb short loc_3D1C - -loc_3D17: - mov ax, 1 - jmp short loc_3D24 -; --------------------------------------------------------------------------- - -loc_3D1C: - xor ax, ax - jmp short loc_3D24 -; --------------------------------------------------------------------------- - -loc_3D20: - push ax - -loc_3D21: - call __IOERROR - -loc_3D24: - pop di - pop si - mov sp, bp - pop bp - retf -_eof endp - +include libs/BorlandC/eof.asm include libs/BorlandC/fclose.asm include libs/BorlandC/fflush.asm include libs/BorlandC/flength.asm @@ -4949,9 +4856,7 @@ loc_4A31: mov al, es:[bx+4] cbw push ax ; handle - nop - push cs - call near ptr _eof + nopcall _eof pop cx cmp ax, 1 jz short loc_4A6D diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 8aec1aac..c0a2bbc1 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -7603,100 +7603,7 @@ handle = word ptr 6 retf __close endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl eof(int handle) -_eof proc far - -var_4 = word ptr -4 -var_2 = word ptr -2 -handle = word ptr 6 - - push bp - mov bp, sp - sub sp, 4 - push si - push di - mov ax, [bp+handle] - cmp ax, __nfile - jb short loc_5244 - mov ax, 6 - push ax - jmp short loc_52A1 -; --------------------------------------------------------------------------- - -loc_5244: - mov bx, [bp+handle] - add bx, bx - test byte ptr [bx+1BE9h], 2 - jz short loc_5255 - mov ax, 1 - jmp short loc_52A4 -; --------------------------------------------------------------------------- - -loc_5255: - mov ax, 4400h - mov bx, [bp+handle] - int 21h ; DOS - 2+ - IOCTL - GET DEVICE INFORMATION - ; BX = file or device handle - jb short loc_52A0 - test dl, 80h - jnz short loc_529C - mov ax, 4201h - xor cx, cx - mov dx, cx - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from present location - jb short loc_52A0 - push dx - push ax - mov ax, 4202h - xor cx, cx - mov dx, cx - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from end of file - mov [bp+var_4], ax - mov [bp+var_2], dx - pop dx - pop cx - jb short loc_52A0 - mov ax, 4200h - int 21h ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK) - ; AL = method: offset from beginning of file - jb short loc_52A0 - cmp dx, [bp+var_2] - jb short loc_529C - ja short loc_5297 - cmp ax, [bp+var_4] - jb short loc_529C - -loc_5297: - mov ax, 1 - jmp short loc_52A4 -; --------------------------------------------------------------------------- - -loc_529C: - xor ax, ax - jmp short loc_52A4 -; --------------------------------------------------------------------------- - -loc_52A0: - push ax - -loc_52A1: - call __IOERROR - -loc_52A4: - pop di - pop si - mov sp, bp - pop bp - retf -_eof endp - +include libs/BorlandC/eof.asm include libs/BorlandC/fclose.asm include libs/BorlandC/fflush.asm include libs/BorlandC/flength.asm @@ -8329,9 +8236,7 @@ loc_5DA7: mov al, es:[bx+4] cbw push ax ; handle - nop - push cs - call near ptr _eof + nopcall _eof pop cx cmp ax, 1 jz short loc_5DE3