diff --git a/source/Makefile b/source/Makefile index cfb61ad9..06b1237d 100644 --- a/source/Makefile +++ b/source/Makefile @@ -4,9 +4,9 @@ # The makefiles on each directory can be used independently as well. all: - $(MAKE) -C kernel + $(MAKE) -C kernel ASSEMBLE_SYMBOLS=$(ASSEMBLE_SYMBOLS) $(MAKE) -C command/msxdos - $(MAKE) -C tools + $(MAKE) -C tools ASSEMBLE_SYMBOLS=$(ASSEMBLE_SYMBOLS) $(MAKE) -C tools/C .PHONY: clean diff --git a/source/kernel/Makefile b/source/kernel/Makefile index 6692ca78..5c5651ff 100644 --- a/source/kernel/Makefile +++ b/source/kernel/Makefile @@ -45,14 +45,20 @@ define copy_to_bin cp $(1) ../../bin/kernels/$(2) endef +ifeq ($(strip $(ASSEMBLE_SYMBOLS)),) +EXTRA_SYMBOLS= +else +EXTRA_SYMBOLS=--define-symbols $(ASSEMBLE_SYMBOLS) +endif + define assemble @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1) - @$(N80) $(1) $$ $(2) + @$(N80) $(1) $$ $(2) $(EXTRA_SYMBOLS) endef define assemble_as @printf "\n\033[0;36mAssembling %s as %s\033[0m\n\n" $(1) $(2) - @$(N80) $(1) $(2) $(3) + @$(N80) $(1) $(2) $(3) $(EXTRA_SYMBOLS) endef define print_linking diff --git a/source/kernel/bank0/init.mac b/source/kernel/bank0/init.mac index 9bde2a32..14eaac7e 100644 --- a/source/kernel/bank0/init.mac +++ b/source/kernel/bank0/init.mac @@ -2143,7 +2143,7 @@ scan_loop: ld e,(hl) inc hl ld d,(hl) - db 0FDh,67h ;LD IYh,A + ld_iyh_a push de pop ix call CALSLT @@ -2173,10 +2173,27 @@ TNEX_LOOP: push hl push bc and 10001111b - db 0FDh,67h ;LD IYh,A + + ifdef DISABLE_UNDOCUMENTED_OPCODES + + ex (sp),iy + ex (sp),hl + ld h,a + ld a,(MASTER_SLOT##) + cp h + ld a,h + ex (sp),hl + ex (sp),iy + + else + + ld iyh,a ld a,(MASTER_SLOT##) - db 0FDh,0BCh ;CP IYh - db 0FDh,7Ch ;LD A,IYh + cp iyh + ld a,iyh + + endif + ld h,40h ld ix,DV_TIRQ## call call_drv diff --git a/source/kernel/bank1/dosinit.mac b/source/kernel/bank1/dosinit.mac index 3ac53654..82985b90 100644 --- a/source/kernel/bank1/dosinit.mac +++ b/source/kernel/bank1/dosinit.mac @@ -1564,7 +1564,7 @@ _U_CALLRAM: ex af,af ... < call _GET_P1 > push af - ld a,iyl + ld_a_iyl ... < call _PUT_P1 > ex af,af call CALSLT## @@ -1651,7 +1651,7 @@ _U_CALLRAM2: dec ix dec ix push ix - ld iyl,e + ld_iyl_e ld a,d and 00111111b @@ -1675,13 +1675,13 @@ _U_CALLRAM2: ld bc,(MAP_TAB##) add hl,bc ld a,(hl) ;A = Slot to call - ld iyh,a + ld_iyh_a ex af,af' exx inc sp inc sp - jr _U_CALLRAM + jp _U_CALLRAM ; ;----------------------------------------------------------------------------- ; diff --git a/source/kernel/bank4/partit.mac b/source/kernel/bank4/partit.mac index 94c0c441..20f501ff 100644 --- a/source/kernel/bank4/partit.mac +++ b/source/kernel/bank4/partit.mac @@ -209,14 +209,14 @@ DO_EXTPAR: jp nz,UNEX_PART ld a,(ix+POFF_PSTART) ;Save the start sector number of the outer extended partition - ld iyl,a ;(the one that includes all other extended partitions). + ld_iyl_a ;(the one that includes all other extended partitions). ld a,(ix+POFF_PSTART+1) ;We need it to calculate the offsets of the inner - ld iyh,a ;extended partitions. + ld_iyh_a ;extended partitions. push iy ld a,(ix+POFF_PSTART+2) - ld iyl,a + ld_iyl_a ld a,(ix+POFF_PSTART+3) - ld iyh,a + ld_iyh_a push iy ;=== Loop for extended partition search === @@ -355,7 +355,7 @@ DEV_READ: push de push hl - ld iyh,c + ld_iyh_c ld ix,DEV_RW## ld (BK4_ADD##),ix ld ix,CALDRV## @@ -597,7 +597,7 @@ AUTODRV_DRVLOOP: ; A = Relative drive for the driver ld c,a - ld a,iyl + ld_a_iyl ld (ix+UD1_SLOT##),a ;Set slot number in table entry ld a,c ld (ix+UD1_RELATIVE_DRIVE##),a @@ -607,7 +607,7 @@ AUTODRV_DRVLOOP: push iy push ix - ld a,iyh ;ld a,(iy+4) + ld_a_iyh ;ld a,(iy+4) and 00000100b ;Driver provides config? jr z,AUTODRV_DRVL2 push ix @@ -708,7 +708,7 @@ AUTOD_UDFND: ;--- Check if it is assigned to a device based driver ld a,(ix+UD_SLOT##) - ld iyh,a + ld_iyh_a ld c,a ld a,(KER250##) @@ -1067,7 +1067,7 @@ AA_CHKDUP_OK: ;--- Obtain device information ld a,(ix+AAD_DRIVER_SLOT) - ld iyh,a + ld_iyh_a ld hl,LUN_INFO## ld (BK4_ADD##),hl ld hl,($SECBUF##) @@ -1566,7 +1566,7 @@ AA_WSEC: AA_RSEC: or a AA_DOSEC: - ld iyh,c + ld_iyh_c ld hl,DEV_RW## ld (BK4_ADD##),hl ld c,b @@ -2482,7 +2482,7 @@ F_CDRVR_GO: ret nz ld (BK4_ADD##),de - ld iyh,c + ld_iyh_c ld l,(ix) ld h,(ix+1) push hl @@ -2630,10 +2630,10 @@ UNMAP_LOOP: inc hl ld h,(hl) ld l,a - cp iyl + cp_iyl jr nz,UNMAP_OK1 ld a,h - cp iyh + cp_iyh jr z,UNMAP_NEXT2 ;It is the unit not to be unassigned UNMAP_OK1: @@ -3084,7 +3084,7 @@ MAP_SPECIFIC: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - ld iyh,c + ld_iyh_c ld hl,($SECBUF##) ld ix,CALDRV## call CALSLT @@ -3121,7 +3121,7 @@ MAP_SPECIFIC: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - ld iyh,c + ld_iyh_c ld ix,CALDRV## call CALSLT pop iy @@ -3650,7 +3650,7 @@ MAPDOS1_DEF: push hl push ix ld a,(ix+UD1_SLOT##) - ld iyh,a + ld_iyh_a call GET_DV_TYPE pop ix pop hl @@ -3815,7 +3815,7 @@ MAPDOS1_CHK_NEXT: ld c,(iy) ld a,(iy+2) ld b,(iy+3) - ld iyh,c + ld_iyh_c ld hl,($SECBUF##) ld ix,CALDRV## call CALSLT @@ -5954,7 +5954,7 @@ DRVS1LOOP: pop de jr c,DRVS1NEXT ;Skip if not a Nextor kernel - ld iyh,e + ld_iyh_e call GET_DV_TYPE bit 0,a ;Device-based? jr z,DRVS1NEXT ;No: skip @@ -6192,7 +6192,7 @@ ASK_DRIVE_CONFIG: push de push bc ;BC=DOS mode and relative unit ld a,(ix+UD_SLOT##) - ld iyh,a + ld_iyh_a ld hl,DV_CONFIG## ld (BK4_ADD##),hl ld a,CFG_DEVLUN diff --git a/source/kernel/drivers/SunriseIDE/sunride.asm b/source/kernel/drivers/SunriseIDE/sunride.asm index 23cb6bdb..933780fb 100644 --- a/source/kernel/drivers/SunriseIDE/sunride.asm +++ b/source/kernel/drivers/SunriseIDE/sunride.asm @@ -6,6 +6,7 @@ ; By FRS ;MASTER_ONLY constant must be defined externally to generate the master-only variant. + INCLUDE ../../macros.inc org 4000h ds 4100h-$,0 ; DRV_START must be at 4100h @@ -1052,8 +1053,7 @@ DEV_RW2: ld b,0 ret DEV_RW_NO0SEC: - ld iyl,e - ld iyh,d + ld_iy_de ld a,(iy+3) and 11110000b jp nz,DEV_RW_NOSEC ;Only 28 bit sector numbers supported @@ -1091,7 +1091,7 @@ DEV_ATA_RD: call CHK_RW_FAULT ret c - ld iyl,b ; iyl=number of blocks + ld_iyl_b ; iyl=number of blocks ex de,hl ; de=destination address ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) @@ -1108,7 +1108,7 @@ DEV_ATA_WR: ld a,ATACMD.PWRSECTRT ; PIO write sector with retry call PIO_CMD jp c,DEV_RW_ERR - ld iyl,b ; iyl=number of blocks + ld_iyl_b ; iyl=number of blocks ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN) call WRITE_DATA @@ -1126,8 +1126,7 @@ DEV_ATAPI_RW: push de ld e,(ix+DEVINFO.pBASEWRK) ; hl=pointer to WorkArea ld d,(ix+DEVINFO.pBASEWRK+1) - ld iyl,e - ld iyh,d ; iy=WRKAREA pointer + ld_iy_de ; iy=WRKAREA pointer pop de ; Set the block size @@ -1174,7 +1173,7 @@ DEV_ATAPI_RD: push bc push hl push iy - ld iyl,1 ; 1 block + ld_iyl_1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1217,13 +1216,13 @@ DEV_ATAPI_RD: ex de,hl ; de=destination address .loopsector: push bc - ld iyl,c ; get the number of blocks per sector + ld_iyl_c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr ld hl,IDE_DATA call RUN_HLPR - dec iyl + dec_iyl jr nz,.loopblock pop bc djnz .loopsector @@ -1245,7 +1244,7 @@ DEV_ATAPI_WR: push bc push hl push iy - ld iyl,1 ; 1 block + ld_iyl_1 ; 1 block ld hl,WRKAREA.PCTBUFF ld bc,PCTRW10._SIZE ; block size=10 bytes call WRITE_DATA ; Send the packet to the device @@ -1287,7 +1286,7 @@ DEV_ATAPI_WR: pop bc .loopsector: push bc - ld iyl,c ; get the number of blocks per sector + ld_iyl_c ; get the number of blocks per sector .loopblock: call WAIT_DRQ jr c,.rderr @@ -1295,7 +1294,7 @@ DEV_ATAPI_WR: call RUN_HLPR call CHK_RW_FAULT jr c,.rderr - dec iyl + dec_iyl jp nz,.loopblock pop bc djnz .loopsector @@ -1841,13 +1840,13 @@ LUN_NFO_ATAPI: ld a,ATAPICMD.PACKET ; PIO send PACKET command call PIO_CMD - jr c,.errorpop + jp c,.errorpop pop hl push hl ; Source=PCTBUF ld bc,12 ; 12 byte packet push iy - ld iyl,1 + ld_iyl_1 call WRITE_DATA ; Send the packet to the device pop iy jr nc,.rdmediapropr ; No error? Then read media proprieties @@ -1865,7 +1864,7 @@ LUN_NFO_ATAPI: pop de ; Destination=PCTBUFF ld bc,8 ; 8 byte response push iy - ld iyl,1 + ld_iyl_1 call READ_DATA pop iy jr c,LUN_INFO_ERROR @@ -2462,7 +2461,7 @@ READ_DATA: ret c ld hl,IDE_DATA call RUN_HLPR - dec iyl + dec_iyl jp nz,.loop ret @@ -2481,7 +2480,7 @@ WRITE_DATA: call RUN_HLPR call CHK_RW_FAULT ret c - dec iyl + dec_iyl jp nz,.loop ret diff --git a/source/kernel/drv.mac b/source/kernel/drv.mac index f7fc0ff0..998f88ca 100644 --- a/source/kernel/drv.mac +++ b/source/kernel/drv.mac @@ -277,6 +277,23 @@ null_message: db "2 - Double side",13,10 db 0 + +;-------------- +; +; Check if we are in disk emulation mode +; Assumes IS_DVB has returned Cy=1 (that is, in DOS 1 mode and DVB_TABLE exists) +; Returns Cy=1 if in emulation mode, Cy=0 if not +; Corruputs: F + +IS_EMU: + push hl + ld hl,(DVB_TABLE##) + bit 7,(hl) + pop hl + scf + ret nz + ccf + ret ;----------------------------------------------------------------------------- ; ; Entries for direct calls. @@ -807,8 +824,25 @@ IS_DVB: jr nz,IS_NOT_DVB ld iy,(DVB_TABLE##) + + ifdef DISABLE_UNDOCUMENTED_OPCODES + + ex (sp),iy + ex (sp),hl + ld a,h + or l + ex (sp),hl + ex (sp),iy + + else + ld a,iyh or iyl + + endif + + ;ld_a_iyh + ;or_iyl jr z,IS_NOT_DVB ld a,(iy) @@ -866,22 +900,6 @@ IS_NOT_DVB: ret -;-------------- -; -; Check if we are in disk emulation mode -; Assumes IS_DVB has returned Cy=1 (that is, in DOS 1 mode and DVB_TABLE exists) -; Returns Cy=1 if in emulation mode, Cy=0 if not -; Corruputs: F - -IS_EMU: - push iy - ld iy,(DVB_TABLE##) - bit 7,(iy) - pop iy - scf - ret nz - ccf - ret ;----------------------------------------------------------------------------- ; diff --git a/source/kernel/macros.inc b/source/kernel/macros.inc index 755846f8..0dcdd383 100644 --- a/source/kernel/macros.inc +++ b/source/kernel/macros.inc @@ -278,3 +278,237 @@ djpnz macro address ; .list ; + + ifndef DISABLE_UNDOCUMENTED_OPCODES + +ld_ixh_a macro + ld ixh,a + endm + +ld_iyh_a macro + ld iyh,a + endm +ld_iyh_c macro + ld iyh,c + endm +ld_iyh_e macro + ld iyh,e + endm +ld_iyh_d macro + ld iyh,d + endm + +ld_iy_de macro + ld iyl,e + ld iyl,d + endm + +ld_iyl_e macro + ld iyl,e + endm +ld_iyl_a macro + ld iyl,a + endm +ld_iyl_b macro + ld iyl,b + endm +ld_iyl_1 macro + ld iyl,1 + endm +ld_iyl_c macro + ld iyl,c + endm + +ld_a_ixh macro + ld a,ixh + endm + +ld_a_ixl macro + ld a,ixl + endm + +ld_a_iyh macro + ld a,iyh + endm + +ld_a_iyl macro + ld a,iyl + endm + +cp_ixl macro + cp ixl + endm + +cp_iyh macro + cp iyh + endm + +cp_iyl macro + cp iyl + endm + +or_iyl macro + or iyl + endm + +dec_iyl macro + dec iyl + endm + + else + +ld_ixh_a macro + ex (sp),ix + ex (sp),hl + ld h,a + ex (sp),hl + ex (sp),ix + endm + +ld_iyh_a macro + ex (sp),iy + ex (sp),hl + ld h,a + ex (sp),hl + ex (sp),iy + endm +ld_iyh_c macro + ex (sp),iy + ex (sp),hl + ld h,c + ex (sp),hl + ex (sp),iy + endm +ld_iyh_e macro + ex (sp),iy + ex (sp),hl + ld h,e + ex (sp),hl + ex (sp),iy + endm +ld_iyh_d macro + ex (sp),iy + ex (sp),hl + ld h,d + ex (sp),hl + ex (sp),iy + endm + +ld_iy_de macro n + ex (sp),iy + ex (sp),hl + ld l,e + ld h,d + ex (sp),hl + ex (sp),iy + endm + +ld_iyl_e macro n + ex (sp),iy + ex (sp),hl + ld l,e + ex (sp),hl + ex (sp),iy + endm +ld_iyl_a macro n + ex (sp),iy + ex (sp),hl + ld l,a + ex (sp),hl + ex (sp),iy + endm +ld_iyl_b macro n + ex (sp),iy + ex (sp),hl + ld l,b + ex (sp),hl + ex (sp),iy + endm +ld_iyl_1 macro n + ex (sp),iy + ex (sp),hl + ld l,1 + ex (sp),hl + ex (sp),iy + endm +ld_iyl_c macro n + ex (sp),iy + ex (sp),hl + ld l,c + ex (sp),hl + ex (sp),iy + endm + +ld_a_ixh macro n + ex (sp),ix + ex (sp),hl + ld a,h + ex (sp),hl + ex (sp),ix + endm + +ld_a_ixl macro + ex (sp),ix + ex (sp),hl + ld a,l + ex (sp),hl + ex (sp),ix + endm + +ld_a_iyh macro n + ex (sp),iy + ex (sp),hl + ld a,h + ex (sp),hl + ex (sp),iy + endm + +ld_a_iyl macro n + ex (sp),iy + ex (sp),hl + ld a,l + ex (sp),hl + ex (sp),iy + endm + +cp_ixl macro + ex (sp),ix + ex (sp),hl + cp l + ex (sp),hl + ex (sp),ix + endm + +cp_iyh macro + ex (sp),iy + ex (sp),hl + cp h + ex (sp),hl + ex (sp),iy + endm + +cp_iyl macro + ex (sp),iy + ex (sp),hl + cp l + ex (sp),hl + ex (sp),iy + endm + +or_iyl macro + ex (sp),iy + ex (sp),hl + or l + ex (sp),hl + ex (sp),iy + endm + +dec_iyl macro + ex (sp),iy + ex (sp),hl + dec l + ex (sp),hl + ex (sp),iy + endm + + endif diff --git a/source/tools/Makefile b/source/tools/Makefile index 0224f31e..6d18ab14 100644 --- a/source/tools/Makefile +++ b/source/tools/Makefile @@ -19,9 +19,15 @@ define copy_to_bin cp $(1) ../../bin/tools/$(2) endef +ifeq ($(strip $(ASSEMBLE_SYMBOLS)),) +EXTRA_SYMBOLS= +else +EXTRA_SYMBOLS=--define-symbols $(ASSEMBLE_SYMBOLS) +endif + define assemble @printf "\n\033[0;36mAssembling %s\033[0m\n\n" $(1) - @$(N80) $(1) $(2) + @$(N80) $(1) $(2) $(EXTRA_SYMBOLS) endef COMS := CONCLUS.COM DELALL.COM DEVINFO.COM DRIVERS.COM DRVINFO.COM FASTOUT.COM LOCK.COM MAPDRV.COM NSYSVER.COM RALLOC.COM