mirror of
https://github.com/g012/l65.git
synced 2025-01-21 18:31:32 +00:00
Added .label syntax for local labels.
This commit is contained in:
parent
262a5aa53c
commit
3eaa655784
10
asm.lua
10
asm.lua
@ -17,7 +17,11 @@ syntax6502_off
|
|||||||
lda = 5 if lda < 6 then print('yep') end
|
lda = 5 if lda < 6 then print('yep') end
|
||||||
syntax6502_on
|
syntax6502_on
|
||||||
|
|
||||||
section "waitForIntim"
|
--@@data samepage byte(1, 2) crosspage byte(3, 4)
|
||||||
|
|
||||||
|
--section{ "toto", align = 256, offset = 16 }
|
||||||
|
--section{ "toto", org = 0xf100 }
|
||||||
|
section "waitForIntim" --alt short syntax when no other option: @@waitForIntim ?
|
||||||
-- n_{ a=INTIM } ?
|
-- n_{ a=INTIM } ?
|
||||||
--lda(INTIM) -- or a=INTIM
|
--lda(INTIM) -- or a=INTIM
|
||||||
--bne "waitForIntim"
|
--bne "waitForIntim"
|
||||||
@ -38,11 +42,11 @@ section "waitForIntim"
|
|||||||
asl
|
asl
|
||||||
asl INTIM
|
asl INTIM
|
||||||
asl
|
asl
|
||||||
@_toto
|
@.toto
|
||||||
bne "test"
|
bne "test"
|
||||||
bne waitForIntim
|
bne waitForIntim
|
||||||
bne f()
|
bne f()
|
||||||
bne _toto
|
bne .toto
|
||||||
|
|
||||||
jam asl lsr ldx #16 ldy 0xf0f0
|
jam asl lsr ldx #16 ldy 0xf0f0
|
||||||
|
|
||||||
|
7
l65.lua
7
l65.lua
@ -1128,11 +1128,13 @@ local function ParseLua(src)
|
|||||||
-- label declarations
|
-- label declarations
|
||||||
if not stat then
|
if not stat then
|
||||||
if tok:ConsumeSymbol('@', tokenList) then
|
if tok:ConsumeSymbol('@', tokenList) then
|
||||||
|
local is_local
|
||||||
|
if tok:ConsumeSymbol('.', tokenList) then is_local = true end
|
||||||
if not tok:Is('Ident') then return false, GenerateError("<ident> expected.") end
|
if not tok:Is('Ident') then return false, GenerateError("<ident> expected.") end
|
||||||
local label_name = tok:Get(tokenList)
|
local label_name = tok:Get(tokenList)
|
||||||
opcode_tok = tokenList[1]
|
opcode_tok = tokenList[1]
|
||||||
label_name = as_string_expr(label_name, label_name.Data)
|
label_name = as_string_expr(label_name, label_name.Data)
|
||||||
stat = emit_call('label', label_name)
|
stat = emit_call(is_local and 'label_local' or 'label', label_name)
|
||||||
end end
|
end end
|
||||||
|
|
||||||
-- 6502 opcodes
|
-- 6502 opcodes
|
||||||
@ -1141,11 +1143,12 @@ local function ParseLua(src)
|
|||||||
if tok:ConsumeKeyword(op, tokenList) then
|
if tok:ConsumeKeyword(op, tokenList) then
|
||||||
opcode_tok = tokenList[1]
|
opcode_tok = tokenList[1]
|
||||||
if opcode_relative[op] then
|
if opcode_relative[op] then
|
||||||
|
if tok:ConsumeSymbol('.', tokenList) then is_local = true end
|
||||||
local st, expr = ParseExpr(scope) if not st then return false, expr end
|
local st, expr = ParseExpr(scope) if not st then return false, expr end
|
||||||
if expr.AstType == 'VarExpr' and expr.Variable.IsGlobal then
|
if expr.AstType == 'VarExpr' and expr.Variable.IsGlobal then
|
||||||
expr = as_string_expr(expr, expr.Name)
|
expr = as_string_expr(expr, expr.Name)
|
||||||
end
|
end
|
||||||
stat = emit_opcode(op .. "_relative", expr) break
|
stat = emit_opcode(op .. "_relative" .. (is_local and '_local' or ''), expr) break
|
||||||
end
|
end
|
||||||
if opcode_immediate[op] and tok:ConsumeSymbol('#') then
|
if opcode_immediate[op] and tok:ConsumeSymbol('#') then
|
||||||
local st, expr = ParseExpr(scope) if not st then return false, expr end
|
local st, expr = ParseExpr(scope) if not st then return false, expr end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user