Verified Commit 5e54f477 authored by Camil Staps's avatar Camil Staps 🚀

Move cmpAC from traps to new bytecode instruction

parent cefc36dc
Pipeline #17018 canceled with stages
in 2 minutes and 25 seconds
......@@ -140,6 +140,7 @@ const char *instruction_type (BC_WORD i) {
case CcatAC: return "";
case Cccall: return "";
case Ccentry: return "";
case CcmpAC: return "";
case CcosR: return "";
case Ccreate: return "";
case Ccreates: return "n";
......
......@@ -126,6 +126,7 @@ enum {
INSTRUCTION(catAC)
INSTRUCTION(ccall)
INSTRUCTION(centry)
INSTRUCTION(cmpAC)
INSTRUCTION(cosR)
INSTRUCTION(create)
INSTRUCTION(creates)
......
......@@ -2260,8 +2260,9 @@ void code_jsr(char label_name[]) {
if (lib_function_n>=0) {
switch (lib_function_n) {
case 0: add_instruction(CeqAC); break;
case 1: add_instruction(CcatAC); break;
case 0: add_instruction(CeqAC); break;
case 1: add_instruction(CcatAC); break;
case 11: add_instruction(CcmpAC); break;
default:
add_instruction_w(Cjesr,lib_function_n);
}
......
......@@ -1662,6 +1662,30 @@ INSTRUCTION_BLOCK(catAC):
pc++;
END_INSTRUCTION_BLOCK;
}
INSTRUCTION_BLOCK(cmpAC):
{
BC_WORD *n1,*n2;
char *s1,*s2;
int sz1,sz2;
n1=(BC_WORD*)asp[0];
n2=(BC_WORD*)asp[-1];
asp-=2;
bsp--;
pc++;
sz1=n1[1];
sz2=n2[1];
s1=(char*)&n1[2];
s2=(char*)&n2[2];
*bsp=strncmp(s1,s2,sz1<sz2 ? sz1 : sz2);
if (sz1!=sz2 && *bsp==0)
*bsp=sz1<sz2 ? -1 : 1;
END_INSTRUCTION_BLOCK;
}
INSTRUCTION_BLOCK(cosR):
{
BC_REAL d=cos(*(BC_REAL*)&bsp[0]);
......@@ -8901,9 +8925,6 @@ INSTRUCTION_BLOCK(jesr):
case 10:
clean_endF();
break;
case 11:
clean_cmpAC();
break;
case 12:
clean_writeFI();
break;
......
......@@ -259,63 +259,6 @@ void clean_endF (void)
return;
}
void clean_cmpAC (void)
{
BC_WORD *asp,*bsp;
BC_WORD *a;
BC_WORD *b;
BC_WORD s;
asp=g_asp;
bsp=g_bsp;
a=(BC_WORD*)asp[0];
b=(BC_WORD*)asp[-1];
g_asp=asp-2;
--bsp;
g_bsp=bsp;
s=b[1];
if (a[1]!=s){
*bsp = a[1]<s;
return;
}
a=(BC_WORD*)(BC_WORD)&a[2];
b=(BC_WORD*)(BC_WORD)&b[2];
// TODO make 64/32-bit agnostic
while ((short int)s>=(short int)4){
if (a[0]!=b[0]){
*bsp = a[0]<b[0] ? -1 : 1;
return;
}
++a;
++b;
s-=4;
}
if ((short int)s>=(short int)2){
if (*(uint16_t*)a!=*(uint16_t*)b){
*bsp = *(uint16_t*)a < *(uint16_t*)b ? -1 : 1;
return;
}
if ((short int)s>(short int)2){
if (((uint8_t*)a)[2]!=((uint8_t*)b)[2]){
*bsp = ((uint8_t*)a)[2] < ((uint8_t*)b)[2] ? -1 : 1;
return;
}
}
} else if ((short int)s>(short int)0){
if (*(uint8_t*)a!=*(uint8_t*)b){
*bsp = *(uint8_t*)a < *(uint8_t*)b ? -1 : 1;
return;
}
}
*bsp = 1;
}
void clean_writeFI (void)
{
BC_WORD *bsp;
......
......@@ -6,7 +6,6 @@ void clean_sliceAC (void);
void clean_ItoAC (void);
void clean_openF (void);
void clean_endF (void);
void clean_cmpAC (void);
void clean_writeFI (void);
void clean_writeFS (void);
void clean_writeFC (void);
......
["","a0","%0","X0","a0a1","a0%1","a0X1","%0a2","%0%2","%0X2","X0a3","X0%3","X0X3","a0a1a4","a0a1%4","a0a1X4","a0%1a5","a0%1%5","a0%1X5","a0X1a6","a0X1%6","a0X1X6","%0a2a7","%0a2%7","%0a2X7","%0%2a8","%0%2%8","%0%2X8","%0X2a9","%0X2%9","%0X2X9","X0a3a10","X0a3%10","X0a3X10","X0%3a11","X0%3%11","X0%3X11","X0X3a12","X0X3%12","X0X3X12","a0a1a4a13","a0a1a4%13","a0a1a4X13","a0a1%4a14","a0a1%4%14","a0a1%4X14","a0a1X4a15","a0a1X4%15","a0a1X4X15","a0%1a5a16","a0%1a5%16","a0%1a5X16","a0%1%5a17","a0%1%5%17","a0%1%5X17","a0%1X5a18","a0%1X5%18","a0%1X5X18","a0X1a6a19","a0X1a6%19","a0X1a6X19","a0X1%6a20","a0X1%6%20","a0X1%6X20","a0X1X6a21","a0X1X6%21","a0X1X6X21","%0a2a7a22","%0a2a7%22","%0a2a7X22","%0a2%7a23","%0a2%7%23","%0a2%7X23","%0a2X7a24","%0a2X7%24","%0a2X7X24","%0%2a8a25","%0%2a8%25","%0%2a8X25","%0%2%8a26","%0%2%8%26","%0%2%8X26","%0%2X8a27","%0%2X8%27","%0%2X8X27","%0X2a9a28","%0X2a9%28","%0X2a9X28","%0X2%9a29","%0X2%9%29","%0X2%9X29","%0X2X9a30","%0X2X9%30","%0X2X9X30","X0a3a10a31","X0a3a10%31","X0a3a10X31","X0a3%10a32","X0a3%10%32","X0a3%10X32"]
(["","a0","%0","X0","a0a1","a0%1","a0X1","%0a2","%0%2","%0X2","X0a3","X0%3","X0X3","a0a1a4","a0a1%4","a0a1X4","a0%1a5","a0%1%5","a0%1X5","a0X1a6","a0X1%6","a0X1X6","%0a2a7","%0a2%7","%0a2X7","%0%2a8","%0%2%8","%0%2X8","%0X2a9"],[True,False,False,False,True,False,False,False,False,False,False,False,True,False,False,False,False,False,False,False,False,False,False,False,True,False,False,False,False,False],[True,False,True,True,False,True,False,False,True,True,False,True,True,False,True,False,False,True,True,False,True,False,False,True,False,False,True,True,False,True])
halt at 4
4548 519740 524288
5273 519015 524288
["","a0","%0","X0","a0a1","a0%1","a0X1","%0a2","%0%2","%0X2","X0a3","X0%3","X0X3","a0a1a4","a0a1%4","a0a1X4","a0%1a5","a0%1%5","a0%1X5","a0X1a6","a0X1%6","a0X1X6","%0a2a7","%0a2%7","%0a2X7","%0%2a8","%0%2%8","%0%2X8","%0X2a9","%0X2%9","%0X2X9","X0a3a10","X0a3%10","X0a3X10","X0%3a11","X0%3%11","X0%3X11","X0X3a12","X0X3%12","X0X3X12","a0a1a4a13","a0a1a4%13","a0a1a4X13","a0a1%4a14","a0a1%4%14","a0a1%4X14","a0a1X4a15","a0a1X4%15","a0a1X4X15","a0%1a5a16","a0%1a5%16","a0%1a5X16","a0%1%5a17","a0%1%5%17","a0%1%5X17","a0%1X5a18","a0%1X5%18","a0%1X5X18","a0X1a6a19","a0X1a6%19","a0X1a6X19","a0X1%6a20","a0X1%6%20","a0X1%6X20","a0X1X6a21","a0X1X6%21","a0X1X6X21","%0a2a7a22","%0a2a7%22","%0a2a7X22","%0a2%7a23","%0a2%7%23","%0a2%7X23","%0a2X7a24","%0a2X7%24","%0a2X7X24","%0%2a8a25","%0%2a8%25","%0%2a8X25","%0%2%8a26","%0%2%8%26","%0%2%8X26","%0%2X8a27","%0%2X8%27","%0%2X8X27","%0X2a9a28","%0X2a9%28","%0X2a9X28","%0X2%9a29","%0X2%9%29","%0X2%9X29","%0X2X9a30","%0X2X9%30","%0X2X9X30","X0a3a10a31","X0a3a10%31","X0a3a10X31","X0a3%10a32","X0a3%10%32","X0a3%10X32"]
(["","a0","%0","X0","a0a1","a0%1","a0X1","%0a2","%0%2","%0X2","X0a3","X0%3","X0X3","a0a1a4","a0a1%4","a0a1X4","a0%1a5","a0%1%5","a0%1X5","a0X1a6","a0X1%6","a0X1X6","%0a2a7","%0a2%7","%0a2X7","%0%2a8","%0%2%8","%0%2X8","%0X2a9"],[True,False,False,False,True,False,False,False,False,False,False,False,True,False,False,False,False,False,False,False,False,False,False,False,True,False,False,False,False,False],[True,False,True,True,False,True,False,False,True,True,False,True,True,False,True,False,False,True,True,False,True,False,False,True,False,False,True,True,False,True])
halt at 4
4441 257703 262144
5222 256922 262144
......@@ -7,4 +7,8 @@ import StdString
strings :: [String]
strings = ["":[s +++ {#c} +++ toString i \\ s <- strings & i <- [0..], c <- ['a%X']]]
Start = take 100 strings
Start =
( take 29 strings
, take 30 [s1 == s2 \\ (s1,s2) <- diag2 strings strings]
, take 30 [s1 < s2 \\ s1 <- strings & s2 <- tl strings]
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment