1
0
mirror of https://github.com/g012/l65.git synced 2024-11-19 00:07:10 +00:00
l65/asm.lua

161 lines
4.5 KiB
Lua
Raw Normal View History

dofile "vcs.lua"
TIM_OVERSCAN = 50 -- TIM64T, 3200 cycles = ~ 42 scanlines
TIM_VBLANK = 61 -- TIM64T, 3904 cycles = ~ 51 scanlines
TIM_KERNEL = 17 -- T1024T, 17408 cycles = ~229 scanlines
location(0x000, 0xfff)
2017-09-03 14:10:28 +00:00
if toto ~= 15 then end
abc = 13 ~ 0x7
xyz = 1 << 2
x={ f=function() end }
2017-09-03 23:17:54 +00:00
x:f()
::lualabel::
2017-09-09 22:11:21 +00:00
;
lda = 5 if lda < 6 then sta=7 end
2017-09-09 22:11:21 +00:00
;
local function ptr_table(label, ...)
local vals = {...}
2017-09-18 14:01:52 +00:00
section{label .. "_lo", align=16} byte_lo(vals)
section{label .. "_hi", align=16} byte_hi(vals)
end
charset(" abcdefghijklmnopqrstuvwxyz-")
2017-09-18 14:01:52 +00:00
section("message2") byte(4, "test", 0)
charset()
2017-09-18 14:01:52 +00:00
section("message") byte(4, "test", 0)
2017-09-18 14:01:52 +00:00
section("data")
do crosspage()
byte(1, 2) byte(3, 4) endpage()
end
word(0xf080) byte(16, 3, 4, 5, 6,
24, 32)
word(message2)
byte_lo(message) byte_hi(message)
byte(function() return message&0xff end, function() return message>>8 end)
2017-09-04 22:56:04 +00:00
ptr_table("ptrs", function() return message end, data, 0)
2017-09-04 22:56:04 +00:00
--section{ "toto", align = 256, offset = 16 }
--section{ "toto", org = 0xf100 }
--section "waitForIntim"
2017-09-18 14:01:52 +00:00
section("waitForIntim") --alt short syntax when no other option
-- n_{ a=INTIM } ?
--lda(INTIM) -- or a=INTIM
--bne "waitForIntim"
ldximm (function(o) return o+(0xf0) end)
ldximm (function(o) return o+(13) end)
ldyimm (function(o) return o+(0xAB - 16 + 27 & 3 | 6 ~ 0xf >> ~3 << 1 // 5) end)
ldximm (function(o) return o+(15) end,3)
local kernel_cycles,kernel_size
2017-09-18 14:01:52 +00:00
table.insert(section_current.instructions, { asbin=function() kernel_cycles=cycles kernel_size=size end })
ldazab(function(o) return o+( data) end)
ldazab(function(o) return o+( data) end,5)
ldazax(function(o) return o+( data) end,5)
2017-09-18 22:53:37 +00:00
ldaaby(function(o) return o+( data) end,5)
2017-09-18 14:01:52 +00:00
ldazab(function(o) return o+( data+3) end,12)
ldazax(function(o) return o+( data+3) end,12)
2017-09-18 22:53:37 +00:00
ldaaby(function(o) return o+( data+3) end,12)
2017-09-19 13:53:10 +00:00
ldainx (function(o) return o+(VBLANK) end,5)
ldainx (function(a) return a+2 end,VBLANK)
ldainy (function(o) return o+(VBLANK) end,5)
ldainy (function(a) return a&3 end,VBLANK)
jmpind (function(o) return o+(VBLANK) end)
jmpind (function(o) return o+(VBLANK) end,12)
jmpind (function(o) return o+(VBLANK-4) end)
-- cycles are counted without taking any branch
2017-09-18 14:01:52 +00:00
table.insert(section_current.instructions, { asbin=function() print('kernel cycles: ', cycles-kernel_cycles, 'kernel size: ', size-kernel_size) end })
2017-09-18 14:01:52 +00:00
ldazab( function(c) return data * c end, v)
ldazab( function(c) return data*c end, v)
local f = function(c) return data*c end v=5 ldazab(f,v) v=12 ldazab(f,v)
local g = function() return function(c) return data * c end end
2017-09-18 14:01:52 +00:00
ldazab(g(),v)
ldazab( f,v)
ldazax (function(o) return o+(_toto+15) end,16)
ldaimm (15)
2017-09-09 22:11:21 +00:00
do samepage()
ldaimm (function(o) return o+(0xac) end)
2017-09-19 13:53:10 +00:00
ldaimm (function(o) return o+(VBLANK) end)
2017-09-18 14:01:52 +00:00
ldazab(function(o) return o+( 0xbeef) end)
2017-09-19 13:53:10 +00:00
ldazab(function(o) return o+( VBLANK) end)
ldaabs(function(o) return o+( VBLANK) end)
ldazax(function(o) return o+( VBLANK) end)
ldaaby(function(o) return o+( VBLANK) end)
ldainx (function(o) return o+(VBLANK) end)
ldainy (function(o) return o+(VBLANK) end) endpage()
2017-09-09 14:49:10 +00:00
end
aslimp()
2017-09-19 13:53:10 +00:00
aslzab(function(o) return o+( VBLANK) end)
aslimp()
2017-09-18 14:01:52 +00:00
label("_toto")
2017-09-19 13:53:10 +00:00
bnerel( "_toto")
2017-09-18 14:01:52 +00:00
bnerel( "waitForIntim")
2017-09-19 13:53:10 +00:00
f=function() return "_toto" end bnerel( f())
2017-09-18 14:01:52 +00:00
bnerel( "_toto")
2017-09-18 14:01:52 +00:00
jamimp() aslimp() lsrimp() ldximm (function(o) return o+(16) end) ldyzab(function(o) return o+( 0xf0f0) end)
rtsimp()
writebin()
2017-09-19 13:53:10 +00:00
writesym()
--[[
section "doOverscan"
sta{WSYNC} -- WSYNC=a
lda(2) sta{VBLANK} -- a=2 VBLANK=a
lda(TIM_OVERSCAN) sta{TIM64T} -- a=TIM_OVERSCAN TIM64T=a
jsr "waitForIntim"
section "doVBlank"
lda(0x0e)
label ".vsyncLoop"
sta{WSYNC}
sta{VSYNC}
lsr()
bne ".vsyncLoop"
lda(2)
sta{VBLANK}
lda(TIM_VBLANK)
sta{TIM64T}
jsr "waitForIntim"
section "doKernel"
lda(TIM_KERNEL)
sta{T1024T}
jsr "waitForIntim"
section "start"
-- clear zeropage
cld()
ldx(0)
txa()
label ".clearLoop"
dex()
tsx()
pha()
bne ".clearLoop"
-- main
label "mainLoop"
jsr "doOverscan"
jsr "doVBlank"
jsr "doKernel"
jmp "mainLoop"
section{ name="vectors", org=0xfffc }
word{ "start", "start" }
]]