summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/oasm/emit.c10
-rw-r--r--usr.bin/oasm/include/oasm/emit.h2
-rw-r--r--usr.bin/oasm/include/oasm/lex.h2
-rw-r--r--usr.bin/oasm/lex.c8
-rw-r--r--usr.bin/oasm/parse.c14
5 files changed, 35 insertions, 1 deletions
diff --git a/usr.bin/oasm/emit.c b/usr.bin/oasm/emit.c
index 63f716a..099f0b2 100644
--- a/usr.bin/oasm/emit.c
+++ b/usr.bin/oasm/emit.c
@@ -402,6 +402,14 @@ emit_encode_bitw(struct emit_state *state, struct oasm_token *tok)
opcode = OSMX64_XOR;
inst_str = "xor";
break;
+ case TT_LSR:
+ opcode = OSMX64_LSR;
+ inst_str = "lsr";
+ break;
+ case TT_LSL:
+ opcode = OSMX64_LSL;
+ inst_str = "lsl";
+ break;
}
/* Next token should be a register */
@@ -532,6 +540,8 @@ emit_process(struct oasm_state *oasm, struct emit_state *emit)
case TT_AND:
case TT_OR:
case TT_XOR:
+ case TT_LSR:
+ case TT_LSL:
curtok = emit_encode_bitw(emit, curtok);
break;
case TT_BR:
diff --git a/usr.bin/oasm/include/oasm/emit.h b/usr.bin/oasm/include/oasm/emit.h
index 3fc2674..57683a8 100644
--- a/usr.bin/oasm/include/oasm/emit.h
+++ b/usr.bin/oasm/include/oasm/emit.h
@@ -66,6 +66,8 @@
#define OSMX64_MROW 0x11 /* Mask register over word */
#define OSMX64_MROD 0x12 /* Mask register over dword */
#define OSMX64_MROQ 0x13 /* Mask register over qword */
+#define OSMX64_LSR 0x14 /* Logical shift right */
+#define OSMX64_LSL 0x15 /* Logical shift left */
/*
* OSMX64 register definitions
diff --git a/usr.bin/oasm/include/oasm/lex.h b/usr.bin/oasm/include/oasm/lex.h
index 4c81bc4..93422a6 100644
--- a/usr.bin/oasm/include/oasm/lex.h
+++ b/usr.bin/oasm/include/oasm/lex.h
@@ -106,6 +106,8 @@ typedef enum {
TT_AND, /* 'and' */
TT_OR, /* 'or' */
TT_XOR, /* 'xor' */
+ TT_LSR, /* 'lsr' */
+ TT_LSL, /* 'lsl' */
/* Register ops */
TT_MOV, /* 'mov' */
diff --git a/usr.bin/oasm/lex.c b/usr.bin/oasm/lex.c
index ce97400..1f58d07 100644
--- a/usr.bin/oasm/lex.c
+++ b/usr.bin/oasm/lex.c
@@ -57,6 +57,8 @@ static char putback = '\0';
#define S_IMN_AND "and"
#define S_IMN_OR "or"
#define S_IMN_XOR "xor"
+#define S_IMN_LSL "lsl"
+#define S_IMN_LSR "lsr"
/* Instruction length */
#define OSMX64_INST_LEN 4
@@ -269,6 +271,12 @@ token_bitw(char *p)
return token;
}
+ if (strcmp(p, S_IMN_LSL) == 0) {
+ return TT_LSL;
+ } else if (strcmp(p, S_IMN_LSR) == 0) {
+ return TT_LSR;
+ }
+
return TT_UNKNOWN;
}
diff --git a/usr.bin/oasm/parse.c b/usr.bin/oasm/parse.c
index ce5a446..042cce8 100644
--- a/usr.bin/oasm/parse.c
+++ b/usr.bin/oasm/parse.c
@@ -51,7 +51,9 @@ static const char *tokstr[] = {
[ TT_DEC ] = "dec",
[ TT_MOV ] = "mov",
[ TT_IMM ] = "<imm>",
- [ TT_LABEL] = "<label>",
+ [ TT_LABEL ] = "<label>",
+ [ TT_LSR ] = "lsr",
+ [ TT_LSL ] = "lsl",
/* Bitwise */
[ TT_MROB ] = "mrob",
@@ -129,6 +131,8 @@ parse_reg(struct oasm_state *state, struct oasm_token *tok)
case TT_AND:
case TT_OR:
case TT_XOR:
+ case TT_LSR:
+ case TT_LSL:
state->last = tok->type;
break;
default:
@@ -195,6 +199,14 @@ parse_tok(struct oasm_state *state, struct oasm_token *tok)
state->last = tok->type;
emit_osmx64(&emit_state, tok);
break;
+ case TT_LSR:
+ state->last = tok->type;
+ emit_osmx64(&emit_state, tok);
+ break;
+ case TT_LSL:
+ state->last = tok->type;
+ emit_osmx64(&emit_state, tok);
+ break;
case TT_MOV:
state->last = tok->type;
emit_osmx64(&emit_state, tok);