llvm-mos-sdk
peekpoke.h
Go to the documentation of this file.
1 // Copyright 2023 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 // Originally from cc65. Modified from original version.
7 
8 // clang-format off
9 
10 /*****************************************************************************/
11 /* */
12 /* peekpoke.h */
13 /* */
14 /* PEEK and POKE macros for those who want to write BASIC code in C */
15 /* */
16 /* */
17 /* */
18 /* (C) 2003 Ullrich von Bassewitz */
19 /* Roemerstrasse 52 */
20 /* D-70794 Filderstadt */
21 /* EMail: uz@cc65.org */
22 /* */
23 /* */
24 /* This software is provided 'as-is', without any expressed or implied */
25 /* warranty. In no event will the authors be held liable for any damages */
26 /* arising from the use of this software. */
27 /* */
28 /* Permission is granted to anyone to use this software for any purpose, */
29 /* including commercial applications, and to alter it and redistribute it */
30 /* freely, subject to the following restrictions: */
31 /* */
32 /* 1. The origin of this software must not be misrepresented; you must not */
33 /* claim that you wrote the original software. If you use this software */
34 /* in a product, an acknowledgment in the product documentation would be */
35 /* appreciated but is not required. */
36 /* 2. Altered source versions must be plainly marked as such, and must not */
37 /* be misrepresented as being the original software. */
38 /* 3. This notice may not be removed or altered from any source */
39 /* distribution. */
40 /* */
41 /*****************************************************************************/
42 
43 
44 
45 #ifndef _PEEKPOKE_H
46 #define _PEEKPOKE_H
47 
48 
49 
50 /*****************************************************************************/
51 /* Macros */
52 /*****************************************************************************/
53 
54 
55 
56 #define POKE(addr,val) (*(volatile unsigned char*) (addr) = (val))
57 #define POKEW(addr,val) (*(volatile unsigned*) (addr) = (val))
58 #define PEEK(addr) (*(volatile unsigned char*) (addr))
59 #define PEEKW(addr) (*(volatile unsigned*) (addr))
60 
61 
62 
63 /* End of peekpoke.h */
64 #endif