egg

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 0139d5e9310633cc66ad450fbb05e631e1cb251a
parent 54dc5c0b9932fa2ce0ec4a59edfc9de204b8d0f6
Author: Gabriel G. de Brito <gabrielgbrito@icloud.com>
Date:   Thu, 21 Dec 2023 21:30:50 -0300

Added test Assembly files

Diffstat:
Ariscv/test-rars.asm | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mriscv/test.asm | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 142 insertions(+), 6 deletions(-)

diff --git a/riscv/test-rars.asm b/riscv/test-rars.asm @@ -0,0 +1,72 @@ +# +# Test source file with RARS syntax for RISC-V IM 32 bits implementation at +# EGG. +# + + # Arithmetic instructions. + add x3, x5, x7 + sub x3, x5, x7 + xor x3, x5, x7 + or x3, x5, x7 + and x3, x5, x7 + sll x3, x5, x7 + srl x3, x5, x7 + sra x3, x5, x7 + slt x3, x5, x7 + sltu x3, x5, x7 + + # Arithmetic immediate instructions. + addi x3, x5, 42 + xori x3, x5, 42 + ori x3, x5, 42 + andi x3, x5, 42 + slli x3, x5, 3 + srli x3, x5, 3 + srai x3, x5, 3 + slti x3, x5, 42 + sltiu x3, x5, 42 + + # Load instructions. + lb x3, 42(x5) + lh x3, 42(x5) + lw x3, 42(x5) + lbu x3, 42(x5) + lhu x3, 42(x5) + + # Store instructions. + sb x3, 3(x5) + sh x3, 3(x5) + sw x3, 3(x5) + sb x3, -3(x5) + sh x3, -3(x5) + sw x3, -3(x5) + + # Branch instructions. + beq x3, x5, 3 + bne x3, x5, 3 + blt x3, x5, 3 + bge x3, x5, 3 + bltu x3, x5, 3 + bgeu x3, x5, 3 + beq x3, x5, 3 + bne x3, x5, -3 + blt x3, x5, -3 + bge x3, x5, -3 + bltu x3, x5, -3 + bgeu x3, x5, -3 + + # Jump instructions. + jal x3, 5 + jal x3, -5 + jalr x3, x5, 7 + jalr x3, x5, -7 + + # UI instructions. + lui x3, 5 + auipc x3, 5 + lui x3, -5 + auipc x3, -5 + + # Calls + ecall + ebreak diff --git a/riscv/test.asm b/riscv/test.asm @@ -1,13 +1,77 @@ ;; ;; Test source file for RISC-V IM 32 bits implementation at EGG. ;; +;; This implements all instructions with arguments that allows correctness +;; checking in the assembler (endianess, etc) by comparison with a known-correct +;; assembler. +;; +;; The assembly file with RARS syntax is at test-rars.asm. +;; + + ;; Arithmetic instructions. + add 3, 5, 7 + sub 3, 5, 7 + xor 3, 5, 7 + or 3, 5, 7 + and 3, 5, 7 + sll 3, 5, 7 + srl 3, 5, 7 + sra 3, 5, 7 + slt 3, 5, 7 + sltu 3, 5, 7 + + ;; Arithmetic immediate instructions. + addi 3, 5, 42 + xori 3, 5, 42 + ori 3, 5, 42 + andi 3, 5, 42 + slli 3, 5, 3 + srli 3, 5, 3 + srai 3, 5, 3 + slti 3, 5, 42 + sltiu 3, 5, 42 + + ;; Load instructions. + lb 3, 5, 42 + lh 3, 5, 42 + lw 3, 5, 42 + lbu 3, 5, 42 + lhu 3, 5, 42 + + ;; Store instructions. + sb 3, 5, 3 + sh 3, 5, 3 + sw 3, 5, 3 + sb 3, 5, -3 + sh 3, 5, -3 + sw 3, 5, -3 + + ;; Branch instructions. + beq 3, 5, 3 + bne 3, 5, 3 + blt 3, 5, 3 + bge 3, 5, 3 + bltu 3, 5, 3 + bgeu 3, 5, 3 + beq 3, 5, -3 + bne 3, 5, -3 + blt 3, 5, -3 + bge 3, 5, -3 + bltu 3, 5, -3 + bgeu 3, 5, -3 -_start: - addi t1, zero, 5 - addi t2, zero, 1 + ;; Jump instructions. + jal 3, 5 + jal 3, -5 + jalr 3, 5, 7 + jalr 3, 5, -7 -test: ;; This is a loop. - sub t1, t1, t2 - bne t1, zero, test ;; Go out of the loop when tq = 0. + ;; UI instructions. + lui 3, 5 + auipc 3, 5 + lui 3, -5 + auipc 3, -5 + ;; Calls + ecall ebreak