pc-relative code from the compiler

This commit is contained in:
Romain Dolbeau 2022-10-06 22:08:48 +02:00
parent c3c96cf119
commit 17a9aebd78
2 changed files with 21 additions and 16 deletions

View File

@ -2,6 +2,10 @@ AS=/home/dolbeau/Retro68/build/toolchain/bin/m68k-apple-macos-as
CC=/home/dolbeau/Retro68/build/toolchain/bin/m68k-apple-macos-gcc
OBJCOPY=/home/dolbeau/Retro68/build/toolchain/bin/m68k-apple-macos-objcopy
HOSTCC=gcc
HOSTCFLAGS=-O2
ARCHFLAGS=-march=68020 -mcpu=68020
CFLAGS=-O2 -mpcrel
NS816DECLROMDIR=/home/dolbeau/ns816-declrom
NUBUS_CHECKSUM=${NS816DECLROMDIR}/nubus_checksum
@ -20,7 +24,7 @@ CSRC_ASM=${CSRC:.c=.s}
GEN_ASM=VidRomDef.s VidRomDir.s VidRomName.s VidRomRes.s VidRomRsrcDir.s
gen_mode: gen_mode.c
$(HOSTCC) -Wall -O2 $^ -o $@
$(HOSTCC) -Wall ${HOSTCFLAGS} $^ -o $@
${GEN_ASM}: gen_mode
./gen_mode ${HRES} ${VRES}
@ -30,62 +34,62 @@ all: vid_decl_rom.bin vid_decl_rom.srec
vid_decl_rom.o: vid_decl_rom.s NuBusFPGAPrimaryInit.s NuBusFPGAPrimaryInit_Primary.s NuBusFPGASecondaryInit.s NuBusFPGASecondaryInit_Secondary.s NuBusFPGADrvr.s ${APPLEINCS} ${CSRC_ASM} DepVideo.inc ${GEN_ASM}
rm -f res.inc
echo -e "HRES=${HRES}\nVRES=${VRES}\n" | tee res.inc
${AS} -march=68020 -mcpu=68020 -I${NS816DECLROMDIR} $< -o $@ -a > vid_decl_rom.l
${AS} ${ARCHFLAGS} -I${NS816DECLROMDIR} $< -o $@ -a > vid_decl_rom.l
NuBusFPGADrvr_OpenClose.s: NuBusFPGADrvr_OpenClose.c NuBusFPGADrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.OpenClose_\1/g' $@
NuBusFPGADrvr_Ctrl.s: NuBusFPGADrvr_Ctrl.c NuBusFPGADrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.Ctrl_\1/g' $@
NuBusFPGADrvr_Status.s: NuBusFPGADrvr_Status.c NuBusFPGADrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.Status_\1/g' $@
NuBusFPGARAMDskDrvr_OpenClose.s: NuBusFPGARAMDskDrvr_OpenClose.c NuBusFPGARAMDskDrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.RDOpenClose_\1/g' $@
NuBusFPGARAMDskDrvr_Prime.s: NuBusFPGARAMDskDrvr_Prime.c NuBusFPGARAMDskDrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.RDPrime_\1/g' $@
NuBusFPGARAMDskDrvr_Ctrl.s: NuBusFPGARAMDskDrvr_Ctrl.c NuBusFPGARAMDskDrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.RDCtrl_\1/g' $@
NuBusFPGARAMDskDrvr_Status.s: NuBusFPGARAMDskDrvr_Status.c NuBusFPGARAMDskDrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.RDStatus_\1/g' $@
myrle.s: myrle.c
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DSKIP_MAIN
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DSKIP_MAIN
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.myrle_\1/g' $@
dump_cpr.s: dump_cpr.c
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DSKIP_MAIN
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DSKIP_MAIN
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.dump_cpr_\1/g' $@
NuBusFPGAPrimaryInit_Primary.s: NuBusFPGAPrimaryInit_Primary.c NuBusFPGADrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.PIPrimary_\1/g' $@
NuBusFPGASecondaryInit_Secondary.s: NuBusFPGASecondaryInit_Secondary.c NuBusFPGADrvr.h
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
${CC} ${ARCHFLAGS} ${CFLAGS} $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
sed -i -e 's/\.\(L[0-9][0-9]*\)/.PISecondary_\1/g' $@

View File

@ -69,9 +69,10 @@ OSErr cNuBusFPGAOpen(IOParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
/* siqel->sqParm = (long)dce->dCtlDevBase; */
/* not sure how to get the proper result in C... */
SlotIntServiceProcPtr sqAddr;
asm("lea %%pc@(fbIrq),%0\n" : "=a"(sqAddr));
siqel->sqAddr = sqAddr;
/* ... from ~mac68k, you need option "-mpcrel", and it works */
/* SlotIntServiceProcPtr sqAddr; */
/* asm("lea %%pc@(fbIrq),%0\n" : "=a"(sqAddr)); */
siqel->sqAddr = fbIrq;
/* siqel->sqParm = (long)dce; */
siqel->sqParm = (long)dce->dCtlDevBase;
dStore->siqel = siqel;