xyw.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#ifndef XYW_H
#define XYW_H
#define XYW_MODE_X 0x20
#define XYW_MODE_Y 0x40
#define XYW_MODE_W 0x80
#define XYW_TOTAL_INSTRUCTIONS 0x20
#define XYW_TOTAL_DEVICES 0x10
// clang-format off
#define PEEKW(d) (*(d) << 8 | (d)[1])
#define POKEW(d, v) { *(d) = (v) >> 8; (d)[1] = (v); }
// clang-format on
typedef unsigned char xyw_byte;
typedef unsigned short xyw_word;
typedef xyw_byte (*xyw_read)(xyw_byte addr, xyw_byte *error);
typedef void (*xyw_write)(xyw_byte addr, xyw_byte val, xyw_byte *error);
typedef xyw_word (*xyw_readw)(xyw_byte addr, xyw_byte *error);
typedef void (*xyw_writew)(xyw_byte addr, xyw_word val, xyw_byte *error);
typedef struct xyw_device
{
xyw_read read;
xyw_write write;
xyw_readw readw;
xyw_writew writew;
} xyw_device;
// clang-format off
#define xyw_dbg(...) do { if (xyw_debug) fprintf(stdout, __VA_ARGS__); } while(0)
// clang-format on
extern const char xyw_instructions[][4];
extern int xyw_debug;
extern xyw_device xyw_devices[XYW_TOTAL_DEVICES];
int xyw_assemble(const char *input, const char *output);
int xyw_run(const char *input);
#endif // XYW_H
|