diff --git a/codeGenVirtual/src/prog8/codegen/virtual/AssemblyProgram.kt b/codeGenVirtual/src/prog8/codegen/virtual/AssemblyProgram.kt index eefc307dd..cbf99b8ca 100644 --- a/codeGenVirtual/src/prog8/codegen/virtual/AssemblyProgram.kt +++ b/codeGenVirtual/src/prog8/codegen/virtual/AssemblyProgram.kt @@ -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") } diff --git a/compiler/res/prog8lib/virtual/conv.p8 b/compiler/res/prog8lib/virtual/conv.p8 index 43b0d7d0c..3798a8f13 100644 --- a/compiler/res/prog8lib/virtual/conv.p8 +++ b/compiler/res/prog8lib/virtual/conv.p8 @@ -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 }} diff --git a/compiler/res/prog8lib/virtual/floats.p8 b/compiler/res/prog8lib/virtual/floats.p8 index c2975511a..494c89a3b 100644 --- a/compiler/res/prog8lib/virtual/floats.p8 +++ b/compiler/res/prog8lib/virtual/floats.p8 @@ -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 }} diff --git a/compiler/res/prog8lib/virtual/prog8_lib.p8 b/compiler/res/prog8lib/virtual/prog8_lib.p8 index 59a2864e6..9936522df 100644 --- a/compiler/res/prog8lib/virtual/prog8_lib.p8 +++ b/compiler/res/prog8lib/virtual/prog8_lib.p8 @@ -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 }} diff --git a/compiler/res/prog8lib/virtual/syslib.p8 b/compiler/res/prog8lib/virtual/syslib.p8 index c7c9b2f8c..5a0797615 100644 --- a/compiler/res/prog8lib/virtual/syslib.p8 +++ b/compiler/res/prog8lib/virtual/syslib.p8 @@ -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 }} diff --git a/compiler/res/prog8lib/virtual/textio.p8 b/compiler/res/prog8lib/virtual/textio.p8 index 35ea70fe0..2e6cd4a86 100644 --- a/compiler/res/prog8lib/virtual/textio.p8 +++ b/compiler/res/prog8lib/virtual/textio.p8 @@ -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 }} diff --git a/docs/source/todo.rst b/docs/source/todo.rst index c4da1433e..54c411ebc 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -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 ...