aboutsummaryrefslogtreecommitdiff
path: root/libgloss/m32r/trap0.S
diff options
context:
space:
mode:
Diffstat (limited to 'libgloss/m32r/trap0.S')
-rw-r--r--libgloss/m32r/trap0.S16
1 files changed, 16 insertions, 0 deletions
diff --git a/libgloss/m32r/trap0.S b/libgloss/m32r/trap0.S
new file mode 100644
index 0000000..04efa13
--- /dev/null
+++ b/libgloss/m32r/trap0.S
@@ -0,0 +1,16 @@
+; Trap 0 handler (syscall interface).
+;
+; The trap handler returns the result in r0 and the error code (errno value)
+; in r2. r1 is reserved in case an 8 byte quantity ever needs to be
+; returned in registers.
+
+ .text
+ .global __trap0
+__trap0:
+ trap #0 ; trap 0 returns result in r0, error code in r2
+ cmpui r2,#1 ; is error code zero?
+ bc .Lret ; yes, skip setting errno
+ ld r4,@(sp) ; no, set errno
+ st r2,@r4
+.Lret:
+ jmp lr ; return to caller