You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/general.md
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -42,15 +42,17 @@ In order to avoid ambiguity it is suggested that the file name extension always
42
42
c: "otherthing.c"
43
43
```
44
44
45
+
Note that when a BASIC or C file is included as an object in Spin, that single file becomes an independent object: the functions defined in the file are methods of the object, and variables are the members. If a file like "otherthing.c" is included multiple times, it will create multiple object instances (just like a Spin file does). Static variables in C and shared variables in BASIC are shared amongst instances (as though declared in a Spin DAT section); ordinary variables, by contrast, are per-instance member variables (as though declared in a Spin VAR section).
46
+
45
47
### Objects in other languages
46
48
47
-
In BASIC`class using` and C `struct __using` the full filename of the source object, including extension, must always be used.
49
+
Files (Spin, BASIC, or C) may be included as objects in BASIC via `class using`, or in C via `struct __using`. Both of these require the filename to include the extension.
48
50
49
51
BASIC and C also allow inline declarations of classes, using `class`. See the respective language documents for more details.
50
52
51
53
### Calling cross language
52
54
53
-
Every language may call functions written in the other languages. Spin and BASIC are case-insensitive, but C is case sensitive. This means that even in a Spin or BASIC program, you must use the proper case in order to access C functions or variables.
55
+
Every language may call functions written in the other languages. Spin and BASIC are case-insensitive, but C is case sensitive. This means that even in a Spin or BASIC program, you must use the proper case in order to access C functions or variables. It also means that symbols declared in Spin or BASIC may unexpectedly conflict with symbols in C: for example, a Spin constant named `DEVPIN` may conflict with a C symbol named `DevPin`, because the Spin constant is case-insensitive. It is relatively rare for such conflicts to arise, but it is good to be aware of the possibility.
54
56
55
57
## Inline assembly
56
58
@@ -90,7 +92,7 @@ Do not try to declare registers; the inline assembly probably will not be runnin
90
92
91
93
#### General Guidelines
92
94
93
-
Try to keep inline assembly as simple as possible. Use the high level language for loops and conditional control structures; the high level language is there for a reason!
95
+
Try to keep inline assembly as simple as possible. Use the high level language for loops and conditional control structures; the high level language is there for a reason! Generally the flexspin optimizer is fairly good at optimizing simple loops.
94
96
95
97
### Inline assembly in bytecode
96
98
@@ -141,7 +143,7 @@ Similarly use `__attribute__((lut))` to place the function into LUT memory.
141
143
142
144
### Small functions
143
145
144
-
Small functions are expanded inline (without a function call) if the `-Oinline-small` optimization is specified. This option is enabled at `-O1` and `-O2`. In this case "small" means just a few assembly language instructions are generated for it (2 instructions for P1, 4 instructions for P2 where memory is not quite so constrained).
146
+
Small functions are expanded inline (without a function call) if the `-Oinline-small` optimization is specified. This option is enabled at levels `-O1` and `-O2`. In this case "small" means just a few assembly language instructions are generated for it (2 instructions for P1, 4 instructions for P2 where memory is not quite so constrained).
0 commit comments