#include "assemble.h" void interpret (unsigned char *string, OperandType *operand, AddressingType addtype, long value, unsigned char output[]) { static unsigned char tmp[14]; strcpy ((char*)tmp, (char*)string); /* If ZP mode doesn't work, try ABS */ if (tmp[addtype] == 0xFF) { if (addtype == ZP && tmp[ABS] != 0xFF) { addtype = ABS; strcpy(operand->addtype_text, "Forced Absolute"); } else if (addtype == ZPY && tmp[ABSY] != 0xFF) { addtype = ABSY; strcpy(operand->addtype_text, "Forced Absolute,Y"); } else if (addtype == ZPX && tmp[ABSX] != 0xFF) { addtype = ABSX; strcpy(operand->addtype_text, "Forced Absolute,X"); } } if (tmp[addtype] != 0xFF) { output[1] = tmp[addtype] & 0xff; if (addtype == IMM || addtype == ZP || addtype == INDX || addtype == ZPY || addtype == INDY || addtype == ZPX || addtype == REL) { output[0] = 2; output[2] = value; } else if (addtype == ABS || addtype == ABSX || addtype == ABSY || addtype == IND) { output[0] = 3; output[2] = value & 0x00ff; output[3] = (value & 0xff00) >> 8; } else { output[0] = 1; } } else { output[0] = 0; } }