tern-assembler/asm_rules.c

44 lines
784 B
C
Raw Normal View History

2024-02-19 22:25:25 +01:00
#include <string.h>
2024-02-29 22:53:11 +01:00
void asm_rules(char *in, char _asm[27]){
2024-02-19 22:25:25 +01:00
2024-03-12 10:18:56 +01:00
for (int i=0; i<27; i++) {
_asm[i] = 0;
}
2024-02-19 22:25:25 +01:00
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) {
2024-03-12 10:18:56 +01:00
_asm[6] = 1;
} else if (strcmp(word, "min") == 0) {
_asm[6] = 2;
} else if (strcmp(word, "any") == 0) {
2024-02-29 22:53:11 +01:00
_asm[6] = 2;
_asm[5] = 1;
2024-03-12 10:18:56 +01:00
} else if (strcmp(word, "cons") == 0) {
2024-02-29 22:53:11 +01:00
_asm[6] = 1;
_asm[5] = 1;
2024-02-19 22:25:25 +01:00
}
2024-03-12 10:18:56 +01:00
else if (word[0] == '$') {
//constants
} else if (word[0] == '@') {
//address location
}
2024-02-19 22:25:25 +01:00
}
word = strtok(NULL, " ");
}
}