<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://oldwiki.cpcwiki.eu/index.php?action=history&amp;feed=atom&amp;title=PDS_download_source_code</id>
		<title>PDS download source code - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://oldwiki.cpcwiki.eu/index.php?action=history&amp;feed=atom&amp;title=PDS_download_source_code"/>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=PDS_download_source_code&amp;action=history"/>
		<updated>2026-08-28T15:33:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.1</generator>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=PDS_download_source_code&amp;diff=101279&amp;oldid=prev</id>
		<title>Arnoldemu at 12:39, 11 March 2018</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=PDS_download_source_code&amp;diff=101279&amp;oldid=prev"/>
				<updated>2018-03-11T12:39:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 12:39, 11 March 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L683&quot; &gt;Line 683:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 683:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; END&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; END&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; [[Category:Programming]] [[Category:Programming_software]] [[Category:CrossDev]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff:version:1.11a:oldid:44486:newid:101279 --&gt;
&lt;/table&gt;</summary>
		<author><name>Arnoldemu</name></author>	</entry>

	<entry>
		<id>https://oldwiki.cpcwiki.eu/index.php?title=PDS_download_source_code&amp;diff=44486&amp;oldid=prev</id>
		<title>Nocash: Created page with 'Here is the original Amstrad CPC source code of the PDS development system download functions. Below DLn files (and other versions for C64, BBC, Spectrum) are also found in […'</title>
		<link rel="alternate" type="text/html" href="https://oldwiki.cpcwiki.eu/index.php?title=PDS_download_source_code&amp;diff=44486&amp;oldid=prev"/>
				<updated>2010-04-16T11:12:25Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;Here is the original Amstrad CPC source code of the &lt;a href=&quot;/index.php/PDS_development_system&quot; title=&quot;PDS development system&quot;&gt;PDS development system&lt;/a&gt; download functions. Below DLn files (and other versions for C64, BBC, Spectrum) are also found in […&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Here is the original Amstrad CPC source code of the [[PDS development system]] download functions. Below DLn files (and other versions for C64, BBC, Spectrum) are also found in [[Media:PDS source code.zip]].&lt;br /&gt;
&lt;br /&gt;
== AMSTRAD.DL0 (short version, 114 bytes) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
;   Amstrad short download software&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;Only to be used for assembling and downloading, most monitor functions&lt;br /&gt;
;will not opperate with this download software. It has been kept as short&lt;br /&gt;
;as possible. Note that the interupts are disabled. This is to prevent&lt;br /&gt;
;your own interupt routines crashing if they are overwritten.&lt;br /&gt;
;The code is 114 bytes long. It may be ORG'ed anywhere.&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        ORG 8000H&lt;br /&gt;
;&lt;br /&gt;
START   LD A,255&lt;br /&gt;
        LD BC,0FBEEH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        INC C&lt;br /&gt;
        OUT (C),A       ;Initial port setup&lt;br /&gt;
        LD C,0EDH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        LD C,0EFH&lt;br /&gt;
        LD A,63&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        LD D,64 ;Protocol flags to input from main computer&lt;br /&gt;
        DI&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
;&lt;br /&gt;
MAINLOOP        CALL GETBYTE    ;Get 'command byte'&lt;br /&gt;
        LD A,E&lt;br /&gt;
        CP 180  ;Download code into aabb, len=ccdd&lt;br /&gt;
        JZ DLOAD&lt;br /&gt;
        CP 183&lt;br /&gt;
        JZ BANK&lt;br /&gt;
        CP 181&lt;br /&gt;
        JNZ MAINLOOP    ;If unknown, keep looping&lt;br /&gt;
;&lt;br /&gt;
; Function 181, Execute code from aabb&lt;br /&gt;
;&lt;br /&gt;
        CALL GETBYTE&lt;br /&gt;
        LD H,E  ;Get address&lt;br /&gt;
        CALL GETBYTE&lt;br /&gt;
        LD L,E&lt;br /&gt;
        LD BC,MAINLOOP  ;CALL it.&lt;br /&gt;
        PUSH BC&lt;br /&gt;
        JP (HL)&lt;br /&gt;
;&lt;br /&gt;
; Function 183, Select bank aa&lt;br /&gt;
;&lt;br /&gt;
BANK    CALL GETBYTE&lt;br /&gt;
        LD B,7FH        ;You may write your own routine here.&lt;br /&gt;
        LD C,E  ;You may corrupt everything except E&lt;br /&gt;
        OUT (C),C       ;This allows you to page in rom and ram&lt;br /&gt;
        JR MAINLOOP&lt;br /&gt;
;&lt;br /&gt;
; Function 180, Download code into aabb, length=ccdd&lt;br /&gt;
;&lt;br /&gt;
DLOAD   CALL GETBYTE&lt;br /&gt;
        LD H,E&lt;br /&gt;
        CALL GETBYTE    ;Get start address of code&lt;br /&gt;
        LD L,E&lt;br /&gt;
        CALL GETBYTE&lt;br /&gt;
        LD B,E&lt;br /&gt;
        CALL GETBYTE    ;Get length of code&lt;br /&gt;
        LD C,E&lt;br /&gt;
DLOAD1  CALL GETBYTE&lt;br /&gt;
        LD (HL),E       ;Get and store bytes&lt;br /&gt;
        INC HL&lt;br /&gt;
        DEC BC&lt;br /&gt;
        LD A,B&lt;br /&gt;
        OR C&lt;br /&gt;
        JNZ DLOAD1&lt;br /&gt;
        JR MAINLOOP     ;Go back into main download loop&lt;br /&gt;
;&lt;br /&gt;
; Get a byte from the main computer into E&lt;br /&gt;
;&lt;br /&gt;
GETBYTE PUSH BC&lt;br /&gt;
        LD BC,0FBEDH&lt;br /&gt;
$1      IN A,(C)&lt;br /&gt;
        XOR D           ;Wait for 'sent the byte'&lt;br /&gt;
        RRCA&lt;br /&gt;
        JC $1&lt;br /&gt;
        DEC C&lt;br /&gt;
        IN E,(C)        ;Get the byte&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        OUT (C),A       ;Say 'byte received'&lt;br /&gt;
        XOR 129&lt;br /&gt;
        LD D,A  ;Flip flags ready for next byte&lt;br /&gt;
        POP BC&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
; The end of the PDS download software.&lt;br /&gt;
;&lt;br /&gt;
; Now is a short routine to return to basic from the ASMSTRAD download&lt;br /&gt;
; software supplied with the system. Note that to run the download software&lt;br /&gt;
; you must use the following :&lt;br /&gt;
;&lt;br /&gt;
; LOAD &amp;quot;D&amp;quot; : CALL 40000&lt;br /&gt;
;&lt;br /&gt;
; When you assemble and download this program you will return to basic, to&lt;br /&gt;
; save to disk or tape use the following:&lt;br /&gt;
;&lt;br /&gt;
; SAVE &amp;quot;DLOAD&amp;quot;,B,start address,114,start address&lt;br /&gt;
;&lt;br /&gt;
; Now it will be saved so it will auto run when RUN &amp;quot;DLOAD is typed.&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        ORG START-3&lt;br /&gt;
        POP HL  ;Get rid of return to PDS software&lt;br /&gt;
        EI&lt;br /&gt;
        RET             ;Start interupts and return&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        SEND COMPUTER1&lt;br /&gt;
        END&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== AMSTRAD.DL1 (long version, 374 bytes) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
;   Amstrad long download software&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;This download software can be used for assembling and download, and will&lt;br /&gt;
;work with all the monitor functions, such as trace, upload etc...It will&lt;br /&gt;
;not work with the Analyze command, which requires the DL2 software.&lt;br /&gt;
;Interupts are disabled. Jump to START the first time, this will setup all&lt;br /&gt;
;the ports. If you wish to enter the download software again, jump to&lt;br /&gt;
;MONITOR. The length of the code is 374 bytes.&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        ORG 8000H&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
; Initial setup code&lt;br /&gt;
;&lt;br /&gt;
START   PUSH AF&lt;br /&gt;
        LD A,255&lt;br /&gt;
        LD BC,0FBEEH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        INC C&lt;br /&gt;
        OUT (C),A       ;Initial port setup&lt;br /&gt;
        LD C,0EDH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        LD C,0EFH&lt;br /&gt;
        LD A,63&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        INC A&lt;br /&gt;
        LD (FLAGIO),A   ;Initial flags 0 - Input&lt;br /&gt;
        POP AF&lt;br /&gt;
;&lt;br /&gt;
; Now main part of download software&lt;br /&gt;
;&lt;br /&gt;
MONITOR DI              ;Interupts would corrupt the stack&lt;br /&gt;
        LD (ZHL),HL     ;Save HL&lt;br /&gt;
        LD (ZSP),SP     ;Save SP&lt;br /&gt;
        POP HL  ;Get 'return' address&lt;br /&gt;
        LD (ZPC),HL     ;Where I was called from&lt;br /&gt;
        LD SP,ZHL       ;Top of register block&lt;br /&gt;
        PUSH DE&lt;br /&gt;
        PUSH BC&lt;br /&gt;
        EXX&lt;br /&gt;
        PUSH HL&lt;br /&gt;
        PUSH DE&lt;br /&gt;
        PUSH BC ;All registers are saved for PDS&lt;br /&gt;
        PUSH IX&lt;br /&gt;
        PUSH IY&lt;br /&gt;
        PUSH AF&lt;br /&gt;
        LD A,I&lt;br /&gt;
        LD H,A&lt;br /&gt;
        LD A,R&lt;br /&gt;
        LD L,A&lt;br /&gt;
        PUSH HL&lt;br /&gt;
        EX AF,AF'&lt;br /&gt;
        PUSH AF&lt;br /&gt;
        LD D,0  ;D is the download flag&lt;br /&gt;
FLAGIO  EQU $-1&lt;br /&gt;
;&lt;br /&gt;
; Mainloop&lt;br /&gt;
;&lt;br /&gt;
MAINLOOP        CALL GETBYTE&lt;br /&gt;
        LD A,E&lt;br /&gt;
        CP 180  ;Download code into aabb, len=ccdd&lt;br /&gt;
        JZ DLOAD&lt;br /&gt;
        CP 186  ;Run code aa,bb,cc,dd&lt;br /&gt;
        JP Z,EXECUTE&lt;br /&gt;
        CP 184  ;Send register block to Apricot&lt;br /&gt;
        JP Z,SENDREG&lt;br /&gt;
        CP 185  ;Get register block from Apricot&lt;br /&gt;
        JP Z,GETREG&lt;br /&gt;
        CP 183  ;Select bank aa&lt;br /&gt;
        JZ SBANK&lt;br /&gt;
        CP 182  ;Upload code from aabb len=ccdd&lt;br /&gt;
        JZ UPLOAD&lt;br /&gt;
        CP 181  ;Execute code from aabb?&lt;br /&gt;
        JNZ MAINLOOP    ;Not recognised - keep looping.&lt;br /&gt;
;&lt;br /&gt;
; Function 181, Execute code from aabb&lt;br /&gt;
;&lt;br /&gt;
        CALL GETBYTE&lt;br /&gt;
        LD H,E&lt;br /&gt;
        CALL GETBYTE    ;Notice that the address is downloaded H then L&lt;br /&gt;
        LD L,E&lt;br /&gt;
        LD (EXEC+2),HL  ;Put NOP, CALL &amp;lt;xxxx&amp;gt; into execution buffer&lt;br /&gt;
        LD HL,0CD00H&lt;br /&gt;
        LD (EXEC),HL&lt;br /&gt;
        JP RUNIT&lt;br /&gt;
;&lt;br /&gt;
; Function 180, Download code into aabb, length=ccdd&lt;br /&gt;
;&lt;br /&gt;
DLOAD   CALL GETBYTE&lt;br /&gt;
        LD H,E&lt;br /&gt;
        CALL GETBYTE    ;Get start address of code&lt;br /&gt;
        LD L,E&lt;br /&gt;
        CALL GETBYTE&lt;br /&gt;
        LD B,E&lt;br /&gt;
        CALL GETBYTE    ;Get length of code&lt;br /&gt;
        LD C,E&lt;br /&gt;
DLOAD1  CALL GETBYTE&lt;br /&gt;
        LD (HL),E       ;Get and store bytes&lt;br /&gt;
        INC HL&lt;br /&gt;
        DEC BC&lt;br /&gt;
        LD A,B&lt;br /&gt;
        OR C&lt;br /&gt;
        JNZ DLOAD1&lt;br /&gt;
        JR MAINLOOP     ;Go back into main download loop&lt;br /&gt;
;&lt;br /&gt;
; Function 183, select bank aa&lt;br /&gt;
;&lt;br /&gt;
SBANK   CALL GETBYTE&lt;br /&gt;
        LD B,7FH        ;You may write your own routine here.&lt;br /&gt;
        LD C,E  ;You may corrupt everything except E&lt;br /&gt;
        OUT (C),C       ;This allows you to page in rom and ram&lt;br /&gt;
        JR MAINLOOP&lt;br /&gt;
;&lt;br /&gt;
; Function 184, upload register block to the main computer.&lt;br /&gt;
;&lt;br /&gt;
SENDREG LD HL,REGISTERS&lt;br /&gt;
        LD BC,26&lt;br /&gt;
        JR UPLOAD1      ;Upload the register block&lt;br /&gt;
;&lt;br /&gt;
; Function 185, download register block from the main computer.&lt;br /&gt;
;&lt;br /&gt;
GETREG  LD HL,REGISTERS&lt;br /&gt;
        LD BC,26&lt;br /&gt;
        JR DLOAD1       ;Download the register block&lt;br /&gt;
;&lt;br /&gt;
; Upload code, from aabb, length ccdd&lt;br /&gt;
;&lt;br /&gt;
UPLOAD  CALL GETBYTE&lt;br /&gt;
        LD H,E&lt;br /&gt;
        CALL GETBYTE    ;Get start address of code&lt;br /&gt;
        LD L,E&lt;br /&gt;
        CALL GETBYTE&lt;br /&gt;
        LD B,E&lt;br /&gt;
        CALL GETBYTE    ;Get length of code&lt;br /&gt;
        LD C,E&lt;br /&gt;
;&lt;br /&gt;
UPLOAD1 PUSH BC&lt;br /&gt;
        LD BC,0FBEDH&lt;br /&gt;
$0      IN A,(C)&lt;br /&gt;
        XOR D&lt;br /&gt;
        RRCA&lt;br /&gt;
        JC $0&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,255&lt;br /&gt;
        OUT (C),A       ;This swaps the PDS interface direction around&lt;br /&gt;
        INC A&lt;br /&gt;
        OUT (C),A       ;The Amstrad now transmitts to the Apricot&lt;br /&gt;
        LD A,D&lt;br /&gt;
        XOR 65&lt;br /&gt;
        LD D,A&lt;br /&gt;
        POP BC&lt;br /&gt;
;&lt;br /&gt;
$1      LD A,(HL)&lt;br /&gt;
        CALL SENDBYTE&lt;br /&gt;
        INC HL  ;Send the area of memory&lt;br /&gt;
        DEC BC&lt;br /&gt;
        LD A,B&lt;br /&gt;
        OR C&lt;br /&gt;
        JNZ $1&lt;br /&gt;
;&lt;br /&gt;
        DEC A&lt;br /&gt;
        LD BC,0FBEEH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        DEC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        XOR 64  ;Swap the ports back to normal&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        XOR 128&lt;br /&gt;
        LD D,A&lt;br /&gt;
;&lt;br /&gt;
        JP MAINLOOP&lt;br /&gt;
;&lt;br /&gt;
; Function 186, execute the next 4 bytes, and reenter monitor&lt;br /&gt;
;&lt;br /&gt;
EXECUTE CALL GETBYTE&lt;br /&gt;
        LD L,E&lt;br /&gt;
        CALL GETBYTE&lt;br /&gt;
        LD H,E&lt;br /&gt;
        LD (EXEC),HL&lt;br /&gt;
        CALL GETBYTE    ;Get the 4 bytes to be run&lt;br /&gt;
        LD L,E&lt;br /&gt;
        CALL GETBYTE    ;Store in execution buffer&lt;br /&gt;
        LD H,E&lt;br /&gt;
        LD (EXEC+2),HL&lt;br /&gt;
RUNIT   LD A,D&lt;br /&gt;
        LD (FLAGIO),A&lt;br /&gt;
        POP AF&lt;br /&gt;
        EX AF,AF'&lt;br /&gt;
        POP HL&lt;br /&gt;
        LD A,H&lt;br /&gt;
        LD I,A&lt;br /&gt;
        LD A,L&lt;br /&gt;
        LD R,A&lt;br /&gt;
        POP AF&lt;br /&gt;
        POP IY&lt;br /&gt;
        POP IX  ;Get all registers off stack&lt;br /&gt;
        POP BC&lt;br /&gt;
        POP DE&lt;br /&gt;
        POP HL&lt;br /&gt;
        EXX&lt;br /&gt;
        POP BC&lt;br /&gt;
        POP DE&lt;br /&gt;
        POP HL&lt;br /&gt;
        LD SP,(ZSP)&lt;br /&gt;
EXEC    DS 4            ;All code to be run is placed here&lt;br /&gt;
        JP MONITOR&lt;br /&gt;
;&lt;br /&gt;
; Get a byte from the main computer into E&lt;br /&gt;
;&lt;br /&gt;
GETBYTE PUSH BC&lt;br /&gt;
        LD BC,0FBEDH&lt;br /&gt;
$1      IN A,(C)&lt;br /&gt;
        XOR D           ;Wait for 'sent byte'&lt;br /&gt;
        RRCA&lt;br /&gt;
        JC $1&lt;br /&gt;
        DEC C&lt;br /&gt;
        IN E,(C)        ;Get the byte&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        OUT (C),A       ;Set 'byte received'&lt;br /&gt;
        XOR 129&lt;br /&gt;
        LD D,A  ;Flip flags for next byte&lt;br /&gt;
        POP BC&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
; Send A to the main computer&lt;br /&gt;
;&lt;br /&gt;
SENDBYTE        PUSH BC&lt;br /&gt;
        LD BC,0FBECH&lt;br /&gt;
        OUT (C),A       ;Send the byte&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        OUT (C),A       ;Set 'sent the byte'&lt;br /&gt;
        XOR 129&lt;br /&gt;
        LD D,A&lt;br /&gt;
$1      IN A,(C)&lt;br /&gt;
        XOR D           ;Wait for 'byte received'&lt;br /&gt;
        RRCA&lt;br /&gt;
        JNC $1&lt;br /&gt;
        POP BC&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
        DW 0,0  ;Uses two levels of stack&lt;br /&gt;
REGISTERS       DS 20           ;Other registers stored here&lt;br /&gt;
ZHL     DW 0            ;HL stored here&lt;br /&gt;
ZPC     DW 0            ;PC stored here&lt;br /&gt;
ZSP     DW 0            ;SP stored here&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
; The end of the PDS download software.&lt;br /&gt;
;&lt;br /&gt;
; Now is a short routine to return to basic from the ASMSTRAD download&lt;br /&gt;
; software supplied with the system. Note that to run the download software&lt;br /&gt;
; you must use the following :&lt;br /&gt;
;&lt;br /&gt;
; LOAD &amp;quot;D&amp;quot; : CALL 40000&lt;br /&gt;
;&lt;br /&gt;
; When you assemble and download this program you will return to basic, to&lt;br /&gt;
; save to disk or tape use the following:&lt;br /&gt;
;&lt;br /&gt;
; SAVE &amp;quot;DLOAD&amp;quot;,B,start address,374,start address&lt;br /&gt;
;&lt;br /&gt;
; Now it will be saved so it will auto run when RUN &amp;quot;DLOAD is typed.&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        ORG START-3&lt;br /&gt;
        EXEC $&lt;br /&gt;
        EI&lt;br /&gt;
        POP HL&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        SEND COMPUTER1&lt;br /&gt;
        END&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== AMSTRAD.DL2 (interrupt driven) ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
;   This is the interupt driven download software for the Amstrad&lt;br /&gt;
;&lt;br /&gt;
; To use this software, insert a CALL to the routine PDSSETUP in the&lt;br /&gt;
; 'cold start' or 'once only' part of your program. Also insert a CALL&lt;br /&gt;
; to the routine MONITOR in your interupt routine. PDS corrupts HL,DE,BC&lt;br /&gt;
; and AF. The call to monitor must have HL containing the address where&lt;br /&gt;
; the interupt occured.&lt;br /&gt;
; You will now be able to use most of the monitor functions while your&lt;br /&gt;
; program is running and interupts enabled. Note that you cannot alter&lt;br /&gt;
; the registers or trace as this would not make sense under the interupts.&lt;br /&gt;
; The analyze command will also opperate now.&lt;br /&gt;
;&lt;br /&gt;
; Note that if you try and download programs, containing the PDS download&lt;br /&gt;
; software, chances are that you will crash the system as the download&lt;br /&gt;
; software contains self modifiying code that would get overwritten.&lt;br /&gt;
; To download programs just make sure you never download over the&lt;br /&gt;
; download software currently running.&lt;br /&gt;
;&lt;br /&gt;
; Below is the PDS download software and a short program that sets up the&lt;br /&gt;
; amstrad and returns you to basic, so you may modify memory while you&lt;br /&gt;
; are running basic programs.&lt;br /&gt;
; To run this, use the download software disk supplied and type :&lt;br /&gt;
;&lt;br /&gt;
; LOAD &amp;quot;D&lt;br /&gt;
; CALL 40000&lt;br /&gt;
;&lt;br /&gt;
; If you had used RUN&amp;quot;D you would not have been able to return to basic&lt;br /&gt;
; Now you can download the program&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        ORG 39000&lt;br /&gt;
        EXEC $&lt;br /&gt;
;&lt;br /&gt;
; Setup interupts and return to basic&lt;br /&gt;
;&lt;br /&gt;
        CALL PDSSETUP   ;Initialize PDS software&lt;br /&gt;
        DI&lt;br /&gt;
        LD HL,(39H)&lt;br /&gt;
        LD (INTEND+1),HL        ;Redirect interupt vector&lt;br /&gt;
        LD HL,INTR&lt;br /&gt;
        LD (39H),HL&lt;br /&gt;
        EI&lt;br /&gt;
        POP HL  ;Remove PDS return to download software address&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
; End of example program&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
; Now the main PDS download software routines&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
; Initial setup code - only called once.&lt;br /&gt;
;&lt;br /&gt;
PDSSETUP        LD A,255&lt;br /&gt;
        LD BC,0FBEEH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        INC C&lt;br /&gt;
        OUT (C),A       ;Initial port setup&lt;br /&gt;
        LD C,0EDH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        LD C,0EFH&lt;br /&gt;
        LD A,63&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        INC A&lt;br /&gt;
        LD (FLAGIO),A   ;Initial protocol flags, input&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
; An example interupt routine&lt;br /&gt;
;&lt;br /&gt;
INTR    LD (STKSTO+1),SP&lt;br /&gt;
        PUSH HL&lt;br /&gt;
        PUSH DE&lt;br /&gt;
STKSTO  LD HL,1&lt;br /&gt;
        LD E,(HL)&lt;br /&gt;
        INC HL  ;Get HL=old PC address&lt;br /&gt;
        LD D,(HL)&lt;br /&gt;
        EX DE,HL&lt;br /&gt;
        CALL MONITOR    ;Do download software&lt;br /&gt;
        POP DE&lt;br /&gt;
        POP HL  ;Now go back into AMSTRAD routines&lt;br /&gt;
INTEND  JP 1&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
; Call this address from your interupt routine&lt;br /&gt;
;&lt;br /&gt;
MONITOR PUSH AF&lt;br /&gt;
        PUSH BC ;Save all regs from your program&lt;br /&gt;
        PUSH DE&lt;br /&gt;
        PUSH HL&lt;br /&gt;
        LD D,0  ;D is the download flag&lt;br /&gt;
FLAGIO  EQU $-1&lt;br /&gt;
;&lt;br /&gt;
        LD BC,0FBEDH&lt;br /&gt;
        IN A,(C)&lt;br /&gt;
        XOR D           ;WAIT UNTIL GOT=I&lt;br /&gt;
        RRCA&lt;br /&gt;
        JC EXIT&lt;br /&gt;
        DEC C&lt;br /&gt;
        IN E,(C)        ;GET BYTE&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        OUT (C),A       ;SET SEND=I&lt;br /&gt;
        XOR 129&lt;br /&gt;
        LD D,A  ;I=1-I (ready for next byte)&lt;br /&gt;
;&lt;br /&gt;
        LD A,E&lt;br /&gt;
        SUB 180&lt;br /&gt;
        JZ DLOAD&lt;br /&gt;
        DEC A&lt;br /&gt;
        JZ EXECUTE&lt;br /&gt;
        DEC A&lt;br /&gt;
        JZ UPLOAD&lt;br /&gt;
        DEC A&lt;br /&gt;
        JZ SBANK&lt;br /&gt;
        CP 4&lt;br /&gt;
        JZ ANALYZE&lt;br /&gt;
;&lt;br /&gt;
EXIT    LD A,D&lt;br /&gt;
        LD (FLAGIO),A&lt;br /&gt;
        POP HL&lt;br /&gt;
        POP DE  ;Return to your program&lt;br /&gt;
        POP BC&lt;br /&gt;
        POP AF&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
; Send PC address back to main computer&lt;br /&gt;
;&lt;br /&gt;
ANALYZE CALL PORTOUT&lt;br /&gt;
        LD A,L&lt;br /&gt;
        CALL SENDA&lt;br /&gt;
        LD A,H&lt;br /&gt;
        CALL SENDA&lt;br /&gt;
        CALL PORTIN&lt;br /&gt;
        JR EXIT&lt;br /&gt;
;&lt;br /&gt;
; Execute code from aaaa - does a jump note! (call would be silly from ints)&lt;br /&gt;
;&lt;br /&gt;
EXECUTE CALL GETA&lt;br /&gt;
        LD H,E&lt;br /&gt;
        CALL GETA       ;Notice that the address is downloaded H then L&lt;br /&gt;
        LD L,E&lt;br /&gt;
        JP (HL)&lt;br /&gt;
;&lt;br /&gt;
; Download code into aaaa, length=bbbb&lt;br /&gt;
;&lt;br /&gt;
DLOAD   CALL GETA&lt;br /&gt;
        LD H,E&lt;br /&gt;
        CALL GETA       ;Get start address&lt;br /&gt;
        LD L,E&lt;br /&gt;
        CALL GETA&lt;br /&gt;
        LD B,E&lt;br /&gt;
        CALL GETA       ;Get length of code&lt;br /&gt;
        LD C,E&lt;br /&gt;
DLOAD1  CALL GETA&lt;br /&gt;
        LD (HL),E       ;Get and store code&lt;br /&gt;
        INC HL&lt;br /&gt;
        DEC BC&lt;br /&gt;
        LD A,B&lt;br /&gt;
        OR C&lt;br /&gt;
        JNZ DLOAD1&lt;br /&gt;
        JR EXIT&lt;br /&gt;
;&lt;br /&gt;
; Upload code, from aaaa, length bbbb&lt;br /&gt;
;&lt;br /&gt;
UPLOAD  CALL GETA&lt;br /&gt;
        LD H,E&lt;br /&gt;
        CALL GETA       ;Get start address&lt;br /&gt;
        LD L,E&lt;br /&gt;
        CALL GETA&lt;br /&gt;
        LD B,E&lt;br /&gt;
        CALL GETA       ;Get length of code&lt;br /&gt;
        LD C,E&lt;br /&gt;
        CALL PORTOUT&lt;br /&gt;
$1      LD A,(HL)&lt;br /&gt;
        CALL SENDA&lt;br /&gt;
        INC HL  ;Send the area of memory&lt;br /&gt;
        DEC BC&lt;br /&gt;
        LD A,B&lt;br /&gt;
        OR C&lt;br /&gt;
        JNZ $1&lt;br /&gt;
        CALL PORTIN&lt;br /&gt;
        JP EXIT&lt;br /&gt;
;&lt;br /&gt;
; Function 183, select bank xx (This is different for each computer)&lt;br /&gt;
;&lt;br /&gt;
SBANK   CALL GETA&lt;br /&gt;
;&lt;br /&gt;
; HL, BC and A may be corrupted here&lt;br /&gt;
; Please write your own bank changing routine, for example it could just&lt;br /&gt;
; be LD BC,nnnn  then  OUT (C),A. Note that A contains the number of the&lt;br /&gt;
; bank, sent from the PDS BANK n command in the assembler&lt;br /&gt;
;&lt;br /&gt;
        JP EXIT&lt;br /&gt;
;&lt;br /&gt;
; Turn port direction TO main computer&lt;br /&gt;
;&lt;br /&gt;
PORTOUT PUSH BC&lt;br /&gt;
        LD BC,0FBEDH&lt;br /&gt;
$R      IN A,(C)&lt;br /&gt;
        XOR D&lt;br /&gt;
        RRCA&lt;br /&gt;
        JC $R&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,255&lt;br /&gt;
        OUT (C),A       ;This swaps the PDS interface direction around&lt;br /&gt;
        INC A&lt;br /&gt;
        OUT (C),A       ;The Spectrum now transmitts to the Apricot&lt;br /&gt;
        LD A,D&lt;br /&gt;
        XOR 65&lt;br /&gt;
        LD D,A&lt;br /&gt;
        POP BC&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
; Turn port direction FROM main computer&lt;br /&gt;
;&lt;br /&gt;
PORTIN  LD A,255&lt;br /&gt;
        LD BC,0FBEEH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        DEC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        XOR 64  ;Swap the ports round again&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        XOR 128&lt;br /&gt;
        LD D,A&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
; Get a byte from the APRICOT in E&lt;br /&gt;
;&lt;br /&gt;
GETA    PUSH BC&lt;br /&gt;
        LD BC,0FBEDH&lt;br /&gt;
$1      IN A,(C)&lt;br /&gt;
        XOR D           ;WAIT UNTIL GOT=I&lt;br /&gt;
        RRCA&lt;br /&gt;
        JC $1&lt;br /&gt;
        DEC C&lt;br /&gt;
        IN E,(C)        ;GET BYTE&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        OUT (C),A       ;SET SEND=I&lt;br /&gt;
        XOR 129&lt;br /&gt;
        LD D,A  ;I=1-I (ready for next byte)&lt;br /&gt;
        POP BC&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
; Send A to the APRICOT&lt;br /&gt;
;&lt;br /&gt;
SENDA   PUSH BC&lt;br /&gt;
        LD BC,0FBECH&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        INC C&lt;br /&gt;
        LD A,D&lt;br /&gt;
        OUT (C),A&lt;br /&gt;
        XOR 129&lt;br /&gt;
        LD D,A&lt;br /&gt;
$1      IN A,(C)&lt;br /&gt;
        XOR D&lt;br /&gt;
        RRCA&lt;br /&gt;
        JNC $1&lt;br /&gt;
        POP BC&lt;br /&gt;
        RET&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
;&lt;br /&gt;
        SEND COMPUTER1&lt;br /&gt;
        END&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nocash</name></author>	</entry>

	</feed>