[JWasm move] Fix the remaining small issues to get through the first pass

Thanks to the LOCALS directive, we do need to break compatibility to TASM at
one point after all. This is the rest we can reasonably change to get at least
through JWasm's first pass without errors while maintaining compatibility to
TASM.

Includes:
* the OPTION syntax to switch in and out of floating-point emulation mode
* REP CMPSB → REPE CMPSB
* Hacks for two 80-byte short jumps
* lack of support for floating-point stupidity ♥
as well as other issues that I covered in previous commits and overlooked in
some files.
This commit is contained in:
nmlgc 2014-11-21 11:24:47 +01:00
parent 2279e82167
commit 5ad97a08ea
14 changed files with 72 additions and 67 deletions

View File

@ -1,7 +1,7 @@
E87_PROG segment para public 'CODE' use16
assume cs:E87_PROG
assume es:nothing, ss:nothing, ds:_STACK, fs:nothing, gs:nothing
noemul
option noemulator
e87trap_10070:
pop di

View File

@ -287,7 +287,7 @@ emu1st proc near
pop ds
emu1st endp
emul
option emulator
public ___fpreset
___fpreset proc near
@@temp1 = dword ptr -8

View File

@ -8,7 +8,7 @@ __control87 proc
push bp
mov bp, sp
sub sp, 2
emul
option emulator
fstcw [bp+@@Control]
mov ax, [bp+@@new]
mov bx, [bp+@@mask]

View File

@ -17,7 +17,7 @@
NAME Ftol
emul ; generate emulated '87 code
option emulator ; generate emulated '87 code
; FTOL@
; Calls to FTOL@ are generated by the compiler for code

View File

