diff options
author | Ian C <ianc@noddybox.co.uk> | 2016-03-08 13:51:57 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2016-03-08 13:51:57 +0000 |
commit | 282fa7725993c9b0b0d2bb0977c124f11abea1fd (patch) | |
tree | e798be921f3cfc51ef0ca39c195a07218defc8d8 | |
parent | 3bad2fc2e05e0ddbf7d398f120b6d5d525476ff9 (diff) |
Wildcard for args, EX changes and CP/M test.
+ Added '*' wildcard for macro arguments
+ Allow 'EX' with parameters reversed on the Z80
+ Added simple CP/M example test.
+ Added some files to gitignore
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | doc/manual.asciidoc | 26 | ||||
-rw-r--r-- | doc/manual.html | 27 | ||||
-rw-r--r-- | doc/manual.pdf | bin | 145493 -> 148743 bytes | |||
-rw-r--r-- | src/casm.c | 2 | ||||
-rw-r--r-- | src/macro.c | 26 | ||||
-rw-r--r-- | src/test/cpm.1 | 44 | ||||
-rw-r--r-- | src/test/z80.1 | 5 | ||||
-rw-r--r-- | src/z80.c | 7 |
9 files changed, 136 insertions, 7 deletions
@@ -30,3 +30,9 @@ # Debug files *.dSYM/ + +# Custom +src/casm +*.com +src/A-Hdrive +src/output diff --git a/doc/manual.asciidoc b/doc/manual.asciidoc index 888a9f0..99d07f6 100644 --- a/doc/manual.asciidoc +++ b/doc/manual.asciidoc @@ -317,7 +317,9 @@ Macros ~~~~~~ Macros can be defined in one of two ways; either parameterless or with named -parameters. Macro names are case-insensitive. +parameters. Macro names are case-insensitive. In the parameterless mode the +special identifier '*' can be used to expand all arguments, which will be +separated with commas. ---- macro1: macro @@ -325,6 +327,7 @@ macro1: macro ld a,\1 ld b,\2 call \3 + defb \* endm @@ -456,6 +459,27 @@ EOR can be used the same as XOR: and b ---- +For exchange opcodes with parameters the parameters can be reversed from their +official form: + +---- + ; The official forms + ; + ex de,hl + ex af,af' + ex (sp),hl + ex (sp),ix + ex (sp),iy + + ; Also supported + ; + ex hl,de + ex af',af + ex hl,(sp) + ex ix,(sp) + ex iy,(sp) +---- + Where the high/low register parts of the IX and IY registers are to be used, simply use ixl, iyl, ixh and iyh. Note that the assembler will accept illegal pairings involving H and L, but these will be warned about: diff --git a/doc/manual.html b/doc/manual.html index 4aa250c..c25be2e 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -1259,7 +1259,9 @@ cbm <div class="sect2">
<h3 id="_macros">Macros</h3>
<div class="paragraph"><p>Macros can be defined in one of two ways; either parameterless or with named
-parameters. Macro names are case-insensitive.</p></div>
+parameters. Macro names are case-insensitive. In the parameterless mode the
+special identifier <em>*</em> can be used to expand all arguments, which will be
+separated with commas.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>macro1: macro
@@ -1267,6 +1269,7 @@ parameters. Macro names are case-insensitive.</p></div> ld a,\1
ld b,\2
call \3
+ defb \*
endm
@@ -1477,6 +1480,26 @@ EOR can be used the same as XOR:</p></div> and a,b ; These are equivalent
and b</tt></pre>
</div></div>
+<div class="paragraph"><p>For exchange opcodes with parameters the parameters can be reversed from their
+official form:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt> ; The official forms
+ ;
+ ex de,hl
+ ex af,af'
+ ex (sp),hl
+ ex (sp),ix
+ ex (sp),iy
+
+ ; Also supported
+ ;
+ ex hl,de
+ ex af',af
+ ex hl,(sp)
+ ex ix,(sp)
+ ex iy,(sp)</tt></pre>
+</div></div>
<div class="paragraph"><p>Where the high/low register parts of the IX and IY registers are to be used,
simply use ixl, iyl, ixh and iyh. Note that the assembler will accept
illegal pairings involving H and L, but these will be warned about:</p></div>
@@ -1570,7 +1593,7 @@ lda $8000,x ; Produces $bd $00 $80</tt></pre> <div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Last updated 2016-01-27 16:12:35 GMT
+Last updated 2016-03-08 13:51:08 GMT
</div>
</div>
</body>
diff --git a/doc/manual.pdf b/doc/manual.pdf Binary files differindex d39db3e..5cd5ea7 100644 --- a/doc/manual.pdf +++ b/doc/manual.pdf @@ -406,6 +406,8 @@ static struct { {"equ", EQU}, {".equ", EQU}, + {"eq", EQU}, + {".eq", EQU}, {"org", ORG}, {".org", ORG}, {"ds", DS}, diff --git a/src/macro.c b/src/macro.c index 03891c2..3e0ce2b 100644 --- a/src/macro.c +++ b/src/macro.c @@ -390,9 +390,29 @@ char *MacroPlay(Macro *macro) } else { - num[in_num] = 0; - AddArg(str, macro, atoi(num)); - in_num = -1; + if (in_num == 0 && line[rd] == '*') + { + int f; + + rd++; + + for(f = 0; f < macro->argc; f++) + { + if (f > 0) + { + VarcharAddChar(str, ','); + } + + AddArg(str, macro, f); + } + in_num = -1; + } + else + { + num[in_num] = 0; + AddArg(str, macro, atoi(num)); + in_num = -1; + } } } else if (in_arg != -1) diff --git a/src/test/cpm.1 b/src/test/cpm.1 new file mode 100644 index 0000000..60ec8c2 --- /dev/null +++ b/src/test/cpm.1 @@ -0,0 +1,44 @@ + ; + ; CP/M example (macro test) + ; + cpu z80 + option output-file,x.com + +BDOS: equ 5 +CONOUT: eq 9 + +strout: macro addr + ld de,@addr + ld c,CONOUT + call BDOS + endm + +strout1:macro + ld de,str + ld a,'$' + ld c,CONOUT +.loop + ex de,hl + cp (hl) + ex hl,de + jr z,end_str + call BDOS + inc de + jr loop + +.str defb \*,0 +.end_str + + endm + + + ; Main code + ; + org $100 + + strout str + strout1 "Bye world", 13, 10, '$' + + ret + +str: defb "Hello World",13,10,'$' diff --git a/src/test/z80.1 b/src/test/z80.1 index d41828e..732d1cb 100644 --- a/src/test/z80.1 +++ b/src/test/z80.1 @@ -221,6 +221,11 @@ exchange: ex (sp),hl ex (sp),ix ex (sp),iy + ex hl,de + ex af',af + ex hl,(sp) + ex ix,(sp) + ex iy,(sp) ldi ldir ldd @@ -1206,10 +1206,15 @@ CommandStatus EX(const char *label, int argc, char *argv[], static RegisterPairCodes codes[] = { DE16, HL16, {0xeb}, + HL16, DE16, {0xeb}, AF16, AF16_ALT, {0x08}, + AF16_ALT, AF16, {0x08}, SP_ADDRESS, HL16, {0xe3}, + HL16, SP_ADDRESS, {0xe3}, SP_ADDRESS, IX16, {SHIFT_IX, 0xe3}, - SP_ADDRESS, IY16, {SHIFT_IY, 0xe3} + IX16, SP_ADDRESS, {SHIFT_IX, 0xe3}, + SP_ADDRESS, IY16, {SHIFT_IY, 0xe3}, + IY16, SP_ADDRESS, {SHIFT_IY, 0xe3} }; RegisterMode r1, r2; |