6502: syscall return helper so we can set up errno correctly
authorAlan Cox <alan@linux.intel.com>
Fri, 16 Jan 2015 15:51:59 +0000 (15:51 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 16 Jan 2015 15:51:59 +0000 (15:51 +0000)
Library/libs/fuzix6502/syscall.s [new file with mode: 0644]

diff --git a/Library/libs/fuzix6502/syscall.s b/Library/libs/fuzix6502/syscall.s
new file mode 100644 (file)
index 0000000..53e3eab
--- /dev/null
@@ -0,0 +1,18 @@
+       .export __syscall
+       .import _errno
+
+.proc __syscall
+       jsr     callfe
+       bne     error
+       tya             ; x,a form the return code
+       rts
+error:
+       sta     _errno
+       ldx     #0
+       stx     _errno+1
+       dex     ;       Return $FFFF (-1)
+       txa
+       rts
+callfe:        jmp     ($fe)
+
+.endproc