all mov ops
This commit is contained in:
parent
a5866173e5
commit
1afdc0db58
104
asm/asm.c
104
asm/asm.c
@ -177,6 +177,56 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
ADD_LABEL(op2);
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov8_Reg_Reg: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
|
||||
uint32_t ins = Op_Mov8;
|
||||
ins |= (op2 & 0xfu) << 7;
|
||||
ins |= (dst & 0xfu) << 12;
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov8_Reg_Imm: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.imm;
|
||||
|
||||
uint32_t ins = Op_Mov8;
|
||||
set_is_imm(&ins);
|
||||
ins |= (dst & 0xfu) << 12;
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
out[ip++] = op2;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov8_Reg_MemReg: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
|
||||
uint32_t ins = Op_Mov8;
|
||||
add_op2_reg(&ins, op2);
|
||||
set_mov_is_memory(&ins);
|
||||
set_mov_addr_is_reg(&ins);
|
||||
add_dst_reg(&ins, dst);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
out[ip++] = line->offset;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov8_Reg_MemImm: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.imm;
|
||||
|
||||
uint32_t ins = Op_Mov8;
|
||||
set_is_imm(&ins);
|
||||
set_mov_is_memory(&ins);
|
||||
add_dst_reg(&ins, dst);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
out[ip++] = op2;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov8_MemReg_Reg: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
@ -192,17 +242,19 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
out[ip++] = line->offset;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov8_MemImm_Imm: {
|
||||
uint16_t dst = line->dst.imm;
|
||||
uint16_t op2 = line->op2.imm;
|
||||
case LineTy_Mov8_MemReg_Imm: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
|
||||
uint32_t ins = Op_Mov8;
|
||||
set_is_imm(&ins);
|
||||
set_mov_is_memory(&ins);
|
||||
set_mov_addr_is_reg(&ins);
|
||||
set_mov_is_store(&ins);
|
||||
add_dst_reg(&ins, dst);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
out[ip++] = dst;
|
||||
out[ip++] = line->offset;
|
||||
out[ip++] = op2;
|
||||
break;
|
||||
}
|
||||
@ -219,6 +271,20 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
out[ip++] = dst;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov8_MemImm_Imm: {
|
||||
uint16_t dst = line->dst.imm;
|
||||
uint16_t op2 = line->op2.imm;
|
||||
|
||||
uint32_t ins = Op_Mov8;
|
||||
set_is_imm(&ins);
|
||||
set_mov_is_memory(&ins);
|
||||
set_mov_is_store(&ins);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
out[ip++] = dst;
|
||||
out[ip++] = op2;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_Reg_Reg: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
@ -308,6 +374,22 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
out[ip++] = line->offset;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_MemReg_Imm: {
|
||||
uint16_t dst = line->dst.reg;
|
||||
uint16_t op2 = line->op2.imm;
|
||||
|
||||
uint32_t ins = Op_Mov16;
|
||||
set_is_imm(&ins);
|
||||
set_mov_is_memory(&ins);
|
||||
set_mov_addr_is_reg(&ins);
|
||||
set_mov_is_store(&ins);
|
||||
add_dst_reg(&ins, dst);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
out[ip++] = line->offset;
|
||||
out[ip++] = op2;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_MemImm_Reg: {
|
||||
uint16_t dst = line->dst.imm;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
@ -321,6 +403,20 @@ uint16_t assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
|
||||
out[ip++] = dst;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_MemImm_Imm: {
|
||||
uint16_t dst = line->dst.imm;
|
||||
uint16_t op2 = line->op2.imm;
|
||||
|
||||
uint32_t ins = Op_Mov16;
|
||||
set_is_imm(&ins);
|
||||
set_mov_is_memory(&ins);
|
||||
set_mov_is_store(&ins);
|
||||
|
||||
out[ip++] = (uint16_t)ins;
|
||||
out[ip++] = dst;
|
||||
out[ip++] = op2;
|
||||
break;
|
||||
}
|
||||
case LineTy_Mov16_MemLabel_Reg: {
|
||||
int dst = line->dst.label;
|
||||
uint16_t op2 = line->op2.reg;
|
||||
|
18
asm/asm.h
18
asm/asm.h
@ -19,9 +19,14 @@ typedef enum {
|
||||
LineTy_Cmp_Reg,
|
||||
LineTy_Cmp_Imm,
|
||||
LineTy_Cmp_Label,
|
||||
LineTy_Mov8_Reg_Reg,
|
||||
LineTy_Mov8_Reg_Imm,
|
||||
LineTy_Mov8_Reg_MemReg,
|
||||
LineTy_Mov8_Reg_MemImm,
|
||||
LineTy_Mov8_MemReg_Reg,
|
||||
LineTy_Mov8_MemImm_Imm,
|
||||
LineTy_Mov8_MemReg_Imm,
|
||||
LineTy_Mov8_MemImm_Reg,
|
||||
LineTy_Mov8_MemImm_Imm,
|
||||
LineTy_Mov16_Reg_Reg,
|
||||
LineTy_Mov16_Reg_Imm,
|
||||
LineTy_Mov16_Reg_Label,
|
||||
@ -29,7 +34,9 @@ typedef enum {
|
||||
LineTy_Mov16_Reg_MemImm,
|
||||
LineTy_Mov16_Reg_MemLabel,
|
||||
LineTy_Mov16_MemReg_Reg,
|
||||
LineTy_Mov16_MemReg_Imm,
|
||||
LineTy_Mov16_MemImm_Reg,
|
||||
LineTy_Mov16_MemImm_Imm,
|
||||
LineTy_Mov16_MemLabel_Reg,
|
||||
LineTy_In_Imm,
|
||||
LineTy_Call_Imm,
|
||||
@ -112,9 +119,14 @@ Line s_jnz_l(Reg op1_reg, int op2_label);
|
||||
Line s_cmp_r(Reg op1_reg, Reg op2_reg);
|
||||
Line s_cmp_i(Reg op1_reg, uint16_t op2_imm);
|
||||
Line s_cmp_l(Reg op1_reg, int op2_label);
|
||||
Line s_mov8_r_r(Reg dst_reg, Reg op2_reg);
|
||||
Line s_mov8_r_i(Reg dst_reg, uint16_t op2_imm);
|
||||
Line s_mov8_r_mr(Reg dst_reg, Reg op2_reg, uint16_t op2_offset);
|
||||
Line s_mov8_r_mi(Reg dst_reg, uint16_t op2_imm);
|
||||
Line s_mov8_mr_r(Reg dst_reg, Reg op2_reg);
|
||||
Line s_mov8_mi_i(uint16_t dst_imm, uint16_t op2_imm);
|
||||
Line s_mov8_mr_i(Reg dst_reg, uint16_t op2_imm);
|
||||
Line s_mov8_mi_r(uint16_t dst_imm, Reg op2_reg);
|
||||
Line s_mov8_mi_i(uint16_t dst_imm, uint16_t op2_imm);
|
||||
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);
|
||||
@ -122,7 +134,9 @@ 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_mr_i(Reg dst_reg, uint16_t dst_offset, uint16_t op2_imm);
|
||||
Line s_mov16_mi_r(uint16_t dst_imm, Reg op2_reg);
|
||||
Line s_mov16_mi_i(uint16_t dst_imm, uint16_t op2_imm);
|
||||
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);
|
||||
|
64
asm/ctors.c
64
asm/ctors.c
@ -98,6 +98,39 @@ Line s_cmp_l(Reg op1_reg, int op2_label)
|
||||
.op2 = (Ex) { .label = op2_label },
|
||||
};
|
||||
}
|
||||
Line s_mov8_r_r(Reg dst_reg, Reg op2_reg)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov8_Reg_Reg,
|
||||
.dst = (Ex) { .reg = (uint16_t)dst_reg },
|
||||
.op2 = (Ex) { .reg = (uint16_t)op2_reg },
|
||||
};
|
||||
}
|
||||
Line s_mov8_r_i(Reg dst_reg, uint16_t op2_imm)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov8_Reg_Imm,
|
||||
.dst = (Ex) { .reg = (uint16_t)dst_reg },
|
||||
.op2 = (Ex) { .imm = op2_imm },
|
||||
};
|
||||
}
|
||||
Line s_mov8_r_mr(Reg dst_reg, Reg op2_reg, uint16_t op2_offset)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov8_Reg_MemReg,
|
||||
.dst = (Ex) { .reg = (uint16_t)dst_reg },
|
||||
.op2 = (Ex) { .reg = (uint16_t)op2_reg },
|
||||
.offset = op2_offset,
|
||||
};
|
||||
}
|
||||
Line s_mov8_r_mi(Reg dst_reg, uint16_t op2_imm)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov8_Reg_MemImm,
|
||||
.dst = (Ex) { .reg = (uint16_t)dst_reg },
|
||||
.op2 = (Ex) { .imm = op2_imm },
|
||||
};
|
||||
}
|
||||
Line s_mov8_mr_r(Reg dst_reg, Reg op2_reg)
|
||||
{
|
||||
return (Line) {
|
||||
@ -106,11 +139,11 @@ Line s_mov8_mr_r(Reg dst_reg, Reg op2_reg)
|
||||
.op2 = (Ex) { .reg = (uint16_t)op2_reg },
|
||||
};
|
||||
}
|
||||
Line s_mov8_mi_i(uint16_t dst_imm, uint16_t op2_imm)
|
||||
Line s_mov8_mr_i(Reg dst_reg, uint16_t op2_imm)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov8_MemImm_Imm,
|
||||
.dst = (Ex) { .imm = dst_imm },
|
||||
.ty = LineTy_Mov8_MemReg_Imm,
|
||||
.dst = (Ex) { .reg = (uint16_t)dst_reg },
|
||||
.op2 = (Ex) { .imm = op2_imm },
|
||||
};
|
||||
}
|
||||
@ -122,6 +155,14 @@ Line s_mov8_mi_r(uint16_t dst_imm, Reg op2_reg)
|
||||
.op2 = (Ex) { .reg = (uint16_t)op2_reg },
|
||||
};
|
||||
}
|
||||
Line s_mov8_mi_i(uint16_t dst_imm, uint16_t op2_imm)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov8_MemImm_Imm,
|
||||
.dst = (Ex) { .imm = dst_imm },
|
||||
.op2 = (Ex) { .imm = op2_imm },
|
||||
};
|
||||
}
|
||||
Line s_mov16_r_r(Reg dst_reg, Reg op2_reg)
|
||||
{
|
||||
return (Line) {
|
||||
@ -180,6 +221,15 @@ Line s_mov16_mr_r(Reg dst_reg, uint16_t dst_offset, Reg op2_reg)
|
||||
.offset = dst_offset,
|
||||
};
|
||||
}
|
||||
Line s_mov16_mr_i(Reg dst_reg, uint16_t dst_offset, uint16_t op2_imm)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov16_MemReg_Imm,
|
||||
.dst = (Ex) { .reg = (uint16_t)dst_reg },
|
||||
.op2 = (Ex) { .imm = op2_imm },
|
||||
.offset = dst_offset,
|
||||
};
|
||||
}
|
||||
Line s_mov16_mi_r(uint16_t dst_imm, Reg op2_reg)
|
||||
{
|
||||
return (Line) {
|
||||
@ -188,6 +238,14 @@ Line s_mov16_mi_r(uint16_t dst_imm, Reg op2_reg)
|
||||
.op2 = (Ex) { .reg = (uint16_t)op2_reg },
|
||||
};
|
||||
}
|
||||
Line s_mov16_mi_i(uint16_t dst_imm, uint16_t op2_imm)
|
||||
{
|
||||
return (Line) {
|
||||
.ty = LineTy_Mov16_MemImm_Imm,
|
||||
.dst = (Ex) { .imm = dst_imm },
|
||||
.op2 = (Ex) { .imm = op2_imm },
|
||||
};
|
||||
}
|
||||
Line s_mov16_ml_r(int dst_label, Reg op2_reg)
|
||||
{
|
||||
return (Line) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user