!
rem Include file accepts nested-loop
$blockno=0
$offset=0

rem loop for block
loop

$row=$blockno*0x20
$row1=$row&0xFF
$row2=$row>>8
$row2=$row2&0xFF
$row3=$row>>16
$row3=$row3&0xFF

rem loop in block
loop

rem deassert WP# Write protect
rem outport 0xbfffffd8 0x0
rem assert CE#
outport 0xbfffffc4 0x0
rem assert CLE
outport 0xbfffffc8 0x0
rem Issue read command, phase 1		0x1?
outport 0xbfffffec 0x0
rem toggle WE
outport 0xbfffffe0 0x0
rem deassert CLE
outport 0xbfffffcc 0x0
rem assert ALE
outport 0xbfffffd0 0x0
rem Issue Col, A0-A7
outport 0xbfffffec 0x0
rem toggle WE
outport 0xbfffffe0 0x0

rem Issue Row1, A9-A16
outport 0xbfffffec $row1
rem toggle WE
outport 0xbfffffe0 0x0
rem Issue Row2, A17-A24
outport 0xbfffffec $row2
rem toggle WE
outport 0xbfffffe0 0x0
rem Issue Row3, A25
outport 0xbfffffec $row3
rem toggle WE
outport 0xbfffffe0 0x0
rem deassert ALE
outport 0xbfffffd4 0x0

rem pause 1
inport 0xbffffff0

rem pause 1
inport 0xbffffff0

rem read data from Page 1
inport 0xbffffff4 512 File "h:\test1.log" Offset $offset Count 1 0xbfffffe4 0x0 -W PRE
rem drop OOB data
outport 0xbfffffe4 0x0 Length 16

$offset=$offset+512
$row1=$row1+1

rem deassert CLE
rem outport 0xbfffffcc 0x0
rem pause 1
rem deassert CE#	0x1?
outport 0xbfffffc0 0x0
rem Assert WP# Write protect
rem outport 0xbfffffdc 0x1

rem pause 1

loopend 31

$blockno=$blockno+1

loopend 9
!