Added if statements and bitwise operations
This commit is contained in:
parent
1140b5b140
commit
848a01ff7d
6 changed files with 116 additions and 0 deletions
|
|
@ -96,6 +96,8 @@ static inline bool isKW(Lz_SB *sb) {
|
||||||
|| SBeq(sb, "endwhile")
|
|| SBeq(sb, "endwhile")
|
||||||
|| SBeq(sb, "==")
|
|| SBeq(sb, "==")
|
||||||
|| SBeq(sb, "not")
|
|| SBeq(sb, "not")
|
||||||
|
|| SBeq(sb, "bor")
|
||||||
|
|| SBeq(sb, "band")
|
||||||
|| SBeq(sb, "u+")
|
|| SBeq(sb, "u+")
|
||||||
|| SBeq(sb, "u-")
|
|| SBeq(sb, "u-")
|
||||||
|| SBeq(sb, "u*")
|
|| SBeq(sb, "u*")
|
||||||
|
|
@ -327,6 +329,27 @@ codegen:
|
||||||
printf(" pushstack 96\n");
|
printf(" pushstack 96\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (SBeq(&tokenAccumulator, "band")) {
|
||||||
|
printf(" popstack 97\n");
|
||||||
|
printf(" popstack 98\n");
|
||||||
|
printf(" AndR64 98, 97\n");
|
||||||
|
printf(" pushstack 98\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (SBeq(&tokenAccumulator, "bor")) {
|
||||||
|
printf(" popstack 97\n");
|
||||||
|
printf(" popstack 98\n");
|
||||||
|
printf(" OrR64 98, 97\n");
|
||||||
|
printf(" pushstack 98\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (SBeq(&tokenAccumulator, "xor")) {
|
||||||
|
printf(" popstack 97\n");
|
||||||
|
printf(" popstack 98\n");
|
||||||
|
printf(" xorR64 98, 97\n");
|
||||||
|
printf(" pushstack 98\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (SBeq(&tokenAccumulator, "u+")) {
|
if (SBeq(&tokenAccumulator, "u+")) {
|
||||||
printf(" popstack 97\n");
|
printf(" popstack 97\n");
|
||||||
printf(" popstack 98\n");
|
printf(" popstack 98\n");
|
||||||
|
|
|
||||||
13
flagpole/tests/isprime.fp
Normal file
13
flagpole/tests/isprime.fp
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
$inc fvmstd.fp
|
||||||
|
|
||||||
|
proc main
|
||||||
|
:getuint @x
|
||||||
|
2 @checkFact
|
||||||
|
while &checkFact &checkFact u* 1 u- &x u< do
|
||||||
|
if &x &checkFact u% 0 == then
|
||||||
|
"Not Prime" :puts :newline return
|
||||||
|
endif
|
||||||
|
&checkFact 1 u+ @checkFact
|
||||||
|
endwhile
|
||||||
|
"Prime" :puts :newline
|
||||||
|
endproc
|
||||||
39
flagpole/tests/tempconv.fp
Normal file
39
flagpole/tests/tempconv.fp
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
$inc fvmstd.fp
|
||||||
|
|
||||||
|
proc mainvar
|
||||||
|
"Source Fahrenheit or Celsius (F/C): " :puts
|
||||||
|
:getchar @srcUnit
|
||||||
|
:getchar drop # newline pmo
|
||||||
|
if &srcUnit 0x43 == &srcUnit 0x63 == bor then
|
||||||
|
"Source Temp: " :puts :getuint @srcTemp
|
||||||
|
&srcTemp 9 u* 5 u/ 32 u+ @dstTemp
|
||||||
|
&srcTemp :putuint "*C == " :puts &dstTemp :putuint "*F" :puts :newline
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
if &srcUnit 0x46 == &srcUnit 0x66 == bor then
|
||||||
|
"Source Temp: " :puts :getuint @srcTemp
|
||||||
|
&srcTemp 32 u- 5 u* 9 u/ @dstTemp
|
||||||
|
&srcTemp :putuint "*F == " :puts &dstTemp :putuint "*C" :puts :newline
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
"Invalid Unit" :puts :newline
|
||||||
|
endproc
|
||||||
|
|
||||||
|
proc main
|
||||||
|
"Source Fahrenheit or Celsius (F/C): " :puts
|
||||||
|
:getchar
|
||||||
|
:getchar drop # newline pmo
|
||||||
|
if dup 0x43 == dup 0x63 == bor then
|
||||||
|
"Source Temp: " :puts :getuint
|
||||||
|
dup 9 u* 5 u/ 32 u+
|
||||||
|
swap :putuint "*C == " :puts :putuint "*F" :puts :newline
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
if dup 0x46 == dup 0x66 == bor then
|
||||||
|
"Source Temp: " :puts :getuint
|
||||||
|
dup 32 u- 5 u* 9 u/
|
||||||
|
swap :putuint "*F == " :puts :putuint "*C" :puts :newline
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
"Invalid Unit" :puts :newline
|
||||||
|
endproc
|
||||||
5
flagpole/tests/underflow.fp
Normal file
5
flagpole/tests/underflow.fp
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
$inc fvmstd.fp
|
||||||
|
|
||||||
|
proc main
|
||||||
|
1 u+ :putuint
|
||||||
|
endproc
|
||||||
18
src/interp.c
18
src/interp.c
|
|
@ -230,6 +230,24 @@ int main(int argc, char **argv) {
|
||||||
registers[dst] = registers[src];
|
registers[dst] = registers[src];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 0x79: { // AndR64
|
||||||
|
unsigned char dst = inputs[0];
|
||||||
|
unsigned char src = inputs[1];
|
||||||
|
registers[dst] &= registers[src];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x7A: { // OrR64
|
||||||
|
unsigned char dst = inputs[0];
|
||||||
|
unsigned char src = inputs[1];
|
||||||
|
registers[dst] |= registers[src];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x7B: { // XorR64
|
||||||
|
unsigned char dst = inputs[0];
|
||||||
|
unsigned char src = inputs[1];
|
||||||
|
registers[dst] ^= registers[src];
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 0x6E: { // AddR64
|
case 0x6E: { // AddR64
|
||||||
unsigned char dst = inputs[0];
|
unsigned char dst = inputs[0];
|
||||||
unsigned char src = inputs[1];
|
unsigned char src = inputs[1];
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,24 @@ macro St64 dst, addr
|
||||||
db addr
|
db addr
|
||||||
end macro
|
end macro
|
||||||
|
|
||||||
|
macro AndR64 dst, src
|
||||||
|
db 0x79
|
||||||
|
db dst
|
||||||
|
db src
|
||||||
|
end macro
|
||||||
|
|
||||||
|
macro OrR64 dst, src
|
||||||
|
db 0x7A
|
||||||
|
db dst
|
||||||
|
db src
|
||||||
|
end macro
|
||||||
|
|
||||||
|
macro XorR64 dst, src
|
||||||
|
db 0x7B
|
||||||
|
db dst
|
||||||
|
db src
|
||||||
|
end macro
|
||||||
|
|
||||||
macro AddR64 dst, src
|
macro AddR64 dst, src
|
||||||
db 0x6E
|
db 0x6E
|
||||||
db dst
|
db dst
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue