diff options
author | Freya Murphy <freya@freyacat.org> | 2024-09-22 16:02:42 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-09-22 16:02:42 -0400 |
commit | 85471efb4c740bb775c9ebdb10f775620c979598 (patch) | |
tree | c4afa5cf8108df4192e73488c4da271ed166217c /masm/parse.c | |
parent | update make clear (diff) | |
download | mips-85471efb4c740bb775c9ebdb10f775620c979598.tar.gz mips-85471efb4c740bb775c9ebdb10f775620c979598.tar.bz2 mips-85471efb4c740bb775c9ebdb10f775620c979598.zip |
mld done
Diffstat (limited to 'masm/parse.c')
-rw-r--r-- | masm/parse.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/masm/parse.c b/masm/parse.c index 6c817d4..2e404ad 100644 --- a/masm/parse.c +++ b/masm/parse.c @@ -1,6 +1,5 @@ #include <mlimits.h> #include <merror.h> -#include <netinet/in.h> #include <stdint.h> #include <stdio.h> #include <string.h> @@ -10,6 +9,9 @@ #include "lex.h" #include "mips.h" +#define B16(x) (x) +#define B32(x) (x) + static int next_token(struct parser *parser, struct token *tok) { if (parser->peek.type != TOK_EOF) { @@ -475,7 +477,7 @@ off: if (assert_token(parser, TOK_NUMBER, &token)) return M_ERROR; - fi->data.offset = htons(token.number); + fi->data.immd = B16(token.number); if (peek_token(parser, &token)) return M_ERROR; @@ -618,7 +620,7 @@ static int parse_instruction_i(struct parser *parser, if (token.number >= MAX16) return M_ERROR; - ins->data.immd = htons(token.number); + ins->data.immd = B16(token.number); return M_SUCCESS; } @@ -634,12 +636,12 @@ static int parse_instruction_offset(struct parser *parser, case MAX26: if (get_offset_26(parser, &n, ref)) return M_ERROR; - ins->data.offs26 = htonl(n); + ins->data.offs26 = B32(n); break; case MAX16: if (get_offset(parser, &n, ref)) return M_ERROR; - ins->data.offset = htons(n); + ins->data.offset = B16(n); break; default: return M_ERROR; @@ -682,7 +684,7 @@ static int parse_instruction_branch_equal(struct parser *parser, int32_t off; if (get_offset(parser, &off, ref)) return M_ERROR; - ins->data.offset = htons(off); + ins->data.offset = B16(off); return M_SUCCESS; } @@ -703,7 +705,7 @@ static int parse_instruction_branch(struct parser *parser, if (get_offset(parser, &n, ref)) return M_ERROR; - ins->data.offset = htons(n); + ins->data.offset = B16(n); return M_SUCCESS; } @@ -742,7 +744,7 @@ static int parse_instruction_sli(struct parser *parser, if (assert_token(parser, TOK_NUMBER, &token) || token.number > MAX16) return M_ERROR; - ins->data.immd = htons(token.number); + ins->data.immd = B16(token.number); return M_SUCCESS; } @@ -818,7 +820,7 @@ static int parse_pseudo_li(struct parser *parser, struct ins_expr *expr) expr->ins[0] = mips_instructions[MIPS_INS_ORI]; expr->ins[0].data.rt = reg; expr->ins[0].data.rs = MIPS_REG_ZERO; - expr->ins[0].data.immd = htons(immd); + expr->ins[0].data.immd = B16(immd); expr->ref[0].type = R_MIPS_NONE; return M_SUCCESS; @@ -859,11 +861,11 @@ static int parse_pseudo_la(struct parser *parser, struct ins_expr *expr) expr->ins_len = 2; expr->ins[0] = mips_instructions[MIPS_INS_LUI]; expr->ins[0].data.rt = reg; - expr->ins[0].data.immd = htons(hi); + expr->ins[0].data.immd = B16(hi); expr->ins[1] = mips_instructions[MIPS_INS_ORI]; expr->ins[1].data.rt = reg; expr->ins[1].data.rs = MIPS_REG_ZERO; - expr->ins[1].data.immd = htons(lo); + expr->ins[1].data.immd = B16(lo); return M_SUCCESS; } |