very basic assembly
This commit is contained in:
42
asm_rules.c
Normal file
42
asm_rules.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void asm_rules(char *in, char _asm[9]){
|
||||
|
||||
char src_addr[9];
|
||||
char dest_addr[9];
|
||||
char tryte[9];
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
_asm[i] = 0;
|
||||
}
|
||||
|
||||
char *instruction = (char*) malloc(10*sizeof(char));
|
||||
int instruction_location = 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;
|
||||
//printf("%c\n", tryte[6]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
instruction[instruction_location] = _asm[i];
|
||||
instruction_location++;
|
||||
}
|
||||
instruction[instruction_location] = ' ';
|
||||
word = strtok(NULL, " ");
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user