riscv-non-isa / riscv-asm-manual

RISC-V Assembly Programmer's Manual
https://jira.riscv.org/browse/RVG-4
Creative Commons Attribution 4.0 International
1.44k stars 238 forks source link

unrecognized opcode `ld a1,a0' #48

Closed quantrpeter closed 4 years ago

quantrpeter commented 4 years ago

Hi When compile

.equ RTC_BASE,      0x40000000
.equ TIMER_BASE,    0x40004000

# setup machine trap vector
1:      auipc   t0, %pcrel_hi(mtvec)        # load mtvec(hi)
        addi    t0, t0, %pcrel_lo(1b)       # load mtvec(lo)
        csrrw   zero, mtvec, t0

# set mstatus.MIE=1 (enable M mode interrupt)
        li      t0, 8
        csrrs   zero, mstatus, t0

# set mie.MTIE=1 (enable M mode timer interrupts)
        li      t0, 128
        csrrs   zero, mie, t0

# read from mtime
        li      a0, RTC_BASE
        ld      a1, 0(a0)

# write to mtimecmp
        li      a0, TIMER_BASE
        li      t0, 1000000000
        add     a1, a1, t0
        sd      a1, 0(a0)

# loop
loop:
        wfi
        j loop

# break on interrupt
mtvec:
        csrrc  t0, mcause, zero
        bgez t0, fail       # interrupt causes are less than zero
        slli t0, t0, 1      # shift off high bit
        srli t0, t0, 1
        li t1, 7            # check this is an m_timer interrupt
        bne t0, t1, fail
        j pass

pass:
        la a0, pass_msg
        jal puts
        j shutdown

fail:
        la a0, fail_msg
        jal puts
        j shutdown

.section .rodata

pass_msg:
        .string "PASS\n"

fail_msg:
        .string "FAIL\n"

I got:

riscv-none-embed-as -march=rv32imac -mabi=ilp32 a.s -o a.o
a.s: Assembler messages:
a.s: Warning: end of file not at end of a line; newline inserted
a.s:19: Error: unrecognized opcode `ld a1,a0'
a.s:25: Error: unrecognized opcode `sd a1,0(a0)'
make: *** [a.elf] Error 1

Please help Thanks

kito-cheng commented 4 years ago

ld and sd are load/store double word, which require RV64, the error message is little confused I know :P

quantrpeter commented 4 years ago

Thank Kito, you are chinese? china / hong kong / tai wan?

kito-cheng commented 4 years ago

@quantrpeter Yeah, I am Taiwanese, in case you have question which is hard to describe in English you can written in Chinese :P