README: describe more syntax

This commit is contained in:
Zack Buhman 2023-08-24 12:16:40 -07:00
parent 6647d6ddda
commit a8572a7fb8
2 changed files with 79 additions and 18 deletions

View File

@ -7,13 +7,13 @@ scu-dsp-asm is an assembler for SCU DSP mnemonics, using SEGA syntax.
Usage: Usage:
.. code:: .. code::
scu-dsp-asm input-file.asm output-file.bin scu-dsp-asm input-file.asm output-file.bin
Alternately, use the ``-s`` (source code) command-line argument to Alternately, use the ``-s`` (source code) command-line argument to
emit a C-syntax source code fragment: emit a C-syntax source code fragment:
.. code:: .. code::
scu-dsp-asm -s input-file.asm output-file.inc scu-dsp-asm -s input-file.asm output-file.inc
@ -45,17 +45,17 @@ M0-M3 must not appear in in DMA source/destination arguments
For example, the following are not legal: For example, the following are not legal:
.. code:: .. code::
DMA D0,M0,#$02 DMA D0,M0,#$02
DMA M1,D0,#$02 DMA M1,D0,#$02
Instead, they should be written as: Instead, they should be written as:
.. code:: .. code::
DMA D0,MC0,#$02 DMA D0,MC0,#$02
DMA MC1,D0,#$02 DMA MC1,D0,#$02
``dspasm.exe`` generates the same code given either the former or ``dspasm.exe`` generates the same code given either the former or
latter example as input. scu-dsp-asm, however, rejects the former latter example as input. scu-dsp-asm, however, rejects the former
example as invalid: it misleads what the result of the operation is. example as invalid: it misleads what the result of the operation is.
@ -73,25 +73,25 @@ Under seemingly-random circumstances, ``dspasm.exe`` emits the
undefined X-bus opcode ``001``. Given: undefined X-bus opcode ``001``. Given:
.. code:: .. code::
MOV M3,A MOV 1,PL MOV M3,A MOV 1,PL
The ``dspasm.exe``-generated code is: The ``dspasm.exe``-generated code is:
.. code:: .. code::
00000000100001101101010100000001 00000000100001101101010100000001
^ ^
However, the correct code should be: However, the correct code should be:
.. code:: .. code::
00000000000001101101010100000001 00000000000001101101010100000001
^ ^
This is particularly interesting because the example mnemonics did not This is particularly interesting because the example mnemonics did not
contain any X-bus operation to start with. contain any X-bus operation to start with.
Motorola S-record output is not supported Motorola S-record output is not supported
----------------------------------------- -----------------------------------------
@ -109,7 +109,7 @@ default DMA "add mode" for both dspasm.exe and scp-dsp-asm is
``2``. E.g: ``2``. E.g:
- ``DMA`` is a synonym for ``DMA2`` - ``DMA`` is a synonym for ``DMA2``
- ``DMAH`` is a synonym for ``DMAH2`` - ``DMAH`` is a synonym for ``DMAH2``
In "Sega Developers Conference Conference Proceedings March 5-7, 1996" In "Sega Developers Conference Conference Proceedings March 5-7, 1996"
@ -124,9 +124,9 @@ emit "add mode 1" via the ``DMA1`` and ``DMAH1`` mnemonics.
DMA "add mode" and bytes DMA "add mode" and bytes
------------------------ ------------------------
All of the documentation you have read is invalid; here is the correct All of the documentation you have read is invalid; this is the correct
relationship between DMA "add mode" mnemonics, and the number of relationship between DMA "add mode" mnemonics. The right columns represent the
incremented bytes: the increment added an offset of RA0/WA0 after each bus transfer:
.. list-table:: .. list-table::
:header-rows: 1 :header-rows: 1
@ -159,3 +159,63 @@ incremented bytes:
* - DMA64 * - DMA64
- 4 bytes - 4 bytes
- 128 bytes - 128 bytes
Note that the DMA transfer length is always decremented by 1 after 4 bytes are
transferred, regardless of the size of the bus transfer.
The SCU manual (ST-97-R5-072694) contains this contradictory text:
Only add numbers 0 and 1 are valid for the A-Bus and the write unit is
32bit. [...] Write unit is 16bit; 32bit data is divided in half and written
at intervals of 16X (0-64).
"Multiply the 'add number' by the [number of bytes per transfer] **depending on
the value of WA0/RA0**" is completely incorrect. The text in the original
Japanese document is also incorrect.
Syntax features that are supported, but with misleading consequences
====================================================================
``NOP`` mnemonics inside OP instructions
----------------------------------------
In both scu-dsp-asm and ``dspasm.exe``, ALU, X-bus, Y-bus, and D1-bus mnemonics
may appear in any order in a single OP instruction and/or line of source code.
From a grammar perspective, it is impossible to disambiguate which bus a ``NOP``
is referring to. For example, this is valid code:
.. code::
NOP NOP NOP NOP MOV MUL,P
Even though it visually might appear that the X-bus operation might be
simultaneously ``NOP`` and ``MOV MUL,P``, due to syntactical ambiguity the
assembler is not able to generate an error for this case.
There is no restriction on the number of ``NOP`` values that can appear on a
single line.
Feel free to use this syntax feature if desired stylistically, but be aware
scu-dsp-asm is not able to verify intent, and does not/can not generate errors
related to a "conflict" between a ``NOP`` mnemonic and any other bus operation.
Immediates with ``:``-suffixes or ``#``-prefixes
------------------------------------------------
In both scu-dsp-asm and ``dspasm.exe``, neither of these characters mean
anything in the grammar. If encountered, they are ignored.
For example, all of the following is valid source code:
.. code::
MVI #1,MC0
MVI 1:,MC0
MVI #foobar,MC0
MVI #foobar:,MC0
MVI #1+1:,MC0
MVI #(1+1):,MC0
Feel free to use these characters if desired stylistically, but be aware that
scu-dsp-asm does not generate errors regardless of how they are used.

View File

@ -1,7 +1,8 @@
V=2 V=2
M=scu-dsp-asm.$V M=scu-dsp-asm.$V
make TARGET=x86_64-pc-linux-gnu- MAIN=$M.Linux.x86_64 clean all make TARGET=x86_64-pc-linux-gnu- MAIN=$M.Linux.x86_64 clean all
make TARGET=x86_64-w64-mingw32- MAIN=$M.Windows.x86_64.exe clean all make TARGET=aarch64-unknown-linux-gnu- MAIN=$M.Linux.aarch64 clean all
make TARGET=i686-w64-mingw32- MAIN=$M.Windows.i686.exe clean all make TARGET=x86_64-w64-mingw32- MAIN=$M.Windows.x86_64.exe clean all
make TARGET=i686-w64-mingw32- MAIN=$M.Windows.i686.exe clean all
#make MAIN=$M.MacOS-Ventura.x86_64 clean all #make MAIN=$M.MacOS-Ventura.x86_64 clean all