mirror of
https://github.com/irmen/prog8.git
synced 2024-11-29 17:50:35 +00:00
added sys.push() and sys.pop() to put values on cpu stack. Added missing builtin functions to syntax-files.
This commit is contained in:
parent
62485b6851
commit
e8e25c6fd6
@ -67,6 +67,8 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
"peek" -> throw AssemblyError("peek() should have been replaced by @()")
|
"peek" -> throw AssemblyError("peek() should have been replaced by @()")
|
||||||
"pokew" -> funcPokeW(fcall)
|
"pokew" -> funcPokeW(fcall)
|
||||||
"poke" -> throw AssemblyError("poke() should have been replaced by @()")
|
"poke" -> throw AssemblyError("poke() should have been replaced by @()")
|
||||||
|
// "push", "pushw" -> funcPush(fcall, func)
|
||||||
|
// "pop", "popw" -> funcPop(func)
|
||||||
"cmp" -> funcCmp(fcall)
|
"cmp" -> funcCmp(fcall)
|
||||||
"callfar" -> funcCallFar(fcall)
|
"callfar" -> funcCallFar(fcall)
|
||||||
"callrom" -> funcCallRom(fcall)
|
"callrom" -> funcCallRom(fcall)
|
||||||
@ -74,6 +76,30 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private fun funcPop(func: FSignature) {
|
||||||
|
// if(func.name=="pop") {
|
||||||
|
// asmgen.out(" pla")
|
||||||
|
// } else {
|
||||||
|
// if (asmgen.isTargetCpu(CpuType.CPU65c02))
|
||||||
|
// asmgen.out(" ply | pla")
|
||||||
|
// else
|
||||||
|
// asmgen.out(" pla | tay | pla")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private fun funcPush(fcall: IFunctionCall, func: FSignature) {
|
||||||
|
// if(func.name=="push") {
|
||||||
|
// asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.A)
|
||||||
|
// asmgen.out(" pha")
|
||||||
|
// } else {
|
||||||
|
// asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.AY)
|
||||||
|
// if (asmgen.isTargetCpu(CpuType.CPU65c02))
|
||||||
|
// asmgen.out(" pha | phy")
|
||||||
|
// else
|
||||||
|
// asmgen.out(" pha | tya | pha")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
private fun funcCallFar(fcall: IFunctionCall) {
|
private fun funcCallFar(fcall: IFunctionCall) {
|
||||||
if(asmgen.options.compTarget !is Cx16Target)
|
if(asmgen.options.compTarget !is Cx16Target)
|
||||||
throw AssemblyError("callfar only works on cx16 target at this time")
|
throw AssemblyError("callfar only works on cx16 target at this time")
|
||||||
|
@ -627,32 +627,60 @@ _longcopy
|
|||||||
|
|
||||||
inline asmsub read_flags() -> ubyte @A {
|
inline asmsub read_flags() -> ubyte @A {
|
||||||
%asm {{
|
%asm {{
|
||||||
php
|
php
|
||||||
pla
|
pla
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub push(ubyte @A) {
|
||||||
|
%asm {{
|
||||||
|
pha
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub pop() -> ubyte @A {
|
||||||
|
%asm {{
|
||||||
|
pla
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub pushw(uword @AY) {
|
||||||
|
%asm {{
|
||||||
|
pha
|
||||||
|
tya
|
||||||
|
pha
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub popw() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
pla
|
||||||
|
tay
|
||||||
|
pla
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline asmsub clear_carry() {
|
inline asmsub clear_carry() {
|
||||||
%asm {{
|
%asm {{
|
||||||
clc
|
clc
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline asmsub set_carry() {
|
inline asmsub set_carry() {
|
||||||
%asm {{
|
%asm {{
|
||||||
sec
|
sec
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline asmsub clear_irqd() {
|
inline asmsub clear_irqd() {
|
||||||
%asm {{
|
%asm {{
|
||||||
cli
|
cli
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline asmsub set_irqd() {
|
inline asmsub set_irqd() {
|
||||||
%asm {{
|
%asm {{
|
||||||
sei
|
sei
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,27 +887,53 @@ sys {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline asmsub push(ubyte value @A) {
|
||||||
|
%asm {{
|
||||||
|
pha
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub pop() -> ubyte @A {
|
||||||
|
%asm {{
|
||||||
|
pla
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub pushw(uword value @AY) {
|
||||||
|
%asm {{
|
||||||
|
pha
|
||||||
|
phy
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub popw() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
ply
|
||||||
|
pla
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub clear_carry() {
|
inline asmsub clear_carry() {
|
||||||
%asm {{
|
%asm {{
|
||||||
clc
|
clc
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline asmsub set_carry() {
|
inline asmsub set_carry() {
|
||||||
%asm {{
|
%asm {{
|
||||||
sec
|
sec
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline asmsub clear_irqd() {
|
inline asmsub clear_irqd() {
|
||||||
%asm {{
|
%asm {{
|
||||||
cli
|
cli
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline asmsub set_irqd() {
|
inline asmsub set_irqd() {
|
||||||
%asm {{
|
%asm {{
|
||||||
sei
|
sei
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +142,10 @@ private val functionSignatures: List<FSignature> = listOf(
|
|||||||
FSignature("peekw" , true, listOf(FParam("address", arrayOf(DataType.UWORD))), DataType.UWORD),
|
FSignature("peekw" , true, listOf(FParam("address", arrayOf(DataType.UWORD))), DataType.UWORD),
|
||||||
FSignature("poke" , false, listOf(FParam("address", arrayOf(DataType.UWORD)), FParam("value", arrayOf(DataType.UBYTE))), null),
|
FSignature("poke" , false, listOf(FParam("address", arrayOf(DataType.UWORD)), FParam("value", arrayOf(DataType.UBYTE))), null),
|
||||||
FSignature("pokew" , false, listOf(FParam("address", arrayOf(DataType.UWORD)), FParam("value", arrayOf(DataType.UWORD))), null),
|
FSignature("pokew" , false, listOf(FParam("address", arrayOf(DataType.UWORD)), FParam("value", arrayOf(DataType.UWORD))), null),
|
||||||
|
// FSignature("pop" , false, emptyList(), DataType.UBYTE),
|
||||||
|
// FSignature("popw" , false, emptyList(), DataType.UWORD),
|
||||||
|
// FSignature("push" , false, listOf(FParam("value", ByteDatatypes)), null),
|
||||||
|
// FSignature("pushw" , false, listOf(FParam("value", WordDatatypes)), null),
|
||||||
FSignature("rnd" , false, emptyList(), DataType.UBYTE),
|
FSignature("rnd" , false, emptyList(), DataType.UBYTE),
|
||||||
FSignature("rndw" , false, emptyList(), DataType.UWORD),
|
FSignature("rndw" , false, emptyList(), DataType.UWORD),
|
||||||
FSignature("rndf" , false, emptyList(), DataType.FLOAT),
|
FSignature("rndf" , false, emptyList(), DataType.FLOAT),
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
|
%import test_stack
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
uword ww
|
test_stack.test()
|
||||||
|
|
||||||
main.routine2.num = ww+1
|
sys.push(-22 as ubyte)
|
||||||
main.routine2.switch=true
|
sys.push(44)
|
||||||
|
sys.pushw(-11234 as uword)
|
||||||
|
sys.pushw(12345)
|
||||||
|
sys.push(1)
|
||||||
|
sys.push(2)
|
||||||
|
ubyte @shared ub = sys.pop()
|
||||||
|
byte @shared bb = sys.pop() as byte
|
||||||
|
uword @shared uw = sys.popw()
|
||||||
|
word @shared ww = sys.popw() as word
|
||||||
|
void sys.pop()
|
||||||
|
void sys.pop()
|
||||||
|
|
||||||
routine2(ww+1, true)
|
; routine2(uw+1, true)
|
||||||
|
|
||||||
|
test_stack.test()
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<keywords keywords="&;->;@;\$;and;as;asmsub;break;clobbers;do;downto;else;false;for;goto;if;if_cc;if_cs;if_eq;if_mi;if_ne;if_neg;if_nz;if_pl;if_pos;if_vc;if_vs;if_z;in;inline;not;or;repeat;return;romsub;step;sub;to;true;until;when;while;xor;~" ignore_case="false" />
|
<keywords keywords="&;->;@;\$;and;as;asmsub;break;clobbers;do;downto;else;false;for;goto;if;if_cc;if_cs;if_eq;if_mi;if_ne;if_neg;if_nz;if_pl;if_pos;if_vc;if_vs;if_z;in;inline;not;or;repeat;return;romsub;step;sub;to;true;until;when;while;xor;~" ignore_case="false" />
|
||||||
<keywords2 keywords="%address;%asm;%asmbinary;%asminclude;%breakpoint;%import;%launcher;%option;%output;%zeropage;%zpreserved" />
|
<keywords2 keywords="%address;%asm;%asmbinary;%asminclude;%breakpoint;%import;%launcher;%option;%output;%zeropage;%zpreserved" />
|
||||||
<keywords3 keywords="byte;const;float;shared;str;ubyte;uword;void;word;zp" />
|
<keywords3 keywords="byte;const;float;shared;str;ubyte;uword;void;word;zp" />
|
||||||
<keywords4 keywords="abs;acos;all;any;asin;atan;avg;callfar;callrom;ceil;cmp;cos;cos16;cos16u;cos8;cos8u;deg;floor;len;ln;log2;lsb;lsl;lsr;max;memory;min;mkword;msb;peek;peekw;poke;pokew;rad;reverse;rnd;rndf;rndw;rol;rol2;ror;ror2;round;sgn;sin;sin16;sin16u;sin8;sin8u;sizeof;sort;sqrt;sqrt16;sum;swap;tan" />
|
<keywords4 keywords="abs;acos;all;any;asin;atan;avg;callfar;callrom;ceil;cmp;cos;cos16;cos16u;cos8;cos8u;cosr16;cosr16u;cosr8;cosr8u;deg;floor;len;ln;log2;lsb;lsl;lsr;max;memory;min;mkword;msb;peek;peekw;poke;pokew;rad;reverse;rnd;rndf;rndw;rol;rol2;ror;ror2;round;sgn;sin;sin16;sin16u;sin8;sin8u;sinr16;sinr16u;sinr8;sinr8u;sizeof;sort;sqrt;sqrt16;sum;swap;tan" />
|
||||||
</highlighting>
|
</highlighting>
|
||||||
<extensionMap>
|
<extensionMap>
|
||||||
<mapping ext="p8" />
|
<mapping ext="p8" />
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<Keywords name="Keywords1">void const
str
byte ubyte
word uword
float
zp shared</Keywords>
|
<Keywords name="Keywords1">void const
str
byte ubyte
word uword
float
zp shared</Keywords>
|
||||||
<Keywords name="Keywords2">%address
%asm
%asmbinary
%asminclude
%breakpoint
%import
%launcher
%option
%output
%zeropage
%zpreserved</Keywords>
|
<Keywords name="Keywords2">%address
%asm
%asmbinary
%asminclude
%breakpoint
%import
%launcher
%option
%output
%zeropage
%zpreserved</Keywords>
|
||||||
<Keywords name="Keywords3">inline sub asmsub romsub
clobbers
asm
if
when else
if_cc if_cs if_eq if_mi if_neg if_nz if_pl if_pos if_vc if_vs if_z
for in step do while repeat
break return goto</Keywords>
|
<Keywords name="Keywords3">inline sub asmsub romsub
clobbers
asm
if
when else
if_cc if_cs if_eq if_mi if_neg if_nz if_pl if_pos if_vc if_vs if_z
for in step do while repeat
break return goto</Keywords>
|
||||||
<Keywords name="Keywords4">abs acos all any asin atan avg callfar callrom ceil cmp cos cos16 cos16u cos8 cos8u deg floor len ln log2 lsb lsl lsr max memory min mkword msb peek peekw poke pokew rad reverse rnd rndf rndw rol rol2 ror ror2 round sgn sin sin16 sin16u sin8 sin8u sizeof sort sqrt sqrt16 sum swap tan
</Keywords>
|
<Keywords name="Keywords4">abs acos all any asin atan avg callfar callrom ceil cmp cos cos16 cos16u cos8 cos8u cosr8 cosr8u cosr16 cosr16u deg floor len ln log2 lsb lsl lsr max memory min mkword msb peek peekw poke pokew rad reverse rnd rndf rndw rol rol2 ror ror2 round sgn sin sin16 sin16u sin8 sin8u sinr8 sinr8u sinr16 sinr16u sizeof sort sqrt sqrt16 sum swap tan
</Keywords>
|
||||||
<Keywords name="Keywords5">true false
not and or xor
as to downto</Keywords>
|
<Keywords name="Keywords5">true false
not and or xor
as to downto</Keywords>
|
||||||
<Keywords name="Keywords6"></Keywords>
|
<Keywords name="Keywords6"></Keywords>
|
||||||
<Keywords name="Keywords7"></Keywords>
|
<Keywords name="Keywords7"></Keywords>
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
" Built-in functions
|
" Built-in functions
|
||||||
|
|
||||||
" Math functions
|
" Math functions
|
||||||
syn keyword prog8BuiltInFunc abs atan ceil cos cos8u cos8 cos16u cos16 deg floor
|
syn keyword prog8BuiltInFunc abs atan ceil cos cos8u cos8 cos16u cos16 cosr8 cosr8u cosr16 cosr16u deg floor
|
||||||
syn keyword prog8BuiltInFunc ln log2 rad round sin sgn sin8u sin8 sin16u sin16
|
syn keyword prog8BuiltInFunc ln log2 rad round sin sgn sin8u sin8 sin16u sin16 sinr8 sinr8u sinr16 sinr16u
|
||||||
syn keyword prog8BuiltInFunc sqrt16 sqrt tan
|
syn keyword prog8BuiltInFunc sqrt16 sqrt tan
|
||||||
|
|
||||||
" Array functions
|
" Array functions
|
||||||
|
Loading…
Reference in New Issue
Block a user