"cdr", AO_LISP_FUNC_LAMBDA, builtin_cdr,
"cons", AO_LISP_FUNC_LAMBDA, builtin_cons,
"last", AO_LISP_FUNC_LAMBDA, builtin_last,
+ "length", AO_LISP_FUNC_LAMBDA, builtin_length,
"quote", AO_LISP_FUNC_NLAMBDA, builtin_quote,
"set", AO_LISP_FUNC_LAMBDA, builtin_set,
"setq", AO_LISP_FUNC_MACRO, builtin_setq,
">", AO_LISP_FUNC_LEXPR, builtin_greater,
"<=", AO_LISP_FUNC_LEXPR, builtin_less_equal,
">=", AO_LISP_FUNC_LEXPR, builtin_greater_equal,
+ "pack", AO_LISP_FUNC_LAMBDA, builtin_pack,
+ "unpack", AO_LISP_FUNC_LAMBDA, builtin_unpack,
+ "flush", AO_LISP_FUNC_LAMBDA, builtin_flush,
"delay", AO_LISP_FUNC_LAMBDA, builtin_delay,
"led", AO_LISP_FUNC_LEXPR, builtin_led,
+ "save", AO_LISP_FUNC_LAMBDA, builtin_save,
+ "restore", AO_LISP_FUNC_LAMBDA, builtin_restore,
};
#define N_FUNC (sizeof funcs / sizeof funcs[0])
return 0;
}
+#define AO_FEC_CRC_INIT 0xffff
+
+static inline uint16_t
+ao_fec_crc_byte(uint8_t byte, uint16_t crc)
+{
+ uint8_t bit;
+
+ for (bit = 0; bit < 8; bit++) {
+ if (((crc & 0x8000) >> 8) ^ (byte & 0x80))
+ crc = (crc << 1) ^ 0x8005;
+ else
+ crc = (crc << 1);
+ byte <<= 1;
+ }
+ return crc;
+}
+
+uint16_t
+ao_fec_crc(const uint8_t *bytes, uint8_t len)
+{
+ uint16_t crc = AO_FEC_CRC_INIT;
+
+ while (len--)
+ crc = ao_fec_crc_byte(*bytes++, crc);
+ return crc;
+}
+
int
main(int argc, char **argv)
{
ao_lisp_atom_set(ao_lisp_atom_poly(a),
ao_lisp_atom_poly(a));
- for (;;) {
- sexpr = ao_lisp_read();
- if (!sexpr)
- break;
- printf ("sexpr: ");
- ao_lisp_poly_print(sexpr);
- printf("\n");
- val = ao_lisp_eval(sexpr);
- if (ao_lisp_exception)
- exit(1);
- printf("\t");
- ao_lisp_poly_print(val);
- printf("\n");
- }
+ /* end of file value */
+ a = ao_lisp_atom_intern("eof");
+ ao_lisp_atom_set(ao_lisp_atom_poly(a),
+ ao_lisp_atom_poly(a));
+
+ ao_lisp_read_eval_print();
/* Reduce to referenced values */
ao_lisp_collect();
printf("extern const uint8_t ao_lisp_const[AO_LISP_POOL_CONST] __attribute__((aligned(4)));\n");
printf("#define ao_builtin_atoms 0x%04x\n", ao_lisp_atom_poly(ao_lisp_atoms));
printf("#define ao_builtin_frame 0x%04x\n", ao_lisp_frame_poly(ao_lisp_frame_global));
+ printf("#define ao_lisp_const_checksum ((uint16_t) 0x%04x)\n", ao_fec_crc(ao_lisp_const, ao_lisp_top));
for (a = ao_lisp_atoms; a; a = ao_lisp_poly_atom(a->next)) {
char *n = a->name, c;