mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-29 18:49:42 +00:00
Treating ASM bytes as expressions.
This commit is contained in:
parent
33e33cf543
commit
54aa66b96e
@ -250,15 +250,18 @@ public class AsmFragmentInstance {
|
||||
|
||||
@Override
|
||||
public Object visitAsmBytes(KickCParser.AsmBytesContext ctx) {
|
||||
List<KickCParser.AsmExprContext> asmExpr = ctx.asmExpr();
|
||||
ArrayList<String> values = new ArrayList<>();
|
||||
for(int i = 1; i < ctx.getChildCount(); i = i + 2) {
|
||||
values.add(ctx.getChild(i).getText());
|
||||
for(int i = 0; i < asmExpr.size(); i++) {
|
||||
if(asmExpr.get(i) != null) {
|
||||
AsmParameter par = (AsmParameter)this.visit(asmExpr.get(i));
|
||||
values.add(par.getParam());
|
||||
}
|
||||
}
|
||||
AsmDataNumeric data = new AsmDataNumeric(null, AsmDataNumeric.Type.BYTE, values);
|
||||
handleTags(data, ctx.ASM_TAG());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitAsmInstruction(KickCParser.AsmInstructionContext ctx) {
|
||||
KickCParser.AsmParamModeContext paramModeCtx = ctx.asmParamMode();
|
||||
|
@ -12,7 +12,7 @@
|
||||
main: {
|
||||
// asm
|
||||
jmp qwe
|
||||
.byte 0, 25, 51, 76, 102, 128, 153, 179, 204, 230
|
||||
.byte 0, $19, $33, $4c, $66, $80, $99, $b3, $cc, $e6
|
||||
qwe:
|
||||
lda #$32
|
||||
// *((char*)0x0400) = 'c'
|
||||
|
@ -83,7 +83,7 @@ ASSEMBLER BEFORE OPTIMIZATION
|
||||
main: {
|
||||
// asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
|
||||
jmp qwe
|
||||
.byte 0, 25, 51, 76, 102, 128, 153, 179, 204, 230
|
||||
.byte 0, $19, $33, $4c, $66, $80, $99, $b3, $cc, $e6
|
||||
qwe:
|
||||
lda #$32
|
||||
// [1] *((char *) 1024) = 'c' -- _deref_pbuc1=vbuc2
|
||||
@ -130,7 +130,7 @@ main: {
|
||||
// asm
|
||||
// asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
|
||||
jmp qwe
|
||||
.byte 0, 25, 51, 76, 102, 128, 153, 179, 204, 230
|
||||
.byte 0, $19, $33, $4c, $66, $80, $99, $b3, $cc, $e6
|
||||
qwe:
|
||||
lda #$32
|
||||
// *((char*)0x0400) = 'c'
|
||||
|
@ -457,7 +457,7 @@ dtvSetCpuBankSegment1: {
|
||||
// asm
|
||||
.byte $32, $dd
|
||||
lda.z $ff
|
||||
.byte $32, $00
|
||||
.byte $32, 0
|
||||
// }
|
||||
rts
|
||||
}
|
||||
|
@ -1872,7 +1872,7 @@ dtvSetCpuBankSegment1: {
|
||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||
.byte $32, $dd
|
||||
lda.z $ff
|
||||
.byte $32, $00
|
||||
.byte $32, 0
|
||||
jmp __breturn
|
||||
// dtvSetCpuBankSegment1::@return
|
||||
__breturn:
|
||||
@ -2714,7 +2714,7 @@ dtvSetCpuBankSegment1: {
|
||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||
.byte $32, $dd
|
||||
lda.z $ff
|
||||
.byte $32, $00
|
||||
.byte $32, 0
|
||||
// dtvSetCpuBankSegment1::@return
|
||||
// }
|
||||
// [87] return
|
||||
|
@ -365,7 +365,7 @@ dtvSetCpuBankSegment1: {
|
||||
// asm
|
||||
.byte $32, $dd
|
||||
lda.z $ff
|
||||
.byte $32, $00
|
||||
.byte $32, 0
|
||||
// }
|
||||
rts
|
||||
}
|
||||
|
@ -1260,7 +1260,7 @@ dtvSetCpuBankSegment1: {
|
||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||
.byte $32, $dd
|
||||
lda.z $ff
|
||||
.byte $32, $00
|
||||
.byte $32, 0
|
||||
jmp __breturn
|
||||
// dtvSetCpuBankSegment1::@return
|
||||
__breturn:
|
||||
@ -1881,7 +1881,7 @@ dtvSetCpuBankSegment1: {
|
||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||
.byte $32, $dd
|
||||
lda.z $ff
|
||||
.byte $32, $00
|
||||
.byte $32, 0
|
||||
// dtvSetCpuBankSegment1::@return
|
||||
// }
|
||||
// [57] return
|
||||
|
Loading…
Reference in New Issue
Block a user