test.asm (1384B)
1 ;; 2 ;; Test source file for RISC-V IM 32 bits implementation at EGG. 3 ;; 4 ;; This implements all instructions with arguments that allows correctness 5 ;; checking in the assembler (endianess, etc) by comparison with a known-correct 6 ;; assembler. 7 ;; 8 ;; The assembly file with RARS syntax is at test-rars.asm. 9 ;; 10 _start: 11 ;; Arithmetic instructions. 12 add 3, 5, 7 13 sub 3, 5, 7 14 xor 3, 5, 7 15 or 3, 5, 7 16 and 3, 5, 7 17 sll 3, 5, 7 18 srl 3, 5, 7 19 sra 3, 5, 7 20 slt 3, 5, 7 21 sltu 3, 5, 7 22 23 ;; Arithmetic immediate instructions. 24 addi 3, 5, 42 25 xori 3, 5, 42 26 ori 3, 5, 42 27 andi 3, 5, 42 28 slli 3, 5, 3 29 srli 3, 5, 3 30 srai 3, 5, 3 31 slti 3, 5, 42 32 sltiu 3, 5, 42 33 34 ;; Load instructions. 35 lb 3, 5, 42 36 lh 3, 5, 42 37 lw 3, 5, 42 38 lbu 3, 5, 42 39 lhu 3, 5, 42 40 41 ;; Store instructions. 42 sb 5, 3, 3 43 sh 5, 3, 3 44 sw 5, 3, 3 45 sb 5, 3, -3 46 sh 5, 3, -3 47 sw 5, 3, -3 48 49 ;; Branch instructions. 50 beq 3, 5, end 51 bne 3, 5, end 52 blt 3, 5, end 53 bge 3, 5, end 54 bltu 3, 5, end 55 bgeu 3, 5, end 56 beq 3, 5, _start 57 bne 3, 5, _start 58 blt 3, 5, _start 59 bge 3, 5, _start 60 bltu 3, 5, _start 61 bgeu 3, 5, _start 62 63 ;; Jump instructions. 64 jal 3, end 65 jal 3, _start 66 jalr 3, 5, 3 67 jalr 3, 5, -3 68 69 ;; UI instructions. 70 lui 3, 5 71 auipc 3, 5 72 lui 3, -5 73 auipc 3, -5 74 75 ;; Calls 76 ecall 77 ebreak 78 79 ;; Multiplication extension. 80 mul 3, 5, 7 81 mulh 3, 5, 7 82 mulsu 3, 5, 7 83 mulu 3, 5, 7 84 div 3, 5, 7 85 divu 3, 5, 7 86 rem 3, 5, 7 87 remu 3, 5, 7 88 end: