Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
non-paged supervisor code calling paged application code
#8
well I changed the sjasmplus linker to attempt to run a short piece of ASM from $8000 and I set the SP to $BEEF and I can see in zesarux that the SP in indeed $BEEF    so.... we know that my project.nex is making it to be started but for some reason zesarux is stubbornly doing two things...  1) holding on to speccy ROM    2) but more tellingly zesarux is not executing my code at $8000 whose job is this :

named: load.bas

Code:
Asm
    org $8000
    di

    ld a, 2             ; red color
    out ($fe), a        ; set border
.loop:
    jr .loop            ; stay here forever

    ld bc, $243b        ; select the rom lock register (nextreg $8f)
    ld a, $8f           ; rom lock register
    out (c), a
    inc b
    ld a, 0             ; value 0: unlock and map ram
    out (c), a

    ld bc, $243b        ; select the write enable register (nextreg $8e)
    ld a, $8e           ; write control register
    out (c), a
    inc b
    ld a, 3             ; write 3 to allow writing to the new ram in slots 0 and 1
    out (c), a

    ld bc, $243b        ; force page 50 into slot 0 to be absolutely certain
    ld a, $50           ; mmu slot 0 register
    out (c), a
    inc b
    ld a, 50            ; page 50
    out (c), a

    jp $0000            ; jump to your actual core logic
End Asm


here's my build script named "build.ps1" :

Code:
$ErrorActionPreference = 'Stop'

Function Abort {
    Param( [string]$Text )
    Write-Error $Text
    Break Script
}

$Compiler  = 'D:\zxnext\boriel\zxbc.py'
$Assembler = 'D:\zxnext\sjasmplus\sjasmplus.exe'
$Emulator  = 'D:\zxnext\zesarux\zesarux.exe'
$SDCard    = 'D:\zxnext\projects\demo\sdcard.mmc'

python $Compiler --version


Write-Host '...compiling to ASM:  load' -ForegroundColor DarkYellow
python $Compiler load.bas -f asm -o load.asm --org 32768 --headerless --explicit --strict --zxnext -i --arch zxnext --opt-strategy size --heap-address 40000 --heap-size 400
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }

Write-Host '...compiling to bin:  load' -ForegroundColor DarkYellow
python $Compiler load.bas -f bin -o load.bin --org 32768 --headerless --explicit --strict --zxnext -i --arch zxnext --opt-strategy size --heap-address 40000 --heap-size 400 -M load.map
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }


# compile the core engine, this sits at address 0 and contains the IM1 interrupt vector...
# ...help says this:  headerless mode: omit ASM prologue and epilogue
# ...I have no idea as yet whether I need either or neither or both...

Write-Host '...compiling to ASM:  core' -ForegroundColor DarkYellow
python $Compiler core.bas -f asm -o core.asm --org 0 -W140 -W160 --headerless --explicit --strict --zxnext -i --arch zxnext --opt-strategy size --heap-address 16000 --heap-size 383
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }

Write-Host '...compiling to bin:  core' -ForegroundColor DarkYellow
python $Compiler core.bas -f bin -o core.bin --org 0 -W140 -W160 --headerless --explicit --strict --zxnext -i --arch zxnext --opt-strategy size --heap-address 16000 --heap-size 383 -M core.map
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }


# compile the paged stage modules, these all target the MMU3 slot at $6000 (24576)...
$Stages = @( 'init', 'left', 'right' )
ForEach ( $Stage In $Stages ) {
    $Name = "stage-$($Stage)"
    Write-Host "...compiling to ASM:  $Name" -ForegroundColor DarkYellow
    python $Compiler "$($Name).bas" -f asm -o "$($Name).asm" --org 24576 -W150 --headerless --explicit --strict --zxnext -i --arch zxnext --opt-strategy size --heap-address 32000 --heap-size 767
    $Status = $LastExitCode
    If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }

    Write-Host "...compiling to ASM:  $Name" -ForegroundColor DarkYellow
    python $Compiler "$($Name).bas" -f bin -o "$($Name).bin" --org 24576 -W150 --headerless --explicit --strict --zxnext -i --arch zxnext --opt-strategy size --heap-address 32000 --heap-size 767 -M "$($Name).map"
    $Status = $LastExitCode
    If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }
}


# stitch everything together with sjasmplus...
Write-Host '...assembling nex file...' -ForegroundColor DarkYellow
& $Assembler project.cfg --nologo --msg=all --lst=project.lst --lstlab
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }

$CoreFile = Get-Item "core.bin"
$CoreSize = [math]::Round( ( $CoreFile.Length / 16384 ) * 100, 2 )
Write-Host "...core size:  $( $CoreFile.Length) bytes  ($CoreSize% of 16KB)" -ForegroundColor Cyan
   
