<commit_before>
import {Assembler} from '../src/Assembler';
import 'mocha';
import {assert} from "chai";
import {Lib} from "../src/Lib";
import {EXCEPTION_CODE} from "../src/CPU";
import {FunctionalCPU} from "../src/CPU/Functional";
import {Memory} from "../src/Memory";

let helloworld_code =`
# hello world program
# support .data and .text
.data
str: .asciiz "hello world!"
.text
# main program
main:
# support basic pseudo instruction
# including la, pushr, popr
la $s0, str
add $a0, $r0, $s0
pushr $ra
la $ra, main_ret
j convert
nop
main_ret:
# debug print, not true instruction
prints $s0
break
nop

# subroutine
# convert to upper case
# $a0 - address of the string
convert:
loop:
# get byte
lb $t0, 0($a0)
andi $t0, $t0, 0xff
beq $t0, $r0, conv_end
# check range
sltiu $t1, $t0, 97
bne $t1, $r0, conv_next
nop
addi $t1, $t0, -123
slti $t1, $t1, 0
beq $t1, $r0, conv_next
nop
# convert
addi $t0, $t0, -32
sb $t0, 0($a0)
conv_next:
addi $a0, $a0, 1
j loop
nop
conv_end:
lw $t0, 4($sp)
jr $ra
add $ra, $r0, $t0 # delay slot
nop
break
`;

describe("Functional CPU Testing",function () {
    it("hello world testing",function () {
        let assembler = new Assembler();
        let mem = new Memory();
        let cpu = new FunctionalCPU(mem);
        let exCode = EXCEPTION_CODE;
        registerEvents(cpu);
        let assembleres = assembler.assemble(helloworld_code);
        mem.importAsm(assembleres);
        cpu.reset();
        console.log(assembleres);
        Runcpu(cpu,exCode);
    });

});<commit_msg>add srl to the unit test<commit_after>
import {Assembler} from '../src/Assembler';
import 'mocha';
import {assert} from "chai";
import {Lib} from "../src/Lib";
import {EXCEPTION_CODE} from "../src/CPU";
import {FunctionalCPU} from "../src/CPU/Functional";
import {Memory} from "../src/Memory";

let helloworld_code =`
# hello world program
# support .data and .text
.data
str: .asciiz "hello world!"
.text
# main program
main:
# support basic pseudo instruction
# including la, pushr, popr
la $s0, str
add $a0, $r0, $s0
pushr $ra
la $ra, main_ret
j convert
nop
main_ret:
# debug print, not true instruction
prints $s0
break
nop

# subroutine
# convert to upper case
# $a0 - address of the string
convert:
loop:
# get byte
lb $t0, 0($a0)
andi $t0, $t0, 0xff
beq $t0, $r0, conv_end
# check range
sltiu $t1, $t0, 97
bne $t1, $r0, conv_next
nop
addi $t1, $t0, -123
slti $t1, $t1, 0
beq $t1, $r0, conv_next
nop
# convert
addi $t0, $t0, -32
sb $t0, 0($a0)
conv_next:
addi $a0, $a0, 1
j loop
nop
conv_end:
lw $t0, 4($sp)
jr $ra
add $ra, $r0, $t0 # delay slot
nop
srl $ra,$r0,4
break
`;

describe("Functional CPU Testing",function () {
    it("hello world testing",function () {
        let assembler = new Assembler();
        let mem = new Memory();
        let cpu = new FunctionalCPU(mem);
        let exCode = EXCEPTION_CODE;
        registerEvents(cpu);
        let assembleres = assembler.assemble(helloworld_code);
        mem.importAsm(assembleres);
        cpu.reset();
        console.log(assembleres);
        Runcpu(cpu,exCode);
    });

});
{'fraction_non_alphanumeric': 0.14607107923051843, 'fraction_numerical': 0.029344636452559504, 'mean_word_length': 3.498533724340176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2944053', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1184, 'n_words': 379}