The OpenRISC 1000 no-operation instruction, l.nop
(32'h1500_0000
), can take an optional 16-bit
immediate parameter, which forms the least significant 16-bits of the
instruction word. This value is ignored by the CPU, but may be
monitored by test benches
In ORPSoC this is used to provide I/O and control functions for the C code running on the processor.
l.nop 1
(32'h1500_0001
). Terminates execution, with the
value in GPR 3 as return code. Thus the C library routine exit is
implemented as:
void exit (int i) { asm("l.add r3,r0,%0": : "r" (i)); asm("l.nop %0": :"K" (NOP_EXIT)); while (1); }
l.nop 2
(32'h1500_0002
). Provides a reporting
function. The value in GPR 3 is printed in hex.
l.nop 3
(32'h1500_0003
). Provides
printf
functionality, with the arguments
passed according to the OpenRISC 1000 Application Binary Interface
(ABI). Not currently implemented.
l.nop 4
(32'h1500_0004
). An Embecosm addition. The
least significant byte of GPR 3 is printed as a character. Thus
the C function putc
can be implemented as:
void putc(int value) { asm("l.addi\tr3,%0,0": :"r" (value)); asm("l.nop %0": :"K" (NOP_PUTC)); }
More complex library routines (to print strings, numbers etc) can then be built up from this.