Mercurial > hg-old > index.cgi
comparison src/lwasm.c @ 27:f736579569b4
Added handlers for inherent and register to register instructions
author | lost |
---|---|
date | Fri, 02 Jan 2009 02:56:04 +0000 |
parents | d2e86babd958 |
children | 9bd0fbfe7405 |
comparison
equal
deleted
inserted
replaced
26:d2e86babd958 | 27:f736579569b4 |
---|---|
54 | 54 |
55 va_end(args); | 55 va_end(args); |
56 | 56 |
57 return r; | 57 return r; |
58 } | 58 } |
59 | |
60 void lwasm_emit(asmstate_t *as, lwasm_line_t *l, int b) | |
61 { | |
62 as -> addr += 1; | |
63 | |
64 if (as -> passnum == 1) | |
65 return; | |
66 | |
67 fprintf(stderr, "FIXME: trying to emit code in pass 2 but not implemented.\n"); | |
68 } | |
69 | |
70 void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o) | |
71 { | |
72 if (o >= 0x100) | |
73 lwasm_emit(as, l, o >> 8); | |
74 lwasm_emit(as, l, o & 0xff); | |
75 } | |
76 | |
77 int lwasm_lookupreg2(const char *reglist, char **str) | |
78 { | |
79 int rval = 0; | |
80 | |
81 while (*reglist) | |
82 { | |
83 if (toupper(**str) == *reglist) | |
84 { | |
85 // first char matches | |
86 if (reglist[1] == ' ' && !isalpha(*(*str + 1))) | |
87 break; | |
88 if (toupper(*(*str + 1)) == reglist[1]) | |
89 break; | |
90 } | |
91 reglist += 2; | |
92 rval++; | |
93 } | |
94 if (!*reglist) | |
95 return -1; | |
96 if (reglist[1] == ' ') | |
97 (*str)++; | |
98 else | |
99 (*str) += 2; | |
100 return rval; | |
101 } |