Mercurial > hg-old > index.cgi
changeset 42:4bb7b723e5b7
Added pass2 code generation to lwasm_emit()
author | lost |
---|---|
date | Sun, 04 Jan 2009 06:13:13 +0000 |
parents | 7eafdb3a8074 |
children | b33eca135258 |
files | src/lwasm.c src/lwasm.h src/pass1.c |
diffstat | 3 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lwasm.c Sat Jan 03 19:50:30 2009 +0000 +++ b/src/lwasm.c Sun Jan 04 06:13:13 2009 +0000 @@ -67,7 +67,14 @@ if (as -> passnum == 1) return; - fprintf(stderr, "FIXME: trying to emit code in pass 2 but not implemented.\n"); + + if (l -> codelen >= l -> codesize) + { + l -> bytes = realloc(l -> bytes, l -> codesize + 16); + l -> codesize += 16; + } + l -> bytes[l -> codelen] = b & 0xff; + l -> codelen += 1; } void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o)
--- a/src/lwasm.h Sat Jan 03 19:50:30 2009 +0000 +++ b/src/lwasm.h Sun Jan 04 06:13:13 2009 +0000 @@ -50,6 +50,9 @@ lwasm_error_t *err; // error messages int fsize; // forced size (0 = no forced size) char *sym; // scratch area to record the presence of a symbol + unsigned char *bytes; // actual bytes emitted + int codelen; // number of bytes emitted + int codesize; // the size of the code buffer }; // for keeping track of symbols