ia16-elf-gcc port: compile all asm files with -f elf.

Because ia16-elf-gcc and the GNU linker do not understand OMF we
need to use ELF everywhere.
This also means we cannot use "wrt", "seg" and "call/jmp far".
Most wrt's are superfluous, and seg and call/jmp far can be
replaced by explicit ?GROUP references (to be defined in the
linker script).
This commit is contained in:
Bart Oldeman 2017-12-19 08:22:58 -05:00 committed by Kenneth J Davis
parent fbdbc4c25c
commit 7bf4b77233
12 changed files with 137 additions and 110 deletions

View File

@ -36,15 +36,15 @@ segment HMA_TEXT
global _DosIdle_int
global _DosIdle_hlt
extern _InDOS:wrt DGROUP
extern _cu_psp:wrt DGROUP
extern _MachineId:wrt DGROUP
extern critical_sp:wrt DGROUP
extern _user_r:wrt DGROUP
extern _InDOS
extern _cu_psp
extern _MachineId
extern critical_sp
extern _user_r
; variables as the following are "part of" module inthndlr.c
; because of the define MAIN before include globals.h there!
extern _HaltCpuWhileIdle:wrt DGROUP
extern _DGROUP_:wrt HMA_TEXT
extern _HaltCpuWhileIdle
extern _DGROUP_
;
_DosIdle_hlt:
push ds

View File

@ -35,20 +35,20 @@ segment HMA_TEXT
extern _int21_syscall
extern _int21_service
extern _int2526_handler
extern _error_tos:wrt DGROUP
extern _char_api_tos:wrt DGROUP
extern _disk_api_tos:wrt DGROUP
extern _user_r:wrt DGROUP
extern _ErrorMode:wrt DGROUP
extern _InDOS:wrt DGROUP
extern _cu_psp:wrt DGROUP
extern _MachineId:wrt DGROUP
extern critical_sp:wrt DGROUP
extern _error_tos
extern _char_api_tos
extern _disk_api_tos
extern _user_r
extern _ErrorMode
extern _InDOS
extern _cu_psp
extern _MachineId
extern critical_sp
extern int21regs_seg:wrt DGROUP
extern int21regs_off:wrt DGROUP
extern int21regs_seg
extern int21regs_off
extern _Int21AX:wrt DGROUP
extern _Int21AX
extern _DGROUP_

View File

@ -32,8 +32,8 @@
%include "stacks.inc"
segment HMA_TEXT
extern _cu_psp:wrt DGROUP
extern _HaltCpuWhileIdle:wrt DGROUP
extern _cu_psp
extern _HaltCpuWhileIdle
extern _syscall_MUX14
extern _DGROUP_
@ -123,7 +123,7 @@ Int2f?iret:
; DRIVER.SYS calls - now only 0803.
DriverSysCal:
extern _Dyn:wrt DGROUP
extern _Dyn
cmp al, 3
jne Int2f?iret
mov ds, [cs:_DGROUP_]
@ -431,7 +431,7 @@ int2f_restore_ds:
; extern UWORD ASMPASCAL call_nls(UWORD bp, UWORD FAR *buf,
; UWORD subfct, UWORD cp, UWORD cntry, UWORD bufsize);
extern _nlsInfo:wrt DGROUP
extern _nlsInfo
global CALL_NLS
CALL_NLS:
pop es ; ret addr

View File

@ -31,18 +31,18 @@
%include "segs.inc"
%include "stacks.inc"
extern ConTable:wrt LGROUP
extern LptTable:wrt LGROUP
extern ComTable:wrt LGROUP
extern uPrtNo:wrt LGROUP
extern CommonNdRdExit:wrt LGROUP
;!! extern _NumFloppies:wrt DGROUP
extern blk_stk_top:wrt DGROUP
extern clk_stk_top:wrt DGROUP
extern ConTable
extern LptTable
extern ComTable
extern uPrtNo
extern CommonNdRdExit
;!! extern _NumFloppies
extern blk_stk_top
extern clk_stk_top
extern _reloc_call_blk_driver
extern _reloc_call_clk_driver
extern _TEXT_DGROUP:wrt LGROUP
extern _TEXT_DGROUP
;---------------------------------------------------
;
@ -501,12 +501,12 @@ GetUnitNum:
blk_driver_params:
dw blk_stk_top
dw _reloc_call_blk_driver
dw seg _reloc_call_blk_driver
dw DGROUP
clk_driver_params:
dw clk_stk_top
dw _reloc_call_clk_driver
dw seg _reloc_call_clk_driver
dw DGROUP
; clock device interrupt
clk_entry:

