!

$blkno=0
loop

rem erase block 0
rem deassert WP# Write protect
outport 0xbfffffd8 0x0
rem assert CE#
outport 0xbfffffc4 0x0
rem assert CLE
outport 0xbfffffc8 0x0
rem Issue erase command, phase 1
outport 0xbfffffec 0x60
rem toggle WE
outport 0xbfffffe0 0x0
rem deassert CLE
outport 0xbfffffcc 0x0
rem assert ALE
outport 0xbfffffd0 0x0
rem Issue A09-A16 ==32 page per block (0x4000)
$row=$blkno*0x20
$row0=$row&0xFF
outport 0xbfffffec $row0
rem toggle WE
outport 0xbfffffe0 0x0
rem Issue A17-A24
$row1=$row>>8
$row1=$row1&0xFF
outport 0xbfffffec $row1
rem toggle WE
outport 0xbfffffe0 0x0
rem Issue A31-A25
$row2=$row>>16
$row2=$row1&0xFF
outport 0xbfffffec $row2
rem toggle WE
outport 0xbfffffe0 0x0

rem deassert ALE
outport 0xbfffffd4 0x0
rem assert CLE
outport 0xbfffffc8 0x0

rem Issue erase block command, phase 2
outport 0xbfffffec 0xd0

rem toggle WE
outport 0xbfffffe0 0x0
rem deassert CLE
outport 0xbfffffcc 0x0

pause 1
rem deassert CE#
outport 0xbfffffc0 0x0
rem Assert WP# Write protect
outport 0xbfffffdc 0x0

$blkno=$blkno+1
loopend 31

rem ====32 pages per block, so 128 pages for 4 blocks (loopend 3)

!
reset

