add halt command handling

This commit is contained in:
EDiasAlberto 2024-06-04 04:24:56 +01:00
parent 13e2cc8c9d
commit ce0f825e1d
2 changed files with 10 additions and 3 deletions

View File

@ -14,7 +14,7 @@
// - count operands and match type/values
// - generate final a64inst and return
void classifyOpcode(char* opcode, a64inst_instruction *instr){
void classifyOpcode(char* opcode, a64inst_instruction *instr, char *operandList[]){
if((int isUnconditional = strcmp(opcode, "b")) == 0 ||
(int isRegister = strcmp(opcode, "br")) == 0 ||
strncmp(opcode, "b.", 2) == 0){
@ -29,7 +29,8 @@ void classifyOpcode(char* opcode, a64inst_instruction *instr){
}
} else if(strcmp(opcode, "ldr") == 0 || strcmp(opcode, "str") == 0){
//loading/storing instruction; classify operands
instr->type = a64inst_SINGLETRANSFER;
char *address = opcode[1];
} else {
//data processing
@ -57,6 +58,11 @@ a64inst_instruction *parser(char asmLine[]){
exit(EXIT_FAILURE);
}
if(strcmp(asmLine, HALT_ASM_CMD) == 0){
instr->type = a64inst_HALT;
return(instr);
}
//"opcode operand1, {operand2}, ..."
char *stringptr = strdup(asmLine);

View File

@ -1 +1,2 @@
#define OPERAND_DELIMITER ", "
#define HALT_ASM_CMD "and x0, x0, x0"