View File

@ -49,12 +49,12 @@
%define E_FAILURE 12 ; General Failure
extern _IOExit:wrt LGROUP
extern _IOSuccess:wrt LGROUP
extern _IOErrorExit:wrt LGROUP
extern _IOErrCnt:wrt LGROUP
extern _IODone:wrt LGROUP
extern _IOCommandError:wrt LGROUP
extern GetUnitNum:wrt LGROUP
extern _ReqPktPtr:wrt LGROUP
extern _IOExit
extern _IOSuccess
extern _IOErrorExit
extern _IOErrCnt
extern _IODone
extern _IOCommandError
extern GetUnitNum
extern _ReqPktPtr

View File

@ -34,7 +34,7 @@
segment PSP
extern _ReqPktPtr:wrt LGROUP
extern _ReqPktPtr
STACK_SIZE equ 384/2 ; stack allocated in words
@ -42,7 +42,9 @@ STACK_SIZE equ 384/2 ; stack allocated in words
; KERNEL BEGINS HERE, i.e. this is byte 0 of KERNEL.SYS
;************************************************************
%ifidn __OUTPUT_FORMAT__, obj
..start:
%endif
entry:
jmp short realentry
@ -103,8 +105,8 @@ realentry: ; execution continues here
pop bx
pop ax
jmp far kernel_start
beyond_entry: resb 256-(beyond_entry-entry)
jmp IGROUP:kernel_start
beyond_entry: times 256-(beyond_entry-entry) db 0
; scratch area for data (DOS_PSP)
segment INIT_TEXT
@ -125,31 +127,31 @@ kernel_start:
popf
pop bx
mov ax,seg init_tos
mov ax,I_GROUP
cli
mov ss,ax
mov sp,init_tos
int 12h ; move init text+data to higher memory
mov cl,6
shl ax,cl ; convert kb to para
mov dx,15 + init_end wrt INIT_TEXT
mov dx,15 + INITSIZE
mov cl,4
shr dx,cl
sub ax,dx
mov es,ax
mov dx,__INIT_DATA_START wrt INIT_TEXT ; para aligned
mov dx,INITTEXTSIZE ; para aligned
shr dx,cl
add ax,dx
mov ss,ax ; set SS to init data segment
sti ; now enable them
mov ax,cs
mov dx,__InitTextStart wrt HMA_TEXT ; para aligned
mov dx,__HMATextEnd ; para aligned
shr dx,cl
%ifdef WATCOM
add ax,dx
%endif
mov ds,ax
mov si,-2 + init_end wrt INIT_TEXT ; word aligned
mov si,-2 + INITSIZE; word aligned
lea cx,[si+2]
mov di,si
shr cx,1
@ -163,7 +165,7 @@ kernel_start:
sub ax,dx
mov es,ax ; es = new HMA_TEXT
mov si,-2 + __InitTextStart wrt HMA_TEXT
mov si,-2 + __HMATextEnd
lea cx,[si+2]
mov di,si
shr cx,1
@ -289,7 +291,7 @@ segment CONST
global _nul_strtgy
extern GenStrategy
_nul_strtgy:
jmp far GenStrategy
jmp LGROUP:GenStrategy
;
; NUL device interrupt
@ -378,7 +380,7 @@ _sfthead dd 0 ; 0004 System File Table head
global _clock
_clock dd 0 ; 0008 CLOCK$ device
global _syscon
_syscon dw _con_dev,seg _con_dev ; 000c console device
_syscon dw _con_dev,LGROUP ; 000c console device
global _maxsecsize
_maxsecsize dw 512 ; 0010 maximum bytes/sector of any block device
dd 0 ; 0012 pointer to buffers info structure
@ -394,8 +396,8 @@ _nblkdev db 0 ; 0020 number of block devices
_lastdrive db 0 ; 0021 value of last drive
global _nul_dev
_nul_dev: ; 0022 device chain root
extern _con_dev:wrt LGROUP
dw _con_dev, seg _con_dev
extern _con_dev
dw _con_dev, LGROUP
; next is con_dev at init time.
dw 8004h ; attributes = char device, NUL bit set
dw _nul_strtgy
@ -885,9 +887,9 @@ __U4D:
LDIVMODU
%endif
resb 0xd0 - ($-begin_hma)
times 0xd0 - ($-begin_hma) db 0
; reserve space for far jump to cp/m routine
resb 5
times 5 db 0
;End of HMA segment
segment HMA_TEXT_END
@ -899,7 +901,7 @@ __HMATextEnd: ; and c version
; The default stack (_TEXT:0) will overwrite the data area, so I create a dummy
; stack here to ease debugging. -- ror4
segment _STACK class=STACK stack
segment _STACK class(STACK) nobits stack
@ -1067,7 +1069,7 @@ forceEnableA20retry:
; ok, we have to enable A20 )at least seems so
;
call far _ENABLEA20
call DGROUP:_ENABLEA20
jmp short forceEnableA20retry
@ -1096,7 +1098,7 @@ _ExecUserDisableA20:
je noNeedToDisable
NeedToDisable:
push ax
call far _DISABLEA20
call DGROUP:_DISABLEA20
pop ax
noNeedToDisable:
iret

