← DLL loading, ownership, and banking

Commands

DLL loading, ownership, and banking

Build and boot the policy exercise

Terminal
mkdir -p build
rules_build=$(mktemp -d build/rules-tutorial.XXXXXX)
./zig-out/bin/zp64c compile docs/tutorial-examples/dll-policy.zp64 -o "$rules_build/boot.prg"
c1541 -format 'rules policy,01' d64 "$rules_build/rules.d64" \
  -write "$rules_build/boot.prg" boot \
  -write "$rules_build/boot.prg.zpmod.disk.prg" rules
x64sc -reu -reusize 16384 -autostart "$rules_build/rules.d64:boot"

Return to the guide

Build and boot the missing-dependency disk

Terminal
mkdir -p build
out=$(mktemp -d build/rollback.XXXXXX)
./zig-out/bin/zp64c compile tests/fixtures/emu/modules/math_core_dispatch.zp64 -o "$out/math.prg"
./zig-out/bin/zp64c compile docs/tutorial-examples/dll-rollback.zp64 -o "$out/boot.prg" \
  --dependency-module "math_core=$out/math.prg.zpmod.json" \
  --dependency-relocsim "math_core=$out/math.prg.zpmod.relocsim.json"
c1541 -format 'rollback,01' d64 "$out/boot.d64" \
  -write "$out/boot.prg" boot -write "$out/math.prg.zpmod.disk.prg" mathcore
x64sc -reu -reusize 16384 -autostart "$out/boot.d64:boot"

Return to the guide

Build and run this example

Terminal
mkdir -p build
./zig-out/bin/zp64c compile examples/small/93_module_kernal_console_trampoline.zp64 -o build/banked-console.prg
x64sc -reu -reusize 16384 -autostart build/banked-console.prg

Return to the guide

Build and run this example

Terminal
mkdir -p build
./zig-out/bin/zp64c compile docs/tutorial-examples/dll-state-cycle.zp64 -o build/dll-state-cycle.prg
x64sc -reu -reusize 16384 -autostart build/dll-state-cycle.prg

Return to the guide

Build the module and inspect its relocation records

Terminal
mkdir -p build
./zig-out/bin/zp64c compile examples/small/45_module_relocation_sim.zp64 -o build/reloc.prg
python3 -m json.tool build/reloc.prg.zpmod.relocsim.json

Return to the guide

Build the producer once and boot both callers

Terminal
mkdir -p build
reuse_build=$(mktemp -d build/dll-reuse.XXXXXX)
compiler=./zig-out/bin/zp64c
"$compiler" compile docs/tutorial-examples/memory-plan-math.zp64 -o "$reuse_build/math.prg"
for caller in dll-reuse memory-plan; do
  "$compiler" compile "docs/tutorial-examples/$caller.zp64" -o "$reuse_build/$caller.prg" \
    --dependency-module "fixed_math=$reuse_build/math.prg.zpmod.json" \
    --dependency-relocsim "fixed_math=$reuse_build/math.prg.zpmod.relocsim.json"
  c1541 -format 'fixed math,01' d64 "$reuse_build/$caller.d64" \
    -write "$reuse_build/$caller.prg" boot \
    -write "$reuse_build/math.prg.zpmod.disk.prg" fixedmath
done
x64sc -reu -reusize 16384 -autostart "$reuse_build/dll-reuse.d64:boot"
x64sc -reu -reusize 16384 -autostart "$reuse_build/memory-plan.d64:boot"

Return to the guide

Rebuild the producer and assign its execution window

Terminal
mkdir -p build
window_build=$(mktemp -d build/window-fit.XXXXXX)
sed 's/at 0x6000 size 0x1000/at 0x7000 size 0x0800/' \
  docs/tutorial-examples/memory-plan-math.zp64 > "$window_build/producer.zp64"
sed '/        file = "fixedmath";/a\
        window = main;
' docs/tutorial-examples/dll-reuse.zp64 > "$window_build/caller.zp64"
compiler=./zig-out/bin/zp64c
"$compiler" compile "$window_build/producer.zp64" -o "$window_build/math.prg"
"$compiler" compile "$window_build/caller.zp64" -o "$window_build/caller.prg" \
  --dependency-module "fixed_math=$window_build/math.prg.zpmod.json" \
  --dependency-relocsim "fixed_math=$window_build/math.prg.zpmod.relocsim.json"
c1541 -format 'assigned window,01' d64 "$window_build/caller.d64" \
  -write "$window_build/caller.prg" boot \
  -write "$window_build/math.prg.zpmod.disk.prg" fixedmath
x64sc -reu -reusize 256 -autostart "$window_build/caller.d64:boot"

Return to the guide

Extract and compare the disk payload

Terminal
c1541 -attach build/dll-tutorial/typed.d64 -list \
  -read enemyrt build/dll-tutorial/enemyrt-from-disk.prg
cmp build/dll-tutorial/enemyrt-from-disk.prg build/dll-tutorial/typed.prg.zpmod.disk.prg
od -An -tx1 -N5 build/dll-tutorial/enemyrt-from-disk.prg
wc -c build/dll-tutorial/enemyrt-from-disk.prg

Return to the guide