~grimmware/lc3

d4d299961f0631cb687ba8eed491450777d04e74 — glenda 1 year, 2 months ago bc22162
Added BR variants!
2 files changed, 26 insertions(+), 11 deletions(-)

M asm.c
M tests/hello.asm
M asm.c => asm.c +20 -11
@@ 392,18 392,27 @@ parseline(char *l)
			} else if(strcmp(t, "JSRR") == 0) {
				inst = newinst(OP_JSR);
				pos++;
			} else if(strcmp(t, "BRn") == 0) {
			} else if(strncmp(t, "BR", 2) == 0){
				int i = 2;
				inst = newinst(OP_BR);
				inst->mode = FL_NEG;
				pos++;
			} else if(strcmp(t, "BRz") == 0) {
				inst = newinst(OP_BR);
				inst->mode = FL_ZRO;
				pos++;
			} else if(strcmp(t, "BRp") == 0) {
				inst = newinst(OP_BR);
				inst->mode = FL_POS;
				pos++;
				while(t[i]){
					print("%c\n", t[i]);
					switch(t[i]){
					case 'n':
						inst->mode |= FL_NEG;
						break;
					case 'z':
						inst->mode |= FL_ZRO;
						break;
					case 'p':
						inst->mode |= FL_POS;
						break;
					default:
						syntaxerr(smprint("%s is not a valid opcode", t));
					}
					i++;
				}
				pos++;	
			} else {
				int op = matchopcode(t);
				if(op == -1){

M tests/hello.asm => tests/hello.asm +6 -0
@@ 22,6 22,12 @@ O	.FILL	x6f
	.BLKW	x5
	LEA	R0,WRLD
	PUTSP
	BRnzp	x0
	BRnz	x0
	BRzp	x0
	BRpzn	x0
	BRnp	x0
	BR	x0
	HALT
WRLD	.STRINGZ	x20776f726c64210a
	.END