commit 3d77ed5
zzo38
·
2023-10-01 03:57:04 +0000 UTC
parent 6da7f9b
Add a assembler feature for non-counted loops in special calculations
M
asm.doc
+2,
-0
1@@ -220,6 +220,8 @@ G ( address -- value ) Read 16-bits from memory.
2 k ( count -- count? ) Similar to o (below) but ends the loop if the new
3 count is zero instead of the old count.
4
5+L ( condition -- ) Go back to beginning of loop if condition is nonzero.
6+
7 o ( count -- count? ) If count is nonzero, decrement and go back to the
8 beginning; if it is already zero then just discards it and continues the
9 execution from here instead.
M
uxnasm.c
+1,
-0
1@@ -350,6 +350,7 @@ static int special_calc(const char*w) {
2 case 'g': if(ssptr<1) return 0; a=sstack[--ssptr]; sstack[ssptr++]=p.data[a]; break;
3 case 'G': if(ssptr<1) return 0; a=sstack[--ssptr]; if(a==0xFFFF) return 0; sstack[ssptr++]=(p.data[a]<<8)|p.data[a+1]; break;
4 case 'k': if(ssptr<1) return 0; if(--sstack[ssptr-1]) w=loop; else --ssptr; break;
5+ case 'L': if(ssptr<1) return 0; if(sstack[--ssptr]) w=loop; break;
6 case 'o': if(ssptr<1) return 0; if(sstack[ssptr-1]--) w=loop; else --ssptr; break;
7 case 'p': if(ssptr<2) return 0; a=sstack[--ssptr]; b=sstack[--ssptr]; p.data[a]=b; break;
8 case 'P': if(ssptr<2) return 0; a=sstack[--ssptr]; b=sstack[--ssptr]; if(a==0xFFFF) return 0; p.data[a]=b>>8; p.data[a+1]=b&255; break;