Rodolfo Azevedo
MC404 - Organização Básica de Computadores e Linguagem de Montagem
http://www.ic.unicamp.br/~rodolfo/mc404
lw
sw
in
out
ecall
As rotinas de tratamento são similares, focaremos em interrupções
switch
x1
x31
pc
csrr
csrw
csrrw
mtvec
mepc
mcause
mtval
mscratch
sp
#include <stdio.h> int main() { puts("Hello World!\n"); }
compilado com:
$ riscv64-linux-gnu-gcc hello.c -S hello.s
.file "hello.c" .option pic .attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0" .attribute unaligned_access, 0 .attribute stack_align, 16 .text .section .rodata .align 3 .LC0: .string "Hello World!\n" .text .align 1 .globl main .type main, @function main: addi sp,sp,-16 sd ra,8(sp) sd s0,0(sp) addi s0,sp,16 lla a0,.LC0 call puts@plt li a5,0 mv a0,a5 ld ra,8(sp) ld s0,0(sp) addi sp,sp,16 jr ra .size main, .-main .ident "GCC: (Ubuntu 12.2.0-14ubuntu2) 12.2.0" .section .note.GNU-stack,"",@progbits