2016-12-28 20:32:00 +00:00
|
|
|
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
|
|
|
|
// Copyright (C) 1998-2016 Marco Baye
|
2012-02-27 21:14:46 +00:00
|
|
|
// Have a look at "acme.c" for further info
|
|
|
|
//
|
2014-12-22 00:47:52 +00:00
|
|
|
// flow control stuff (loops, conditional assembly etc.)
|
2012-02-27 21:14:46 +00:00
|
|
|
#ifndef flow_H
|
|
|
|
#define flow_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
2014-12-22 00:47:52 +00:00
|
|
|
struct block {
|
|
|
|
int start; // line number of start of block
|
|
|
|
char *body;
|
|
|
|
};
|
2012-02-27 21:14:46 +00:00
|
|
|
|
2014-12-22 00:47:52 +00:00
|
|
|
// struct to pass "!for" loop stuff from pseudoopcodes.c to flow.c
|
|
|
|
struct for_loop {
|
|
|
|
struct symbol *symbol;
|
|
|
|
int old_algo; // actually bool
|
2015-06-14 23:16:23 +00:00
|
|
|
struct {
|
|
|
|
intval_t first,
|
|
|
|
last,
|
|
|
|
increment;
|
|
|
|
int addr_refs; // address reference count
|
|
|
|
} counter;
|
2014-12-22 00:47:52 +00:00
|
|
|
struct block block;
|
|
|
|
};
|
|
|
|
|
|
|
|
// structs to pass "!do" loop stuff from pseudoopcodes.c to flow.c
|
|
|
|
struct loop_condition {
|
|
|
|
int line; // original line number
|
|
|
|
int is_until; // actually bool (0 for WHILE, 1 for UNTIL)
|
|
|
|
char *body; // pointer to actual expression
|
|
|
|
};
|
|
|
|
struct do_loop {
|
|
|
|
struct loop_condition head_cond;
|
|
|
|
struct block block;
|
|
|
|
struct loop_condition tail_cond;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// back end function for "!for" pseudo opcode
|
|
|
|
extern void flow_forloop(struct for_loop *loop);
|
|
|
|
// try to read a condition into DynaBuf and store copy pointer in
|
|
|
|
// given loop_condition structure.
|
|
|
|
// if no condition given, NULL is written to structure.
|
|
|
|
// call with GotByte = first interesting character
|
|
|
|
extern void flow_store_doloop_condition(struct loop_condition *condition, char terminator);
|
|
|
|
// back end function for "!do" pseudo opcode
|
|
|
|
extern void flow_doloop(struct do_loop *loop);
|
2014-12-04 15:31:54 +00:00
|
|
|
// parse a whole source code file
|
2014-12-22 00:47:52 +00:00
|
|
|
extern void flow_parse_and_close_file(FILE *fd, const char *filename);
|
2014-12-04 15:31:54 +00:00
|
|
|
// parse {block} [else {block}]
|
|
|
|
extern void flow_parse_block_else_block(int parse_first);
|
2012-02-27 21:14:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|