【发布时间】:2016-09-11 02:10:04
【问题描述】:
我正在阅读 RISC-V 测试模式的源代码。 并且在riscv-test.h中有一个宏定义,
我想知道1:在这段代码中是什么意思:
#define RVTEST_CODE_BEGIN \
.section .text.init; \
.align 6; \
.weak stvec_handler; \
.weak mtvec_handler; \
.globl _start; \
_start: \
/* reset vector */ \
j reset_vector; \
.align 2; \
trap_vector: \
/* test whether the test came from pass/fail */ \
csrr t5, mcause; \
li t6, CAUSE_USER_ECALL; \
beq t5, t6, write_tohost; \
li t6, CAUSE_SUPERVISOR_ECALL; \
beq t5, t6, write_tohost; \
li t6, CAUSE_MACHINE_ECALL; \
beq t5, t6, write_tohost; \
/* if an mtvec_handler is defined, jump to it */ \
la t5, mtvec_handler; \
beqz t5, 1f; \
jr t5; \
/* was it an interrupt or an exception? */ \
1: csrr t5, mcause; \
bgez t5, handle_exception; \
INTERRUPT_HANDLER; \
【问题讨论】:
-
我已经有一段时间没有写任何 asm 代码了,但是 1: 对我来说确实像是一个标签。
-
具体是本地标签。你可以在这里阅读更多关于它们的信息:sourceware.org/binutils/docs-2.24/as/…
标签: assembly gnu-assembler riscv