- /* just dump operands into words, I guess */
- fprintf(stderr, "FIXME unhandled raw data\n");
- /* count total length of data.. */
- /* realloc instruction */
- /* populate words */
+ DEBUG_PRINTF("processing DAT...\n");
+
+ i->length = 0;
+
+ while (o) {
+ size_t j, dat_len;
+ char *x;
+ unsigned long l;
+
+ DEBUG_PRINTF("DAT operand:'%s' next:%p\n", o->operand, o->next);
+
+ /* is this a string? */
+ if ( (x = strchr("\"'`", o->operand[0])) ) {
+ dat_len = strlen(o->operand) - 1;
+ if (o->operand[dat_len] == *x) {
+ /* it is a string */
+ DEBUG_PRINTF("DAT string operand: %s\n", o->operand);
+
+ for (j = 0, x = o->operand + 1;
+ j < dat_len - 1;
+ j++, x++) {
+ i->instr_words[i->length] = (DCPU16_WORD)*x;
+ i->length++;
+ }
+ }
+ o = o->next;
+ continue;
+ }
+
+ char *ep;
+ errno = 0;
+ l = strtoul(o->operand, &ep, 0);
+ if (errno == 0
+ && (*o->operand && (*ep == '\0')) ) {
+ /* conversion succeeded */
+ if (l > 0xffff) {
+ fprintf(stderr, "value '%lu' out of range\n", l);
+ return -1;
+ }
+ }
+
+ fprintf(stderr, "FIXME finish implementing DAT\n");
+ /* check if it's a parsable number */
+
+ /* otherwise assume it's a label */
+
+
+
+ o = o->next;
+ }
+