tern-assembler/asm_rules.c
2024-03-12 10:18:56 +01:00

44 lines
784 B
C

#include <string.h>
void asm_rules(char *in, char _asm[27]){
for (int i=0; i<27; i++) {
_asm[i] = 0;
}
char *word = strtok(in, " ");
while(word != NULL) {
if (word[strlen(word)-1] == '\n') {
word[strlen(word)-1] = '\0'; //cleans newline from string
}
if (strcmp(word, "nop") == 0) {
//keeps the default value (0)
} else {
if (strcmp(word, "max") == 0) {
_asm[6] = 1;
} else if (strcmp(word, "min") == 0) {
_asm[6] = 2;
} else if (strcmp(word, "any") == 0) {
_asm[6] = 2;
_asm[5] = 1;
} else if (strcmp(word, "cons") == 0) {
_asm[6] = 1;
_asm[5] = 1;
}
else if (word[0] == '$') {
//constants
} else if (word[0] == '@') {
//address location
}
}
word = strtok(NULL, " ");
}
}