Fix instructions tests
This commit is contained in:
parent
5000c28b97
commit
c862c42e43
@ -349,11 +349,11 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_op() {
|
fn test_op() {
|
||||||
let sub = Instruction::new(0b0100000_10000_10001_000_11100_0110011);
|
let sub = Instruction::new(0b0100000_10000_10001_000_11100_0110011_u64.to_le());
|
||||||
let add = Instruction::new(0b0000000_10000_10001_000_11100_0110011);
|
let add = Instruction::new(0b0000000_10000_10001_000_11100_0110011_u64.to_le());
|
||||||
let xor = Instruction::new(0b0000000_10000_10001_100_11100_0110011);
|
let xor = Instruction::new(0b0000000_10000_10001_100_11100_0110011_u64.to_le());
|
||||||
let slr = Instruction::new(0b0000000_10000_10001_101_11100_0110011);
|
let slr = Instruction::new(0b0000000_10000_10001_101_11100_0110011_u64.to_le());
|
||||||
let sra = Instruction::new(0b0100000_10000_10001_101_11100_0110011);
|
let sra = Instruction::new(0b0100000_10000_10001_101_11100_0110011_u64.to_le());
|
||||||
|
|
||||||
assert_eq!("sub\tt3,a7,a6", instruction_debug(&sub, 0));
|
assert_eq!("sub\tt3,a7,a6", instruction_debug(&sub, 0));
|
||||||
assert_eq!("xor\tt3,a7,a6", instruction_debug(&xor, 0));
|
assert_eq!("xor\tt3,a7,a6", instruction_debug(&xor, 0));
|
||||||
@ -365,13 +365,13 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_opi() {
|
fn test_opi() {
|
||||||
let addi = Instruction::new(0b0000000000_10001_000_11100_0010011);
|
let addi = Instruction::new(0b0000000000_10001_000_11100_0010011_u64.to_le());
|
||||||
let slli = Instruction::new(0b0000000000_10001_001_11100_0010011);
|
let slli = Instruction::new(0b0000000000_10001_001_11100_0010011_u64.to_le());
|
||||||
let slti = Instruction::new(0b0000000000_10001_010_11100_0010011);
|
let slti = Instruction::new(0b0000000000_10001_010_11100_0010011_u64.to_le());
|
||||||
let sltiu = Instruction::new(0b0000000000_10001_011_11100_0010011);
|
let sltiu = Instruction::new(0b0000000000_10001_011_11100_0010011_u64.to_le());
|
||||||
let xori = Instruction::new(0b_0000000000010001_100_11100_0010011);
|
let xori = Instruction::new(0b_0000000000010001_100_11100_0010011_u64.to_le());
|
||||||
let ori = Instruction::new(0b00000000000_10001_110_11100_0010011);
|
let ori = Instruction::new(0b00000000000_10001_110_11100_0010011_u64.to_le());
|
||||||
let andi = Instruction::new(0b000000000000_10001_111_11100_0010011);
|
let andi = Instruction::new(0b000000000000_10001_111_11100_0010011_u64.to_le());
|
||||||
assert_eq!("andi\tt3,a7,0", instruction_debug(&andi, 0));
|
assert_eq!("andi\tt3,a7,0", instruction_debug(&andi, 0));
|
||||||
assert_eq!("addi\tt3,a7,0", instruction_debug(&addi, 0));
|
assert_eq!("addi\tt3,a7,0", instruction_debug(&addi, 0));
|
||||||
assert_eq!("slli\tt3,a7,0", instruction_debug(&slli, 0));
|
assert_eq!("slli\tt3,a7,0", instruction_debug(&slli, 0));
|
||||||
@ -383,8 +383,8 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lui() {
|
fn test_lui() {
|
||||||
let lui = Instruction::new(0b01110001000011111000_11100_0110111);
|
let lui = Instruction::new(0b01110001000011111000_11100_0110111_u64.to_le());
|
||||||
let lui_negatif = Instruction::new(0b11110001000011111000_11100_0110111);
|
let lui_negatif = Instruction::new(0b11110001000011111000_11100_0110111_u64.to_le());
|
||||||
assert_eq!("lui\tt3,710f8000", instruction_debug(&lui, 0));
|
assert_eq!("lui\tt3,710f8000", instruction_debug(&lui, 0));
|
||||||
assert_eq!("lui\tt3,f10f8000", instruction_debug(&lui_negatif, 0));
|
assert_eq!("lui\tt3,f10f8000", instruction_debug(&lui_negatif, 0));
|
||||||
}
|
}
|
||||||
@ -392,13 +392,13 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_ld() {
|
fn test_ld() {
|
||||||
// imm rs1 f3 rd opcode
|
// imm rs1 f3 rd opcode
|
||||||
let lb = Instruction::new(0b010111110000_10001_000_11100_0000011);
|
let lb = Instruction::new(0b010111110000_10001_000_11100_0000011_u64.to_le());
|
||||||
let lh = Instruction::new(0b010111110000_10001_001_11100_0000011);
|
let lh = Instruction::new(0b010111110000_10001_001_11100_0000011_u64.to_le());
|
||||||
let lw = Instruction::new(0b010111110000_10001_010_11100_0000011);
|
let lw = Instruction::new(0b010111110000_10001_010_11100_0000011_u64.to_le());
|
||||||
let lbu = Instruction::new(0b010111110000_10001_100_11100_0000011);
|
let lbu = Instruction::new(0b010111110000_10001_100_11100_0000011_u64.to_le());
|
||||||
let lhu = Instruction::new(0b010111110000_10001_101_11100_0000011);
|
let lhu = Instruction::new(0b010111110000_10001_101_11100_0000011_u64.to_le());
|
||||||
let ld = Instruction::new(0b010111110000_10001_011_11100_0000011);
|
let ld = Instruction::new(0b010111110000_10001_011_11100_0000011_u64.to_le());
|
||||||
let lwu = Instruction::new(0b010111110000_10001_110_11100_0000011);
|
let lwu = Instruction::new(0b010111110000_10001_110_11100_0000011_u64.to_le());
|
||||||
|
|
||||||
assert_eq!("lb\tt3,1520(a7)", instruction_debug(&lb, 0));
|
assert_eq!("lb\tt3,1520(a7)", instruction_debug(&lb, 0));
|
||||||
assert_eq!("lh\tt3,1520(a7)", instruction_debug(&lh, 0));
|
assert_eq!("lh\tt3,1520(a7)", instruction_debug(&lh, 0));
|
||||||
@ -411,10 +411,10 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_opw() {
|
fn test_opw() {
|
||||||
let addw: Instruction = Instruction::new(0b0000000_10000_10001_000_11100_0111011);
|
let addw: Instruction = Instruction::new(0b0000000_10000_10001_000_11100_0111011_u64.to_le());
|
||||||
let sllw: Instruction = Instruction::new(0b0000000_10000_10001_001_11100_0111011);
|
let sllw: Instruction = Instruction::new(0b0000000_10000_10001_001_11100_0111011_u64.to_le());
|
||||||
let srlw: Instruction = Instruction::new(0b0000000_10000_10001_101_11100_0111011);
|
let srlw: Instruction = Instruction::new(0b0000000_10000_10001_101_11100_0111011_u64.to_le());
|
||||||
let sraw: Instruction = Instruction::new(0b0100000_10000_10001_101_11100_0111011);
|
let sraw: Instruction = Instruction::new(0b0100000_10000_10001_101_11100_0111011_u64.to_le());
|
||||||
|
|
||||||
assert_eq!("addw\tt3,a7,a6", instruction_debug(&addw, 0));
|
assert_eq!("addw\tt3,a7,a6", instruction_debug(&addw, 0));
|
||||||
assert_eq!("sllw\tt3,a7,a6", instruction_debug(&sllw, 0));
|
assert_eq!("sllw\tt3,a7,a6", instruction_debug(&sllw, 0));
|
||||||
@ -424,9 +424,9 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_opwi() {
|
fn test_opwi() {
|
||||||
let addiw: Instruction =Instruction::new(0b000000000000_10001_000_11100_0011011);
|
let addiw: Instruction =Instruction::new(0b000000000000_10001_000_11100_0011011_u64.to_le());
|
||||||
let slliw: Instruction = Instruction::new(0b0000000_10000_10001_001_11100_0011011);
|
let slliw: Instruction = Instruction::new(0b0000000_10000_10001_001_11100_0011011_u64.to_le());
|
||||||
let srai: Instruction = Instruction::new(0b010000010001_10001_101_11100_0010011);
|
let srai: Instruction = Instruction::new(0b010000010001_10001_101_11100_0010011_u64.to_le());
|
||||||
assert_eq!("addiw\tt3,a7,0x0", instruction_debug(&addiw, 0));
|
assert_eq!("addiw\tt3,a7,0x0", instruction_debug(&addiw, 0));
|
||||||
assert_eq!("slliw\tt3,a7,0x10", instruction_debug(&slliw, 0));
|
assert_eq!("slliw\tt3,a7,0x10", instruction_debug(&slliw, 0));
|
||||||
assert_eq!("srai\tt3,a7,17", instruction_debug(&srai, 0));
|
assert_eq!("srai\tt3,a7,17", instruction_debug(&srai, 0));
|
||||||
@ -435,13 +435,13 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_br() {
|
fn test_br() {
|
||||||
let beq: Instruction = Instruction::new(0b0000000_10000_10001_000_00000_1100011);
|
let beq: Instruction = Instruction::new(0b0000000_10000_10001_000_00000_1100011_u64.to_le());
|
||||||
let bne: Instruction = Instruction::new(0b0000000_10000_10001_001_00000_1100011);
|
let bne: Instruction = Instruction::new(0b0000000_10000_10001_001_00000_1100011_u64.to_le());
|
||||||
let blt: Instruction = Instruction::new(0b0000000_10000_10001_100_00000_1100011);
|
let blt: Instruction = Instruction::new(0b0000000_10000_10001_100_00000_1100011_u64.to_le());
|
||||||
let bge: Instruction = Instruction::new(0b0000000_10000_10001_101_00000_1100011);
|
let bge: Instruction = Instruction::new(0b0000000_10000_10001_101_00000_1100011_u64.to_le());
|
||||||
let bge2: Instruction = Instruction::new(0x00f75863);
|
let bge2: Instruction = Instruction::new(0x00f75863_u64.to_le());
|
||||||
let bltu: Instruction = Instruction::new(0b0000000_10000_10001_110_00000_1100011);
|
let bltu: Instruction = Instruction::new(0b0000000_10000_10001_110_00000_1100011_u64.to_le());
|
||||||
let bgeu: Instruction = Instruction::new(0b0000000_10000_10001_111_00000_1100011);
|
let bgeu: Instruction = Instruction::new(0b0000000_10000_10001_111_00000_1100011_u64.to_le());
|
||||||
assert_eq!("blt\ta7,a6,0", instruction_debug(&blt, 0));
|
assert_eq!("blt\ta7,a6,0", instruction_debug(&blt, 0));
|
||||||
assert_eq!("bge\ta7,a6,0", instruction_debug(&bge, 0));
|
assert_eq!("bge\ta7,a6,0", instruction_debug(&bge, 0));
|
||||||
assert_eq!("bge\ta4,a5,104d4", instruction_debug(&bge2, 0x104c4));
|
assert_eq!("bge\ta4,a5,104d4", instruction_debug(&bge2, 0x104c4));
|
||||||
@ -461,72 +461,72 @@ mod test {
|
|||||||
a = a + b;
|
a = a + b;
|
||||||
b = a - b;
|
b = a - b;
|
||||||
*/
|
*/
|
||||||
assert_eq!("addi sp,sp,-32", instruction_debug(&Instruction::new(0xfe010113), 0));
|
assert_eq!("addi sp,sp,-32", instruction_debug(&Instruction::new(0xfe010113_u64.to_le()), 0));
|
||||||
assert_eq!("sd s0,24(sp)", instruction_debug(&Instruction::new(0x00813c23), 0));
|
assert_eq!("sd s0,24(sp)", instruction_debug(&Instruction::new(0x00813c23_u64.to_le()), 0));
|
||||||
assert_eq!("addi s0,sp,32", instruction_debug(&Instruction::new(0x02010413), 0));
|
assert_eq!("addi s0,sp,32", instruction_debug(&Instruction::new(0x02010413_u64.to_le()), 0));
|
||||||
assert_eq!("sw zero,-20(s0)", instruction_debug(&Instruction::new(0xfe042623), 0));
|
assert_eq!("sw zero,-20(s0)", instruction_debug(&Instruction::new(0xfe042623_u64.to_le()), 0));
|
||||||
assert_eq!("addi a5,zero,5", instruction_debug(&Instruction::new(0x00500793), 0));
|
assert_eq!("addi a5,zero,5", instruction_debug(&Instruction::new(0x00500793_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-24(s0)", instruction_debug(&Instruction::new(0xfef42423), 0));
|
assert_eq!("sw a5,-24(s0)", instruction_debug(&Instruction::new(0xfef42423_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783), 0));
|
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623), 0));
|
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783), 0));
|
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783_u64.to_le()), 0));
|
||||||
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713), 0));
|
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783), 0));
|
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783_u64.to_le()), 0));
|
||||||
assert_eq!("mulw a5,a4,a5", instruction_debug(&Instruction::new(0x02f707bb), 0));
|
assert_eq!("mulw a5,a4,a5", instruction_debug(&Instruction::new(0x02f707bb_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623), 0));
|
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783), 0));
|
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783_u64.to_le()), 0));
|
||||||
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713), 0));
|
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783), 0));
|
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783_u64.to_le()), 0));
|
||||||
assert_eq!("addw a5,a4,a5", instruction_debug(&Instruction::new(0x00f707bb), 0));
|
assert_eq!("addw a5,a4,a5", instruction_debug(&Instruction::new(0x00f707bb_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623), 0));
|
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783), 0));
|
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783_u64.to_le()), 0));
|
||||||
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713), 0));
|
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783), 0));
|
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783_u64.to_le()), 0));
|
||||||
assert_eq!("subw a5,a4,a5", instruction_debug(&Instruction::new(0x40f707bb), 0));
|
assert_eq!("subw a5,a4,a5", instruction_debug(&Instruction::new(0x40f707bb_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-24(s0)", instruction_debug(&Instruction::new(0xfef42423), 0));
|
assert_eq!("sw a5,-24(s0)", instruction_debug(&Instruction::new(0xfef42423_u64.to_le()), 0));
|
||||||
assert_eq!("addi a5,zero,0", instruction_debug(&Instruction::new(0x00000793), 0));
|
assert_eq!("addi a5,zero,0", instruction_debug(&Instruction::new(0x00000793_u64.to_le()), 0));
|
||||||
assert_eq!("addi a0,a5,0", instruction_debug(&Instruction::new(0x00078513), 0));
|
assert_eq!("addi a0,a5,0", instruction_debug(&Instruction::new(0x00078513_u64.to_le()), 0));
|
||||||
assert_eq!("ld s0,24(sp)", instruction_debug(&Instruction::new(0x01813403), 0));
|
assert_eq!("ld s0,24(sp)", instruction_debug(&Instruction::new(0x01813403_u64.to_le()), 0));
|
||||||
assert_eq!("addi sp,sp,32", instruction_debug(&Instruction::new(0x02010113), 0));
|
assert_eq!("addi sp,sp,32", instruction_debug(&Instruction::new(0x02010113_u64.to_le()), 0));
|
||||||
assert_eq!("jalr zero,0(ra)", instruction_debug(&Instruction::new(0x00008067), 0));
|
assert_eq!("jalr zero,0(ra)", instruction_debug(&Instruction::new(0x00008067_u64.to_le()), 0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fibo() {
|
fn test_fibo() {
|
||||||
assert_eq!("jal zero,10504", instruction_debug(&Instruction::new(0x0500006f), 0x104b4));
|
assert_eq!("jal zero,10504", instruction_debug(&Instruction::new(0x0500006f_u64.to_le()), 0x104b4));
|
||||||
assert_eq!("blt a4,a5,104b8", instruction_debug(&Instruction::new(0xfaf740e3), 0x10518));
|
assert_eq!("blt a4,a5,104b8", instruction_debug(&Instruction::new(0xfaf740e3_u64.to_le()), 0x10518));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mul_prog() {
|
fn test_mul_prog() {
|
||||||
assert_eq!("addi sp,sp,-32", instruction_debug(&Instruction::new(0xfe010113), 0));
|
assert_eq!("addi sp,sp,-32", instruction_debug(&Instruction::new(0xfe010113_u64.to_le()), 0));
|
||||||
assert_eq!("sd s0,24(sp)", instruction_debug(&Instruction::new(0x00813c23), 0));
|
assert_eq!("sd s0,24(sp)", instruction_debug(&Instruction::new(0x00813c23_u64.to_le()), 0));
|
||||||
assert_eq!("addi s0,sp,32", instruction_debug(&Instruction::new(0x02010413), 0));
|
assert_eq!("addi s0,sp,32", instruction_debug(&Instruction::new(0x02010413_u64.to_le()), 0));
|
||||||
assert_eq!("addi a5,zero,5", instruction_debug(&Instruction::new(0x00500793), 0));
|
assert_eq!("addi a5,zero,5", instruction_debug(&Instruction::new(0x00500793_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623), 0));
|
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783), 0));
|
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783_u64.to_le()), 0));
|
||||||
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713), 0));
|
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713_u64.to_le()), 0));
|
||||||
assert_eq!("addi a5,a4,0", instruction_debug(&Instruction::new(0x00070793), 0));
|
assert_eq!("addi a5,a4,0", instruction_debug(&Instruction::new(0x00070793_u64.to_le()), 0));
|
||||||
assert_eq!("slliw a5,a5,0x2", instruction_debug(&Instruction::new(0x0027979b), 0));
|
assert_eq!("slliw a5,a5,0x2", instruction_debug(&Instruction::new(0x0027979b_u64.to_le()), 0));
|
||||||
assert_eq!("addw a5,a5,a4", instruction_debug(&Instruction::new(0x00e787bb), 0));
|
assert_eq!("addw a5,a5,a4", instruction_debug(&Instruction::new(0x00e787bb_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-24(s0)", instruction_debug(&Instruction::new(0xfef42423), 0));
|
assert_eq!("sw a5,-24(s0)", instruction_debug(&Instruction::new(0xfef42423_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783), 0));
|
assert_eq!("lw a5,-20(s0)", instruction_debug(&Instruction::new(0xfec42783_u64.to_le()), 0));
|
||||||
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713), 0));
|
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783), 0));
|
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783_u64.to_le()), 0));
|
||||||
assert_eq!("mulw a5,a4,a5", instruction_debug(&Instruction::new(0x02f707bb), 0));
|
assert_eq!("mulw a5,a4,a5", instruction_debug(&Instruction::new(0x02f707bb_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-28(s0)", instruction_debug(&Instruction::new(0xfef42223), 0));
|
assert_eq!("sw a5,-28(s0)", instruction_debug(&Instruction::new(0xfef42223_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-28(s0)", instruction_debug(&Instruction::new(0xfe442783), 0));
|
assert_eq!("lw a5,-28(s0)", instruction_debug(&Instruction::new(0xfe442783_u64.to_le()), 0));
|
||||||
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713), 0));
|
assert_eq!("addi a4,a5,0", instruction_debug(&Instruction::new(0x00078713_u64.to_le()), 0));
|
||||||
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783), 0));
|
assert_eq!("lw a5,-24(s0)", instruction_debug(&Instruction::new(0xfe842783_u64.to_le()), 0));
|
||||||
assert_eq!("divw a5,a4,a5", instruction_debug(&Instruction::new(0x02f747bb), 0));
|
assert_eq!("divw a5,a4,a5", instruction_debug(&Instruction::new(0x02f747bb_u64.to_le()), 0));
|
||||||
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623), 0));
|
assert_eq!("sw a5,-20(s0)", instruction_debug(&Instruction::new(0xfef42623_u64.to_le()), 0));
|
||||||
assert_eq!("addi a5,zero,0", instruction_debug(&Instruction::new(0x00000793), 0));
|
assert_eq!("addi a5,zero,0", instruction_debug(&Instruction::new(0x00000793_u64.to_le()), 0));
|
||||||
assert_eq!("addi a0,a5,0", instruction_debug(&Instruction::new(0x00078513), 0));
|
assert_eq!("addi a0,a5,0", instruction_debug(&Instruction::new(0x00078513_u64.to_le()), 0));
|
||||||
assert_eq!("ld s0,24(sp)", instruction_debug(&Instruction::new(0x01813403), 0));
|
assert_eq!("ld s0,24(sp)", instruction_debug(&Instruction::new(0x01813403_u64.to_le()), 0));
|
||||||
assert_eq!("addi sp,sp,32", instruction_debug(&Instruction::new(0x02010113), 0));
|
assert_eq!("addi sp,sp,32", instruction_debug(&Instruction::new(0x02010113_u64.to_le()), 0));
|
||||||
assert_eq!("jalr zero,0(ra)", instruction_debug(&Instruction::new(0x00008067), 0));
|
assert_eq!("jalr zero,0(ra)", instruction_debug(&Instruction::new(0x00008067_u64.to_le()), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,9 +2,10 @@
|
|||||||
#include "userlib/libnachos.h"
|
#include "userlib/libnachos.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
n_printf("Hello World 1");
|
n_printf("Hello World 1\n");
|
||||||
n_printf("Hello World 2");
|
n_printf("Hello World 2\n");
|
||||||
n_printf("Hello World 3");
|
n_printf("Hello World 3\n");
|
||||||
n_printf("Hello World 4");
|
n_printf("Hello World 4\n");
|
||||||
|
Shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -9,20 +9,6 @@ int tab[3];
|
|||||||
SemId svide;
|
SemId svide;
|
||||||
SemId splein;
|
SemId splein;
|
||||||
|
|
||||||
void producteur();
|
|
||||||
|
|
||||||
void consommateur();
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
svide = SemCreate("producteur", N);
|
|
||||||
splein = SemCreate("consommateur", 0);
|
|
||||||
ThreadId producteurTh = threadCreate("producteur", producteur);
|
|
||||||
ThreadId consommateurTh = threadCreate("consommateur", consommateur);
|
|
||||||
Join(producteurTh);
|
|
||||||
Join(consommateurTh);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void producteur() {
|
void producteur() {
|
||||||
for(int i = 0; i < 10; i++)
|
for(int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
@ -46,3 +32,13 @@ void consommateur() {
|
|||||||
n_printf("exploiter l'information : %d\n", info);
|
n_printf("exploiter l'information : %d\n", info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
svide = SemCreate("producteur", N);
|
||||||
|
splein = SemCreate("consommateur", 0);
|
||||||
|
ThreadId producteurTh = threadCreate("producteur", producteur);
|
||||||
|
ThreadId consommateurTh = threadCreate("consommateur", consommateur);
|
||||||
|
Join(producteurTh);
|
||||||
|
Join(consommateurTh);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user