# ...clean up intermediate bin files to keep the project tidy
# ...Remove-Item core.bin, stage-init.bin, stage-left.bin, stage-right.bin


$FileName = "project.nex"
$FileBytes = [System.Text.Encoding]::ASCII.GetBytes($FileName)

# the line length is the filename + 4 bytes (for the token, two quotes, and the CR)
$LineLength = $FileBytes.Count + 4

$Header = [byte[]](
    0x00, 0x0A,      # line number 10
    $LineLength, 0x00, # length of the line in bytes
    0x00,            # dummy byte
    0xEF,            # LOAD token
    0x22             # opening quote (")
)

$Footer = [byte[]](
    0x22,            # closing quote (")
    0x0D             # carriage return
)

# combine everything into one array
$FinalBytes = $Header + $FileBytes + $Footer
$AutoExec = Join-Path -Path $PWD -ChildPath "autoexec.bas"
[System.IO.File]::WriteAllBytes( $AutoExec, $FinalBytes )


# use hdfmonkey to swap it onto the mmc
.\hdfmonkey.exe rm .\tbblue.mmc autoexec.dot
.\hdfmonkey.exe put .\tbblue.mmc autoexec.bas


Write-Host '...hdfmonkey rm...' -ForegroundColor DarkYellow
.\hdfmonkey.exe rm tbblue.mmc project.nex /project.nex
$Status = $LastExitCode
# If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }

Write-Host '...hdfmonkey ls...' -ForegroundColor DarkYellow
.\hdfmonkey.exe ls  tbblue.mmc | Select-String 'project'
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }

Write-Host '...hdfmonkey put...' -ForegroundColor DarkYellow
.\hdfmonkey.exe put tbblue.mmc project.nex /project.nex
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }

Write-Host '...hdfmonkey ls...' -ForegroundColor DarkYellow
.\hdfmonkey.exe ls  tbblue.mmc | Select-String 'project'
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }


Write-Host "...launching emulator..." -ForegroundColor DarkYellow
& $Emulator --configfile zesarux.cfg
$Status = $LastExitCode
If ( $Status -ne 0 ) { Abort "...failed, status:  $Status" }


Break Script

here's my sjasmplus linker named "project.cfg" 

Code:
    DEVICE ZXSPECTRUMNEXT

    SAVENEX OPEN "project.nex", $8000, $BEEF, 54
    SAVENEX CFG 0, 0, 0, 1

    ORG $0000 : MMU 0, 50, $0000
    ORG $2000 : MMU 1, 51, $2000
    ORG $4000 : MMU 2, 52, $4000
    ORG $6000 : MMU 3, 53, $6000
    ORG $8000 : MMU 4, 54, $8000
    ORG $A000 : MMU 5, 55, $A000
    ORG $C000 : MMU 6, 56, $C000
    ORG $E000 : MMU 7, 57, $E000

    ORG $8000 : MMU 4, 54, $8000 : INCBIN "load.bin"
   
    ORG $0000 : MMU 0, 50, $0000 : INCBIN "core.bin"
    ORG $C000 : MMU 6, 56, $C000 : INCBIN "fon-056.fon"

    ORG $6000 : MMU 3, 60, $6000 : INCBIN "stage-init.bin"
    ORG $6000 : MMU 3, 68, $6000 : INCBIN "stage-left.bin"
    ORG $6000 : MMU 3, 69, $6000 : INCBIN "stage-right.bin"

; move the address counter back to where the loader is
    ORG $8000 : MMU 4, 54, $8000

    SAVENEX BANK 50
    SAVENEX BANK 51
    SAVENEX BANK 52
    SAVENEX BANK 53
    SAVENEX BANK 54
    SAVENEX BANK 55
    SAVENEX BANK 56
    SAVENEX BANK 57
    SAVENEX BANK 60
    SAVENEX BANK 68
    SAVENEX BANK 69

    SAVENEX CLOSE


here's my zesarux.cfg file :

Code:
--machine tbblue
--set-breakpoint 1 "PC=1"
--set-breakpoint 2 "PC=8000"
--set-breakpoint 3 "PC=8001"
--set-breakpointaction 1 ""
--set-breakpointaction 2 ""
--set-breakpointaction 3 ""
--enable-breakpoints
--nowelcomemessage
--quickexit
--no-saveconf-on-exit
--zoomx 1
--zoomy 1
--mmc-file tbblue.mmc
--enable-mmc
--enable-divmmc-ports
--realvideo
--smartloadpath project.nex


so I still cannot fathom a way to get the speccy ROM out of the way :/
Reply


Messages In This Thread
RE: non-paged supervisor code calling paged application code - by sdo303 - 2026-02-19, 10:54 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)