#console
includepath "$\inc\"
include "Console.inc"
indexbase 0
#define T_ATOM 16384 /* 0100000000000000 *//* only for gc */
#define CLRATOM 114687 /* 11011111111111111 *//* only for gc */
#define DOMARK 32768 /* 01000000000000000 */
#define ctype(p) *(p + sizeof(sys) + sizeof(sys))
#define isatom(p) (ctype(p) & T_ATOM)
#define setatom(p) ctype(p) |= T_ATOM
#define clratom(p) ctype(p) &= CLRATOM
#define setmark(p) ctype(p) |= DOMARK
#define ismark(p) (ctype(p) & DOMARK)
#define car(p) *p
#define cdr(p) *(p + sizeof(sys))
sub gcmark(sys a)
sys t, q, p
t = 0
p = a
E2:
setmark(p)
if (isatom(p)) then goto E6
q = car(p)
if ((q != 0) && (ismark(q) != 0)) then
setatom(p)
car(p) = t
t = p
p = q
goto E2
end if
E5:
q = cdr(p)
if ((q != 0) && (ismark(q) != 0)) then
cdr(p) = t
t = p
p = q
goto E2
end if
E6:
if (t == 0) then exit sub
q = t
if (isatom(q)) then
clratom(q)
t = car(q)
car(q) = p
p = q
goto E5
else
t = cdr(q)
cdr(q) = p
p = q
goto E6
end if
end sub