comments?

This commit is contained in:
xamidev
2024-10-18 21:23:10 +02:00
parent 4c6c501955
commit 730bc7858d
2 changed files with 7 additions and 3 deletions

8
cpu.c
View File

@@ -127,8 +127,12 @@ void assemble(const char* filename)
{ {
char instruction[10]; char instruction[10];
int reg1, reg2, addr; int reg1, reg2, addr;
if (strncmp(line, ";", 1) == 0)
if (sscanf(line, "%s %d %d", instruction, &reg1, &reg2) == 3) {
// comment, ignore
continue;
}
else if (sscanf(line, "%s %d %d", instruction, &reg1, &reg2) == 3)
{ {
if (strncmp(instruction, "MOV", 3) == 0) if (strncmp(instruction, "MOV", 3) == 0)
{ {

View File

@@ -1,3 +1,3 @@
;this is a comment
MOV 1 2 MOV 1 2
HLT HLT