llvm-mos-sdk
kernel.h
Go to the documentation of this file.
1 // Copyright 2024 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 
6 #ifndef _KERNEL_H
7 #define _KERNEL_H
8 
9 #include <neo6502.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
20 #define KWriteCharacterInline(c) \
21  __attribute__((leaf)) asm volatile("jsr 0xFFF5\n.byte %0\n" : : "i"(c) : "p")
22 
28 __attribute__((leaf))
29 static inline void KReadLine(char *s) {
30  uint8_t sl = (uint16_t) s;
31  uint8_t sh = ((uint16_t) s) >> 8;
32  __attribute__((leaf)) asm volatile("jsr 0xFFEB" : : "x"(sl), "y"(sh) : "p");
33 }
34 
40 __attribute__((leaf))
41 static inline char KReadCharacter(void) {
42  char c;
43  __attribute__((leaf)) asm volatile("jsr 0xFFEE" : "=a"(c) : : "p");
44  return c;
45 }
46 
52 __attribute__((leaf))
53 static inline void KWriteCharacter(char c) {
54  __attribute__((leaf)) asm volatile("jsr 0xFFF1" : : "a"(c) : "p");
55 }
56 
60 __attribute__((leaf))
61 static inline void KWaitMessage(void) {
62  __attribute__((leaf)) asm volatile("jsr 0xFFF4" : : : "p");
63 }
64 
71 #define KSendMessage(group, function) \
72  __attribute__((leaf)) asm volatile("jsr 0xFFF7\n.byte %0, %1\n" : : "i"(group), "i"(function) : "p")
73 
77 #define KSendMessageSync(group, function) \
78  KSendMessage(group, function); \
79  KWaitMessage()
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
std::uint16_t
::uint16_t uint16_t
Definition: cstdint:22
std::uint8_t
::uint8_t uint8_t
Definition: cstdint:21
neo6502.h
c
byte byte c
Definition: api.h:59