Go to the source code of this file.
◆ ut16
◆ ut8
◆ dcpu16_assemble()
int dcpu16_assemble |
( |
ut8 * |
out, |
|
|
const char * |
unoline |
|
) |
| |
Definition at line 216 of file asm.c.
217 ut16 wordA = 0, wordB = 0;
218 int basic_opcode = 0;
219 int non_basic_opcode = 0;
220 char line[256] = { 0 }, *param;
227 if (strlen(
line) < 4)
233 if (!strncmp(
"SET",
line, 3))
235 else if (!strncmp(
"ADD",
line, 3))
237 else if (!strncmp(
"SUB",
line, 3))
239 else if (!strncmp(
"MUL",
line, 3))
241 else if (!strncmp(
"DIV",
line, 3))
243 else if (!strncmp(
"MOD",
line, 3))
245 else if (!strncmp(
"SHL",
line, 3))
247 else if (!strncmp(
"SHR",
line, 3))
249 else if (!strncmp(
"AND",
line, 3))
251 else if (!strncmp(
"BOR",
line, 3))
253 else if (!strncmp(
"XOR",
line, 3))
255 else if (!strncmp(
"IFE",
line, 3))
257 else if (!strncmp(
"IFN",
line, 3))
259 else if (!strncmp(
"IFG",
line, 3))
261 else if (!strncmp(
"IFB",
line, 3))
265 if (basic_opcode == 0) {
266 if (!strncmp(
"JSR",
line, 3)) {
267 non_basic_opcode = 0x1;
269 fprintf(stderr,
"Unknown instruction\n");
275 if (basic_opcode != 0) {
276 ut8 paramA = 0, paramB = 0;
280 while (cn < 256 && param[cn] !=
',' && param[cn] !=
'\n' && param[cn] != 0)
283 if (param[cn] ==
',') {
305 first_word = ((paramB & 0x3F) << 10) | ((paramA & 0x3F) << 4) | (basic_opcode & 0xF);
320 out[0] = (first_word >> 8) & 0xff;
321 out[1] = first_word & 0xff;
323 out[2] = (wordA >> 8) & 0xff;
324 out[3] = wordA & 0xff;
329 out[
off] = (wordB >> 8) & 0xff;
330 out[
off + 1] = wordB & 0xff;
335 fprintf(stderr,
"Missing comma\n");
341 if (non_basic_opcode == 0x1) {
343 ut16 first_word, wordX = 0;
346 first_word = ((
p & 0x3F) << 10) | ((non_basic_opcode & 0x3F) << 4) | (basic_opcode & 0xF);
355 out[0] = (first_word >> 8) & 0xff;
356 out[1] = first_word & 0xff;
358 out[2] = (wordX >> 8) & 0xff;
359 out[3] = wordX & 0xff;
static void clean_line(char *oline, const char *line)
static ut8 decode_parameter(char *param, int *extra_word_needed, ut16 *extra_word_value)
const lzma_allocator const uint8_t size_t uint8_t * out
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
References clean_line(), decode_parameter(), setup::line, memcpy(), off, out, and p.
Referenced by assemble().
◆ dcpu16_disasm()
Definition at line 130 of file dis.c.
static int instrPrint(char *out, size_t size_out, const op *o)
static int instrGetCycles(const op *o)
static int instrGet(ut16 in, op *o, ut16 a, ut16 b)
References op::b, delta, instrGet(), instrGetCycles(), instrPrint(), op_basic::opcode, and out.
Referenced by disassemble().