basic asm, if else if else if else if else if el-

This commit is contained in:
nova 2024-03-17 19:27:08 +01:00
parent 1db3a98e13
commit fb59048075

View File

@ -1,4 +1,5 @@
#include <string.h> #include <string.h>
#include <stdio.h>
void asm_rules(char *in, char _asm[27]){ void asm_rules(char *in, char _asm[27]){
@ -10,30 +11,87 @@ void asm_rules(char *in, char _asm[27]){
while(word != NULL) { while(word != NULL) {
if (word[strlen(word)-1] == '\n') { //instruction set
word[strlen(word)-1] = '\0'; //cleans newline from string //aaaaaa bbbbbbb ccccccc ddddddd
} //a = opcode, b = input 0, c = input 1, d = output
if (strcmp(word, "nop") == 0) { if (strcmp(word, "nop") == 0) {
//keeps the default value (0) //keeps the default value (0) if nop
} else if (word[0] == ';') {
//comments
break;
} else { } else {
if (strcmp(word, "max") == 0) { //cases make larger checks harder to read
_asm[6] = 1; if(word[0] == 'i') {
} else if (strcmp(word, "min") == 0) { //integer
_asm[6] = 2; _asm[1] = 1;
} else if (strcmp(word, "any") == 0) { } else if(word[0] == 'f') {
_asm[6] = 2; //floating
_asm[5] = 1; _asm[1] = 2;
} else if (strcmp(word, "cons") == 0) {
_asm[6] = 1;
_asm[5] = 1;
} }
else if (word[0] == '$') { if (word[0] == '$') {
//constants //constants
_asm[0] = 2; //set constant loading (on input 1)
} else if (word[0] == '@') { } else if (word[0] == '@') {
//address location //address location
//beware: beginning yandev style
} else if (strstr(word, "max")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 0;
_asm[4] = 0;
_asm[5] = 1;
} else if (strstr(word, "min")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 0;
_asm[4] = 0;
_asm[5] = 2;
} else if (strstr(word, "any")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 0;
_asm[4] = 2;
_asm[5] = 2;
} else if (strstr(word, "cons")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 0;
_asm[4] = 1;
_asm[5] = 1;
} else if (strstr(word, "add")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 1;
_asm[4] = 0;
_asm[5] = 1;
} else if (strstr(word, "sub")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 1;
_asm[4] = 0;
_asm[5] = 2;
} else if (strstr(word, "mul")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 1;
_asm[4] = 1;
_asm[5] = 0;
} else if (strstr(word, "div")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 1;
_asm[4] = 2;
_asm[5] = 0;
} else if (strstr(word, "dec")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 2;
_asm[4] = 2;
_asm[5] = 0;
} else if (strstr(word, "inc")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 2;
_asm[4] = 2;
_asm[5] = 1;
} else if (strstr(word, "not")) {
_asm[2] = 2; //set layer to arithmetics and logic
_asm[3] = 2;
_asm[4] = 2;
_asm[5] = 2;
} }
} }