From 3eaa6557848593b73cbf9579660c2b98116a7f9a Mon Sep 17 00:00:00 2001 From: g012 Date: Tue, 5 Sep 2017 00:56:04 +0200 Subject: [PATCH] Added .label syntax for local labels. --- asm.lua | 10 +++++++--- l65.lua | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/asm.lua b/asm.lua index 6c6cb3c..91a2572 100644 --- a/asm.lua +++ b/asm.lua @@ -17,7 +17,11 @@ syntax6502_off lda = 5 if lda < 6 then print('yep') end 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 } ? --lda(INTIM) -- or a=INTIM --bne "waitForIntim" @@ -38,11 +42,11 @@ section "waitForIntim" asl asl INTIM asl -@_toto +@.toto bne "test" bne waitForIntim bne f() - bne _toto + bne .toto jam asl lsr ldx #16 ldy 0xf0f0 diff --git a/l65.lua b/l65.lua index db25050..bf2b2e1 100644 --- a/l65.lua +++ b/l65.lua @@ -1128,11 +1128,13 @@ local function ParseLua(src) -- label declarations if not stat 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(" expected.") end local label_name = tok:Get(tokenList) opcode_tok = tokenList[1] 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 -- 6502 opcodes @@ -1141,11 +1143,12 @@ local function ParseLua(src) if tok:ConsumeKeyword(op, tokenList) then opcode_tok = tokenList[1] 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 if expr.AstType == 'VarExpr' and expr.Variable.IsGlobal then expr = as_string_expr(expr, expr.Name) end - stat = emit_opcode(op .. "_relative", expr) break + stat = emit_opcode(op .. "_relative" .. (is_local and '_local' or ''), expr) break end if opcode_immediate[op] and tok:ConsumeSymbol('#') then local st, expr = ParseExpr(scope) if not st then return false, expr end