@ -110,7 +110,7 @@ FreeLastBlock PROC NEAR
cmp [__first],bx ;freeing the ONLY block?
je @@KillHeap
mov si,[bx.prev_real] ;si = next-to-last block
test BYTE PTR [si.bsize],01h
test BYTE PTR [si.NEARHEAP_Header.bsize],01h
jz @@PreviousBlockIsFree
@@PreviousBlockIsUsed:
mov __last,si
@ -147,18 +147,18 @@ FreeLastBlock ENDP
; Returns: void
;-----------------------------------------------------------------------------
FreeInnerBlock PROC NEAR
dec WORD PTR [bx.bsize] ;mark the block as free
dec WORD PTR [bx.NEARHEAP_Header.bsize]
cmp bx,[__first] ;first block?
je @@PreviousBlockIsUsed
mov si,[bx.prev_real] ;get the previous block (si)
mov ax,[si.bsize] ;is the previous block free?
mov ax,[si.NEARHEAP_Header.bsize]
test al,01h
jnz @@PreviousBlockIsUsed
; join this block to the previous block
@@PreviousBlockIsFree:
add ax,[bx.bsize] ;add the size of this block to
mov [si.bsize],ax ;the size of the previous block
mov di,[bx.bsize] ;get the next block (di)
add ax,[bx.NEARHEAP_Header.bsize]
mov [si.NEARHEAP_Header.bsize],ax
mov di,[bx.NEARHEAP_Header.bsize]
add di,bx
mov [di.prev_real],si ;adjust the prev_real pointer
mov bx,si ;set up the current block
@ -166,10 +166,10 @@ FreeInnerBlock PROC NEAR
@@PreviousBlockIsUsed:
call InsertFreeBlock ;add it to the free queue
@@CheckNextBlock:
mov di,[bx.bsize] ;get the next block (di)
mov di,[bx.NEARHEAP_Header.bsize]
add di,bx
mov ax,[di.bsize] ;is the next block free?
test al,01h
mov ax,[di.NEARHEAP_Header.bsize]
test al,01h ;is the next block free?
jz JoinFreeBlocks ;join this block to the next
@@AllDone:
ret ;all done
@ -187,7 +187,7 @@ FreeInnerBlock ENDP
; This routine falls through to PullFreeBlock
;-----------------------------------------------------------------------------
JoinFreeBlocks PROC NEAR
add [bx.bsize],ax ;adjust the size of the lower block
add [bx.NEARHEAP_Header.bsize],ax
mov si,di ;si = the next block after di
add si,ax
mov [si.prev_real],bx ;adjust the link
@ -276,8 +276,8 @@ _malloc PROC
jz @@AddToHeap
mov dx,bx ;dx = rover pointer
@@SearchHeap:
cmp [bx.bsize],ax ;big enough to use at all?
jae @@AllocateBlock
cmp [bx.NEARHEAP_Header.bsize],ax
jae @@AllocateBlock ;big enough to use at all?
@@TooSmall:
mov bx,[bx.next_free] ;move to the next free block
cmp bx,dx ;at the end of the list?
@ -297,10 +297,10 @@ _malloc PROC
@@AllocateBlock:
mov si,ax ;si = smallest divisible block size
add si,FreeHeaderSize
cmp [bx.bsize],si ;big enough to break up?
jae @@DivideFreeBlock
cmp [bx.NEARHEAP_Header.bsize],si
jae @@DivideFreeBlock ;big enough to break up?
call PullFreeBlock ;remove it from the free-block queue
inc [bx.bsize] ;mark it as allocated
inc [bx.NEARHEAP_Header.bsize]
mov ax,bx
add ax,UsedHeaderSize
@@AllDone:
@ -352,7 +352,7 @@ CreateHeap PROC NEAR
mov __last,bx
pop ax ;retrieve the size
inc ax ;mark it as allocated
mov [bx.bsize],ax
mov [bx.NEARHEAP_Header.bsize],ax
add bx,UsedHeaderSize
mov ax,bx
ret
@ -387,7 +387,7 @@ ExtendHeap PROC NEAR
mov __last,bx ;update last-block pointer
pop ax ;retrieve the size
inc ax ;mark it as allocated
mov [bx.bsize],ax
mov [bx.NEARHEAP_Header.bsize],ax
add bx,UsedHeaderSize
mov ax,bx
ret
@ -406,13 +406,13 @@ ExtendHeap ENDP
; from the heap (ax)
;-----------------------------------------------------------------------------
AllocatePartialBlock PROC NEAR
sub [bx.bsize],ax ;make room!
sub [bx.NEARHEAP_Header.bsize],ax ;make room!
mov si,bx ;si = new block address
add si,[bx.bsize]
add si,[bx.NEARHEAP_Header.bsize]
mov di,si ;di = the block after the new block
add di,ax
inc ax
mov [si.bsize],ax
mov [si.NEARHEAP_Header.bsize],ax
mov [si.prev_real],bx
mov [di.prev_real],si
add si,UsedHeaderSize
@ -449,7 +449,7 @@ ExpandBlock PROC NEAR
cld
mov di,ax ;di = data area of new block
mov si,[bp-2] ;si = old block
mov cx,[si.bsize] ;cx = old block size
mov cx,[si.NEARHEAP_Header.bsize]
add si,UsedHeaderSize ;si = data area of old block
push si ;save for call to _free
sub cx,UsedHeaderSize+1 ;cx = number of bytes in old data area
@ -486,8 +486,8 @@ ShrinkBlock PROC NEAR
cmp bx,[__last] ;last block in the heap?
jne @@InnerBlock
@@LastBlock:
mov [bx.bsize],ax
inc [bx.bsize]
mov [bx.NEARHEAP_Header.bsize],ax
inc [bx.NEARHEAP_Header.bsize]
add ax,bx
push bx ;save the old block
push ax
@ -500,12 +500,12 @@ ShrinkBlock PROC NEAR
add di,ax ;di = new (free) block
mov [di.prev_real],bx
sub dx,ax ;dx = size of new (free) block
sub [bx.bsize],dx
sub [bx.NEARHEAP_Header.bsize],dx
mov si,di ;si = next block after the new one
add si,dx
mov [si.prev_real],di ;adjust the link
inc dx ;mark it as used
mov [di.bsize],dx
mov [di.NEARHEAP_Header.bsize],dx
mov cx,bx ;save the old block
mov bx,di
call FreeInnerBlock
@ -542,7 +542,7 @@ _realloc PROC
sub bx,UsedHeaderSize ;make bx = start of block
mov cx,[bx.bsize] ;cx = size of block
mov cx,[bx.NEARHEAP_Header.bsize]
dec cx
mov dx,ax

