提交 4cc6b82f 编写于 作者: Z Zihao Yu

mips32: pass litenes

上级 b36805eb
......@@ -27,6 +27,7 @@ make_EHelper(mfhi);
make_EHelper(mflo);
make_EHelper(mul);
make_EHelper(mult);
make_EHelper(multu);
make_EHelper(div);
make_EHelper(divu);
......@@ -38,6 +39,8 @@ make_EHelper(bne);
make_EHelper(beq);
make_EHelper(blez);
make_EHelper(bltz);
make_EHelper(bgtz);
make_EHelper(bgez);
make_EHelper(inv);
make_EHelper(nemu_trap);
......@@ -52,3 +52,16 @@ make_EHelper(bltz) {
print_asm_template3(bltz);
}
make_EHelper(bgtz) {
rtl_jrelop(RELOP_GT, &id_src->val, &id_src2->val, decinfo.jmp_pc);
print_asm_template3(blez);
}
make_EHelper(bgez) {
rtl_li(&t0, 0);
rtl_jrelop(RELOP_GE, &id_src->val, &t0, decinfo.jmp_pc);
print_asm_template3(bltz);
}
......@@ -5,7 +5,7 @@ static OpcodeEntry special_table [64] = {
/* b000 */ IDEX(shift, sll), EMPTY, IDEX(shift, srl), IDEX(shift, sra), IDEX(R, sll), EMPTY, IDEX(R, srl), IDEX(R, sra),
/* b001 */ IDEX(R, jr), IDEX(R, jalr), IDEX(cmov, movz), IDEX(cmov, movn), EMPTY, EMPTY, EMPTY, EMPTY,
/* b010 */ IDEX(R, mfhi), EMPTY, IDEX(R, mflo), EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
/* b011 */ IDEX(R, mult), EMPTY, IDEX(R, div), IDEX(R, divu), EMPTY, EMPTY, EMPTY, EMPTY,
/* b011 */ IDEX(R, mult), IDEX(R, multu), IDEX(R, div), IDEX(R, divu), EMPTY, EMPTY, EMPTY, EMPTY,
/* b100 */ EMPTY, IDEX(R, add), EMPTY, IDEX(R, sub), IDEX(R, and), IDEX(R, or), IDEX(R, xor), IDEX(R, nor),
/* b101 */ EMPTY, EMPTY, IDEX(R, slt), IDEX(R, sltu), EMPTY, EMPTY, EMPTY, EMPTY,
/* b110 */ EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
......@@ -32,7 +32,7 @@ static make_EHelper(special2) {
}
static OpcodeEntry regimm_table [32] = {
/* b00 */ IDEX(B, bltz), EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
/* b00 */ IDEX(B, bltz), IDEX(B, bgez), EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
/* b01 */ EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
/* b10 */ EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
/* b11 */ EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
......@@ -43,7 +43,7 @@ static make_EHelper(regimm) {
}
static OpcodeEntry opcode_table [64] = {
/* b000 */ EX(special), EX(regimm), IDEX(J, j), IDEX(J, jal), IDEX(B, beq), IDEX(B, bne), IDEX(B, blez), EMPTY,
/* b000 */ EX(special), EX(regimm), IDEX(J, j), IDEX(J, jal), IDEX(B, beq), IDEX(B, bne), IDEX(B, blez), IDEX(B, bgtz),
/* b001 */ EMPTY, IDEX(I, add), IDEX(I, slt), IDEX(I, sltu), IDEX(IU, and), IDEX(IU, or), IDEX(IU, xor), IDEX(I, lui),
/* b010 */ EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
/* b011 */ EMPTY, EMPTY, EMPTY, EMPTY, EX(special2), EMPTY, EMPTY, EMPTY,
......
......@@ -53,8 +53,6 @@ make_EHelper(swl) {
// write back
rtl_sm(&t0, &t1, 4);
Log("addr = 0x%08x, val = 0x%08x", t0, t1);
print_asm_template3(swl);
}
......@@ -85,8 +83,6 @@ make_EHelper(swr) {
// write back
rtl_sm(&t0, &t1, 4);
Log("addr = 0x%08x, val = 0x%08x", t0, t1);
print_asm_template3(swr);
}
......@@ -118,8 +114,6 @@ make_EHelper(lwl) {
// write back
rtl_sr(id_dest->reg, &id_dest->val, 4);
Log("val = 0x%08x", id_dest->val);
print_asm_template3(lwl);
}
......@@ -133,7 +127,6 @@ make_EHelper(lwr) {
// load the aligned memory word
rtl_andi(&t0, &t0, ~0x3u);
rtl_lm(&t1, &t0, 4);
Log("addr = 0x%08x, mem = 0x%08x", t0, t1);
// prepare memory data
rtl_shr(&t1, &t1, &t3);
......@@ -146,15 +139,11 @@ make_EHelper(lwr) {
// prepare register data
rtl_and(&id_dest->val, &id_dest->val, &t2);
Log("mem = 0x%08x, reg = 0x%08x", t1, id_dest->val);
// merge the word
rtl_or(&id_dest->val, &id_dest->val, &t1);
// write back
rtl_sr(id_dest->reg, &id_dest->val, 4);
Log("val = 0x%08x", id_dest->val);
print_asm_template3(lwr);
}
......@@ -26,6 +26,13 @@ make_EHelper(mult) {
print_asm_template3(mult);
}
make_EHelper(multu) {
rtl_mul_lo(&cpu.lo, &id_src->val, &id_src2->val);
rtl_mul_hi(&cpu.hi, &id_src->val, &id_src2->val);
print_asm_template3(multu);
}
make_EHelper(div) {
rtl_idiv_q(&cpu.lo, &id_src->val, &id_src2->val);
rtl_idiv_r(&cpu.hi, &id_src->val, &id_src2->val);
......
......@@ -4,11 +4,12 @@
#include "cpu/rtl.h"
static inline void rtl_lr(rtlreg_t* dest, int r, int width) {
rtl_mv(dest, &reg_l(r));
if (r != 0) { rtl_mv(dest, &reg_l(r)); }
else { rtl_li(dest, 0); }
}
static inline void rtl_sr(int r, const rtlreg_t *src1, int width) {
rtl_mv(&reg_l(r), src1);
if (r != 0) { rtl_mv(&reg_l(r), src1); }
}
#endif
#include "common.h"
#include "device/map.h"
#define NR_MAP 4
#define NR_MAP 8
static IOMap maps[NR_MAP];
static int nr_map = 0;
......
......@@ -3,6 +3,7 @@
#include <SDL2/SDL.h>
#define I8042_DATA_PORT 0x60
#define I8042_DATA_MMIO 0x4060
#define KEYBOARD_IRQ 1
static uint32_t *i8042_data_port_base;
......@@ -59,6 +60,7 @@ static void i8042_data_io_handler(uint32_t offset, int len, bool is_write) {
void init_i8042() {
i8042_data_port_base = (void *)new_space(4);
add_pio_map(I8042_DATA_PORT, (void *)i8042_data_port_base, 4, i8042_data_io_handler);
i8042_data_port_base[0] = _KEY_NONE;
add_pio_map(I8042_DATA_PORT, (void *)i8042_data_port_base, 4, i8042_data_io_handler);
add_mmio_map(I8042_DATA_MMIO, (void *)i8042_data_port_base, 4, i8042_data_io_handler);
}
......@@ -8,6 +8,7 @@
#define VMEM 0x40000
#define SCREEN_PORT 0x100 // Note that this is not the standard
#define SCREEN_MMIO 0x4100
#define SCREEN_H 300
#define SCREEN_W 400
......@@ -35,6 +36,7 @@ void init_vga() {
screensize_port_base = (void *)new_space(4);
*screensize_port_base = ((SCREEN_W) << 16) | (SCREEN_H);
add_pio_map(SCREEN_PORT, (void *)screensize_port_base, 4, NULL);
add_mmio_map(SCREEN_MMIO, (void *)screensize_port_base, 4, NULL);
vmem = (void *)new_space(0x80000);
add_mmio_map(VMEM, (void *)vmem, 0x80000, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册