Simple RISC-V Assembly Instructions Verification
(08-19-2020, 02:22 PM)bluewww Wrote: r0? Did you try x0? Also why would you move x0 to x0. x0 is always zero.

I think I noticed the problem, it was a simple thing, \n \t were missing, so maybe the console in Linux wasn't working.

I tried the following just a bunch of things, and the C test is now compiling,

asm volatile(
"lw     t0, 0(x2)\n\t"
"lw     t1, 4(x2)\n\t"
"sw     t1, 0(x2)\n\t"
"sw     t0, 4(x2)\n \t"
"add    t0, t1,    0x4\n \t"
"xor    t0, t1,    0x4\n \t"
"sb    t3, 0(a0)\n \t"
"add    x10, x10, x3\n \t"

But if try the following, it doesn't 'mov' and shows an error,

"mov    t3, 8(sp)\n \t"

Error: unrecognized opcode 'mov   t3, 8(sp)'

I am trying to maybe compare two register values or one register value to a stored variable value, and print either a pass or fail, so that I can verify the assembly instruction. I am trying to first print string the following way,

".LC0:        \n\t"
"    .string, pass\n\t"
"    .align, 2\n\t" 

But this shows : Error: junk at end of line, first unrecognized character is 'p'

I am still looking into the branch instructions of risc-v that are the C equivalent of if-else. Is there a simple way for the above verification that I mentioned?

Messages In This Thread
RE: Simple RISC-V Assembly Instructions Verification - by ufsahu - 08-21-2020, 05:46 AM

Forum Jump: