mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-21 14:30:21 +00:00
Merge branch '821-asm-byte-expressions' into 'master'
Treating ASM bytes as expressions. Closes #821 See merge request camelot/kickc!46
This commit is contained in:
commit
712b044350
@ -250,15 +250,18 @@ public class AsmFragmentInstance {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visitAsmBytes(KickCParser.AsmBytesContext ctx) {
|
public Object visitAsmBytes(KickCParser.AsmBytesContext ctx) {
|
||||||
|
List<KickCParser.AsmExprContext> asmExpr = ctx.asmExpr();
|
||||||
ArrayList<String> values = new ArrayList<>();
|
ArrayList<String> values = new ArrayList<>();
|
||||||
for(int i = 1; i < ctx.getChildCount(); i = i + 2) {
|
for(int i = 0; i < asmExpr.size(); i++) {
|
||||||
values.add(ctx.getChild(i).getText());
|
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);
|
AsmDataNumeric data = new AsmDataNumeric(null, AsmDataNumeric.Type.BYTE, values);
|
||||||
handleTags(data, ctx.ASM_TAG());
|
handleTags(data, ctx.ASM_TAG());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visitAsmInstruction(KickCParser.AsmInstructionContext ctx) {
|
public Object visitAsmInstruction(KickCParser.AsmInstructionContext ctx) {
|
||||||
KickCParser.AsmParamModeContext paramModeCtx = ctx.asmParamMode();
|
KickCParser.AsmParamModeContext paramModeCtx = ctx.asmParamMode();
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
main: {
|
main: {
|
||||||
// asm
|
// asm
|
||||||
jmp qwe
|
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:
|
qwe:
|
||||||
lda #$32
|
lda #$32
|
||||||
// *((char*)0x0400) = 'c'
|
// *((char*)0x0400) = 'c'
|
||||||
|
@ -83,7 +83,7 @@ ASSEMBLER BEFORE OPTIMIZATION
|
|||||||
main: {
|
main: {
|
||||||
// asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
|
// asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
|
||||||
jmp qwe
|
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:
|
qwe:
|
||||||
lda #$32
|
lda #$32
|
||||||
// [1] *((char *) 1024) = 'c' -- _deref_pbuc1=vbuc2
|
// [1] *((char *) 1024) = 'c' -- _deref_pbuc1=vbuc2
|
||||||
@ -130,7 +130,7 @@ main: {
|
|||||||
// asm
|
// asm
|
||||||
// asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
|
// asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
|
||||||
jmp qwe
|
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:
|
qwe:
|
||||||
lda #$32
|
lda #$32
|
||||||
// *((char*)0x0400) = 'c'
|
// *((char*)0x0400) = 'c'
|
||||||
|
@ -457,7 +457,7 @@ dtvSetCpuBankSegment1: {
|
|||||||
// asm
|
// asm
|
||||||
.byte $32, $dd
|
.byte $32, $dd
|
||||||
lda.z $ff
|
lda.z $ff
|
||||||
.byte $32, $00
|
.byte $32, 0
|
||||||
// }
|
// }
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
@ -1872,7 +1872,7 @@ dtvSetCpuBankSegment1: {
|
|||||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||||
.byte $32, $dd
|
.byte $32, $dd
|
||||||
lda.z $ff
|
lda.z $ff
|
||||||
.byte $32, $00
|
.byte $32, 0
|
||||||
jmp __breturn
|
jmp __breturn
|
||||||
// dtvSetCpuBankSegment1::@return
|
// dtvSetCpuBankSegment1::@return
|
||||||
__breturn:
|
__breturn:
|
||||||
@ -2714,7 +2714,7 @@ dtvSetCpuBankSegment1: {
|
|||||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||||
.byte $32, $dd
|
.byte $32, $dd
|
||||||
lda.z $ff
|
lda.z $ff
|
||||||
.byte $32, $00
|
.byte $32, 0
|
||||||
// dtvSetCpuBankSegment1::@return
|
// dtvSetCpuBankSegment1::@return
|
||||||
// }
|
// }
|
||||||
// [87] return
|
// [87] return
|
||||||
|
@ -365,7 +365,7 @@ dtvSetCpuBankSegment1: {
|
|||||||
// asm
|
// asm
|
||||||
.byte $32, $dd
|
.byte $32, $dd
|
||||||
lda.z $ff
|
lda.z $ff
|
||||||
.byte $32, $00
|
.byte $32, 0
|
||||||
// }
|
// }
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
@ -1260,7 +1260,7 @@ dtvSetCpuBankSegment1: {
|
|||||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||||
.byte $32, $dd
|
.byte $32, $dd
|
||||||
lda.z $ff
|
lda.z $ff
|
||||||
.byte $32, $00
|
.byte $32, 0
|
||||||
jmp __breturn
|
jmp __breturn
|
||||||
// dtvSetCpuBankSegment1::@return
|
// dtvSetCpuBankSegment1::@return
|
||||||
__breturn:
|
__breturn:
|
||||||
@ -1881,7 +1881,7 @@ dtvSetCpuBankSegment1: {
|
|||||||
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
// asm { .byte$32,$dd lda$ff .byte$32,$00 }
|
||||||
.byte $32, $dd
|
.byte $32, $dd
|
||||||
lda.z $ff
|
lda.z $ff
|
||||||
.byte $32, $00
|
.byte $32, 0
|
||||||
// dtvSetCpuBankSegment1::@return
|
// dtvSetCpuBankSegment1::@return
|
||||||
// }
|
// }
|
||||||
// [57] return
|
// [57] return
|
||||||
|
Loading…
Reference in New Issue
Block a user