# Script to create the cc8.tu56 image that hosts the
# OS/8 Native C compiler.
# We build with the OS8_TOOLTIME packs: v3d-patched.rk05

mount rk0 $os8mo/v3d-patched.rk05 required scratch
mount dt0 $os8mo/cc8.tu56 new
boot rk0

os8 ZERO DTA0:

# Header .SB Assembler file used by compilations:
# HEADER.SB

# Modules : C source cross-compiled to .SB Assembler by cc8:
# libc, c8, n8, p8

# Example Programs:
# src/cc8/os8/*.c

# Copy source files into DSK for use.
cpto $src/src/cc8/os8/header.sb DSK:
# Although ctbl is ASCII, it's one long line
# PIP /A doesn't like that. But /I works.
cpto $src/src/cc8/os8/ctbl.tx DSK: /I
cpto $src/src/cc8/os8/ccr.bi DSK:
cpto $obj/cc8/os8/libc.sb DSK:
cpto $obj/cc8/os8/c8.sb DSK:
cpto $obj/cc8/os8/n8.sb DSK:
cpto $obj/cc8/os8/p8.sb DSK:

# Assembly/Save phase taken from bldcc8.bi 

os8 COPY DTA0:<DSK:HEADER.SB
os8 COPY DTA0:<DSK:CTBL.TX
os8 COPY DTA0:<DSK:CCR.BI

os8 COMP LIBC.SB

# IMPORTANT! The starting block of where LIBC.RL is stored
# Affects the contents of the resulting .SV files.
# (I guess it's a file pointer that ends up in the .SV)
# The location of the other input does not seem to matter.
# (Perhaps it's the pointers to the LAST file linked.)
# For this reason we copy LIBC.RL to our output tu56 image and
# use it from there.
os8 COPY DTA0:<LIBC.RL

# Deleting it from DSK: is optional.  This is a scratch image.
# os8 DEL DSK:LIBC.RL
# os8 SQUISH DSK:/O

os8 COMP C8.SB
begin cdprog SYS:LOADER
C8,DTA0:LIBC/I/O
end  cdprog SYS:LOADER
os8 SAVE DTA0 CC

os8 COMP N8.SB
begin cdprog SYS:LOADER
N8,DTA0:LIBC/I/O
end  cdprog SYS:LOADER
os8 SAVE DTA0 CC1

os8 COMP P8.SB
begin cdprog SYS:LOADER
P8,DTA0:LIBC/I/O
end  cdprog SYS:LOADER
os8 SAVE DTA0 CC2

cpto $obj/cc8/os8/calc.c DTA0:
cpto $obj/cc8/os8/fib.c DTA0:
cpto $obj/cc8/os8/forth.c DTA0:
cpto $obj/cc8/os8/hlb.c DTA0:
cpto $obj/cc8/os8/pd.c DTA0:
cpto $obj/cc8/os8/ps.c DTA0:
