mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
change syntax of address-of in p8virt code to &X, instead of {X}
This commit is contained in:
parent
7dd14955c1
commit
e34bab9585
@ -48,9 +48,9 @@ class AssemblyProgram(override val name: String, private val allocations: Variab
|
||||
}
|
||||
is VmCodeLabel -> write("_" + line.name.joinToString(".") + ":\n")
|
||||
is VmCodeInlineAsm -> {
|
||||
val asm = line.assembly.replace("""\{[a-zA-Z\d_\.]+\}""".toRegex()) { matchResult ->
|
||||
// "{ X }" -> address of X // TODO USE &X instead for address of X????
|
||||
val name = matchResult.value.substring(1, matchResult.value.length-1).split('.')
|
||||
val asm = line.assembly.replace("""&[a-zA-Z\d_\.]+""".toRegex()) { matchResult ->
|
||||
// "&X" -> address of X
|
||||
val name = matchResult.value.substring(1, matchResult.value.length).split('.')
|
||||
allocations.get(name).toString() }
|
||||
write(asm+"\n")
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ sub str2uword(str string) -> uword {
|
||||
; the number may NOT be preceded by a + sign and may NOT contain spaces
|
||||
; (any non-digit character will terminate the number string that is parsed)
|
||||
%asm {{
|
||||
loadm.w r0, {conv.str2uword.string}
|
||||
loadm.w r0,&conv.str2uword.string
|
||||
syscall 11
|
||||
return
|
||||
}}
|
||||
@ -207,7 +207,7 @@ sub str2word(str string) -> word {
|
||||
; the number may be preceded by a + or - sign but may NOT contain spaces
|
||||
; (any non-digit character will terminate the number string that is parsed)
|
||||
%asm {{
|
||||
loadm.w r0, {conv.str2word.string}
|
||||
loadm.w r0,&conv.str2word.string
|
||||
syscall 12
|
||||
return
|
||||
}}
|
||||
|
@ -10,7 +10,7 @@ floats {
|
||||
sub print_f(float value) {
|
||||
; ---- prints the floating point value (without a newline).
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.print_f.value}
|
||||
loadm.f fr0,&floats.print_f.value
|
||||
syscall 25
|
||||
return
|
||||
}}
|
||||
@ -18,8 +18,8 @@ sub print_f(float value) {
|
||||
|
||||
sub pow(float value, float power) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.pow.value}
|
||||
loadm.f fr1,{floats.pow.power}
|
||||
loadm.f fr0,&floats.pow.value
|
||||
loadm.f fr1,&floats.pow.power
|
||||
fpow.f fr0,fr1
|
||||
return
|
||||
}}
|
||||
@ -27,7 +27,7 @@ sub pow(float value, float power) -> float {
|
||||
|
||||
sub fabs(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.fabs.value}
|
||||
loadm.f fr0,&floats.fabs.value
|
||||
fabs.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -35,7 +35,7 @@ sub fabs(float value) -> float {
|
||||
|
||||
sub sin(float angle) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.sin.angle}
|
||||
loadm.f fr0,&floats.sin.angle
|
||||
fsin.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -43,7 +43,7 @@ sub sin(float angle) -> float {
|
||||
|
||||
sub cos(float angle) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.cos.angle}
|
||||
loadm.f fr0,&floats.cos.angle
|
||||
fcos.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -51,7 +51,7 @@ sub cos(float angle) -> float {
|
||||
|
||||
sub tan(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.tan.value}
|
||||
loadm.f fr0,&floats.tan.value
|
||||
ftan.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -59,7 +59,7 @@ sub tan(float value) -> float {
|
||||
|
||||
sub atan(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.atan.value}
|
||||
loadm.f fr0,&floats.atan.value
|
||||
fatan.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -67,7 +67,7 @@ sub atan(float value) -> float {
|
||||
|
||||
sub ln(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.ln.value}
|
||||
loadm.f fr0,&floats.ln.value
|
||||
fln.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -75,7 +75,7 @@ sub ln(float value) -> float {
|
||||
|
||||
sub log2(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.log2.value}
|
||||
loadm.f fr0,&floats.log2.value
|
||||
flog.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -83,7 +83,7 @@ sub log2(float value) -> float {
|
||||
|
||||
sub sqrt(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.sqrt.value}
|
||||
loadm.f fr0,&floats.sqrt.value
|
||||
sqrt.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -101,7 +101,7 @@ sub deg(float angle) -> float {
|
||||
|
||||
sub round(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.round.value}
|
||||
loadm.f fr0,&floats.round.value
|
||||
fround.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -109,7 +109,7 @@ sub round(float value) -> float {
|
||||
|
||||
sub floor(float value) -> float {
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.floor.value}
|
||||
loadm.f fr0,&floats.floor.value
|
||||
ffloor.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
@ -118,7 +118,7 @@ sub floor(float value) -> float {
|
||||
sub ceil(float value) -> float {
|
||||
; -- ceil: tr = int(f); if tr==f -> return else return tr+1
|
||||
%asm {{
|
||||
loadm.f fr0,{floats.ceil.value}
|
||||
loadm.f fr0,&floats.ceil.value
|
||||
fceil.f fr0,fr0
|
||||
return
|
||||
}}
|
||||
|
@ -42,8 +42,8 @@ prog8_lib {
|
||||
; Note that you can also directly compare strings and string values with eachother using
|
||||
; comparison operators ==, < etcetera (it will use strcmp for you under water automatically).
|
||||
%asm {{
|
||||
loadm.w r0, {prog8_lib.string_compare.st1}
|
||||
loadm.w r1, {prog8_lib.string_compare.st2}
|
||||
loadm.w r0,&prog8_lib.string_compare.st1
|
||||
loadm.w r1,&prog8_lib.string_compare.st2
|
||||
syscall 29
|
||||
return
|
||||
}}
|
||||
|
@ -15,7 +15,7 @@ sys {
|
||||
sub wait(uword jiffies) {
|
||||
; --- wait approximately the given number of jiffies (1/60th seconds)
|
||||
%asm {{
|
||||
loadm.w r0, {sys.wait.jiffies}
|
||||
loadm.w r0,&sys.wait.jiffies
|
||||
syscall 13
|
||||
}}
|
||||
}
|
||||
@ -62,7 +62,7 @@ sys {
|
||||
sub exit(ubyte returnvalue) {
|
||||
; -- immediately exit the program with a return code in the A register
|
||||
%asm {{
|
||||
loadm.b r0,{sys.exit.returnvalue}
|
||||
loadm.b r0,&sys.exit.returnvalue
|
||||
syscall 1
|
||||
}}
|
||||
}
|
||||
@ -82,24 +82,24 @@ sys {
|
||||
|
||||
sub gfx_enable(ubyte mode) {
|
||||
%asm {{
|
||||
loadm.b r0, {sys.gfx_enable.mode}
|
||||
loadm.b r0,&sys.gfx_enable.mode
|
||||
syscall 8
|
||||
}}
|
||||
}
|
||||
|
||||
sub gfx_plot(uword xx, uword yy, ubyte color) {
|
||||
%asm {{
|
||||
loadm.w r0, {sys.gfx_plot.xx}
|
||||
loadm.w r1, {sys.gfx_plot.yy}
|
||||
loadm.b r2, {sys.gfx_plot.color}
|
||||
loadm.w r0,&sys.gfx_plot.xx
|
||||
loadm.w r1,&sys.gfx_plot.yy
|
||||
loadm.b r2,&sys.gfx_plot.color
|
||||
syscall 10
|
||||
}}
|
||||
}
|
||||
|
||||
sub gfx_getpixel(uword xx, uword yy) -> ubyte {
|
||||
%asm {{
|
||||
loadm.w r0, {sys.gfx_getpixel.xx}
|
||||
loadm.w r1, {sys.gfx_getpixel.yy}
|
||||
loadm.w r0,&sys.gfx_getpixel.xx
|
||||
loadm.w r1,&sys.gfx_getpixel.yy
|
||||
syscall 30
|
||||
return
|
||||
}}
|
||||
|
@ -7,7 +7,7 @@ txt {
|
||||
sub clear_screen() {
|
||||
str @shared sequence = "\x1b[2J\x1B[H"
|
||||
%asm {{
|
||||
load.w r0, {txt.clear_screen.sequence}
|
||||
load.w r0,&txt.clear_screen.sequence
|
||||
syscall 3
|
||||
}}
|
||||
}
|
||||
@ -30,14 +30,14 @@ sub uppercase() {
|
||||
|
||||
sub chrout(ubyte char) {
|
||||
%asm {{
|
||||
loadm.b r0, {txt.chrout.char}
|
||||
loadm.b r0,&txt.chrout.char
|
||||
syscall 2
|
||||
}}
|
||||
}
|
||||
|
||||
sub print (str text) {
|
||||
%asm {{
|
||||
loadm.w r0, {txt.print.text}
|
||||
loadm.w r0,&txt.print.text
|
||||
syscall 3
|
||||
}}
|
||||
}
|
||||
@ -114,7 +114,7 @@ sub input_chars (uword buffer) -> ubyte {
|
||||
; ---- Input a string (max. 80 chars) from the keyboard. Returns length of input. (string is terminated with a 0 byte as well)
|
||||
; It assumes the keyboard is selected as I/O channel!
|
||||
%asm {{
|
||||
loadm.w r0,{txt.input_chars.buffer}
|
||||
loadm.w r0,&txt.input_chars.buffer
|
||||
syscall 6
|
||||
return
|
||||
}}
|
||||
|
@ -3,10 +3,9 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- IR/VM: add address-of support (see CodeGen.addrssOf()) use {X} syntax or change to &X? see AssemblyProgram.kt
|
||||
- IR/VM: add address-of support (see CodeGen.addressOf()) syntax = &X
|
||||
- IR/VM: add proper memory mapped variables support
|
||||
- IR/VM: add proper memory slabs support
|
||||
- IR/VM: fix other TODO's
|
||||
|
||||
...
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user