From ce0f825e1defb6efdb55240592d96f8920d93206 Mon Sep 17 00:00:00 2001 From: EDiasAlberto Date: Tue, 4 Jun 2024 04:24:56 +0100 Subject: [PATCH] add halt command handling --- src/parser.c | 10 ++++++++-- src/parser.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/parser.c b/src/parser.c index 0103a3d..98fa61a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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); diff --git a/src/parser.h b/src/parser.h index 5542aca..8088efa 100644 --- a/src/parser.h +++ b/src/parser.h @@ -1 +1,2 @@ -#define OPERAND_DELIMITER ", " \ No newline at end of file +#define OPERAND_DELIMITER ", " +#define HALT_ASM_CMD "and x0, x0, x0" \ No newline at end of file