View File

@ -27,7 +27,7 @@ ExtSym@ DGROUP@, WORD, __PASCAL__
ELSE
jmp [__ScanTodVector]
ENDIF
endp
_scantod endp
public _scanrslt
@ -39,7 +39,7 @@ ExtSym@ DGROUP@, WORD, __PASCAL__
ELSE
jmp [__ScanTodVector + 2]
ENDIF
endp
_scanrslt endp
public _scanpop
_scanpop proc near
@ -50,4 +50,4 @@ ExtSym@ DGROUP@, WORD, __PASCAL__
ELSE
jmp [__ScanTodVector + 4]
ENDIF
endp
_scanpop endp

View File

@ -26,7 +26,10 @@ Hex4 proc near
mov al, dl
Byte2Ascii:
aam 10h
; Hack (aam 10h)
; AAM trick to separate nibbles in AL. TASM can actually
; assemble "aam 10h" correctly, but MASM/JWasm can't.
db 0d4h,10h
xchg ah, al
call Nibble2Ascii
xchg ah, al

View File

@ -77,7 +77,7 @@ RSDEXIST_FIND:
mov CX,[BP+@@id_len]
_lds SI,[BP+@@id_str]
mov DI,10h ; MCBの次
rep cmpsb
repe cmpsb
je short RSDEXIST_FOUND
RSDEXIST_SKIP:
mov AX,ES:[_mcb_size]

View File

@ -66,7 +66,7 @@ RSPEXIST_FIND:
mov DI,10h ; MCBの次
mov CX,IDLEN
mov SI,offset ResPalID
rep cmpsb
repe cmpsb
je short RSPEXIST_FOUND
RSPEXIST_SKIP:
mov AX,ES:[_mcb_size]

View File

@ -126,21 +126,21 @@ dsseg dw ?
public PiLoad,ToneSet
PiLoad proc near
@@opt = word ptr [bp+4]
@@ton = word ptr [bp+6]
@@y = word ptr [bp+8]
@@x = word ptr [bp+10]
@@bufsiz = word ptr [bp+12]
@@buf = dword ptr [bp+14]
@@nam = dword ptr [bp+18]
@@opt = word ptr 4
@@ton = word ptr 6
@@y = word ptr 8
@@x = word ptr 10
@@bufsiz = word ptr 12
@@buf = dword ptr 14
@@nam = dword ptr 18
push bp
mov bp,sp
push ds
lds dx,@@nam
mov ax,word ptr @@buf
lds dx,[bp+@@nam]
mov ax,word ptr [bp+@@buf]
add ax,15
shr ax,4
add ax,word ptr @@buf+2
add ax,word ptr [bp+@@buf+2]
mov es,ax
cld
mov si,dx
@ -154,14 +154,14 @@ PiLoad proc near
stosb
push es
pop ds
mov si,@@bufsiz
mov ax,word ptr @@buf
mov si,[bp+@@bufsiz]
mov ax,word ptr [bp+@@buf]
and ax,15
sub si,ax
mov bx,@@x
mov cx,@@y
mov di,@@ton
mov ax,@@opt
mov bx,[bp+@@x]
mov cx,[bp+@@y]
mov di,[bp+@@ton]
mov ax,[bp+@@opt]
call piload0
pop ds
pop bp

View File

