1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-09-07 12:54:31 +00:00

Fix mul and optionally skip ELEM library

This commit is contained in:
David Schmenk 2024-07-24 10:42:53 -07:00
parent 6ef1e26249
commit 1e43899f97
4 changed files with 48 additions and 31 deletions

Binary file not shown.

View File

@ -42,6 +42,8 @@ import sexpr
word intval[2]
end
byte trace
var fmt_fpint
var fmt_fpfrac
@ -60,11 +62,11 @@ end
import smath
predef eval_int(expr)#1
predef eval_int16(expr)#1
predef load_elem#0
end
var prog, prog_expr, prog_return // Current PROG expressions
var sym_cond, sym_if, sym_fpint, sym_fpfrac
var pred_true
res[t_except] break_repl // Breeak out of eval processing
@ -298,10 +300,24 @@ end
//
def parse_cmdline#0
var filename
var opt, filename, skip_elem
readfn = @read_keybd
filename = argNext(argFirst)
skip_elem = FALSE
readfn = @read_keybd
opt = argNext(argFirst)
while opt and ^(opt + 1) == '-'
when toupper(^(opt + 2))
is 'E'
skip_elem = TRUE
break
is 'T'
trace = TRUE
break
wend
opt = argNext(opt)
loop
if not skip_elem; load_elem; fin
filename = opt
if ^filename
fileref = fileio:open(filename)
if fileref
@ -331,8 +347,7 @@ end
// REPL
//
puts("DRAWL (LISP 1.5) symbolic processor\n")
pred_true = bool_pred(TRUE) // Capture value of TRUE
puts("DRAWL (LISP 1.5) v1.0 symbolic processor\n")
sym_fpint = new_sym("FMTFPI")
sym_fpfrac = new_sym("FMTFPF")
sym_fpint=>natv = @natv_fpint

View File

@ -50,7 +50,7 @@ end
var hook_eval = NULL // Installable hook for eval_expr()
byte trace = FALSE
export byte trace = FALSE
const fmt_fp = FPSTR_FIXED|FPSTR_STRIP|FPSTR_FLEX
export var fmt_fpint = 6
@ -732,6 +732,7 @@ end
def build_args(argsyms, argbase)#0
var arglist, pairlist
if argsyms == sym_nil; return; fin
arglist = NULL
while argsyms
//
@ -759,6 +760,7 @@ end
def copy_args(argsyms, argbase)#0
var arglist
if argsyms == sym_nil; return; fin
arglist = assoc_list
while argsyms
arglist=>car=>cdr = sweep_stack[argbase]
@ -959,6 +961,7 @@ def copy_expr(expr)
fin
return expr
end
//
// Base native functions
//
@ -1238,7 +1241,7 @@ def natv_trace(symptr, expr)
if expr
trace = eval_expr(expr=>car) ?? TRUE :: FALSE
fin
return bool_pred(prhex)
return bool_pred(trace)
end
def natv_for(symptr, expr)

View File

@ -205,7 +205,7 @@ def natv_mul(symptr, expr)
word[2] intmul
res[t_extended] extmul
intmul[0] = 0
intmul[0] = 1
intmul[1] = 0
num = eval_num(expr)
expr = expr=>cdr
@ -747,6 +747,27 @@ def natv_rotate(symptr, expr)
return new_int(bitval[0], bitval[1])
end
export def load_elem#0
new_sym("COS")=>natv = @natv_cos
new_sym("SIN")=>natv = @natv_sin
new_sym("TAN")=>natv = @natv_tan
new_sym("ATAN")=>natv = @natv_atan
new_sym("LOG2")=>natv = @natv_log2
new_sym("LOG2_1")=>natv = @natv_log21
new_sym("LN")=>natv = @natv_ln
new_sym("LN_1")=>natv = @natv_ln1
new_sym("POW2")=>natv = @natv_pow2
new_sym("POW2_1")=>natv = @natv_pow21
new_sym("POWE")=>natv = @natv_powE
new_sym("POWE_1")=>natv = @natv_powE1
new_sym("POW_I")=>natv = @natv_powI
new_sym("POWY")=>natv = @natv_pow
new_sym("COMP")=>natv = @natv_comp
new_sym("ANNUITY")=>natv = @natv_annuity
sane:saveZP() // Force load of ELEM library
sane:restoreZP(sane:op1ELEM(FOSINX, @ext_pi))
end
//
// Install numerical constants and functions
//
@ -771,22 +792,6 @@ new_sym("SCALEB_I")=>natv = @natv_scalebI
new_sym("TRUNCATE")=>natv = @natv_trunc
new_sym("ROUND")=>natv = @natv_round
new_sym("SQRT")=>natv = @natv_sqrt
new_sym("COS")=>natv = @natv_cos
new_sym("SIN")=>natv = @natv_sin
new_sym("TAN")=>natv = @natv_tan
new_sym("ATAN")=>natv = @natv_atan
new_sym("LOG2")=>natv = @natv_log2
new_sym("LOG2_1")=>natv = @natv_log21
new_sym("LN")=>natv = @natv_ln
new_sym("LN_1")=>natv = @natv_ln1
new_sym("POW2")=>natv = @natv_pow2
new_sym("POW2_1")=>natv = @natv_pow21
new_sym("POWE")=>natv = @natv_powE
new_sym("POWE_1")=>natv = @natv_powE1
new_sym("POW_I")=>natv = @natv_powI
new_sym("POWY")=>natv = @natv_pow
new_sym("COMP")=>natv = @natv_comp
new_sym("ANNUITY")=>natv = @natv_annuity
new_sym("BITNOT")=>natv = @natv_bitnot
new_sym("BITAND")=>natv = @natv_bitand
new_sym("BITOR")=>natv = @natv_bitor
@ -794,11 +799,5 @@ new_sym("BITXOR")=>natv = @natv_bitxor
new_sym("ARITHSHIFT")=>natv = @natv_arithshift
new_sym("LOGICSHIFT")=>natv = @natv_logicshift
new_sym("ROTATE")=>natv = @natv_rotate
memcpy(@tempext, @ext_pi, t_extended)
//
// Force load of ELEM library
//
sane:saveZP()
sane:restoreZP(sane:op1ELEM(FOSINX, @tempext))
return modkeep | modinitkeep
done