View File

@ -14,15 +14,15 @@ _nlsPackageHardcoded:
DB 000h, 000h, 000h, 000h, 001h, 000h, 0b5h, 001h
DB 00fh, 000h, 059h, 000h, 04eh, 000h, 006h, 000h
DB 002h
DW ?table2, SEG ?table2
DW ?table2, DGROUP
DB 004h
DW ?table4, SEG ?table4
DW ?table4, DGROUP
DB 005h
DW ?table5, SEG ?table5
DW ?table5, DGROUP
DB 006h
DW ?table6, SEG ?table6
DW ?table6, DGROUP
DB 007h
DW ?table7, SEG ?table7
DW ?table7, DGROUP
GLOBAL _nlsCountryInfoHardcoded
_nlsCountryInfoHardcoded:
DB 001h
@ -32,8 +32,8 @@ _nlsCntryInfoHardcoded:
DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h
DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh
DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h
extern _CharMapSrvc:wrt DGROUP
DW _CharMapSrvc, SEG _CharMapSrvc
extern _CharMapSrvc
DW _CharMapSrvc, DGROUP
DB 02ch, 000h
GLOBAL _hcTablesStart
_hcTablesStart:

View File

@ -31,10 +31,10 @@
%include "segs.inc"
extern _user_r:wrt DGROUP
extern _user_r
extern _break_flg:wrt DGROUP ; break detected flag
extern _int21_handler:wrt DGROUP ; far call system services
extern _break_flg ; break detected flag
extern _int21_handler ; far call system services
%include "stacks.inc"
@ -71,7 +71,7 @@ _exec_user:
;
POP$ALL
extern _ExecUserDisableA20
jmp far _ExecUserDisableA20
jmp DGROUP:_ExecUserDisableA20
do_iret:
extern _int21_iret
jmp _int21_iret
@ -263,7 +263,7 @@ _spawn_int23:
??int23_respawn:
pop bp ;; Restore the original register
jmp far _int21_handler
jmp DGROUP:_int21_handler
;
; interrupt enable and disable routines

View File

