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
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,4 +174,4 @@ make -j
174
174
make tests
175
175
```
176
176
177
-
This will create a folder called tests in the unit folder. Inside this folder are 3 files that need to be copied to the same directory on your spectrum. The unitnext file is a dotn file which needs to be copied to the /dot directory. Then make sure you are in the folder containing the test_bad and test_op files and type .unitnext.
177
+
This will create a folder called tests in the unit folder. Inside this folder are 3 files that need to be copied to the same directory on your Next. Enter the folder and then type ../unitnext from the command line to launch the tests.
Copy file name to clipboardExpand all lines: docs/specasm.md
+84-7Lines changed: 84 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ Specasm is a Z80 assembler designed to run on the 48k and 128k ZX Spectrums with
6
6
7
7
The editor can be launched from the command line using the .specasm command. Specasm is an integrated editor/assembler.
8
8
9
+
> [!TIP]
10
+
> The ZX Spectrum Next version of Specasm allows the name of a single .x file to be passed on the command line. This file will be automatically loaded into the editor on startup, e.g., .specasm game.x.
11
+
9
12
The editor allows one single source, .x, file to be edited at any one time. Each such file can contain a maximum of 512 lines. Each line can be
10
13
11
14
- An empty line
@@ -60,11 +63,19 @@ On entering command mode, a '>' prompt appears at the bottom of the screen. Fro
60
63
| g *line number*| Moves the cursor to the specified line number|
61
64
| f *string*| Searches for the first instance of *string* starting from the current line. There's no wrap around. |
62
65
66
+
The Next version of Specasm uses one of the Next's 8Kb memory banks to implement a clipboard. This provides a more traditional copy, cut and paste mechanism than the copy and move commands described above, and allows code to be copied from one file to another. Clipboard support is provided via three new Next specific commands.
67
+
68
+
| Command | Description |
69
+
|---------|-------------|
70
+
| x | Replaces the contents of the clipboard with the selected code and deletes the code from the current file |
71
+
| cc | Replaces the contents of the clipboard with the selected code |
72
+
| v | Pastes the contents of the clipboard into the selected code at the cursor position |
73
+
63
74
#### Selecting Mode
64
75
65
-
The *sel* command switches the editor into selection mode. In selection mode the user can press the up and down keys to select a block of code. They can also press the 'a' key to select the entire file. Only whole lines can be selected. To cancel the selection and return to editor mode, press SPACE. To delete the selected lines and return to editor mode, press DELETE. To confirm the selection and return to editor mode, press ENTER. Once the selection has been confirmed an '*' will appear in the status row at the bottom of the screen to the right of 'INS' or 'OVR'. This indicates that some lines are currently selected. These lines can be manipulated using the 'd', 'm', 'c' and 'b' commands described above. For example, to count the number of machine code bytes in the selected line, type SYMSHIFT+w followed by 'b' and ENTER. The editor is capable of computing the exact size in bytes of the machine code associated with the instructions and data in the selected region as it has already assembled these instructions and knows exactly how much space they will consume.
76
+
The *sel* command switches the editor into selection mode. In selection mode the user can press the up and down keys to select a block of code. They can also press the 'a' key to select the entire file. Only whole lines can be selected. To cancel the selection and return to editor mode, press SPACE. To delete the selected lines and return to editor mode, press DELETE. On the Next, the selected lines may be cut to the clipboard by typing 'x'. To confirm the selection and return to editor mode, press ENTER. Once the selection has been confirmed an '*' will appear in the status row at the bottom of the screen to the right of 'INS' or 'OVR'. This indicates that some lines are currently selected. These lines can be manipulated using the 'd', 'm', 'c','b', 'x' and 'cc' commands described above. For example, to count the number of machine code bytes in the selected line, type SYMSHIFT+w followed by 'b' and ENTER. The editor is capable of computing the exact size in bytes of the machine code associated with the instructions and data in the selected region as it has already assembled these instructions and knows exactly how much space they will consume.
66
77
67
-
All of the four commands that manipulate selections, cancel the selection once they have finished executing. So if you select a block of text, and then issue the 'b' command to count the number of bytes it consumes, you'll need to reselect the text once more to copy it. In addition, the current selection is cancelled if you make any changes to the contents of the editor, e.g., edit an existing line or insert a new one.
78
+
All of the six commands that manipulate selections, cancel the selection once they have finished executing. So if you select a block of text, and then issue the 'b' command to count the number of bytes it consumes, you'll need to reselect the text once more to copy it. In addition, the current selection is cancelled if you make any changes to the contents of the editor, e.g., edit an existing line or insert a new one.
68
79
69
80
#### The Status Row
70
81
@@ -578,15 +589,23 @@ The reverse process can be performed using the .saexport command. Note the use
578
589
579
590
## Program structure
580
591
581
-
A Specasm program is comprised of one or more .x files that occupy the same directory. When you build a Specasm program with the .salink command it looks for all the .x files in the folder in which it is run, and links them all together, concatenating them all into one single file and resolving any addresses, e.g., jump targets. One of the .x files in the current folder must contain a label called **Main**, .e.g, it must have the following statement somewhere within one of the files
592
+
A Specasm program is comprised of one or more .x files. When you build a Specasm program with the .salink command it looks for all the .x files in the folder in which it is run, and links them all together, concatenating them all into one single file and resolving any addresses, e.g., jump targets.
593
+
594
+
> [!TIP]
595
+
> Specasm programs can actually span multiple directories. See the +, - and ! directives below.
596
+
597
+
598
+
One of the .x files must contain a label called **Main**, .e.g, it must have the following statement somewhere within one of the files
582
599
583
600
```
584
601
.Main
585
602
```
586
603
587
604
The name of the resulting binary will be derived from the name of the .x file that contains the **Main** label. So if a project places the Main label in a file called **game.x**, the name of the resulting binary created by salink will be **game**.
588
605
589
-
The salink command will place the code from the .x file that declares the Main label first in the newly created binary. The order in which the rest of the code is written to the binary is arbitrary and the user has no control over this. They can however, ask the linker to generate a map file to figure out where all the symbols ended up. This is done by specifying the **map** directive on one line of one .x file, e.g.,
606
+
The salink command will place the code from the .x file that declares the Main label first in the newly created binary. In Specasm versions v7 and eearlier, the order in which the rest of the code is written to the binary is arbitrary and the user has no control over this. In Specasm v8 and above, the order in which the code from the remaining .x files is written to the target binary is defined by the alphabetical order (ascending) of their names. Suppose our program consisted of 3 files, main.x, 02_code.x, 01_data.x, the data/code in main.x would be written first, followed by the contents of 01_data.x, and finally, by the contents of 02_code.x.
607
+
608
+
You can ask the linker to generate a map file to figure out where all the symbols ended up. This is done by specifying the **map** directive on one line of one .x file, e.g.,
590
609
591
610
```
592
611
map
@@ -621,9 +640,12 @@ org 23760
621
640
622
641
will cause the linked program to be assembled at 23760.
623
642
624
-
The linker doesn't currently create a loader program or a tap file. This can however be done using the samake command.
643
+
The linker only creates pure binary files. It isn't capable of creating a loader program or a tap file. This is the task of the samake program, introduced in Specasm v7. See below for more details.
625
644
626
-
### Libraries
645
+
Specasm projects are not limited to the .x files in the main directory. The '-' and '+' directives can be used to include .x files in other directories, allowing a Specasm project to span multiple directories. See below for more details.
646
+
647
+
648
+
### Multi-directory Projects and Libraries
627
649
628
650
Specasm supports two directives that allow the user to include .x files from other directories in the final executable.
629
651
@@ -634,15 +656,70 @@ Specasm supports two directives that allow the user to include .x files from oth
634
656
635
657
These are both linker directives rather than assembler directives. The target of these directives are not included directly into the current source file. Instead they are added to the final binary when it is linked. The '-' directive is intended to be used to create custom libraries or to split your program into multiple folders. The '+' directive is intended to be used to include .x files from a future Specasm standard library. The trailing '.x' extension in <filename> is optional.
636
658
637
-
Here are some examples of their use
659
+
If the path passed to a '-' or a '+' directive is itself a directory, Specasm (v8 and above) will add all the .x files it can find in that directory, and only that directory, to the final binary.
660
+
661
+
Here are some examples of '-' and '+'
638
662
639
663
```
640
664
; include /specasm/gr/rows.x
641
665
+gr/rows
642
666
643
667
; include ./lib/math.x
644
668
-lib/math.x
669
+
670
+
; include all .x files in mylib
671
+
; Specasm v8 and above.
672
+
-mylib
673
+
```
674
+
675
+
The '-' and '+' directives will not add .x files located in any sub-directory of an included directory. For example,
676
+
677
+
```
678
+
-mylib
679
+
```
680
+
681
+
will add mylib/peqnp.x but it will not add mylib/tests/binpack.x. If mylib/tests/binpack.x is needed in the project it will need to be included separately, either with a
682
+
645
683
```
684
+
-mylib/tests/binpack.x
685
+
```
686
+
687
+
or
688
+
689
+
```
690
+
-mylib/tests
691
+
```
692
+
693
+
if all the .x files in mylib/tests are to be part of the project.
694
+
695
+
### Binary files
696
+
697
+
Specasm supports one directive that allows a file to be inserted directly into the final binary at the position at which the directive appears. This is useful when including binary data directly into your final executable rather than shipping it as a separate file and reading it in at runtime, or encoding it using db or dw statements, which isn't really practical when there's a lot of data.
| ! <filename> | Filename is either an absolute or a relative path (relative to the current .x file) |
702
+
703
+
For example,
704
+
705
+
```
706
+
; load pointer to sprite data into hl
707
+
708
+
ld hl, sprites
709
+
710
+
; Load size of sprite file into bc
711
+
712
+
ld bc, =sprite_end-sprites
713
+
714
+
; do something with the sprites
715
+
716
+
ret
717
+
.sprites
718
+
! spritefile
719
+
.sprite_end
720
+
```
721
+
722
+
The data in spritefile will be inserted between the .sprites and .sprite_end label in the final binary by the linker. The register bc will contain the size of that file.
0 commit comments