1
0
mirror of https://github.com/g012/l65.git synced 2024-06-10 18:29:44 +00:00

Added .label syntax for local labels.

This commit is contained in:
g012 2017-09-05 00:56:04 +02:00
parent 262a5aa53c
commit 3eaa655784
2 changed files with 12 additions and 5 deletions

10
asm.lua
View File

@ -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

View File

@ -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