all mov16
This commit is contained in:
parent
4b83e2a8d6
commit
a5866173e5
30
asm/asm.c
30
asm/asm.c
@ -242,6 +242,18 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
out[ip++] = op2;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_Reg_Label: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
int op2 = line->op2.label;
|
||||
|
||||
uint32_t ins = Op_Mov16;
|
||||
set_is_imm(&ins);
|
||||
ins |= (dst & 0xfu) << 12;
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
ADD_LABEL(op2);
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_Reg_MemReg: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
@ -296,7 +308,8 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
out[ip++] = line->offset;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_MemLabel_Reg: {
|
||||
case LineTy_Mov16_MemImm_Reg: {
|
||||
uint16_t dst = line->dst.imm;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
|
||||
uint32_t ins = Op_Mov16;
|
||||
@ -305,7 +318,20 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
set_mov_is_store(&ins);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
ADD_LABEL(line->dst.label);
|
||||
out[ip++] = dst;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_MemLabel_Reg: {
|
||||
int dst = line->dst.label;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
|
||||
uint32_t ins = Op_Mov16;
|
||||
add_op2_reg(&ins, op2);
|
||||
set_mov_is_memory(&ins);
|
||||
set_mov_is_store(&ins);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
ADD_LABEL(dst);
|
||||
break;
|
||||
}
|
||||
case LineTy_In_Imm: {
|
||||
|
@ -24,10 +24,12 @@ typedef enum {
|
||||
LineTy_Mov8_MemImm_Reg,
|
||||
LineTy_Mov16_Reg_Reg,
|
||||
LineTy_Mov16_Reg_Imm,
|
||||
LineTy_Mov16_Reg_Label,
|
||||
LineTy_Mov16_Reg_MemReg,
|
||||
LineTy_Mov16_Reg_MemImm,
|
||||
LineTy_Mov16_Reg_MemLabel,
|
||||
LineTy_Mov16_MemReg_Reg,
|
||||
LineTy_Mov16_MemImm_Reg,
|
||||
LineTy_Mov16_MemLabel_Reg,
|
||||
LineTy_In_Imm,
|
||||
LineTy_Call_Imm,
|
||||
@ -115,10 +117,12 @@ Line s_mov8_mi_i(uint16_t dst_imm, uint16_t op2_imm);
|
||||
Line s_mov8_mi_r(uint16_t dst_imm, Reg op2_reg);
|
||||
Line s_mov16_r_r(Reg dst_reg, Reg op2_reg);
|
||||
Line s_mov16_r_i(Reg dst_reg, uint16_t op2_imm);
|
||||
Line s_mov16_r_l(Reg dst_reg, int op2_label);
|
||||
Line s_mov16_r_mr(Reg dst_reg, Reg op2_reg, uint16_t op2_offset);
|
||||
Line s_mov16_r_mi(Reg dst_reg, uint16_t op2_imm);
|
||||
Line s_mov16_r_ml(Reg dst_reg, int op2_label);
|
||||
Line s_mov16_mr_r(Reg dst_reg, uint16_t dst_offset, Reg op2_reg);
|
||||
Line s_mov16_mi_r(uint16_t dst_imm, Reg op2_reg);
|
||||
Line s_mov16_ml_r(int dst_label, Reg op2_reg);
|
||||
Line s_in_i(Reg dst_reg, uint16_t op1_imm);
|
||||
Line s_call_i(uint16_t op1_imm);
|
||||
|
16
asm/ctors.c
16
asm/ctors.c
@ -138,6 +138,14 @@ Line s_mov16_r_i(Reg dst_reg, uint16_t op2_imm)
|
||||
.op2 = (Ex) { .imm = op2_imm },
|
||||
};
|
||||
}
|
||||
Line s_mov16_r_l(Reg dst_reg, int op2_label)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov16_Reg_Label,
|
||||
.dst = (Ex) { .reg = (uint16_t)dst_reg },
|
||||
.op2 = (Ex) { .label = op2_label },
|
||||
};
|
||||
}
|
||||
Line s_mov16_r_mr(Reg dst_reg, Reg op2_reg, uint16_t op2_offset)
|
||||
{
|
||||
return (Line) {
|
||||
@ -172,6 +180,14 @@ Line s_mov16_mr_r(Reg dst_reg, uint16_t dst_offset, Reg op2_reg)
|
||||
.offset = dst_offset,
|
||||
};
|
||||
}
|
||||
Line s_mov16_mi_r(uint16_t dst_imm, Reg op2_reg)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov16_MemImm_Reg,
|
||||
.dst = (Ex) { .imm = dst_imm },
|
||||
.op2 = (Ex) { .reg = (uint16_t)op2_reg },
|
||||
};
|
||||
}
|
||||
Line s_mov16_ml_r(int dst_label, Reg op2_reg)
|
||||
{
|
||||
return (Line) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user