!
$base=0x1fffff00
$WP_set=$base+0xd8 
$CE_clear=$base+0xC4
$CLE_set=$base+0xC8
$CLE_clear=$base+0xCC
$DATA_port=$base+0xec
$WE_toggle=$base+0xe0
$ALE_set=$base+0xd0
$ALE_clear=$base+0xd4
$READY_busy=$base+0xf0

$blockno=0
$offset=0
loop

rem === every loop start from here ===
$row=$blockno*0x20
$row1=$row&0xFF
$row2=$row>>8
$row2=$row2&0xFF
$row3=$row>>16
$row3=$row3&0xFF
loop

rem deassert WP# Write protect
outport $WP_set 0x0
rem assert CE#
outport $CE_clear 0x0
rem assert CLE
outport $CLE_set 0x0
rem Issue write command, phase 1
outport $DATA_port 0x80
rem toggle WE
outport $WE_toggle 0x0
rem deassert CLE
outport $CLE_clear 0x0
rem assert ALE
outport $ALE_set 0x0
rem Issue Col, A0-A7, always be 0.
outport $DATA_port 0x0
rem toggle WE
outport $WE_toggle 0x0

rem Issue Row1, A9-A16
outport $DATA_port $row1
rem toggle WE
outport $WE_toggle 0x0
rem Issue Row2, A17-A24
outport $DATA_port $row2
rem toggle WE
outport $WE_toggle 0x0
rem Issue Row3, A25
outport $DATA_port $row3
rem toggle WE
outport $WE_toggle 0x0
rem deassert ALE
outport $ALE_clear 0x0

rem rem write data to assigned Page
outport $DATA_port File "h:\linux.bin" Offset $offset Length 512 Count 1 $WE_toggle 0x00 POST
rem write spare space
outport $DATA_port 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Count 1 $WE_toggle 0x00 POST

inport $READY_busy
rem pause 1

:poll_ready
inport $READY_busy
rem pause 1
$offset=$offset+512

rem assert CLE
outport $CLE_set 0x0
rem Issue write command, phase 2
outport $DATA_port 0x10
rem toggle WE
outport $WE_toggle 0x0
rem deassert CLE
outport $CLE_clear 0x0

rem pause 1

rem Issue Row1 ==Move to next Column==
$row1=$row1+1

rem deassert CE#
outport 0xbfffffc0 0x1
rem Assert WP# Write protect
outport 0xbfffffdc 0x1

rem 15 is loop count, you can calc. it by filelength/512.

rem pause 1
rem reset
loopend 31

$blockno=$blockno+1

loopend 9
!
reset