1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-08-09 16:25:01 +00:00

Fix FOR index variable and update lores example

This commit is contained in:
David Schmenk
2024-07-23 17:05:03 -07:00
parent bbfa59ccc7
commit e77ff928ca
3 changed files with 19 additions and 20 deletions

Binary file not shown.

View File

@@ -1,12 +1,12 @@
(DEFINE (DEFINE
(PLOTFUNC (LAMBDA (FN) (PLOTFUNC (LAMBDA (FN)
(PROG (X Y) (PROG (I X Y)
(SETQ X 0) (FOR I 0 1 (< I 40)
A (SETQ Y (* 0.99 (FN (/ (- X 20) 20.0)))) (SETQ X (/ (- I 19.5) 20.0))
(IF (AND (> Y -1.0) (< Y 1.0)) (SETQ Y (FN X))
(PLOT X, (* (+ Y 1.0) 19.0))) (AND (AND (> Y -1.0) (< Y 1.0))
(SETQ X (+ X 1)) (PLOT I (- 19.5 (* Y 20.0))))
(IF (< X 40) (GO A)) )
(RETURN 0) (RETURN 0)
) )
)) ))

View File

@@ -660,6 +660,9 @@ export def new_assoc(symptr, valptr)#0
pairlist=>car = pair pairlist=>car = pair
pairlist=>cdr = assoc_list pairlist=>cdr = assoc_list
assoc_list = pairlist assoc_list = pairlist
if trace
puts("\n New ASSOC:"); print_expr(pair); putln
fin
end end
def assoc_pair(symptr) def assoc_pair(symptr)
@@ -1245,27 +1248,23 @@ def natv_trace(symptr, expr)
end end
def natv_for(symptr, expr) def natv_for(symptr, expr)
var index, ufunc, dlist var idxsym, idxint, ufunc, dlist
var[2] incval, stepval word[2] stepval
if expr=>car->type & TYPE_MASK <> SYM_TYPE idxsym = expr=>car
if idxsym->type & TYPE_MASK <> SYM_TYPE
puts("For index not symbol\n") puts("For index not symbol\n")
return NULL return NULL
fin fin
index = eval_expr(expr=>car) expr = expr=>cdr
expr = expr=>cdr
if index->type <> NUM_INT
puts("FOR index not integer\n")
return NULL
fin
symptr = eval_expr(expr=>car) symptr = eval_expr(expr=>car)
expr = expr=>cdr expr = expr=>cdr
if symptr->type <> NUM_INT if symptr->type <> NUM_INT
puts("FOR initial not integer\n") puts("FOR initial not integer\n")
return NULL return NULL
fin fin
incval[0] = symptr=>intval[0] set_assoc(idxsym, new_int(symptr=>intval[0], symptr=>intval[1]))
incval[1] = symptr=>intval[1] idxint = eval_expr(idxsym)
symptr = eval_expr(expr=>car) symptr = eval_expr(expr=>car)
expr = expr=>cdr expr = expr=>cdr
if symptr->type <> NUM_INT if symptr->type <> NUM_INT
@@ -1289,9 +1288,9 @@ def natv_for(symptr, expr)
sweep_stack[sweep_stack_top - 1] = eval_expr(expr=>car) sweep_stack[sweep_stack_top - 1] = eval_expr(expr=>car)
expr = expr=>cdr expr = expr=>cdr
loop loop
load32(index + intval) // Manipulate integer value directly! load32(idxint + intval) // Manipulate integer value directly!
add32(@stepval) add32(@stepval)
store32(index + intval) store32(idxint + intval)
loop loop
return pop_sweep_stack return pop_sweep_stack
end end