@ -43,57 +43,81 @@ CPU XCPU
%define WATCOM
%endif
%ifidn __OUTPUT_FORMAT__, obj
group PGROUP PSP
group LGROUP _IRQTEXT _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT
group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA
%ifdef WATCOM
group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END INIT_TEXT_START INIT_TEXT INIT_TEXT_END
%define IGROUP TGROUP
group I_GROUP ID_B I_DATA ICONST ICONST2 ID_E IB_B I_BSS IB_E
%else
group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END
group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END
group I_GROUP ID_B ID ID_E IC IDATA IB_B IB IB_E
%endif
%define class(x) class=x
%define nobits
%define exec
%define INITSIZE init_end wrt INIT_TEXT
%define INITTEXTSIZE __INIT_DATA_START wrt INIT_TEXT
segment PSP class=PSP
segment _IRQTEXT class=LCODE
segment _LOWTEXT class=LCODE
segment _IO_TEXT class=LCODE
segment _IO_FIXED_DATA class=LCODE align=2
segment _TEXT class=LCODE
segment _FIXED_DATA class=FDATA align=16
segment _BSS class=BSS align=2
segment _DATA class=DATA align=2
segment _DATAEND class=DATA align=1
%else ; using ELF
BITS 16
; groups are defined in the linker script kernel.ld
extern PGROUP
extern DGROUP
extern LGROUP
extern TGROUP
extern IGROUP
extern I_GROUP
%define class(x)
%define stack
extern INITSIZE
%define INITTEXTSIZE __InitTextEnd
%endif
segment PSP class(PSP)
segment _IRQTEXT class(LCODE) exec
segment _LOWTEXT class(LCODE) exec
segment _IO_TEXT class(LCODE) exec
segment _IO_FIXED_DATA class(LCODE) align=2
segment _TEXT class(LCODE) exec
segment _FIXED_DATA class(FDATA) align=16
segment _BSS class(BSS) align=2
segment _DATA class(DATA) align=2
segment _DATAEND class(DATA) align=1
;for WATCOM
segment CONST class=DATA align=2
segment CONST2 class=DATA align=2
segment CONST class(DATA) align=2
segment CONST2 class(DATA) align=2
;for MSC
segment DCONST class=DCONST align=2
segment DYN_DATA class=DYN_DATA
segment HMA_TEXT_START class=CODE align=16
segment HMA_TEXT class=CODE
segment HMA_TEXT_END class=CODE
segment INIT_TEXT_START class=CODE align=16
segment INIT_TEXT class=CODE
segment INIT_TEXT_END class=CODE
segment DCONST class(DCONST) align=2
segment DYN_DATA class(DYN_DATA)
segment HMA_TEXT_START class(CODE) align=16
segment HMA_TEXT class(CODE) exec
segment HMA_TEXT_END class(CODE) align=16
segment INIT_TEXT_START class(CODE) align=16
segment INIT_TEXT class(CODE) exec
segment INIT_TEXT_END class(CODE) align=16
%ifdef WATCOM
segment ID_B class=FAR_DATA align=16
segment I_DATA class=FAR_DATA align=2
segment ICONST class=FAR_DATA align=2
segment ICONST2 class=FAR_DATA align=2
segment ID_E class=FAR_DATA align=2
segment IB_B class=FAR_DATA align=2
segment I_BSS class=FAR_DATA align=2
segment IB_E class=FAR_DATA align=2
segment ID_B class(FAR_DATA) align=16
segment I_DATA class(FAR_DATA) align=2
segment ICONST class(FAR_DATA) align=2
segment ICONST2 class(FAR_DATA) align=2
segment ID_E class(FAR_DATA) align=2
segment IB_B class(FAR_DATA) align=2
segment I_BSS class(FAR_DATA) align=2
segment IB_E class(FAR_DATA) align=2
%else
segment ID_B class=ID align=16
segment ID class=ID align=2
segment IDATA class=ID align=2
segment ID_E class=ID align=2
segment IC class=IC align=2
segment IB_B class=IB align=2
segment IB class=IB align=2
segment IB_E class=IB align=2
segment ID_B class(ID) align=16
segment ID class(ID) align=2
segment IDATA class(ID) align=2
segment ID_E class(ID) align=2
segment IC class(IC) align=2
segment IB_B class(IB) align=2 nobits
segment IB class(IB) align=2 nobits
segment IB_E class(IB) align=2 nobits
%endif

View File

@ -50,7 +50,7 @@ ComTable db 0Ah
segment _IO_TEXT
extern CommonNdRdExit:wrt LGROUP
extern CommonNdRdExit
ComRead:
jcxz ComRd3

View File

@ -38,6 +38,7 @@ TARGET=KGC
ALLCFLAGS=-I../hdr $(TARGETOPT) $(ALLCFLAGS) -mcmodel=small -fleading-underscore -fno-common -fpack-struct -ffreestanding -fcall-used-es -mrtd -w -Werror
INITCFLAGS=$(ALLCFLAGS) -o $@
CFLAGS=$(ALLCFLAGS) -o $@
NASMFLAGS=$(NASMFLAGS) -f elf -o $@
DIRSEP=/
RM=rm -f

View File

@ -47,7 +47,7 @@ CLC=$(CL) $(CFLAGSC) -I$(INCLUDEPATH)
TARGET=$(TARGET)$(XCPU)$(XFAT)
.asm.obj :
$(NASM) -D$(COMPILER) $(NASMFLAGS) -f obj $*.asm
$(NASM) -D$(COMPILER) -f obj $(NASMFLAGS) $*.asm
# *Implicit Rules*
.c.obj :