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: README.md
+105-3
Original file line number
Diff line number
Diff line change
@@ -191,10 +191,11 @@ Operation: Sets the H bit in the status register, halting the CPU
191
191
halt
192
192
```
193
193
194
-
### Pre-Processor Macros
194
+
### Preprocessor Directives
195
195
196
-
There are a variety of C-style preprocessor macros included in the assembler, indicated with a preceding `@`.
197
-
These macros can apply conditional transformations to the source before compilation.
196
+
There are a variety of C-style preprocessor directives included in the assembler, indicated with a preceding `@`.
197
+
These directives can apply conditional transformations to the source before compilation.
198
+
Macros are processed in top-down order, meaning if a `@define` is placed below an `@ifdef` in the file, the define will not be in scope during the check.
198
199
199
200
#### DEFINE
200
201
@@ -208,6 +209,93 @@ Syntax:
208
209
@define <identifier> <value>
209
210
```
210
211
212
+
#### UNDEF
213
+
214
+
The `@undef` macro removes (undefines) the current definition of the given identifier.
215
+
Consequently, subsequent occurrences of the identifier are ignored by the preprocessor.
216
+
217
+
Syntax:
218
+
```rs
219
+
@undef <identifier>
220
+
```
221
+
222
+
#### ERROR
223
+
224
+
The `@error` directive emits a user-specified error message before terminating the assembly.
225
+
226
+
Syntax:
227
+
```rs
228
+
@error"error message"
229
+
```
230
+
231
+
#### IF
232
+
233
+
The `@if` directive controls compilation of portions of a source file.
234
+
If the expression you write after the `@if` is greater than 0, the block following the `@if` is retained for assembly.
235
+
236
+
Syntax:
237
+
```
238
+
@if <expr>
239
+
...
240
+
@endif
241
+
```
242
+
243
+
#### ELIF
244
+
245
+
The `@elif` directive is only allowed as part of an `@if` block,
246
+
and is only evaluated if the previously evaluated blocks' check evaluates to 0.
247
+
Similar to the `@if` directive, if the expression you write after the `@elif` is greater than 0, the block following the `@elif` is retained for assembly.
248
+
249
+
Syntax:
250
+
251
+
```
252
+
@if <expr>
253
+
...
254
+
@elif <expr>
255
+
...
256
+
@endif
257
+
```
258
+
259
+
#### ELSE
260
+
261
+
The `@else` directive is only allowed at the end of an `@if` block.
262
+
If the expression of the previously evaluated block's check evaluates to 0,
263
+
then the block following the `@else` is retained for assembly.
264
+
265
+
Syntax:
266
+
267
+
```
268
+
@if <expr>
269
+
...
270
+
@else
271
+
...
272
+
@endif
273
+
```
274
+
275
+
#### IFDEF
276
+
277
+
The `@ifdef` directive is functionally the same as `@if 1` if the identifier has been defined,
278
+
and `@if 0` when the identifier hasn't been defined, or has been undefined by the `@undef` directive.
279
+
280
+
Syntax:
281
+
```
282
+
@ifdef <identifier>
283
+
...
284
+
@endif
285
+
```
286
+
287
+
#### IFNDEF
288
+
289
+
The `@ifndef` directive is functionally the same as `@if 0` if the identifier has been defined,
290
+
and `@if 1` when the identifier hasn't been defined, or has been undefined by the `@undef` directive.
291
+
292
+
Syntax:
293
+
```
294
+
@ifndef <identifier>
295
+
...
296
+
@endif
297
+
```
298
+
211
299
#### Include
212
300
213
301
The include macro pastes a stream of tokens from another file.
@@ -229,6 +317,20 @@ Example:
229
317
@include <error/error.asm>
230
318
```
231
319
320
+
### Segments
321
+
322
+
The assembly is divided into segments, specified with the `@cseg` and `@dseg` directives,
323
+
and organized by the `@org` directive.
324
+
Segments can be used to organize blocks of data and code throughout the address space.
325
+
326
+
#### Code Segments
327
+
328
+
Code segments, signified by the `@cseg` directive,
329
+
are where all of your assembly instructions are located.
330
+
Each assembly program starts in an initial code segment.
0 commit comments