mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-29 19:50:12 +00:00
294fe25c36
Stack indexing can now be given either as ",s" or as ",sp" (only relevant for 65816 and 65CE02). git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@78 4df02467-bbd4-4a76-a152-e7ce94205b78
56 lines
1.6 KiB
C
56 lines
1.6 KiB
C
// ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code.
|
|
// Copyright (C) 1998-2016 Marco Baye
|
|
// Have a look at "acme.c" for further info
|
|
//
|
|
// Dynamic buffer stuff
|
|
#ifndef dynabuf_H
|
|
#define dynabuf_H
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
// macros
|
|
#define DYNABUF_CLEAR(db) do {db->size = 0;} while (0)
|
|
#define DYNABUF_APPEND(db, byte) \
|
|
do { \
|
|
if (db->size == db->reserved) \
|
|
DynaBuf_enlarge(db); \
|
|
db->buffer[(db->size)++] = byte;\
|
|
} while (0)
|
|
// the next one is dangerous - the buffer location can change when a character
|
|
// is appended. So after calling this, don't change the buffer as long as you
|
|
// use the address.
|
|
#define GLOBALDYNABUF_CURRENT (GlobalDynaBuf->buffer)
|
|
|
|
|
|
// dynamic buffer structure
|
|
struct dynabuf {
|
|
char *buffer; // pointer to buffer
|
|
int size; // size of buffer's used portion
|
|
int reserved; // total size of buffer
|
|
};
|
|
|
|
|
|
// variables
|
|
extern struct dynabuf *GlobalDynaBuf; // global dynamic buffer
|
|
|
|
|
|
// create global DynaBuf (call once on program startup)
|
|
extern void DynaBuf_init(void);
|
|
// create (private) DynaBuf
|
|
extern struct dynabuf *DynaBuf_create(int initial_size);
|
|
// call whenever buffer is too small
|
|
extern void DynaBuf_enlarge(struct dynabuf *db);
|
|
// return malloc'd copy of buffer contents
|
|
extern char *DynaBuf_get_copy(struct dynabuf *db);
|
|
// copy string to buffer (without terminator)
|
|
extern void DynaBuf_add_string(struct dynabuf *db, const char *);
|
|
// converts buffer contents to lower case
|
|
extern void DynaBuf_to_lower(struct dynabuf *target, struct dynabuf *source);
|
|
// add char to buffer
|
|
extern void DynaBuf_append(struct dynabuf *db, char);
|
|
|
|
|
|
#endif
|