1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-29 04:51:28 +00:00

some cleanups in the arithmetic operations code (#427)

* arithmetic opcode implementations should return LispPTR rather than int

* all callers of ERROR_EXIT() have return type LispPTR, therefore ERROR_EXIT should too

* N_[I]GETNUMBER, [N_]ARITH_SWITCH need (int) casts for some large constants that would otherwise be unsigned

* Expand use of macro N_ARITH_BODY_1_UNSIGNED and correct types

* Remove unused macros N_ARITH_BODY_1 and N_ARITH_BODY_1_UNSIGNED

* Cast to correct type for storing to TopOfStack, and return type of TIMER_EXIT()
This commit is contained in:
Nick Briggs
2022-07-20 10:28:21 -07:00
committed by GitHub
parent 77957d421a
commit 9a10f63fe6
5 changed files with 65 additions and 55 deletions

View File

@@ -32,28 +32,65 @@ N_OP_llsh1
entry LLSH1 OPCODE[0340]
return(a << 1)
************************************************************/
LispPTR N_OP_llsh1(int a) { N_ARITH_BODY_1_UNSIGNED(a, 1, <<); }
LispPTR N_OP_llsh1(int a) {
int arg1;
N_GETNUMBER(a, arg1, du_ufn);
arg1 <<= 1;
N_ARITH_SWITCH(arg1);
du_ufn:
ERROR_EXIT(a);
}
/************************************************************
N_OP_llsh8
entry LLSH8 OPCODE[0341]
return(a << 8)
************************************************************/
LispPTR N_OP_llsh8(int a) { N_ARITH_BODY_1_UNSIGNED(a, 8, <<); }
LispPTR N_OP_llsh8(int a) {
int arg1;
N_GETNUMBER(a, arg1, du_ufn);
arg1 <<= 8;
N_ARITH_SWITCH(arg1);
du_ufn:
ERROR_EXIT(a);
}
/************************************************************
N_OP_lrsh1
entry LRSH1 OPCODE[0342]
return(a >> 1)
************************************************************/
LispPTR N_OP_lrsh1(int a) { N_ARITH_BODY_1_UNSIGNED(a, 1, >>); }
LispPTR N_OP_lrsh1(int a) {
int arg1;
N_GETNUMBER(a, arg1, du_ufn);
arg1 = (unsigned)arg1 >> 1;
N_ARITH_SWITCH(arg1);
du_ufn:
ERROR_EXIT(a);
}
/************************************************************
N_OP_lrsh8
entry LRSH8 OPCODE[0343]
return(a >> 8)
************************************************************/
LispPTR N_OP_lrsh8(int a) { N_ARITH_BODY_1_UNSIGNED(a, 8, >>); }
LispPTR N_OP_lrsh8(int a) {
int arg1;
N_GETNUMBER(a, arg1, du_ufn);
arg1 = (unsigned)arg1 >> 8;
N_ARITH_SWITCH(arg1);
du_ufn:
ERROR_EXIT(a);
}
/************************************************************
N_OP_lsh