2016-12-28 20:32:00 +00:00
|
|
|
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
|
2020-05-01 21:01:23 +00:00
|
|
|
// Copyright (C) 1998-2020 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;
|
2020-05-01 21:01:23 +00:00
|
|
|
boolean use_old_algo;
|
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;
|
|
|
|
};
|
|
|
|
|
2020-05-05 22:56:11 +00:00
|
|
|
// structs to pass "!do"/"!while" stuff from pseudoopcodes.c to flow.c
|
|
|
|
struct condition {
|
2014-12-22 00:47:52 +00:00
|
|
|
int line; // original line number
|
2020-05-05 22:56:11 +00:00
|
|
|
boolean invert; // only set for UNTIL conditions
|
2014-12-22 00:47:52 +00:00
|
|
|
char *body; // pointer to actual expression
|
|
|
|
};
|
2020-05-05 22:56:11 +00:00
|
|
|
struct do_while {
|
|
|
|
struct condition head_cond;
|
2014-12-22 00:47:52 +00:00
|
|
|
struct block block;
|
2020-05-05 22:56:11 +00:00
|
|
|
struct condition tail_cond;
|
2014-12-22 00:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// back end function for "!for" pseudo opcode
|
|
|
|
extern void flow_forloop(struct for_loop *loop);
|
2020-05-05 22:56:11 +00:00
|
|
|
// try to read a condition into DynaBuf and store pointer to copy in
|
|
|
|
// given condition structure.
|
2014-12-22 00:47:52 +00:00
|
|
|
// if no condition given, NULL is written to structure.
|
|
|
|
// call with GotByte = first interesting character
|
2020-05-05 22:56:11 +00:00
|
|
|
extern void flow_store_doloop_condition(struct condition *condition, char terminator);
|
|
|
|
// read a condition into DynaBuf and store pointer to copy in
|
|
|
|
// given condition structure.
|
|
|
|
// call with GotByte = first interesting character
|
|
|
|
extern void flow_store_while_condition(struct condition *condition);
|
2014-12-22 00:47:52 +00:00
|
|
|
// back end function for "!do" pseudo opcode
|
2020-05-05 22:56:11 +00:00
|
|
|
extern void flow_do_while(struct do_while *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}]
|
2020-05-06 12:27:32 +00:00
|
|
|
extern void flow_parse_block_else_block(boolean parse_first);
|
2012-02-27 21:14:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|