mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-16 21:07:56 +00:00
550 lines
17 KiB
Plaintext
550 lines
17 KiB
Plaintext
Calling convention STACK_CALL adding prepare/execute/finalize for (word~) main::$0 ← call plus (number) $1234 (number) $2345
|
|
Calling convention STACK_CALL replacing param((word) plus::a) with stackidx(word,(const byte) plus::OFFSET_STACK_A)
|
|
Calling convention STACK_CALL replacing param((word) plus::b) with stackidx(word,(const byte) plus::OFFSET_STACK_B)
|
|
Calling convention STACK_CALL adding stack return stackidx(word,plus::OFFSET_STACK_RETURN) ← plus::return
|
|
Calling convention STACK_CALL adding stack pull main::$0 ← stackpull(word)
|
|
Calling convention STACK_CALL adding stack push stackpush(word) ← $1234
|
|
Calling convention STACK_CALL adding stack push stackpush(word) ← $2345
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@1
|
|
|
|
(void()) main()
|
|
main: scope:[main] from @1
|
|
stackpush(word) ← (number) $1234
|
|
stackpush(word) ← (number) $2345
|
|
callexecute plus
|
|
sideeffect stackpullbytes((number) 2)
|
|
(word~) main::$0 ← stackpull(word)
|
|
(number~) main::$1 ← (number) 0 * (const byte) SIZEOF_WORD
|
|
*((const nomodify word*) SCREEN + (number~) main::$1) ← (word~) main::$0
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
return
|
|
to:@return
|
|
|
|
__stackcall (word()) plus((word) plus::a , (word) plus::b)
|
|
plus: scope:[plus] from
|
|
(word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A)
|
|
(word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B)
|
|
(word~) plus::$0 ← (word) plus::a#0 + (word) plus::b#0
|
|
(word) plus::return#0 ← (word~) plus::$0
|
|
to:plus::@return
|
|
plus::@return: scope:[plus] from plus
|
|
(word) plus::return#1 ← phi( plus/(word) plus::return#0 )
|
|
stackidx(word,(const byte) plus::OFFSET_STACK_RETURN) ← (word) plus::return#1
|
|
return
|
|
to:@return
|
|
@1: scope:[] from @begin
|
|
call main
|
|
to:@2
|
|
@2: scope:[] from @1
|
|
to:@end
|
|
@end: scope:[] from @2
|
|
|
|
SYMBOL TABLE SSA
|
|
(label) @1
|
|
(label) @2
|
|
(label) @begin
|
|
(label) @end
|
|
(const nomodify word*) SCREEN = (word*)(number) $400
|
|
(const byte) SIZEOF_WORD = (byte) 2
|
|
(const word) STACK_BASE = (word) $103
|
|
(void()) main()
|
|
(word~) main::$0
|
|
(number~) main::$1
|
|
(label) main::@return
|
|
__stackcall (word()) plus((word) plus::a , (word) plus::b)
|
|
(word~) plus::$0
|
|
(label) plus::@return
|
|
(const byte) plus::OFFSET_STACK_A = (byte) 2
|
|
(const byte) plus::OFFSET_STACK_B = (byte) 0
|
|
(const byte) plus::OFFSET_STACK_RETURN = (byte) 2
|
|
(word) plus::a
|
|
(word) plus::a#0
|
|
(word) plus::b
|
|
(word) plus::b#0
|
|
(word) plus::return
|
|
(word) plus::return#0
|
|
(word) plus::return#1
|
|
|
|
Adding number conversion cast (unumber) $1234 in stackpush(word) ← (number) $1234
|
|
Adding number conversion cast (unumber) $2345 in stackpush(word) ← (number) $2345
|
|
Adding number conversion cast (unumber) 0 in (number~) main::$1 ← (number) 0 * (const byte) SIZEOF_WORD
|
|
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (unumber)(number) 0 * (const byte) SIZEOF_WORD
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast stackpush(word) ← (unumber)(number) $1234
|
|
Inlining cast stackpush(word) ← (unumber)(number) $2345
|
|
Successful SSA optimization Pass2InlineCast
|
|
Simplifying constant pointer cast (word*) 1024
|
|
Simplifying constant integer cast $1234
|
|
Simplifying constant integer cast $2345
|
|
Simplifying constant integer cast 0
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (word) $1234
|
|
Finalized unsigned number type (word) $2345
|
|
Finalized unsigned number type (byte) 0
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Inferred type updated to byte in (unumber~) main::$1 ← (byte) 0 * (const byte) SIZEOF_WORD
|
|
Alias plus::return#0 = plus::$0 plus::return#1
|
|
Successful SSA optimization Pass2AliasElimination
|
|
Constant right-side identified [5] (byte~) main::$1 ← (byte) 0 * (const byte) SIZEOF_WORD
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant (const byte) main::$1 = 0*SIZEOF_WORD
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Simplifying constant evaluating to zero (byte) 0*(const byte) SIZEOF_WORD in
|
|
Successful SSA optimization PassNSimplifyConstantZero
|
|
Simplifying expression containing zero SCREEN in [6] *((const nomodify word*) SCREEN + (const byte) main::$1) ← (word~) main::$0
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Eliminating unused constant (const byte) main::$1
|
|
Eliminating unused constant (const byte) SIZEOF_WORD
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @1
|
|
Adding NOP phi() at start of @2
|
|
Adding NOP phi() at start of @end
|
|
CALL GRAPH
|
|
Calls in [] to main:2
|
|
Calls in [main] to plus:7
|
|
|
|
Created 0 initial phi equivalence classes
|
|
Coalesced down to 0 phi equivalence classes
|
|
Culled Empty Block (label) @2
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @1
|
|
Adding NOP phi() at start of @end
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
@begin: scope:[] from
|
|
[0] phi()
|
|
to:@1
|
|
@1: scope:[] from @begin
|
|
[1] phi()
|
|
[2] call main
|
|
to:@end
|
|
@end: scope:[] from @1
|
|
[3] phi()
|
|
|
|
(void()) main()
|
|
main: scope:[main] from @1
|
|
[4] stackpush(word) ← (word) $1234
|
|
[5] stackpush(word) ← (word) $2345
|
|
[6] callexecute plus
|
|
sideeffect stackpullbytes((number) 2)
|
|
[8] (word~) main::$0 ← stackpull(word)
|
|
[9] *((const nomodify word*) SCREEN) ← (word~) main::$0
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[10] return
|
|
to:@return
|
|
|
|
__stackcall (word()) plus((word) plus::a , (word) plus::b)
|
|
plus: scope:[plus] from
|
|
[11] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A)
|
|
[12] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B)
|
|
[13] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0
|
|
to:plus::@return
|
|
plus::@return: scope:[plus] from plus
|
|
[14] stackidx(word,(const byte) plus::OFFSET_STACK_RETURN) ← (word) plus::return#0
|
|
[15] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(void()) main()
|
|
(word~) main::$0 22.0
|
|
__stackcall (word()) plus((word) plus::a , (word) plus::b)
|
|
(word) plus::a
|
|
(word) plus::a#0 101.0
|
|
(word) plus::b
|
|
(word) plus::b#0 202.0
|
|
(word) plus::return
|
|
(word) plus::return#0 202.0
|
|
|
|
Initial phi equivalence classes
|
|
Added variable main::$0 to live range equivalence class [ main::$0 ]
|
|
Added variable plus::a#0 to live range equivalence class [ plus::a#0 ]
|
|
Added variable plus::b#0 to live range equivalence class [ plus::b#0 ]
|
|
Added variable plus::return#0 to live range equivalence class [ plus::return#0 ]
|
|
Complete equivalence classes
|
|
[ main::$0 ]
|
|
[ plus::a#0 ]
|
|
[ plus::b#0 ]
|
|
[ plus::return#0 ]
|
|
Allocated zp[2]:2 [ main::$0 ]
|
|
Allocated zp[2]:4 [ plus::a#0 ]
|
|
Allocated zp[2]:6 [ plus::b#0 ]
|
|
Allocated zp[2]:8 [ plus::return#0 ]
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// Test a procedure with calling convention stack - and enough parameters to use fast ASM for cleaning stack
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(__bbegin)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const STACK_BASE = $103
|
|
.label SCREEN = $400
|
|
// @begin
|
|
__bbegin:
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
__b1_from___bbegin:
|
|
jmp __b1
|
|
// @1
|
|
__b1:
|
|
// [2] call main
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
.label __0 = 2
|
|
// [4] stackpush(word) ← (word) $1234 -- _stackpushword_=vwuc1
|
|
lda #>$1234
|
|
pha
|
|
lda #<$1234
|
|
pha
|
|
// [5] stackpush(word) ← (word) $2345 -- _stackpushword_=vwuc1
|
|
lda #>$2345
|
|
pha
|
|
lda #<$2345
|
|
pha
|
|
// [6] callexecute plus -- jsr
|
|
jsr plus
|
|
// sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2
|
|
pla
|
|
pla
|
|
// [8] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_
|
|
pla
|
|
sta.z __0
|
|
pla
|
|
sta.z __0+1
|
|
// [9] *((const nomodify word*) SCREEN) ← (word~) main::$0 -- _deref_pwuc1=vwuz1
|
|
lda.z __0
|
|
sta SCREEN
|
|
lda.z __0+1
|
|
sta SCREEN+1
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [10] return
|
|
rts
|
|
}
|
|
// plus
|
|
// plus(word zp(4) a, word zp(6) b)
|
|
plus: {
|
|
.const OFFSET_STACK_A = 2
|
|
.const OFFSET_STACK_B = 0
|
|
.const OFFSET_STACK_RETURN = 2
|
|
.label a = 4
|
|
.label b = 6
|
|
.label return = 8
|
|
// [11] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
|
|
tsx
|
|
lda STACK_BASE+OFFSET_STACK_A,x
|
|
sta.z a
|
|
lda STACK_BASE+OFFSET_STACK_A+1,x
|
|
sta.z a+1
|
|
// [12] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
|
|
tsx
|
|
lda STACK_BASE+OFFSET_STACK_B,x
|
|
sta.z b
|
|
lda STACK_BASE+OFFSET_STACK_B+1,x
|
|
sta.z b+1
|
|
// [13] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 -- vwuz1=vwuz2_plus_vwuz3
|
|
lda.z a
|
|
clc
|
|
adc.z b
|
|
sta.z return
|
|
lda.z a+1
|
|
adc.z b+1
|
|
sta.z return+1
|
|
jmp __breturn
|
|
// plus::@return
|
|
__breturn:
|
|
// [14] stackidx(word,(const byte) plus::OFFSET_STACK_RETURN) ← (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
|
|
tsx
|
|
lda.z return
|
|
sta STACK_BASE+OFFSET_STACK_RETURN,x
|
|
lda.z return+1
|
|
sta STACK_BASE+OFFSET_STACK_RETURN+1,x
|
|
// [15] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [4] stackpush(word) ← (word) $1234 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [5] stackpush(word) ← (word) $2345 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement sideeffect stackpullbytes((number) 2) always clobbers reg byte a
|
|
Statement [8] (word~) main::$0 ← stackpull(word) [ main::$0 ] ( main:2 [ main::$0 ] { } ) always clobbers reg byte a
|
|
Statement [9] *((const nomodify word*) SCREEN) ← (word~) main::$0 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [11] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) [ plus::a#0 ] ( main:2::plus:6 [ plus::a#0 ] { } ) always clobbers reg byte a reg byte x
|
|
Statement [12] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) [ plus::a#0 plus::b#0 ] ( main:2::plus:6 [ plus::a#0 plus::b#0 ] { } ) always clobbers reg byte a reg byte x
|
|
Statement [13] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 [ plus::return#0 ] ( main:2::plus:6 [ plus::return#0 ] { } ) always clobbers reg byte a
|
|
Statement [14] stackidx(word,(const byte) plus::OFFSET_STACK_RETURN) ← (word) plus::return#0 [ ] ( main:2::plus:6 [ ] { } ) always clobbers reg byte a reg byte x
|
|
Potential registers zp[2]:2 [ main::$0 ] : zp[2]:2 ,
|
|
Potential registers zp[2]:4 [ plus::a#0 ] : zp[2]:4 ,
|
|
Potential registers zp[2]:6 [ plus::b#0 ] : zp[2]:6 ,
|
|
Potential registers zp[2]:8 [ plus::return#0 ] : zp[2]:8 ,
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [plus] 202: zp[2]:6 [ plus::b#0 ] 202: zp[2]:8 [ plus::return#0 ] 101: zp[2]:4 [ plus::a#0 ]
|
|
Uplift Scope [main] 22: zp[2]:2 [ main::$0 ]
|
|
Uplift Scope []
|
|
|
|
Uplifting [plus] best 164 combination zp[2]:6 [ plus::b#0 ] zp[2]:8 [ plus::return#0 ] zp[2]:4 [ plus::a#0 ]
|
|
Uplifting [main] best 164 combination zp[2]:2 [ main::$0 ]
|
|
Uplifting [] best 164 combination
|
|
Coalescing zero page register [ zp[2]:4 [ plus::a#0 ] ] with [ zp[2]:8 [ plus::return#0 ] ] - score: 1
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Test a procedure with calling convention stack - and enough parameters to use fast ASM for cleaning stack
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(__bbegin)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const STACK_BASE = $103
|
|
.label SCREEN = $400
|
|
// @begin
|
|
__bbegin:
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
__b1_from___bbegin:
|
|
jmp __b1
|
|
// @1
|
|
__b1:
|
|
// [2] call main
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
.label __0 = 2
|
|
// [4] stackpush(word) ← (word) $1234 -- _stackpushword_=vwuc1
|
|
lda #>$1234
|
|
pha
|
|
lda #<$1234
|
|
pha
|
|
// [5] stackpush(word) ← (word) $2345 -- _stackpushword_=vwuc1
|
|
lda #>$2345
|
|
pha
|
|
lda #<$2345
|
|
pha
|
|
// [6] callexecute plus -- jsr
|
|
jsr plus
|
|
// sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2
|
|
pla
|
|
pla
|
|
// [8] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_
|
|
pla
|
|
sta.z __0
|
|
pla
|
|
sta.z __0+1
|
|
// [9] *((const nomodify word*) SCREEN) ← (word~) main::$0 -- _deref_pwuc1=vwuz1
|
|
lda.z __0
|
|
sta SCREEN
|
|
lda.z __0+1
|
|
sta SCREEN+1
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [10] return
|
|
rts
|
|
}
|
|
// plus
|
|
// plus(word zp(4) a, word zp(6) b)
|
|
plus: {
|
|
.const OFFSET_STACK_A = 2
|
|
.const OFFSET_STACK_B = 0
|
|
.const OFFSET_STACK_RETURN = 2
|
|
.label a = 4
|
|
.label b = 6
|
|
.label return = 4
|
|
// [11] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
|
|
tsx
|
|
lda STACK_BASE+OFFSET_STACK_A,x
|
|
sta.z a
|
|
lda STACK_BASE+OFFSET_STACK_A+1,x
|
|
sta.z a+1
|
|
// [12] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
|
|
tsx
|
|
lda STACK_BASE+OFFSET_STACK_B,x
|
|
sta.z b
|
|
lda STACK_BASE+OFFSET_STACK_B+1,x
|
|
sta.z b+1
|
|
// [13] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 -- vwuz1=vwuz1_plus_vwuz2
|
|
lda.z return
|
|
clc
|
|
adc.z b
|
|
sta.z return
|
|
lda.z return+1
|
|
adc.z b+1
|
|
sta.z return+1
|
|
jmp __breturn
|
|
// plus::@return
|
|
__breturn:
|
|
// [14] stackidx(word,(const byte) plus::OFFSET_STACK_RETURN) ← (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
|
|
tsx
|
|
lda.z return
|
|
sta STACK_BASE+OFFSET_STACK_RETURN,x
|
|
lda.z return+1
|
|
sta STACK_BASE+OFFSET_STACK_RETURN+1,x
|
|
// [15] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __bend
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __b1_from___bbegin:
|
|
Removing instruction __b1:
|
|
Removing instruction __bend_from___b1:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
Removing instruction __bend:
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
Updating BasicUpstart to call main directly
|
|
Removing instruction jsr main
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
Removing instruction __bbegin:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(const nomodify word*) SCREEN = (word*) 1024
|
|
(const word) STACK_BASE = (word) $103
|
|
(void()) main()
|
|
(word~) main::$0 zp[2]:2 22.0
|
|
(label) main::@return
|
|
__stackcall (word()) plus((word) plus::a , (word) plus::b)
|
|
(label) plus::@return
|
|
(const byte) plus::OFFSET_STACK_A = (byte) 2
|
|
(const byte) plus::OFFSET_STACK_B = (byte) 0
|
|
(const byte) plus::OFFSET_STACK_RETURN = (byte) 2
|
|
(word) plus::a
|
|
(word) plus::a#0 a zp[2]:4 101.0
|
|
(word) plus::b
|
|
(word) plus::b#0 b zp[2]:6 202.0
|
|
(word) plus::return
|
|
(word) plus::return#0 return zp[2]:4 202.0
|
|
|
|
zp[2]:2 [ main::$0 ]
|
|
zp[2]:4 [ plus::a#0 plus::return#0 ]
|
|
zp[2]:6 [ plus::b#0 ]
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 146
|
|
|
|
// File Comments
|
|
// Test a procedure with calling convention stack - and enough parameters to use fast ASM for cleaning stack
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const STACK_BASE = $103
|
|
.label SCREEN = $400
|
|
// @begin
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
// @1
|
|
// [2] call main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
// @end
|
|
// main
|
|
main: {
|
|
.label __0 = 2
|
|
// plus(0x1234, 0x2345)
|
|
// [4] stackpush(word) ← (word) $1234 -- _stackpushword_=vwuc1
|
|
lda #>$1234
|
|
pha
|
|
lda #<$1234
|
|
pha
|
|
// [5] stackpush(word) ← (word) $2345 -- _stackpushword_=vwuc1
|
|
lda #>$2345
|
|
pha
|
|
lda #<$2345
|
|
pha
|
|
// [6] callexecute plus -- jsr
|
|
jsr plus
|
|
// sideeffect stackpullbytes((number) 2) -- _stackpullbyte_2
|
|
pla
|
|
pla
|
|
// [8] (word~) main::$0 ← stackpull(word) -- vwuz1=_stackpullword_
|
|
pla
|
|
sta.z __0
|
|
pla
|
|
sta.z __0+1
|
|
// SCREEN[0] = plus(0x1234, 0x2345)
|
|
// [9] *((const nomodify word*) SCREEN) ← (word~) main::$0 -- _deref_pwuc1=vwuz1
|
|
lda.z __0
|
|
sta SCREEN
|
|
lda.z __0+1
|
|
sta SCREEN+1
|
|
// main::@return
|
|
// }
|
|
// [10] return
|
|
rts
|
|
}
|
|
// plus
|
|
// plus(word zp(4) a, word zp(6) b)
|
|
plus: {
|
|
.const OFFSET_STACK_A = 2
|
|
.const OFFSET_STACK_B = 0
|
|
.const OFFSET_STACK_RETURN = 2
|
|
.label a = 4
|
|
.label b = 6
|
|
.label return = 4
|
|
// [11] (word) plus::a#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_A) -- vwuz1=_stackidxword_vbuc1
|
|
tsx
|
|
lda STACK_BASE+OFFSET_STACK_A,x
|
|
sta.z a
|
|
lda STACK_BASE+OFFSET_STACK_A+1,x
|
|
sta.z a+1
|
|
// [12] (word) plus::b#0 ← stackidx(word,(const byte) plus::OFFSET_STACK_B) -- vwuz1=_stackidxword_vbuc1
|
|
tsx
|
|
lda STACK_BASE+OFFSET_STACK_B,x
|
|
sta.z b
|
|
lda STACK_BASE+OFFSET_STACK_B+1,x
|
|
sta.z b+1
|
|
// return a+b;
|
|
// [13] (word) plus::return#0 ← (word) plus::a#0 + (word) plus::b#0 -- vwuz1=vwuz1_plus_vwuz2
|
|
lda.z return
|
|
clc
|
|
adc.z b
|
|
sta.z return
|
|
lda.z return+1
|
|
adc.z b+1
|
|
sta.z return+1
|
|
// plus::@return
|
|
// }
|
|
// [14] stackidx(word,(const byte) plus::OFFSET_STACK_RETURN) ← (word) plus::return#0 -- _stackidxword_vbuc1=vwuz1
|
|
tsx
|
|
lda.z return
|
|
sta STACK_BASE+OFFSET_STACK_RETURN,x
|
|
lda.z return+1
|
|
sta STACK_BASE+OFFSET_STACK_RETURN+1,x
|
|
// [15] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|