@ -10275,7 +10275,7 @@ segp = SREGS ptr -8
add sp, 0Ch
mov bx, word ptr [bp+inregs+2]
sub bx, 2
mov es, [bp+segp._es]
mov es, [bp+segp+SREGS._es]
mov si, es:[bx]
loc_E8F1:
@ -11562,12 +11562,12 @@ E87_PROG segment para public 'CODE' use16
; Hack. Let's better use bytes for accuracy here.
tbyte_F300 db 035h, 0c2h, 068h, 021h, 0a2h, 0dah, 00fh, 0c9h, 0feh, 03fh
tbyte_F30A db 035h, 0c2h, 068h, 021h, 0a2h, 0dah, 00fh, 0c9h, 0ffh, 03fh
flt_F314 dd -5.1110893e38
flt_F318 dd -5.1117124e38
flt_F314 dd 0FFC04200r
flt_F318 dd 0FFC04800r
db 0, 4Ah, 0C0h, 0FFh
flt_F320 dd 0.5
tbyte_F324 db 085h, 064h, 0deh, 0f9h, 033h, 0f3h, 004h, 0b5h, 0ffh, 03fh
flt_F32E dd 3.4028237e38
flt_F32E dd 7F800000R
; =============== S U B R O U T I N E =======================================

View File

@ -6383,7 +6383,7 @@ segp = SREGS ptr -8
add sp, 0Ch
mov bx, word ptr [bp+inregs+2]
sub bx, 2
mov es, [bp+segp._es]
mov es, [bp+segp+SREGS._es]
mov si, es:[bx]
loc_D12D:
@ -9430,12 +9430,12 @@ E87_PROG segment para public 'CODE' use16
; Hack. Let's better use bytes for accuracy here.
tbyte_EAF0 db 035h, 0c2h, 068h, 021h, 0a2h, 0dah, 00fh, 0c9h, 0feh, 03fh
tbyte_EAFA db 035h, 0c2h, 068h, 021h, 0a2h, 0dah, 00fh, 0c9h, 0ffh, 03fh
flt_EB04 dd -5.1110893e38
flt_EB08 dd -5.1117124e38
flt_EB04 dd 0FFC04200r
flt_EB08 dd 0FFC04800r
db 0, 4Ah, 0C0h, 0FFh
flt_EB10 dd 0.5
tbyte_EB14 db 085h, 064h, 0deh, 0f9h, 033h, 0f3h, 004h, 0b5h, 0ffh, 03fh
flt_EB1E dd 3.4028237e38
flt_EB1E dd 7F800000R
; ---------------------------------------------------------------------------
mov cl, 0
jmp short loc_EB2C

View File

@ -10163,7 +10163,7 @@ segp = SREGS ptr -8
add sp, 0Ch
mov bx, word ptr [bp+inregs+2]
sub bx, 2
mov es, [bp+segp._es]
mov es, [bp+segp+SREGS._es]
mov si, es:[bx]
loc_10228:

View File

@ -17812,8 +17812,9 @@ loc_248BE:
inc si
loc_24938:
cmp si, 0A0h ; '?'
jl short loc_248BE
cmp si, 0A0h ; '?'
; Hack (jl short loc_248BE) (1 byte too much for JWasm)
db 07ch, 080h
jmp loc_24A9D
; ---------------------------------------------------------------------------
@ -17874,7 +17875,8 @@ loc_2495E:
loc_249D8:
cmp si, 0A0h ; '?'
jl short loc_2495E
; Hack (jl short loc_2495E) (1 byte too much for JWasm)
db 07ch, 080h
add word_3A6C4, 10h
xor di, di
mov si, 20h ; ' '
@ -40749,12 +40751,12 @@ E87_PROG segment para public 'CODE' use16
; Hack. Let's better use bytes for accuracy here.
tbyte_31200 db 035h, 0c2h, 068h, 021h, 0a2h, 0dah, 00fh, 0c9h, 0feh, 03fh
tbyte_3120A db 035h, 0c2h, 068h, 021h, 0a2h, 0dah, 00fh, 0c9h, 0ffh, 03fh
flt_31214 dd -5.1110893e38
flt_31218 dd -5.1117124e38
flt_31214 dd 0FFC04200r
flt_31218 dd 0FFC04800r
db 0, 4Ah, 0C0h, 0FFh
flt_31220 dd 0.5
tbyte_31224 db 085h, 064h, 0deh, 0f9h, 033h, 0f3h, 004h, 0b5h, 0ffh, 03fh
flt_3122E dd 3.4028237e38
flt_3122E dd 7F800000R
; ---------------------------------------------------------------------------
mov cl, 0
jmp short loc_3123C