diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..fe70397 --- /dev/null +++ b/.cproject @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..38b48c0 --- /dev/null +++ b/.project @@ -0,0 +1,26 @@ + + + uBix-Retro + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml new file mode 100644 index 0000000..9b4679b --- /dev/null +++ b/.settings/language.settings.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dump/oa-2.0.9/COPYING b/dump/oa-2.0.9/COPYING new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/dump/oa-2.0.9/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/dump/oa-2.0.9/Makefile b/dump/oa-2.0.9/Makefile new file mode 100644 index 0000000..2d9d047 --- /dev/null +++ b/dump/oa-2.0.9/Makefile @@ -0,0 +1,27 @@ + +version="2.0.9" + +all: + (cd apps; ${MAKE};) + +clean: + (cd arch; ${MAKE} clean;) + (cd apps; ${MAKE} clean;) + (cd sysapps; ${MAKE} clean;) + (cd kernel; ${MAKE} clean;) + +tars: + tar czhvf ../oa-${version}.lib.tar.gz apps \ + include/lib6502.i65 include/kdefs.i65 include/inet.i65 + (cd ..; \ + tar czhvf oa-${version}.base.tar.gz \ + --exclude oa-${version}/arch/csa65 \ + --exclude oa-${version}/arch/gecko \ + --exclude oa-${version}/sysapps/basic \ + --exclude oa-${version}/sysapps/irtx \ + oa-${version} ;\ + tar czhvf oa-${version}.tar.gz \ + oa-${version} ;\ + ) + + diff --git a/dump/oa-2.0.9/README.1st b/dump/oa-2.0.9/README.1st new file mode 100644 index 0000000..d193fb2 --- /dev/null +++ b/dump/oa-2.0.9/README.1st @@ -0,0 +1,27 @@ + +This is the OS/A65 source. +(c) 1989-2013 A. Fachat (afachat@gmx.de) + +This comes of course with no warranty in any form. See +the file COPYING for the GNU public license. + +The doc directory contains all necessary documentation (in html mostly). +I propose reading doc/index.html with your favourite html browser first. + +kernel, lib6502, oldlib, devices and include are general source directories. + +apps holds pure lib6502 applications, like a shell, mkdir, etc. +They should also assemble for other lib6502 operating systems. + +sysapps holds OS/A65 specific programs, like the monitor, slipd, or the +filesystem servers. + +The arch directory holds the architecture specific part. Almost everything +in here is pretty system independent. The arch directory contains a directory +for each supported architecture. "proto" holds a prototype architecture +that can be used for porting. + +Have fun! + +26jan1998 A. Fachat + diff --git a/dump/oa-2.0.9/apps/Makefile b/dump/oa-2.0.9/apps/Makefile new file mode 100644 index 0000000..b03c8c1 --- /dev/null +++ b/dump/oa-2.0.9/apps/Makefile @@ -0,0 +1,14 @@ + +# appdirs= lsh file inet +# appdirs= $(wildcard [a-z]*) + +all: + (for i in * ; do\ + (if test -d $$i; then cd $$i; ${MAKE}; fi;); \ + done) + +clean: + (for i in * ; do\ + (if test -d $$i; then cd $$i; ${MAKE} clean; fi;); \ + done) + diff --git a/dump/oa-2.0.9/apps/README b/dump/oa-2.0.9/apps/README new file mode 100644 index 0000000..ff2c1be --- /dev/null +++ b/dump/oa-2.0.9/apps/README @@ -0,0 +1,8 @@ + +The "apps" directory contains the source for stdlib programs, i.e. +programs that do _not_ use the kernel and do _not_ use hardware specifics. + +lsh: lib6502 shell interpreter + +file: lib6502 file utilities, like rmdir, mkdir, ls, rm + diff --git a/dump/oa-2.0.9/apps/file/Makefile b/dump/oa-2.0.9/apps/file/Makefile new file mode 100644 index 0000000..1eb717a --- /dev/null +++ b/dump/oa-2.0.9/apps/file/Makefile @@ -0,0 +1,23 @@ + +files= mkdir rmdir rm chkdsk format ls cat mv + +all: ${files} + +${files}: %: %.a65 + xa -I../../include -R -LLIB6502 $@.a65 -o $@ + +clean: + rm -f ${files} + +rmdir.a65: mkdir.a65 + cat mkdir.a65 | sed -e "s/mkdir/rmdir/g" -e "s/FC_MKDIR/FC_RMDIR/g" > rmdir.a65 + +rm.a65: mkdir.a65 + cat mkdir.a65 | sed -e "s/mkdir/rm/g" -e "s/FC_MKDIR/FC_DELETE/g" > rm.a65 + +chkdsk.a65: mkdir.a65 + cat mkdir.a65 | sed -e "s/mkdir/chkdsk/g" -e "s/FC_MKDIR/FC_CHKDSK/g" > chkdsk.a65 + +format.a65: mkdir.a65 + cat mkdir.a65 | sed -e "s/mkdir/format/g" -e "s/FC_MKDIR/FC_FORMAT/g" > format.a65 + diff --git a/dump/oa-2.0.9/apps/file/cat.a65 b/dump/oa-2.0.9/apps/file/cat.a65 new file mode 100644 index 0000000..1d7a1a9 --- /dev/null +++ b/dump/oa-2.0.9/apps/file/cat.a65 @@ -0,0 +1,171 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 cat program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#include "lib6502.i65" + +#define BUFLEN 1024 + +main .( + .zero +argp .word 0 + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + + ldx #STDIN + jmp docopy + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + lda argp + ldy argp+1 + + jsr docat + bcs ende + /* TODO: print error code */ + + ldy #0 +l2 lda (argp),y + beq next + iny + bne l2 +next + iny + lda (argp),y + bne ok + + lda #0 +ende + rts + +etxtout + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + + .bss +fileno .byt 0 +frdat .word 0,0 +buf .dsb BUFLEN + .text + +docat ldx #OPEN_RD + jsr fopen + bcc docopy + rts +docopy stx fileno +rdloop + lda #buf + sta frdat+1 + lda #BUFLEN + sta frdat+3 + lda #frdat + ldx fileno + sec + jsr fread + pha + php + + lda #BUFLEN + sbc frdat+3 + sta frdat+3 + lda #buf + sta frdat+1 +wrloop lda #frdat + ldx #STDOUT + sec + jsr fwrite + bcs wrerr + lda frdat+2 + ora frdat+3 + bne wrloop + pla + plp + bcs rderr + jmp rdloop + +wrerr pha + ldx fileno + cpx #STDIN + beq w1 + jsr fclose +w1 pla + tay + pla + pla + tya + sec + rts +rderr cmp #E_EOF + bne rde2 + lda #E_OK +rde2 pha + ldx fileno + cpx #STDIN + beq r1 + jsr fclose +r1 pla + clc + rts + .) + diff --git a/dump/oa-2.0.9/apps/file/chkdsk.a65 b/dump/oa-2.0.9/apps/file/chkdsk.a65 new file mode 100644 index 0000000..ac617a3 --- /dev/null +++ b/dump/oa-2.0.9/apps/file/chkdsk.a65 @@ -0,0 +1,100 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 chkdsk program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * Warning: automatically generated from chkdsk.a65! + */ + +#include "lib6502.i65" + +main .( + .zero +argp .word 0 + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + +usage lda #usagetxt + jmp etxtout + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + lda argp + ldy argp+1 + ldx #FC_CHKDSK + jsr fcmd + + /* TODO: print error code */ + + ldy #0 +l2 lda (argp),y + beq next + iny + bne l2 +next + iny + lda (argp),y + bne ok + + lda #0 + rts + +etxtout + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + +usagetxt + .byt 13,10,"Usage:",13,10," chkdsk dir1 [dir2 ...]",13,10,0 + + .) + diff --git a/dump/oa-2.0.9/apps/file/format.a65 b/dump/oa-2.0.9/apps/file/format.a65 new file mode 100644 index 0000000..a35e1a8 --- /dev/null +++ b/dump/oa-2.0.9/apps/file/format.a65 @@ -0,0 +1,100 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 format program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * Warning: automatically generated from format.a65! + */ + +#include "lib6502.i65" + +main .( + .zero +argp .word 0 + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + +usage lda #usagetxt + jmp etxtout + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + lda argp + ldy argp+1 + ldx #FC_FORMAT + jsr fcmd + + /* TODO: print error code */ + + ldy #0 +l2 lda (argp),y + beq next + iny + bne l2 +next + iny + lda (argp),y + bne ok + + lda #0 + rts + +etxtout + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + +usagetxt + .byt 13,10,"Usage:",13,10," format dir1 [dir2 ...]",13,10,0 + + .) + diff --git a/dump/oa-2.0.9/apps/file/ls.a65 b/dump/oa-2.0.9/apps/file/ls.a65 new file mode 100644 index 0000000..0b3f425 --- /dev/null +++ b/dump/oa-2.0.9/apps/file/ls.a65 @@ -0,0 +1,126 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 ls program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#include "lib6502.i65" + +main .( + .zero +argp .word 0 + .bss +fileno .byt 0 +entry .dsb FD_NAME+MAX_FILENAME + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + +;usage lda #usagetxt +; jmp etxtout + + lda #joker + sta argp+1 ; always not null + bne l1 + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + jsr crlfout + + lda argp + ldy argp+1 + + jsr fopendir + bcc opened + rts + +opened stx fileno +rd ldx fileno + lda #entry + jsr freaddir + bcs eof + + lda #entry+FD_NAME + jsr txtout + + jsr crlfout + jmp rd + +eof ldx fileno + jsr fclose + lda #0 + rts + +crlfout lda #13 + sec + ldx #STDOUT + jsr fputc + lda #10 + sec + jmp fputc + +txtout + .zero +tp .word 0 + .text + + ldx #STDOUT + .byt $2c +etxtout + ldx #STDERR + sta tp + sty tp+1 + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + +joker .asc "*", 0 + +;usagetxt +; .byt 13,10,"Usage:",13,10," ls dir1", 13,10,0 + + .) + diff --git a/dump/oa-2.0.9/apps/file/mkdir.a65 b/dump/oa-2.0.9/apps/file/mkdir.a65 new file mode 100644 index 0000000..530093b --- /dev/null +++ b/dump/oa-2.0.9/apps/file/mkdir.a65 @@ -0,0 +1,100 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 mkdir program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * Warning: automatically generated from mkdir.a65! + */ + +#include "lib6502.i65" + +main .( + .zero +argp .word 0 + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + +usage lda #usagetxt + jmp etxtout + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + lda argp + ldy argp+1 + ldx #FC_MKDIR + jsr fcmd + + /* TODO: print error code */ + + ldy #0 +l2 lda (argp),y + beq next + iny + bne l2 +next + iny + lda (argp),y + bne ok + + lda #0 + rts + +etxtout + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + +usagetxt + .byt 13,10,"Usage:",13,10," mkdir dir1 [dir2 ...]",13,10,0 + + .) + diff --git a/dump/oa-2.0.9/apps/file/mv.a65 b/dump/oa-2.0.9/apps/file/mv.a65 new file mode 100644 index 0000000..6e4c66e --- /dev/null +++ b/dump/oa-2.0.9/apps/file/mv.a65 @@ -0,0 +1,102 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 mv program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#include "lib6502.i65" + +main .( + .zero +argp .word 0 + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + +usage lda #usagetxt + jmp etxtout + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + ldy #0 +c0 lda (argp),y + beq c1 + iny + bne c0 +c1 iny + lda (argp),y + beq usage +c2 lda (argp),y + beq c3 + iny + bne c2 +c3 iny + lda (argp),y + bne usage + + lda argp + ldy argp+1 + ldx #FC_RENAME + jsr fcmd + + /* TODO: print error code */ + + rts + +etxtout + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + +usagetxt + .byt 13,10,"Usage:",13,10," mv oldfilename newfilename",13,10,0 + + .) + diff --git a/dump/oa-2.0.9/apps/file/rm.a65 b/dump/oa-2.0.9/apps/file/rm.a65 new file mode 100644 index 0000000..66a4926 --- /dev/null +++ b/dump/oa-2.0.9/apps/file/rm.a65 @@ -0,0 +1,100 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 rm program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * Warning: automatically generated from rm.a65! + */ + +#include "lib6502.i65" + +main .( + .zero +argp .word 0 + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + +usage lda #usagetxt + jmp etxtout + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + lda argp + ldy argp+1 + ldx #FC_DELETE + jsr fcmd + + /* TODO: print error code */ + + ldy #0 +l2 lda (argp),y + beq next + iny + bne l2 +next + iny + lda (argp),y + bne ok + + lda #0 + rts + +etxtout + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + +usagetxt + .byt 13,10,"Usage:",13,10," rm dir1 [dir2 ...]",13,10,0 + + .) + diff --git a/dump/oa-2.0.9/apps/file/rmdir.a65 b/dump/oa-2.0.9/apps/file/rmdir.a65 new file mode 100644 index 0000000..04a6150 --- /dev/null +++ b/dump/oa-2.0.9/apps/file/rmdir.a65 @@ -0,0 +1,100 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 rmdir program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * Warning: automatically generated from rmdir.a65! + */ + +#include "lib6502.i65" + +main .( + .zero +argp .word 0 + .text + + sta argp + sty argp+1 + + ldy #0 +l0 lda (argp),y + beq first + iny + bne l0 + +first iny + lda (argp),y + bne ok + +usage lda #usagetxt + jmp etxtout + +ok tya + clc + adc argp + sta argp + bcc l1 + inc argp+1 +l1 + lda argp + ldy argp+1 + ldx #FC_RMDIR + jsr fcmd + + /* TODO: print error code */ + + ldy #0 +l2 lda (argp),y + beq next + iny + bne l2 +next + iny + lda (argp),y + bne ok + + lda #0 + rts + +etxtout + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +t0 lda (tp),y + beq te + sec + jsr fputc + iny + bne t0 +te rts + +usagetxt + .byt 13,10,"Usage:",13,10," rmdir dir1 [dir2 ...]",13,10,0 + + .) + diff --git a/dump/oa-2.0.9/apps/inet/Makefile b/dump/oa-2.0.9/apps/inet/Makefile new file mode 100644 index 0000000..a15d8d3 --- /dev/null +++ b/dump/oa-2.0.9/apps/inet/Makefile @@ -0,0 +1,12 @@ + +files= tlogin telnet httpd + +all: ${files} + +${files}: %: %.a65 + xa -I../../include -R -LLIB6502 $@.a65 -o $@ + +clean: + rm -f ${files} + + diff --git a/dump/oa-2.0.9/apps/inet/httpd.a65 b/dump/oa-2.0.9/apps/inet/httpd.a65 new file mode 100644 index 0000000..b362dcc --- /dev/null +++ b/dump/oa-2.0.9/apps/inet/httpd.a65 @@ -0,0 +1,465 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 httpd program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This is a horribly simple www server to show how listen/accept + * should be used. + * It can only serve one file at a time, accepting other connections + * after finishing a file. + * + * The server built into OS/A65 slipd is much better worked out, although + * it also has its flues... + */ + +#include "lib6502.i65" + +#define WWWPORT 8080 +#define BUFLEN 100 +#define FBUFLEN 128 + +#define DEBUG + + .( + .zero +p .word 0 + .bss +lport .byt 0 +netfn .byt 0 +filefn .byt 0 +buf .dsb BUFLEN + .text + ++main .( + sta p + sty p+1 + + lda #0 + sta lport + + lda #wwwpath + jsr chdir + + jsr parsepar + bcs ret + + lda #txt1 + jsr txtout +#ifdef DEBUG + ldx #STDIN + sec + jsr fgetc +#endif + lda #listenarg + ldx #IPV4_TCP + clc + jsr listen + bcs ret + stx lport + + lda #txt2 + jsr txtout +#ifdef DEBUG + ldx #STDIN + sec + jsr fgetc +#endif +aloop + sec + lda #BUFLEN + sta abuf + lda #abuf + ldx lport + jsr accept + bcc gotone +ende + ldx lport + sec + jsr listen + +ret rts + +gotone stx netfn + jsr getline + bcs doclose + jsr parsereq + bcs doclose + jsr dofile + ldx filefn + jsr fclose +doclose + ldx netfn + jsr fclose + jmp aloop + .) + + .data +txt1 .asc "^m^jhttpd: start listening",0 +txt2 .asc "^m^jhttpd: start accepting",0 + +/***********************************************************************/ + +getline .( + ldy #0 + ldx netfn +l0 sec + jsr fgetc + bcs ferr + cmp #13 + beq eol + sta buf,y + iny + cpy #BUFLEN + bcc l0 +ferr + ; file error or buffer overflow error + ldx netfn + jsr fclose + sec + rts + +eol ; end of line + lda #0 + sta buf,y + +#ifdef DEBUG + lda #lt + jsr txtout + lda #buf + jsr txtout + jsr crlfout + + .data +lt .asc "httpd: got request: ",0 + .text + +#endif + clc + rts + .) + +/**************************************************************************/ + +dofile .( + .bss +fpars .dsb 4 +fbuf .dsb FBUFLEN + .text + + ; drain network input, in case it blocks otherwise + ldx netfn +drain clc + jsr fgetc + bcc drain + + jsr yield + + ; read a block from file + lda #fbuf + sta fpars+1 + lda #FBUFLEN + sta fpars+3 + + lda #fpars + ldx filefn + clc + jsr fread + bcs d1 + lda #E_OK +d1 pha + + lda #FBUFLEN + sbc fpars+3 + sta fpars+3 + ora fpars+2 + beq empty + + lda #fbuf + sta fpars+1 + + lda #fpars + ldx netfn + sec + jsr fwrite +empty + pla + cmp #E_EOF + bne dofile + rts + .) + +/**************************************************************************/ + +parsereq .( + .zero +fp .word 0 + .text + + ldy #<-1 +n0 iny + lda buf,y + cmp #" " + beq n0 + + lda buf,y + cmp #"G" + bne malformed + iny + lda buf,y + cmp #"E" + bne malformed + iny + lda buf,y + cmp #"T" + bne malformed + +n1 iny + lda buf,y + cmp #" " + beq n1 + + ; here we have the address of the filename + tya + clc + adc #buf + sta fp+1 + + ldy #<-1 +n2 iny + lda (fp),y + beq ende + cmp #" " + bne n2 ; check for extensions... + lda #0 + sta (fp),y +ende + lda fp + ldy fp+1 + ldx #OPEN_RD + jsr fopen + bcs notopen + stx filefn + rts + +notopen ldx #0 + .byt $2c +malformed + ldx #1 + + txa + asl + asl + tay + ldx #0 +ll lda eaddrs,y + sta fwpars,x + iny + inx + cpx #4 + bcc ll + lda #fwpars + ldx filefn + sec + jsr fwrite + + ldx filefn + jsr fclose + sec + rts + + .bss +fwpars .dsb 4 + .data +eaddrs .word err0, err1-err0 + .word err1, err2-err1 + +err0 .byt "HTTP/1.0 400^m^jContent-Type: text/html^m^j^m^j" + .asc "^m^j^m^jError^m^j^m^j" + .asc "^m^j

Error 400

^m^j^m^j" + .asc "OS/A65" + .asc " TCP httpd server error: file not found^m^j" + .asc "^m^j^m^j" +err1 .asc "HTTP/1.0 400^m^jContent-Type: text/html^m^j^m^j" + .asc "^m^j^m^jError^m^j^m^j" + .asc "^m^j

Error 400

^m^j^m^j" + .asc "OS/A65" + .asc " TCP httpd server error: malformed request^m^j" + .asc "^m^j^m^j" +err2 + .text + .) + +/**************************************************************************/ + + .bss +digit .word 0 + .text + +parsepar .( + ldy #0 +l1 lda (p),y + beq l2 + iny + bne l1 +l2 + iny + tya + clc + adc p + sta p + lda #0 + adc p+1 + sta p+1 + + ldy #0 + lda (p),y + beq ret + lda p + ldy p+1 + jsr chdir + + ldy #0 +l4 lda (p),y + beq l3 + iny + bne l4 +l3 + sta digit + sta digit+1 + + iny + lda (p),y + bne pp + clc + rts +pp + cmp #"0" + bcc err + cmp #"9"+1 + bcs err + + jsr nextwdig + + iny + lda (p),y + bne pp + + lda digit + sta wwwport + lda digit+1 + sta wwwport+1 +ret clc + rts +err sec + rts + .) + +nextwdig .( + pha + asl digit + rol digit+1 + lda digit + ldx digit+1 + asl digit + rol digit+1 + asl digit + rol digit+1 + clc + adc digit + sta digit + txa + adc digit+1 + sta digit+1 + pla + and #$0f + adc digit + sta digit + bcc x1 + inc digit+1 +x1 rts + .) + +txtout .( + .zero +p2 .word 0 + .text + + sta p2 + sty p2+1 + ldy #0 + ldx #STDERR +l lda (p2),y + beq ret + sec + jsr fputc + iny + bne l +ret + rts + .) + +crlfout .( + ldx #STDERR + lda #13 + sec + jsr fputc + lda #10 + sec + jmp fputc + .) + + .data +wwwpath .asc "f:",0 + +listenarg .byt 3 : wwwport .word WWWPORT + + .bss + +abuf .dsb BUFLEN + + .text + .) + + diff --git a/dump/oa-2.0.9/apps/inet/telnet.a65 b/dump/oa-2.0.9/apps/inet/telnet.a65 new file mode 100644 index 0000000..6d69d2e --- /dev/null +++ b/dump/oa-2.0.9/apps/inet/telnet.a65 @@ -0,0 +1,540 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 telnet program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#include "lib6502.i65" + +#define TEL_WILL 251 +#define TEL_WONT 252 +#define TEL_DO 253 +#define TEL_DONT 254 +#define TEL_IAC 255 + +#define TEL_SUPPRESSGA 3 +#define TEL_ECHO 1 + +#define BUFLEN 100 + + .( + .bss +fd .byt 0 +rxst .byt 0 +topt .byt 0 +m_echo .byt 0 + .zero +p .word 0 + .text + ++main .( + sta p + sty p+1 + + /* parse command line */ + + ldy #0 +n0 lda (p),y + beq n1 + iny + bne n0 + +n1 iny + clc + tya + adc p + sta p + bcc n2 + inc p+1 +n2 + jsr parseip + bcs ende + iny + clc + tya + adc p + sta p + bcc n3 + inc p+1 +n3 + jsr parseport + bcs ende + + /* init screen / modes */ + + ldx #STDOUT + lda #13 + sec + jsr fputc + lda #10 + jsr fputc + + lda #0 + sta rxst + lda #1 + sta m_echo + + /* open connection */ + + lda #atext + jsr txtout + + lda #addr + ldx #IPV4_TCP + jsr connect + stx fd + +#if 1 + pha + lda #etext + jsr txtout + pla + pha + jsr hexout + + lda #rtext + jsr txtout + + pla +#endif + cmp #0 + bne donot + + jsr doit +donot + ldx fd + jsr fclose + jmp term + +ende lda #usagetxt + jsr txtout + jmp term + + .data +usagetxt + .byt "^m^jUsage: ^m^j telnet ip-address [port]^m^j" + .byt "where 'ip-address' is the 4 byte dot-^m^j" + .byt "separated IP address (like 192.168.0.1)^m^j",0 + .text + + .) + +/************************************************************************** + * here is the main I/O loop + * + */ + +doit .( + /* copy from keyboard to net */ + + ldx #STDIN + clc + jsr fgetc + bcc ok + cmp #E_EOF + bne rx +ret rts +ok ldx fd + sec + jsr fputc + bcc rx + cmp #E_NUL + beq ret + + /* copy from net to screen */ + +rx ldx fd + clc + jsr fgetc + bcc okw + cmp #E_EOF + bne tx + rts +okw ldx rxst + bne iacrxd + + cmp #TEL_IAC + bne rx0 + inc rxst + jmp tx +rx0 + cmp #128 ; we have 7 bit ASCII + bcs tx + + ldx #STDOUT + sec + jsr fputc + bcc tx + cmp #E_NUL + beq ret +tx + jmp doit + + ;--------------------------- + +iacrxd cpx #1 + bne second + + sta topt + cmp #TEL_WILL + bcc noopt + cmp #TEL_DONT+1 + bcs noopt + inc rxst + jmp tx + +noopt + lda #0 + sta rxst + jmp tx + +second +#if 1 + pha + lda #otxt + jsr txtout + lda topt + sec + sbc #TEL_WILL + asl + tax + lda addrs+1,x + tay + lda addrs,x + jsr txtout + pla + pha + jsr hexout + + .data +otxt .byt "rxd option: ",0 +ttxt .byt " -> ",0 +addrs .word t1,t2,t3,t4 +t1 .byt "will ",0 +t2 .byt "won't ",0 +t3 .byt "do ",0 +t4 .byt "don't ",0 + .text + + pla +#endif + + pha + + ldy #0 +c1 cmp options,y + beq found + iny + cpy #NOPTS + bcc c1 + + /* now we have received the option we deny everything we don't know */ +ireply ldy topt + lda table-TEL_WILL,y +reply ; must have option type on stack, do/dont/ etc in AC + pha + + lda #TEL_IAC + sec + ldx fd + jsr fputc + +#if 1 + lda #ttxt + jsr txtout + pla + pha + sec + sbc #TEL_WILL + asl + tax + lda addrs+1,x + tay + lda addrs,x + jsr txtout +#endif + + pla + sec + ldx fd + jsr fputc + +#if 1 + pla + pha + jsr hexout +#endif + pla + sec + ldx fd + jsr fputc + + .byt $24 +noreply pla + lda #0 + sta rxst +#if 1 + lda #rtext + jsr txtout +#endif + jmp tx + +found + tya + asl + tay + lda oaddrs+1,y + pha + lda oaddrs,y + pha + rts + +to_echo .( + inc topt + inc topt + bne no_dont +ireply2 jmp ireply ; dont echo +no_dont inc topt + bne no_do + lda #TEL_WONT ; do echo + jmp reply +no_do inc topt + bne no_wont + lda m_echo ; wont echo + bne noreply + lda #1 + sta m_echo + lda #TEL_DONT + jmp reply +no_wont inc topt + bne ireply2 + lda m_echo ; will echo + beq noreply + lda #0 + sta m_echo + lda #TEL_DO + jmp reply + .) + +to_ga .( + lda topt + cmp #TEL_WILL + bne ireply1 + lda #TEL_DO + jmp reply +ireply1 jmp ireply + .) + + .data +table .byt TEL_DONT, TEL_DONT, TEL_WONT, TEL_WONT + +NOPTS =2 +options .byt 1, 3 +oaddrs .word to_echo-1, to_ga-1 + + .text + .) + +/************************************************************************** + * stuff + */ + + .bss +digit .word 0 + .text + +parseport .( + ldy #0 + lda (p),y + bne doparse + clc + rts +doparse + sty digit + sty digit+1 + +l0 cmp #"0" + bcc err + cmp #"9"+1 + bcs err + + jsr nextwdig + + iny + lda (p),y + bne l0 + + lda digit + sta addr+6 + lda digit+1 + sta addr+5 + clc + rts +err sec + rts + .) + +nextwdig .( + pha + asl digit + rol digit+1 + lda digit + ldx digit+1 + asl digit + rol digit+1 + asl digit + rol digit+1 + clc + adc digit + sta digit + txa + adc digit+1 + sta digit+1 + pla + and #$0f + adc digit + sta digit + bcc x1 + inc digit+1 +x1 rts + .) + +parseip .( + ldx #0 + ldy #0 +l2 + lda #0 + sta digit + + lda (p),y + beq err +l1 + cmp #"0" + bcc err + cmp #"9"+1 + bcs err + + jsr nextdig + + iny + lda (p),y + beq ende + cmp #"." + bne l1 + + lda digit + sta addr+1,x + inx + iny + cpx #4 + bcc l2 + rts +ende + lda digit + sta addr+1,x + cpx #3 + bcc err + clc + rts +err sec + rts + .) + +nextdig .( ; digit * 10 + AC + pha + asl digit + lda digit + asl + asl + clc + adc digit + sta digit + pla + and #$0f + clc + adc digit + sta digit + rts + .) + +txtout .( + sta p + sty p+1 + ldy #0 +l0 lda (p),y + beq end + sec + ldx #STDOUT + jsr fputc + iny + bne l0 +end rts + .) + +#iflused hexout +&hexout .( + .bss +XR .byt 0 + .text + stx XR + pha + lsr + lsr + lsr + lsr + jsr nibout + pla + and #$0f +nibout ldx #STDOUT + clc + adc #"0" + cmp #"9"+1 + bcc nibok + adc #6 +nibok sec + jsr fputc + ldx XR + rts + .) +#endif + + .data + +; addr .byt 7, 192,168,0,13, 0,7 /* echo port */ +; addr .byt 7, 192,168,0,13, 0,19 /* chargen port */ +addr .byt 7, 192,168,0,13, 0,23 /* telnet port */ + +atext .asc "^m^jTrying to Connect...^m^j",0 +etext .asc "^m^jgot return: ",0 +rtext .asc "^m^j",0 + + .text + .) + + diff --git a/dump/oa-2.0.9/apps/inet/tlogin.a65 b/dump/oa-2.0.9/apps/inet/tlogin.a65 new file mode 100644 index 0000000..8581c38 --- /dev/null +++ b/dump/oa-2.0.9/apps/inet/tlogin.a65 @@ -0,0 +1,193 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 tlogin program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#include "lib6502.i65" + +#define TEL_WILL 251 +#define TEL_WONT 252 +#define TEL_DO 253 +#define TEL_DONT 254 +#define TEL_IAC 255 + +#define TEL_SUPPRESSGA 3 +#define TEL_ECHO 1 + +#define BUFLEN 100 + + .( + .zero +p .word 0 + .bss +buf .dsb BUFLEN + .text + ++main .( + lda #ltext + jsr txtout + + jsr getline + bcs terminate + + lda #pw_name + jsr chkin + php + + lda #ptext + jsr txtout + + jsr getline + bcs terminate + + lda #etext + jsr txtout + + lda #pw_passwd + jsr chkin + bcs terminate + plp + bcs terminate + + jsr clrbuf + + lda #pw_shell + jsr exec + + lda #errsh + jsr txtout + +terminate + jsr clrbuf + jmp term + .) + +clrbuf .( + ldy #0 + tay +l3 sta buf,y + iny + cpy #BUFLEN + bcc l3 + rts + .) + +chkin .( + sta p + sty p+1 + + ldy #<-1 +l1 iny + lda (p),y + cmp buf,y + bne end2 + cmp #0 + bne l1 + clc + rts +end2 sec + rts + .) + +getline .( + .bss + .text + + sta p + sty p+1 + + ldy #0 +l0 sec + ldx #STDIN + jsr fgetc + bcs ende + cmp #TEL_IAC + beq telcmd + cmp #10 + beq l0 + cmp #13 + beq cende + sta buf,y + iny + cpy #BUFLEN + bcc l0 + bcs ende + +cende lda #0 + sta buf,y + clc +ende rts + +telcmd sec + jsr fgetc + cmp #TEL_WILL + bcc xende + cmp #TEL_DO+1 + bcs xende + sec + jsr fgetc +xende jmp l0 + .) + +txtout .( + + sta p + sty p+1 + ldy #0 +l0 lda (p),y + beq end + sec + ldx #STDOUT + jsr fputc + iny + bne l0 +end rts + .) + + .data + +ltext ; .asc TEL_IAC, TEL_DO, TEL_SUPPRESSGA + .asc "^m^jC64 telnet server^m^jOS/A65 operating system^m^j" + .asc "http://www.tu-chemnitz.de/~fachat/8bit/osa/index.html" + .asc "^m^j^m^jlogin: ",0 +ptext .asc "password: ", TEL_IAC, TEL_WILL, TEL_ECHO, 0 +etext .asc TEL_IAC, TEL_WONT, TEL_ECHO, 13,10,0 + +errsh .asc "^m^jCould not open shell!^m^j",0 + +pw_name .asc "c64",0 /* replace this with login name */ +pw_passwd + .asc "guest",0 /* replace this with login password */ +pw_shell + .asc "mon",0,0 /* replace this with shell to exec when + login takes place - pwd as given to + tlogin, i.e. as given to slipd. */ + + .) + + diff --git a/dump/oa-2.0.9/apps/lsh/Makefile b/dump/oa-2.0.9/apps/lsh/Makefile new file mode 100644 index 0000000..5b48582 --- /dev/null +++ b/dump/oa-2.0.9/apps/lsh/Makefile @@ -0,0 +1,8 @@ + + +lsh: lsh.a65 + xa -I../../include -R -LLIB6502 lsh.a65 -o lsh + +clean: + rm -f lsh + diff --git a/dump/oa-2.0.9/apps/lsh/README b/dump/oa-2.0.9/apps/lsh/README new file mode 100644 index 0000000..c20598c --- /dev/null +++ b/dump/oa-2.0.9/apps/lsh/README @@ -0,0 +1,59 @@ + +lsh v0.1 26dec1997 (c) A.Fachat +------------------------------- + +This is a very first implementation of a simple lib6502 compatible shell. +It reads the command line, does I/O redirection and starts the called +program. + +The shell can set environment variables, and substitute them in the command +line. + +The internal commands cannot be piped, only redirected. This may +change in the future (perhaps by threading, at least for pwd and echo) + +lsh command line options: +------------------------- + +Usage: + + lsh [options] [file] + options: + -d debug mode - be more verbose + -- the following arguments are no options + file: + A filename that contains lsh commands. If given, lsh input is read + from here instead of stdin and stdout output is suppressed. + +Syntax of the lsh commands: +--------------------------- + +command [redirection] [ {'|;} command [redirection]] [ {'|;} command... ]] + +command is the usual command (with absolute path if not in the current dir) +with parameter. + +redirection is a list of "> file", "< file", or "! file". +This redirects stdout, stdin or stderr to the given filename. +A combination "!>" or ">!" redirects stdout and stderr to the same file. +A ">>" instead of ">" appends to the file instead of overwriting it +(works for stdout or stdout + stderr only). + +A "'" (the lsh pipe symbol) redirects the stdout of the previous task +to the stdin of the following task. + +A ";" at the end of a command waits for the execution before +further interpreting the command line. + +All redirection chars have to be at the beginning of a 'token'. + +builtin commands: +----------------- + +exit - ends the lsh +cd path - changes current directory +pwd - print current directory +set var=value - sets environment variable +echo text - echos text +uname - print lib6502/OS ident string + diff --git a/dump/oa-2.0.9/apps/lsh/lsh.a65 b/dump/oa-2.0.9/apps/lsh/lsh.a65 new file mode 100644 index 0000000..5baeaf4 --- /dev/null +++ b/dump/oa-2.0.9/apps/lsh/lsh.a65 @@ -0,0 +1,1314 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + lib6502 lsh shell program + + Copyright (C) 1997-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#include "lib6502.i65" + +/* #define LSH_DEBUG */ + +#define BUFLEN 255 + +#define MAXVAR 16 + +#define MAXCHLD 8 +/* + * lib6502 programs are started at the address of the 'main' subroutine. + * The first implementation, however, starts the programs at the start + * of the text segment - which we now make the address of 'main'... + */ + .( + .zero +argp .word 0 + + .bss +shin .byt 0 +debug .byt 0 +quiet .byt 0 ; bit 7 set -> no shell output +waitfl .byt 0 ; bit 7 set -> wait for process termination + +piperd .byt 0 +pipewr .byt 0 +ispiped .byt 0 + +buf .dsb BUFLEN + + .data +version .asc 13,10,"sh v0.1 21dec1997 (c) A. Fachat",13,10,0 + .text + +&main .( + sta argp + sty argp+1 + + jsr instsig + ; install signal handler + + ldx #STDIN + jsr dup + stx shin + + ldx #0 + stx quiet + + lda argp + ldy argp+1 + + jsr parse_myopts /* needs argp in a/y */ + + lda debug + beq loop + lda #version + jsr txtout + + lda #0 + sta ispiped ; init getcmd + + /* command loop */ +loop + jsr checksig + + jsr getcmd + sta argp + sty argp+1 + bcs errclr + + ; do commands +#ifdef LSH_DEBUG + lda #runtxt + jsr txtout + + ldy #0 +x1 lda (argp),y + beq next + jsr putc + iny + bne x1 +next lda #" " + jsr putc + iny + lda (argp),y + bne x1 + + lda #13 + jsr putc + lda #10 + jsr putc +#endif + jsr execfork + stx argp + sty argp+1 + php + jsr clear + plp + bcs loop ; no task forked, x/y invalid + bit waitfl + bpl loop ; no wait + ldx argp + ldy argp+1 + jsr waitpid + jmp loop + +errclr + cmp #E_OK + bne terminate + lda #0 + sta ispiped + jsr clear + jmp loop + +clear .( + ldx buf+0 + jsr fclose + ldx buf+1 + jsr fclose + ldx buf+2 + jsr fclose +#ifdef LSH_DEBUG + lda #13 + jsr putc + lda #10 + jsr putc +#endif + rts + ; jmp loop + .) + +terminate + pha + ldx shin + cpx #STDIN + beq nofile + jsr fclose +nofile pla + rts + .) + +crlfout lda #13 + jsr putc + lda #10 +putc .( + bit quiet + bmi end + ldx #STDOUT + sec + jmp fputc +end rts + .) +/* + * read and execute a command + */ +getcmd .( + .bss +tx .byt 0 +ty .byt 0 +ta .byt 0 + .zero +&ap .word 0 + .text + + ldx #<-1 + stx waitfl + + bit ispiped + bmi pipe2 ; ok, piped + bvs dostdin ; last command ended with ";" + + ldx shin + jsr readline + bcc docmd + pha + cmp #E_EOF + beq cmdend + ldx #3 + jsr errout +cmdend pla + .byt $2c +perr +werr lda #E_OK +; .byt $2c +;perr lda #E_FNOFIL + sec + rts +docmd ; pass a/y ; warning, argp is used outside loop + jsr tokenize + sta ap + sty ap+1 + +#ifdef LSH_DEBUG + lda #10 + jsr putc + ldy #0 +d0 lda (ap),y + beq next + jsr putc + iny + bne d0 +next jsr crlfout + iny + lda (ap),y + bne d0 +#endif + + /* + * now we have to parse the command line for I/O redirection and + * piping, starting the right programs along the way. + */ + + /* prepare stdio for started task */ + + lda #0 + sta ty + +dostdin + ldx #STDIN + jsr dup + stx buf+0 ; stdin + jmp nopipe + +pipe2 ; BUG - when only "|" then no files are opened + lda piperd + sta buf+0 ; stdin +nopipe + ldx #STDOUT + jsr dup + stx buf+1 ; stdout + ldx #STDERR + jsr dup + stx buf+2 ; stderr + + lda ispiped + beq nopipew + lda #0 + sta ispiped + ldy ty + lda (ap),y + bne nopipew + iny + lda (ap),y + beq perr + sty ty +nopipew + /* parse command line, from (ap) to buf+3 */ + /* TODO: interpret "\" escape codes, shell variables */ + + /* copy the filename */ + ldy ty + ldx #3 +f0 lda (ap),y + sta buf,x + jsr checkesc + inx + iny + cmp #0 + bne f0 +pars + lda (ap),y + sta buf,x + beq ende + cmp #">" + beq out1 + cmp #"<" + beq in1 + cmp #"!" + beq err1 + cmp #"'" + beq pipe1 + cmp #"&" + beq back1 + cmp #";" + beq wait1 +f1 + /* TODO: interpret "\" escape codes, shell variables */ + + lda (ap),y + sta buf,x + jsr checkesc + inx + iny + cmp #0 + bne f1 + jmp pars + +in1 jmp redir_in + +out1 jmp redir_out + +err1 jmp redir_err + +ende + lda #buf + clc + rts + +back1 .( + lda #0 + sta waitfl + sta ispiped + sta buf,x + sta buf+1,x + jmp ende + .) + +wait1 .( + iny + sty ty + stx tx + lda #$40 + sta ispiped + asl + sta waitfl + lda #0 + jmp pipe3 + .) + +pipe1 .( + iny + sty ty + stx tx + + jsr pipe + bcs pipend + stx piperd + sty pipewr + + ldx buf+2 ; stdout + jsr fclose + ldx pipewr + stx buf+2 + + lda #$80 + sta ispiped ; set flag for piping + lda #0 + sta waitfl ; background starting +&pipe3 + ;lda #0 + ldx tx + sta buf,x + sta buf+1,x + + lda #buf + clc + rts + +pipend + lda #"?" + jsr putc + + lda #E_OK ; only close streams + sec + rts + .) + + +redir_err .( + stx tx +#ifdef LSH_DEBUG + sty ty + lda #errtxt + jsr txtout + ldy ty + ldx tx +#endif + lda #1 + sta ta ; ta bit 0 = error out + iny + lda (ap),y + cmp #">" + bne nocombine + lda #3 ; ta bit 1 = std out + sta ta + iny + lda (ap),y + cmp #">" + bne nocombine + lda #7 ; ta bit 2 = no create but append + sta ta + iny +&nocombine + lda (ap),y + bne inok + iny + lda (ap),y + beq openend +inok sty ty + tya + clc + adc ap + pha + lda #0 + adc ap+1 + tay + ; pla +#ifdef LSH_DEBUG + pla + pha + tax + tya + pha + txa + jsr txtout + jsr crlfout + pla + tay + ; pla +#endif + ; pha + lda ta + and #4 + beq noap + ldx #OPEN_AP + .byt $2c +noap + ldx #OPEN_WR + pla + jsr fopen + bcs openend + txa + pha + lsr ta + bcc noerr ; no stderr + + jsr dup ; dups xr fileno + bcs noerr + txa + pha + ldx buf+2 ; stderr + jsr fclose + pla + sta buf+2 ; stderr +noerr + lsr ta + bcc nostd + ldx buf+1 + jsr fclose + pla + sta buf+1 + jmp in0 +nostd pla + tax + jsr fclose +in0 + ldx tx + ldy ty +in2 lda (ap),y + iny + cmp #0 + bne in2 + jmp pars +openend + lda #"?" + jsr putc + + lda #E_OK + sec + rts + .) + +redir_out .( + stx tx +#ifdef LSH_DEBUG + sty ty + lda #outxt + jsr txtout + ldy ty + ldx tx +#endif + lda #2 + sta ta ; std out + iny + lda (ap),y + cmp #">" + bne noappend + lda #6 + sta ta + iny +noappend + lda (ap),y + cmp #"!" + bne nocomb1 + inc ta + iny +nocomb1 jmp nocombine + .) + +redir_in .( + stx tx +#ifdef LSH_DEBUG + sty ty + lda #intxt + jsr txtout + ldy ty + ldx tx +#endif + iny + lda (ap),y + bne inok + iny + lda (ap),y + beq openend +inok sty ty + tya + clc + adc ap + pha + lda #0 + adc ap+1 + tay + pla +#ifdef LSH_DEBUG + pha + tax + tya + pha + txa + jsr txtout + jsr crlfout + pla + tay + pla +#endif + ldx #OPEN_RD + jsr fopen + bcs openend + txa + pha + ldx buf+0; stdin + jsr fclose + pla + sta buf+0; stdin + ldx tx + ldy ty +in2 lda (ap),y + iny + cmp #0 + bne in2 + jmp pars +openend + lda #"?" + jsr putc + + lda #E_OK + sec + rts + .) + +#ifdef LSH_DEBUG + .data +intxt .byt 13,10,"stdin from ",0 +outxt .byt 13,10,"stdout from ",0 +errtxt .byt 13,10,"stderr from ",0 +&runtxt .byt 13,10,"run: ",0 + .text +#endif + .) + +/* + * readline reads a line from stdin and puts it into buf. It returns a + * pointer to the command line in a/y. + * Later command line history / command line editing will go here + * For now we ignore codes > 127, and most control codes <32 + */ +readline .( + .bss +instr .byt 0 + .data +promptxt .byt 13,10,">",0 + .text + + stx instr + + lda #promptxt + jsr txtout + + ldy #0 +l0 + ldx instr + sec + jsr fgetc + bcs end + cmp #13 + beq endline + cmp #8 + beq backspace + + cmp #128 + bcs l0 + cmp #32 + bcc l0 + + jsr putc + sta buf,y + iny + cpy #BUFLEN + bcc l0 + /* cmdline too long */ + rts + +backspace + cpy #0 + beq l0 + dey + jsr putc + jmp l0 + +endline lda #0 + sta buf,y + + lda #buf + clc +end + rts + .) + +/* + * Print the error string of the number given in xr + */ +#define NUMERR 6 + +errout .( + cpx #NUMERR + bcc e1 + ldx #0 +e1 + lda errh,x + tay + lda errl,x + jsr etxtout + + lda #errortxt + jmp etxtout + + .data +errh .byt >t0, >t1, >t2, >t3, >t4, >t5 +errl .byt " to + * start in a different drive is supported. + * A "--" ends the options list + * + */ +#define NUMOPTS 3 + +parse_myopts .( + sta argp + sty argp+1 + ; ignore the filename +parse_loop + jsr next + ldy #0 + lda (argp),y + bne noend + clc + rts +noend + cmp #"-" + bne argfile + + iny + lda (argp),y + beq error + + ldx #0 +pl cmp optlist,x + beq found + inx + cpx #NUMOPTS + bcc pl + bcs unknown + +found txa ; when jumping to an option, y holds the + asl ; offset of the command to argp. To return + tax ; either jmp to parse_loop or rts to + lda optaddr+1,x ; the main routine ("--" option) + pha + lda optaddr,x + pha + rts + +ferror lda #4 + .byt $2c +error lda #1 + .byt $2c +unknown lda #2 + pha + lda argp + ldy argp+1 + jsr etxtout + pla + tax + jmp errout + + .data + +optlist .byt "vd-" +optaddr .word opt_debug-1, opt_drive-1, opt_end-1 + + .text + +/* + * This routine increments the argp pointer to the next argument -> argp + */ +next ldy #0 +n0 lda (argp),y + beq n1 + iny + bne n0 +n1 iny + tya + clc + adc argp + sta argp + bcc n2 + inc argp+1 +n2 rts + +/* + * Here are the command line options + */ +opt_debug .( + lda #<-1 + sta debug + jmp parse_loop + .) + +opt_drive .( + lda #<-1 + sta debug + jsr next + ldy #0 + lda (argp),y + beq error ; no drive + lda argp + ldy argp+1 + jsr chdir + bcs n2 + jmp parse_loop + .) + +opt_end .( + jsr next + +&argfile + ldy #0 + lda (argp),y + bne dofile + clc + rts +dofile lda argp + ldy argp+1 + ldx #OPEN_RD + jsr fopen + bcs ferror + txa + pha + ldx shin + jsr fclose + pla + sta shin + lda #<-1 + sta quiet + clc + rts + .) + + .) ; end of parse_myopts + +/* + * tokenize takes the one-string command line and generates + * the tokenized command line. The prompt is removed, too. + */ +tokenize .( + .bss +tbuf .dsb BUFLEN +hk .byt 0 + .text + + sta argp + sty argp+1 + + ldx #0 + ldy #<-1 +kx iny + lda (argp),y + beq ende + cmp #" " + beq kx + cmp #">" + beq kx + + .byt $24 ; ldy #<-1 +k0 iny + lda (argp),y + beq ende + cmp #" " + beq k0 + + cmp #34 + beq starthk + lda #" " + .byt $24 +starthk iny + sta hk + +k1 lda (argp),y + sta tbuf,x + beq ende + cmp hk + beq next + inx + iny + bne k1 + +next lda #0 + sta tbuf,x + inx + jmp k0 + +ende lda #0 + sta tbuf,x + sta tbuf+1,x + lda #tbuf + rts + .) + +/* + * we get the three streams in buf+0,+1 and +2 and the command line in + * buf+3. We now check for builtin commands, and if not found, + * fork a process. + */ +stdin =buf +stdout =buf+1 +stderr =buf+2 +cmdline =buf+3 + +execfork .( + .zero +&cp .word 0 + .bss +cnt .byt 0 + .text + + /* search builtin table */ + lda #bictbl + sta cp+1 + + lda cmdline + beq sret ; E_OK == 0 + + ldy #0 + sty cnt +e1 ldx #0 +e0 lda (cp),y + beq found + cmp cmdline,x + bne nextw + inx + iny + bne e0 +nextw iny + lda (cp),y + bne nextw +nextw2 inc cnt + iny + lda (cp),y + bne e1 + + ; no internal command + lda #buf + jsr forkto + bcc ok + lda #"?" + jsr putc +sret sec +ok rts + +found cmp cmdline,x ; cmdline token must be at end too + bne nextw2 + + lda #E_ILLPAR + bit waitfl + bpl sret ; internal commands cannot go background + + lda cnt + asl + tay + lda bicaddr+1,y + sta cp+1 + lda bicaddr,y + sta cp + lda #buf+3 + jsr doit + sec ; means to close the stdio streams; ac gives return code + rts +doit jmp (cp) + .) + + .data +bicaddr .word bic_echo, bic_exit, bic_cd, bic_pwd, bic_set, bic_uname, bic_reset +bictbl .asc "echo",0, "exit",0, "cd",0, "pwd",0, "set",0, "uname",0, "reset",0 + .byt 0 + .text + +xcrlfout .( + ldx buf+1 ; stdout + lda #13 + sec + jsr fputc + lda #10 + sec + jmp fputc + .) + +bic_uname .( + jsr xcrlfout + jsr getos + ldx buf+1 + jsr xtxtout + jmp xcrlfout + .) + +bic_set .( + inx + txa + clc + adc #buf+3 + tay + pla + jmp putenv + rts + .) + +bic_exit .( + jmp term + .) + +bic_reset .( + jmp ($fffc) + .) + +bic_echo .( + inx + txa + clc + adc #buf+3 + tay + pla + sta cp + sty cp+1 + + jsr xcrlfout + ldx buf+1 ; stdout + + ldy #0 +l0 lda (cp),y + beq n1 + sec + jsr fputc + iny + bne l0 +n1 + lda #" " + sec + jsr fputc + iny + lda (cp),y + bne l0 + rts + .) + +bic_cd .( + inx + txa + clc + adc #buf+3 + tay + pla + jmp chdir + .) + +bic_pwd .( + jsr crlfout + lda #buf+3 + ldx #BUFLEN-3 + jsr cwd + bcs ende + lda #buf+3 + ldx buf+1 + jsr xtxtout + lda #0 +ende rts + .) + + .( + .bss +wpid .word 0 +cnum .byt 0 +ctabl .dsb MAXCHLD +ctabh .dsb MAXCHLD +ctabr .dsb MAXCHLD + .text + +&sigrchld .( + php + sei + pha + tya + ldy cnum + sta ctabh,y + txa + sta ctabl,y + pla + sta ctabr,y + cpy #MAXCHLD-1 + bcs noinc + inc cnum +noinc plp + rts + .) + +&instsig .( + lda #0 + sta cnum + lda #sigrchld + ldx #SIG_CHLD + jmp signal + .) + +&checksig .( + lda cnum + bne found + rts +found jsr crlfout + lda ctabh + jsr ehexout + lda ctabl + jsr ehexout + lda #"," + ldx #STDERR + sec + jsr fputc + lda ctabr + jsr ehexout + ldx #5 + jsr errout + jsr decnum + jmp checksig + .) + +decnum .( + sei + ldy #0 +f1 lda ctabl+1,y + sta ctabl,y + lda ctabh+1,y + sta ctabh,y + lda ctabr+1,y + sta ctabr,y + iny + cpy cnum + bcc f1 + dec cnum + cli + rts + .) + +&waitpid .( + stx wpid + sty wpid+1 +loop lda cnum + bne gotone + jsr yield + jmp loop +gotone lda wpid + cmp ctabl + bne notthis + lda wpid+1 + cmp ctabh + beq found +notthis jsr decnum + jmp loop +found jmp decnum + .) + + .) ; signal handling + +checkesc .( ; command line escape handling + .bss +i1 .byt 0 +i2 .byt 0 +br .byt 0 +vbuf .dsb MAXVAR + .zero +p2 .word 0 + .text + + cmp #"$" + beq varsub + rts + +varsub .( ; first filter variable name from command line + ; dex + stx i1 + lda #0 + sta br + + ldx #0 + iny + sty i2 + + ldx #0 + ; iny + lda (ap),y + cmp #"{" + beq br1 + cmp #"(" + bne nobr + lda #") + .byt $2c +br1 lda #"}" + sta br + iny +nobr + lda (ap),y + sta vbuf,x + beq endname + cmp br + beq endn2 + cmp #"a" + bcc noasc1 + cmp #"z"+1 + bcc nextc +noasc1 cmp #"A" + bcc endname + cmp #"Z"+1 + bcc nextc + cmp #"_" + beq nextc + cmp #"0" + bcc endname + cmp #"9"+1 + bcs endname +nextc + inx + iny + jmp nobr + +endn2 iny +endname lda #0 + sta vbuf,x + dey + sty i2 + +#ifdef ENVTEST +lda #fvar:jsr txtout:lda #vbuf:jsr txtout +lda #cvar:jsr txtout +#endif + + ; now substitute variable in vbuf -> a/y pointer to new value + + lda #vbuf + jsr getenv + sta p2 + sty p2+1 + ora p2+1 + beq notfound + +#ifdef ENVTEST +lda #evar:jsr txtout:lda p2:ldy p2+1:jsr txtout +lda #cvar:jsr txtout +#endif + ldy #0 + ldx i1 +lo lda (p2),y + sta buf,x + beq loe + iny + inx + bne lo +loe dex + stx i1 + +notfound + ldx i1 + ldy i2 + lda (ap),y + rts + +#ifdef ENVTEST + .data +fvar .asc "^m^jfound var :",0 +cvar .asc "^m^j",0 +evar .asc "^m^jgot var :",0 + .text +#endif + .) + + .) ; command line escape handling + + .) diff --git a/dump/oa-2.0.9/arch/Makefile b/dump/oa-2.0.9/arch/Makefile new file mode 100644 index 0000000..dfb899c --- /dev/null +++ b/dump/oa-2.0.9/arch/Makefile @@ -0,0 +1,8 @@ + +# archdirs= c64 csa65 gecko embedded proto cbm8x96 pet32k + +clean: + (for i in *; do \ + (if test -d $$i; then cd $$i; ${MAKE} clean; fi;) \ + done;) + diff --git a/dump/oa-2.0.9/arch/c64/Makefile b/dump/oa-2.0.9/arch/c64/Makefile new file mode 100644 index 0000000..68559d7 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/Makefile @@ -0,0 +1,21 @@ + +TRG=boot/c64rom + +XAINPUT=../../include,..,../.. +XA=xa +FILE=file65 +RELOC=reloc65 + +c64 ${TRG}: # $(wildcard *.a65) + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -R -bt 30718 -bd 768 -bz 8 -bb 2704 c64rom.a65 -o c64rom.o65 -l c64rom.lab ;\ + ${FILE} c64rom.o65;\ + ${RELOC} -xt -o ${TRG} c64rom.o65; \ + if [ $$? -ne 0 ]; then rm ${TRG}; fi;) + + +clean: + rm -f ${TRG} c64rom.lab c64rom.o65 boot.tgz + (cd boot; ${MAKE} clean;) + (cd apps; ${MAKE} clean;) + diff --git a/dump/oa-2.0.9/arch/c64/apps/Makefile b/dump/oa-2.0.9/arch/c64/apps/Makefile new file mode 100644 index 0000000..e3b0dc3 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/apps/Makefile @@ -0,0 +1,13 @@ + + +XAINPUT=../../../include,../../.. +XA=xa + +test.o65: test.a65 + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -DKERNEL=61440 -c test.a65 -o test.o65 ;\ + if [ $$? -ne 0 ]; then rm -f test.o65; fi; ) + +clean: + rm -f test.o65 + diff --git a/dump/oa-2.0.9/arch/c64/apps/test.a65 b/dump/oa-2.0.9/arch/c64/apps/test.a65 new file mode 100644 index 0000000..5b918cf --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/apps/test.a65 @@ -0,0 +1,28 @@ + +#include "kdefs.i65" +#include "kernel.i65" + + *=$2000 + .word 0 + .byt PK_PRG + .byt 12 + .word 0 + .word PRG + .byt <-1 + +PRG +l0 + ldx #STDIN + jsr GETC + bcs l0 + + ldx #STDOUT +l1 pha + jsr PUTC + bcc l2 + pla + bcs l1 + +l2 pla + jmp l0 + diff --git a/dump/oa-2.0.9/arch/c64/boot/Makefile b/dump/oa-2.0.9/arch/c64/boot/Makefile new file mode 100644 index 0000000..70f722e --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/Makefile @@ -0,0 +1,61 @@ + +apps = lsh +sysapps = mon slipd +files = mkdir rmdir rm format chkdsk ls cat mv +inet = tlogin telnet httpd + +XA=xa + +all: boot c64rom ${files} ${apps} ${sysapps} ${inet} + +c64 c64rom: + (cd ..; ${MAKE};) + +boot: boot.a65 + ${XA} boot.a65 -o boot + +clean: + rm -f c64rom boot osa.d64 osa.x64 + rm -f ${files} ${sysapps} ${apps} ${inet} + rm -f vice.trace reltest + +tar ../boot.tgz: boot c64rom loader index.html slip howto.boot + tar czvf ../boot.tgz boot c64rom loader index.html slip howto.boot + +############################################################################## +# +# d64 emulator disk image + run +# + +osa.d64: ${files} ${sysapps} ${apps} ${inet} c64rom boot loader index.html + ./mkdisk ${files} ${sysapps} ${apps} ${inet} c64rom boot loader index.html + dd if=osa.x64 of=osa.d64 bs=64 skip=1 + +emurun: osa.d64 + x64 -1541 -8 osa.d64 + +emuslip: all + x64+rs232 -kernal ~/csa/tmp/kernalb -speed 200 + +############################################################################## +# +# lib6502 programs +# + +${apps}: + (cd ../../../apps/lsh; make lsh;) + (if test ! -r lsh; then ln -s ../../../apps/lsh/lsh lsh; fi) + +${sysapps}: + (cd ../../../sysapps/$@; make $@;) + (if test ! -r $@; then ln -s ../../../sysapps/$@/$@ $@; fi) + +${files}: + (cd ../../../apps/file; make $@;) + (if test ! -r $@; then ln -s ../../../apps/file/$@ $@; fi) + +${inet}: + (cd ../../../apps/inet; make $@;) + (if test ! -r $@; then ln -s ../../../apps/inet/$@ $@; fi) + + diff --git a/dump/oa-2.0.9/arch/c64/boot/boot.a65 b/dump/oa-2.0.9/arch/c64/boot/boot.a65 new file mode 100644 index 0000000..f18a2ce --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/boot.a65 @@ -0,0 +1,132 @@ + + .word $0c00 + *=$0c00 + + sei + lda #0 + sta $d01a ; disable VIC irqs + + lda #$7f + sta $dc0d ; disable CIA1 irqs + sta $dd0d ; disable CIA2 irqs (NMI) + + lda 0 + ora #7 + sta 0 ; cpu ddr + + ; first copy the charom from $d000, under the i/o + + lda 1 + and #%11111011 ; disable I/O, read Charom, write RAM + sta 1 + + ldy #0 +cl0a lda #$ff + sta $d000,y + lda $d900,y + sta $d100,y + lda $da00,y + sta $d200,y + iny + bne cl0a + +cl1a lda $d800,y + sta $d000+64*8,y + iny + cpy #8 + bcc cl1a + +cl1 lda $d800,y + sta $d000+(97-1)*8,y + iny + cpy #27*8 + bcc cl1 + +cl2 lda $d800,y + sta $d000+(91-27)*8,y + iny + bne cl2 + + lda 1 + and #%11111000 ; disable even the charom, only RAM + sta 1 + + ; ldy #0 +cl3 lda c92,y + sta $d000+92*8,y + lda c95,y + sta $d000+95*8,y + lda c96,y + sta $d000+96*8,y + iny + cpy #8 + bcc cl3 + + ldy #0 +cl4 lda c123,y + sta $d000+123*8,y + iny + cpy #5*8 + bcc cl4 + + ldy #0 +cl5 lda $d000,y + eor #$ff + sta $d400,y + iny + bne cl5 + inc cl5+2 + inc cl5+7 + lda cl5+7 + cmp #$d8 + bcc cl5 + + ; now copy the ROM image into its place + + lda 1 ; charom hi, Hiram lo, Loram hi + ora #%101 ; which makes all ROMs disappear... + and #%11111101 ; only I/O is still there + sta 1 + + lda #0 + ldx #$88 + + sta $fb ; target address + sta $fc + + sta $fd ; source address + lda #$a0 + sta $fe + + ldy #0 +loop ; copy xr pages of 256 byte from fd/fe downwards + ; to fb/fc + dec $fc + dec $fe + + lda $fc ; leave out I/O + and #$f0 + cmp #$d0 + beq l2 + +l1 lda ($fd),y + sta ($fb),y + iny + bne l1 +l2 + dex + bne loop +;.byt 2 ; x64 trap... + jmp $f000 + rts + + +c92 .byt $00, $c0, $60, $30, $18, $0c, $06, $00 +c95 .byt $00, $00, $00, $00, $00, $00, $ff, $00 +c96 .byt $06, $0c, $18, $00, $00, $00, $00, $00 +c123 .byt $0e, $18, $18, $30, $18, $18, $0e, $00 + .byt $18, $18, $18, $00, $18, $18, $18, $00 + .byt $38, $0c, $0c, $06, $0c, $0c, $38, $00 + .byt $00, $00, $00, $73, $ce, $00, $00, $00 + .byt $00, $18, $3c, $66, $c3, $ff, $00, $00 + diff --git a/dump/oa-2.0.9/arch/c64/boot/charom b/dump/oa-2.0.9/arch/c64/boot/charom new file mode 120000 index 0000000..8c75a0c --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/charom @@ -0,0 +1 @@ +../../csa65/boot/charom \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/c64/boot/gen b/dump/oa-2.0.9/arch/c64/boot/gen new file mode 120000 index 0000000..8ad50a2 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/gen @@ -0,0 +1 @@ +/site/WWW/root/cbm/own/e1/@GEN.$4000:A,P \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/c64/boot/howto.boot b/dump/oa-2.0.9/arch/c64/boot/howto.boot new file mode 100644 index 0000000..53ddf00 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/howto.boot @@ -0,0 +1,21 @@ + +Howto Boot the C64 and the WWW server +------------------------------------- + +1) transfer all files in this directory to a 1541 disk. (osa.d64) + +2) put this disk to a VC1541 connected with a C64. + +3) load the file "loader" on the C64 and run it + After a while the new OS should come up and running + (F1 switches between virtual terminals) + +4) to start the WWW server, go to the shell (the '#' prompt) and type + + c:slip a:video4 c: c:tlogin a:ser1 & + + This starts the WWW server on serial line interface ser1, which is + the 9600 baud userport interface by Daniel Dallmann. + (ser2 would be a 16550A UART at address $d600) + Debug output goes to the fourth virtual console. + diff --git a/dump/oa-2.0.9/arch/c64/boot/index.html b/dump/oa-2.0.9/arch/c64/boot/index.html new file mode 100644 index 0000000..81d49b0 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/index.html @@ -0,0 +1,20 @@ + + OS/A65 Operating System + +

OS/A65 Operating System

+

(c) 1989-1997 +André Fachat [Mail] +[Homepage]

+

+In 1989 I started this little computer project, building an own 6502 +computer. After a long break I started working on it again in 1996. +I wrote an own operating system for it which I have also ported to the +Commodore 64. +In the meantime it has grown a lot, featuring a standard library, +relocatable files, multithreading/multitasking and much more. +

+However, this is a test file, so please go to the real +GeckOS/A65 +page.

+ + diff --git a/dump/oa-2.0.9/arch/c64/boot/loader b/dump/oa-2.0.9/arch/c64/boot/loader new file mode 100644 index 0000000..32da34b --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/loader Binary files differ diff --git a/dump/oa-2.0.9/arch/c64/boot/loader11 b/dump/oa-2.0.9/arch/c64/boot/loader11 new file mode 100644 index 0000000..767fc11 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/loader11 Binary files differ diff --git a/dump/oa-2.0.9/arch/c64/boot/mkdisk b/dump/oa-2.0.9/arch/c64/boot/mkdisk new file mode 100755 index 0000000..ddfd9b8 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/mkdisk @@ -0,0 +1,24 @@ +#!/bin/sh + +echo "set tmpfile" +tmpfile=/tmp/mkdisk.$user.$$ + +#echo "get files" +#files=`ls *` + +files="$*" + +echo "files=$files" + +echo "format osa,65 x64 osa.x64" > $tmpfile + +for i in $files; do + if test "$i" != "mkdisk" -a "$i" != "osa.d64" ; then + echo "write $i" >> $tmpfile + fi +done + +cat $tmpfile | c1541 > /dev/null + +rm -f $tmpfile + diff --git a/dump/oa-2.0.9/arch/c64/boot/term9600 b/dump/oa-2.0.9/arch/c64/boot/term9600 new file mode 100644 index 0000000..7112739 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/boot/term9600 Binary files differ diff --git a/dump/oa-2.0.9/arch/c64/c64def.i65 b/dump/oa-2.0.9/arch/c64/c64def.i65 new file mode 100644 index 0000000..594db2d --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/c64def.i65 @@ -0,0 +1,34 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * These are the C64 specific defines + */ + +#define C64CIA1 $dc00 +#define C64CIA2 $dd00 +#define C64VIC $d000 + +#include "chips/vicii.i65" +#include "chips/cia6526.i65" + diff --git a/dump/oa-2.0.9/arch/c64/c64rom.a65 b/dump/oa-2.0.9/arch/c64/c64rom.a65 new file mode 100644 index 0000000..ac8fac4 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/c64rom.a65 @@ -0,0 +1,304 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM +/* #define C64 */ + +/* These are necessary for C64 kernel **************************************/ + +#define NOMMU +#define NOSYSPORT +#undef CLK2MHZ /* we only have approx. 1 MHz ... */ +#undef CMOSCPU /* ... and no CMOS cpu */ +#define VIDPAGE 14 +#define SHORTLINE /* prepare for 40 col screen */ +#define RAMTEST +#define NOMIRRORMEM + +#define OSA_CPU "6510" +#define OSA_ARCH "C64" + +/* These are changeable ****************************************************/ + +#undef ANDRE /* my personal configuration... :-) */ +#undef EMUSLIP /* my personal configuration... :-) */ + +#define ROMSTART $7800 /* where the ROM starts */ + +#define RAMSTART 1 + +#define RAMEND >ROMSTART /* The size of the RAM we allow to be used. + Size in pages (256 bytes). Must be below + ROMSTART */ + +#define MIN_MEM >ROMSTART /* minimum memory we need in system env. to + work ok, in pages */ + + + /* if you have a 16550A UART with FIFO */ +#undef UARTBASE $d600 +#define ACIABASE $d600 +/* #define ACIABASE $df00 */ + +#define UARTXTAL 4 /* xtal is 4 times 1.8324 MHz */ + +#define MEMINIVAL 0 /* Clear memory to 0 on boot */ + +#define STACKCOPY /* if defined, save stack area in memory + when context switching, otherwise divide + stack area and give each task a part. + It's faster without, but allows more + tasks with */ + +#define NMIDEV /* necessary for fast RS232 */ + +/*#define C64NEEDCIA1*/ /* disables reading CIA1 ICR in kernel - + needs to be done in device then, as + kernel enables timer irq!! (reading + it causes all flags to be reset!) + If you use the plain C64 9600 baud RS232 + interface (ds3), this must not be defined! */ + +#undef PARALLEL /* for IEEE488 interface from Commodore + disables serial bus interface! */ + +#define C64_BGND_COL 0 /* console background color */ +#define C64_TEXT_COL 13 /* console text color */ +#define C64_BORDER_COL 13 /* console border color */ + +#define C64SWITCH 4 /* terminal switch key number (61= C=, + 4= F1) */ + +/*#define C64NMIRESET*/ /* restore button becomes reset + (doesn't work with NMIDEV and the + plain C64 9600 baud RS232 interface) */ + +#define NEED_CHECKCHLD /* this is necessary if using "init" or + lib6502 */ +#define NEED_GETINFO +#define NEED_SLOCK +#define NEED_RENICE + +#define BOOTDRV "c" /* where are the boot files */ + +#define ROOTPATH "c:" /* where lsh chdirs into on boot */ + +#define WWWDRV BOOTDRV + +#undef INETSTART /* start INET server from init - customization + below */ + +/***************************************************************************/ +/* Better not change anything below */ +/* */ + +#ifdef ANDRE /* C64 with parallel IEEE488, UART and booting from CS/A + computer at IEEE id 10, mapping its fsibm drive there */ + +#define PARALLEL +#define OLDHACK + +#undef ACIABASE +#define UARTBASE $d600 +#undef UARTXTAL +#define UARTXTAL 1 + +#undef BOOTDRV +#define BOOTDRV "e" + +#undef WWWDRV +#define WWWDRV "c" + +#endif /* ANDRE */ + +/***************************************************************************/ + +#ifdef EMUSLIP /* C64 emulator VICE with parallel IEEE488, ACIA emulation + and a nullmodem cable between /dev/modem (VICE) and + a slip line */ + +#undef PARALLEL +#undef OLDHACK + +#undef UARTBASE +#undef ACIABASE +#undef UARTXTAL + +#undef BOOTDRV + +#undef WWWDRV + +#endif /* EMUSLIP */ + +/*************************************************************************** + * + * Here comes the ROM content + */ + +#include "config.i65" +#include "kdefs.i65" +#include "fdefs.i65" +#include "c64def.i65" + +#include "kernel.i65" + +#define STDIOADDR $d000 + + .word $1800 /* load address */ + +.( + +/************* ROM entries */ + +/************* devices */ + +#include "devices/c64dev.a65" + +/************* init process */ + +#define INIT_VERBOSE +#define INIT_RESTART +#define INIT_MERGE +#define INIT_LIB6502 +/* #define INIT_USE_STDLIB */ +/* #define INIT_OUTDEV 2*/ +#include "sysapps/init/init.a65" + +/************* fsdev - converts devices into files */ + +#include "sysapps/fs/fsdev.a65" + +/************* fsiec - IEEE488/IEC bus filesystem */ + +/* both, the parallel and serial iec bus use the same timer */ +#define SEM_CIA2TB SEM_SERIEC +#undef SEM_PARIEC +#undef SEM_SERIEC + +#define NOLOOP +#ifdef PARALLEL +#define FSIEC_DEVICE "devices/piec_c64.a65" +#else +#define FSIEC_DEVICE "devices/siec_c64.a65" +#endif +#include "sysapps/fs/fsiec.a65" +#undef FSIEC_DEVICE +#print * + + +/************* mon - OS/A 1 old style monitor/shell */ + +#define MON_SHEXE $c0 /* ROM executable flag */ +#define MON_MONEXE 0 /* ROM executable flag */ +#define MON_SHDEV 1 /* start on device 0 = video1 */ +#define SHORTMON /* no assembler/disassembler */ +#undef NOSH +#include "sysapps/mon/mon.a65" + + +/************* boot slipd from BOOTDRV, wwwdrv c and stderr to video3 */ + +#ifdef INETSTART + + /* add autostart of lib6502 program 'slipd' */ + + .( + .word end_slipd + .byt PK_LIB+PK_AUTOEXEC ; is lib6502 program + .word 0 ; P_ADDR ignored + .byt 128 ; P_RAM + .byt 128 ; P_SHARED + .byt 0 ; P_PRIORITY + .byt 7,7 ; P_DEV + ; wwwsrv drive is WWWDRV, login prg is "BOOTDRV:tlogin", + ; debug output to 4th console + .byt BOOTDRV,":slipd", 0 + .byt "a:video4", 0 + .byt WWWDRV, ":", 0 + .byt BOOTDRV, ":tlogin", 0 + .byt 0 ; end of parameter list +end_slipd + .) + +#endif + +/************* boot lsh from BOOTDRV */ + +#ifdef BOOTDRV + + /* add autostart of lib6502 program 'lsh' */ + + .( + .word end_auto + .byt PK_LIB+PK_AUTOEXEC+PK_RESTART ; is lib6502 program + .word 0 ; P_ADDR ignored + .byt 16 ; P_RAM + .byt 128 ; P_SHARED + .byt 0 ; P_PRIORITY + .byt 0,0 ; P_DEV + .byt BOOTDRV,":lsh",0,"-d",0,ROOTPATH, 0,0 +end_auto + .) + +#endif + +/************* end of ROM executables */ + + .word -1 + +/************* lib6502 code */ + +#echo "lib6502 starts at" +#print * + +/* lib6502 jmp table is below STDIOADDR */ + +#include "lib6502/lib6502.a65" + +/************* fill not used area (I/O, screens) */ + +#if $d000-* < 0 +#echo "Error after lib6502" +#print * +#endif + +.dsb $d000-*,<-1 +.dsb $2000, <-1 /* from d000 to f000 */ + +/************* Kernel */ + +#include "kernel\kernel.a65" + +/************* Constants for lib6502 memory handling */ + +Memstart =$1600 +Memend =ROMSTART +Zerostart =$70 + +.) + diff --git a/dump/oa-2.0.9/arch/c64/config.i65 b/dump/oa-2.0.9/arch/c64/config.i65 new file mode 100644 index 0000000..f5407d5 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/config.i65 @@ -0,0 +1,73 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef _C64CONFIG_ +#define _C64CONFIG_ + +#echo ******** c64 config ********** + + +/* StreamData */ + +#define ANZSTRM 16 /* number of streams */ + +/* SemaphoreData */ + +#define ANZSEM 8 /* number of semaphores - multiple of 8 */ +#define SYSSEM 8 /* multiple of 8, no of system semaphores + i.e. sems from -SYSSEM to -1 */ + +/* DeviceData */ + +#define MAXDEV 16 /* maximum number of devices */ + +/* EnvData */ + +#define MAXENVS 1 /* one environment only */ + +#ifndef STACKCOPY +#define MAXNTHREADS 5 /* (Stackpage-56)/40 */ +#define MAXNTASKS 5 +#define STACKSIZE 40 /* (TH_SLEN * 5) */ +#else +#define MAXNTHREADS 12 /* (up to 16 is possible, if enough memory) */ +#define MAXNTASKS 12 +#define STACKSIZE 64 /* (TH_SLEN * 8) */ +#endif +#define ANZXENV 5 /* number of redirectable task IDs */ + +/* TaskData */ + +#define IRQCNT 3 /* default priority for ROM-started tasks */ + +/* FileManager */ + +#define MAXFS 4 /* maximum number of fileserver tasks */ + +/* we don't map any of these memory areas */ +#undef MAP_ZERO +#undef MAP_STACK +#undef MAP_MEM + +#endif /* _C64CONFIG_ */ + diff --git a/dump/oa-2.0.9/arch/c64/devices/c64dev.a65 b/dump/oa-2.0.9/arch/c64/devices/c64dev.a65 new file mode 100644 index 0000000..1fc195f --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/devices/c64dev.a65 @@ -0,0 +1,91 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ROM + +#include "kdefs.def" +#include "kernel.i65" + + ;.word $700 + *=$700 + +/*#define NOPRG*/ + +#endif + + +/* Device-Block */ + + .( + +#if 0 /*ndef NOMMU*/ +-sysmem =$300 /* werte um mit OS/A 1.33 nicht zu kollidieren */ +-syszp =$d0 +#endif + +#ifdef ROM + .word endd + .byt PK_DEV+$80 + .word devstart + .dsb P_NAME - P_RAM, $ff + .asc "devices",0 +#else +#ifndef NOPRG + .word 0 + .byt PK_DEV + .byt 0 + .word 0 + .word devstart + .byt 0,0,<-1 +#endif +#endif + +devstart + +-sernr = "1" + +#define CONSOLE_DEVICE "devices/con_c64.a65" +#include "devices/console.a65" ; video device is merged with OS/A now... + +#include "devices/nulldev.a65" ; null device +#include "devices/spooler.a65" ; spooler device +#include "devices/ser_9600.a65" ; fast serial interface by Daniel Dallmann + +#ifdef ACIABASE +#print ACIABASE +#include "devices/ser_acia.a65" +#endif + +#ifdef UARTBASE +#include "devices/ser_uart.a65" ; standard UART 16550A driver +#endif + .word $ffff + +#if 0 +#print sysmem +#print syszp +#endif + +endd .) + diff --git a/dump/oa-2.0.9/arch/c64/devices/con_c64.a65 b/dump/oa-2.0.9/arch/c64/devices/con_c64.a65 new file mode 100644 index 0000000..e9da08c --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/devices/con_c64.a65 @@ -0,0 +1,319 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#define MAX_SCREEN 4 /* hard maximum number of screens */ + +#define MAX_ASCREEN #4 /* soft maximum number of screens */ + +#define SWITCHKEY C64SWITCH + +#define SET_MMU + +#define BELLIRQ + +#define TRIGBELL + +#define MAXSPAL #40 + +#define MAXZEIL #25 + +#define KEY_START 20 /* when does key repetition start */ + + /* screen# -> hi byte of base address in AC */ +#define HI_VID asl:asl:clc:adc #VIDPAGE<<4 + +#define ACT_HI_VID lda hivid + +#define SCR_SPACE 32 + +#define SCR2ASC + +#define ASC2SCR + +&console_init .( + jsr inivid + jsr inicrsr + jsr inikbd + rts + .) + +/* + * For the C64 we put the video screen memory to $e000-$ec00, i.e. + * we have three possible screens only. We need $ec00-$efff for the + * stdlib. We use the std charom at $d000 in the RAM under I/O that + * the VIC doesn't see. The boot loader has to copy the charom there. + * Then we have all the memory below the I/O relatively free. + */ + +inivid .( + lda #0 + sta C64VIC+VIC_IRR ; no interrupts + sta C64VIC+VIC_SPRITE_EN ; sprites off + lda #27 + sta C64VIC+VIC_CR1 ; 25 lines + lda #8 + sta C64VIC+VIC_CR2 ; 40 cols +; lda #(($10 & %001110000)>>3)+(($20 & %00111100)<<2) + lda #%10000100 + sta C64VIC+VIC_BASE ; character and screen base + + lda C64CIA2+CIA_DDRA ; set upper two video address bits + ora #3 ; via CIA2, PRA Bit 0 and 1 + sta C64CIA2+CIA_DDRA ; set bits to output mode + lda C64CIA2+CIA_PRA + and #%11111100 + sta C64CIA2+CIA_PRA ; change to uppermost page ($c000-) + + lda #C64_TEXT_COL ; set the screen (text) color + ldy #0 +coloop sta $d800,y + sta $d900,y + sta $da00,y + sta $db00,y + iny + bne coloop + + lda #C64_BGND_COL ; set the border and background color + sta C64VIC+VIC_BGND_COL0 + lda #C64_BORDER_COL + sta C64VIC+VIC_EXT_COL + rts + .) + +&setact .( + asl + asl + asl + asl + ora #%10000100 + sta C64VIC+VIC_BASE + rts + .) + +/************************************************************************** + * Cursor handling + */ + + .( + .data +crsrfl .byt 0 +crsrcnt .byt 0 + .text + +&inicrsr + lda #0 + sta crsrfl + sta crsrcnt + rts + +&&crsroff .( ; disable cursor + bit crsrfl + bpl ret ; not enabled + + bit crsrfl + bvc clr ; not inversed + ldy spalte + lda (vzei),y + eor #$80 + sta (vzei),y +clr lda #0 + sta crsrfl +&ret rts + .) + +&&crsron .( ; enable cursor + bit crsrfl + bmi irq ; already enabled + lda #0 ; inverse cursor next crsrirq + sta crsrcnt + lda #128 ; enabled, but not invers + sta crsrfl + +&irq + dec crsrcnt + bpl ret ; not this time + lda #10 + sta crsrcnt + + ldy spalte + lda (vzei),y + eor #$80 + sta (vzei),y + lda crsrfl + eor #$40 + sta crsrfl + + rts + .) + + .) + +/**************************************************************************/ + + .( + +kcnt =zei2 + .data +rcnt .byt 0 +shiftfl .byt 0 +prev .byt 0 + .zero +tzei .word 0 + .text + +&inikbd .( + lda #0 + sta C64CIA1+CIA_DDRB + lda #$ff + sta C64CIA1+CIA_DDRA + sta C64CIA1+CIA_PRA + lda #4 + + sta rcnt + sta rspd + rts + .) + +&&getkey .( + lda #0 + sta shiftfl + ldy #$ff + sty kcnt + + sta C64CIA1+CIA_PRA +l0 lda C64CIA1+CIA_PRB + cmp C64CIA1+CIA_PRB + bne l0 + cmp #$ff + beq nokey + + lda #%11111110 + sta C64CIA1+CIA_PRA + pha ; we need to save this, as more pressed + ; keys can change the value read back! + ldx #0 + +l1 lda C64CIA1+CIA_PRB + cmp C64CIA1+CIA_PRB + bne l1 + ldy #8 + +nextbit lsr + bcs nobit + pha + lda ktab,x + cmp #5 + bcs realkey + cmp #3 + beq realkey + ora shiftfl + sta shiftfl + bpl l3 +realkey stx kcnt +l3 pla +nobit inx + cpx #65 + bcs endkey + dey + bne nextbit ; test next bit + pla + sec + rol + sta C64CIA1+CIA_PRA + pha + bne l1 ; always + +endkey pla + lda kcnt + cmp #$ff + beq nokey + cmp prev + bne lx + + dec rcnt + bne nkret + ldx rspd + .byt $2c + +lx ldx #KEY_START + stx rcnt + + sta prev + + tay + lda shiftfl + and #3 + asl + tax + lda ttab,x + sta tzei + lda ttab+1,x + sta tzei+1 + + lda (tzei),y + ldx shiftfl + clc + rts + +nokey ldx #<-1 + stx prev + ldx #KEY_START + stx rcnt +nkret ldx shiftfl + sec + rts + .) + +ttab .word ktab, stab, ctab, sctab + +ktab .byt TC_BS, TC_CR, TC_CRGT, 0, 6 /* F1 */, 0, 0, TC_CDWN + .byt "3wa4zse", 1 /* shift */ + .byt "5rd6cftx7yg8bhuv" + .byt "9ij0mkon+pl-.:@," + .byt "\*;", TC_HOME, 1 /* shift */, "=^^/" + .byt "1_", 2 /* control */, "2 ", 6 /* C= */, "Q", 3 /* stop */ + +stab .byt TC_INS, TC_LF, TC_CLFT, 0, 6 /* F1 */, 0, 0, TC_CUP + .byt "#WA$ZSE", 1 /* shift */ + .byt "%RD&CFTX'YG(BHUV" + .byt ")IJ0MKON+PL->[@<" + .byt "\*]", TC_CLR, 1 /* shift */, "=^^?" + .byt "!", TC_ESC, 2 /* control */, 34," ", 6 /* C= */, "Q", 3 /*stop*/ + +ctab .byt TC_DEL, TC_EOL, TC_WRU, 0, 6 /* F1 */, 0, 0, TC_WLO + .byt "3^w^a4^z^s^e", 1 /* shift */ + .byt "5^r^d6^c^f^t^x7^y^g8^b^h^u^v" + .byt "9^i^j0^m^k^o^n+^p^l-.:@," + .byt "\*;", TC_WCLS, 1 /* shift */, "=^^/" + .byt "1", TC_CLL, 2 /* control */, "2 ", 6 /* C= */, "Q", 3 /*stop*/ + +sctab .byt TC_INS, TC_LF, TC_CLFT, 0, 6 /* F1 */, 0, 0, TC_CUP + .byt "3^W^A4^Z^S^E", 1 /* shift */ + .byt "5^R^D6^C^F^T^X7^Y^G8^B^H^U^V" + .byt "9^I^J0^M^K^O^N+^P^L-.:@," + .byt "\*;", TC_CLR, 1 /* shift */, "=^^/" + .byt "1_", 2 /* control */, "2 ", 6 /* C= */, "Q", 3 /* stop */ + + .) + diff --git a/dump/oa-2.0.9/arch/c64/devices/piec_c64.a65 b/dump/oa-2.0.9/arch/c64/devices/piec_c64.a65 new file mode 100644 index 0000000..1e89826 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/devices/piec_c64.a65 @@ -0,0 +1,460 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * C64 parallel IEC bus + * hardware routines for fsiec + * + */ + + +#define TPI $df00 +#define CIA2 $dd00 + +#include "chips/tpi6525.i65" +#include "chips/cia6526.i65" + + .data +byte .byt 0 +bytfl .byt 0 +eoifl .byt 0 + .text + + /* when we get the IEC semaphore, we have nothing to do left, + assuming that no other program changes the I/O lines. + The timer is configured correctly in setti every time it + is needed. We also assume that any timer interrupt is + disabled by other devices when releasing the interface. */ +&getif .( + clc + ldx #SEM_CIA2TB + jsr PSEM +#ifdef NMIDEV + lda #NMI_OFF + jmp CTRLNMI +#else + rts +#endif + .) + +&freif .( +#ifdef NMIDEV + lda #NMI_ON + jsr CTRLNMI +#endif + ldx #SEM_CIA2TB + jmp VSEM + .) + +&IECINIT .( + jsr getif + ; the following lines are from the original code + lda #%00011100 + sta TPI+TPI_DDPC + cmp TPI+TPI_DDPC + bne inix + lda #0 + sta TPI+TPI_PC + + sta TPI+TPI_DDPB + cmp TPI+TPI_DDPB + bne inix + + lda #%00111010 + sta TPI+TPI_PA + lda #%00111111 + sta TPI+TPI_DDPA + cmp TPI+TPI_DDPA + bne inix + + lda TPI+TPI_PC + and #%11111110 + sta TPI+TPI_PC + ldy #255 +l0 dey + nop + bne l0 + lda TPI+TPI_PC + ora #1 + sta TPI+TPI_PC + + lda #%00111001 + sta TPI+TPI_PA + + lda #0 + sta byte + sta bytfl + sta eoifl + clc + .byt $24 +inix sec + php + jsr freif + plp + rts + .) + +/* Blocktiefe 2 */ + +aout=atnout +/* +aout + sei + pha + jsr iecsetoutput + lda #0 + sta status +; jsr nrfdhi +; jsr ndachi +;jsr eoilo + + lda bytfl + beq oo1 + sec + ror eoifl + jsr iecout + lda #0 + sta bytfl +;jsr eoihi + +oo1 + pla + sta byte +*/ +iec0out + jsr iecsetoutput + jsr waitdavhi + jsr atnlo + +iecout .( + sei +; jsr davhi +lda #%00010010 +ora TPI+TPI_PA +sta TPI+TPI_PA +; jsr iecsetoutput + jsr tstdev ;nrfdhi & ndachi = z + beq devnotpr + lda byte + jsr out +ox1 JSR setti +ox1a JSR fragti + BNE XTO + ;lda VIA1+VIA_DRB + lda TPI+TPI_PA + bpl ox1a ; wait nrfd hi + lda eoifl + bpl o0 + jsr eoilo +o0 jsr davlo + jsr setti +o1 jsr fragti + bne timeout + jsr fragndac ; wait ndac hi + bcc o1 + jsr davhi + jsr eoihi + lsr eoifl + jsr clrdata ; alle data hi +ox2 ;lda VIA1+VIA_DRB + lda TPI+TPI_PA + ;lsr + ;bcs ox2 ; wait ndaclo + asl + bmi ox2 + clc + cli + rts + +XTO JSR YIELD + SEI + JMP ox1 + .) + +&seclisten sta byte + jsr iecout + jsr atnhi + cli + rts + +timeout lda #1 + .byt $2c +devnotpr lda #128 + jsr seterror + jsr eoihi + jsr davhi + jsr ndachi + sec + cli + rts + +§alk sta byte + jsr iecout +; jsr nrfdlo +; jsr ndaclo +; jsr atnhi +; jsr iecsetinput +sectalkend +lda #%00111101 +and TPI+TPI_PA +sta TPI+TPI_PA +lda #%11000011 +sta TPI+TPI_DDPA +lda #0 +sta TPI+TPI_DDPB +jmp atnhi + rts + +/* ++IECOUT bit bytfl + bmi oo2 + dec bytfl + clc + bne oo3 +oo2 pha + jsr iecout + pla +oo3 sta byte + lda status + cmp #1 ; ungleich 0 = c + rts +*/ + +&UNTALK jsr atnlo + lda #95 + .byt $2c +&UNLISTEN lda #63 + jsr aout +; jsr atnhi +jsr sectalkend +/* +.( +lda TPI+TPI_PA +cmp #$38 +bne err +lda TPI+TPI_PB +beq ok +err .byt 2 +ok +.) +*/ +lda #%11111101 +ora TPI+TPI_PA +sta TPI+TPI_PA + +; lda #%00111111 +; sta TPI+TPI_DDPA +; lda #%00111001 +; sta TPI+TPI_PA + + cli + rts + +timeoutx jmp timeout + +&IECIN .( + sei + jsr ndaclo + jsr nrfdhi +i1 ;lda VIA1+VIA_DRB + ;cmp VIA1+VIA_DRB + lda TPI+TPI_PA + cmp TPI+TPI_PA + bne i1 + asl + bcc i1 ; wait nrfd hi + jsr setti +o11 jsr fragti + bne timeoutx ; c= abgelaufen + jsr fragdav ; wait dav lo + bcs o11 + jsr nrfdlo + jsr frageoi + bcs o12 + lda #64 + jsr seterror +o12 jsr bytin + pha + jsr ndachi +o12a jsr fragdav + bcc o12a + jsr ndaclo + lda status + bne o12c + pla + clc + cli + rts +o12c pla + sec + cli + rts + .) + +iecsetinput + lda TPI+TPI_PA + and #%00111101 ;61 + sta TPI+TPI_PA + lda #%11000011 ;195 + sta TPI+TPI_DDPA + lda #0 + sta TPI+TPI_DDPB + rts + +iecsetoutput + lda #%00111011 + sta TPI+TPI_DDPA + lda #$ff + sta TPI+TPI_PB + sta TPI+TPI_DDPB + lda #%11111010 ; ? + sta TPI+TPI_PA ; ? + rts + +atnhi lda TPI+TPI_PA + ora #%00001000 + sta TPI+TPI_PA + rts +atnlo lda TPI+TPI_PA + and #%11110111 + sta TPI+TPI_PA + rts + +eoihi lda TPI+TPI_PA + ora #%00100000 + sta TPI+TPI_PA + rts +eoilo lda TPI+TPI_PA + and #%11011111 + sta TPI+TPI_PA + rts + +ndachi lda TPI+TPI_PA + ora #%01000000 + sta TPI+TPI_PA + rts +ndaclo lda TPI+TPI_PA + and #%10111111 + sta TPI+TPI_PA + rts + +nrfdhi lda TPI+TPI_PA + ora #%10000000 + sta TPI+TPI_PA + rts +nrfdlo lda TPI+TPI_PA + and #%01111111 + sta TPI+TPI_PA + rts + +davhi lda TPI+TPI_PA + ora #%00010000 + sta TPI+TPI_PA + rts +davlo lda TPI+TPI_PA + and #%11101111 + sta TPI+TPI_PA + rts + +waitdavhi lda TPI+TPI_PA + cmp TPI+TPI_PA + bne waitdavhi + and #%00010000 + beq waitdavhi + rts + +tstdev lda TPI+TPI_PA + cmp TPI+TPI_PA + bne tstdev + and #%11000000 + cmp #%11000000 + rts + +clrdata lda #<-1 + sta TPI+TPI_PB + rts + +out eor #$ff + sta TPI+TPI_PB + rts + +waitnrfdhi + lda TPI+TPI_PA + cmp TPI+TPI_PA + bne waitnrfdhi + asl + bcc waitnrfdhi + rts + +fragndac lda TPI+TPI_PA + cmp TPI+TPI_PA + bne fragndac + ;lsr + asl + asl + rts + +fragdav lda TPI+TPI_PA + cmp TPI+TPI_PA + bne fragdav + asl + asl + asl + asl + rts + +bytin lda TPI+TPI_PB + eor #$ff + rts + +&setti lda CIA2+CIA_CRB + and #%11111110 + sta CIA2+CIA_CRB + lda #<65000 + ;sta VIA1+VIA_T1CL + sta CIA2+CIA_TBL + lda #>65000 + ;sta VIA1+VIA_T1CH + sta CIA2+CIA_TBH + lda CIA2+CIA_ICR ; clear overflow flag + lda #%00010001 + sta CIA2+CIA_CRB + rts + +&fragti lda CIA2+CIA_ICR + and #%00000010 + rts + +frageoi lda TPI+TPI_PA + cmp TPI+TPI_PA + bne frageoi + asl + asl + asl + rts + +#undef TPI +#undef CIA2 + + diff --git a/dump/oa-2.0.9/arch/c64/devices/ser_9600.a65 b/dump/oa-2.0.9/arch/c64/devices/ser_9600.a65 new file mode 100644 index 0000000..aa5690c --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/devices/ser_9600.a65 @@ -0,0 +1,558 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This is a driver for the newly developed 9600 baud RS232 interface + * for the C64 and the C128. It uses the shift registers of the two + * CIA 6526 for receiving and transmitting bytes. + * Currently it runs on 1MHz CPU clock (i.e. C64) only. + * + * When sending, it shifts the data byte out through the CIA1 SR, + * adding a start bit at the beginning and 7 stopbits at the end, + * which makes up two bytes for the SR. It should be possible to compress + * the stuff, but not now... + * When receiving, we wait for an NMI at Flag2, that comes with the + * received start bit. Then C64CIA2 TimerB is started and gives pulses + * at PB7, which are routed to CNT2 at the userport. The C64CIA2 shifts + * the incoming data bits to the SR and generates an NMI when the SR + * is full. + * This procedure slows down sending, but enables us to receive at + * 9600 baud. It has to be guaranteed that the NMI routine is done + * within a bit's time (i.e. about 100 CPU cycles @ 1MHz) at 9600 baud. + * + * Only 9600 Baud are supported now. Timer values etc are taken from + * the miniterm program by Daniel Dallmann + */ + + .( + .word devend2 + jmp prg1 + .asc "ser",sernr, 0 +-sernr += 1 + +/* + * status: Bit 0 = 1= handshake enabled + * 1 : 1= no ACIA found + * 4 : 1= we want to process NMIs + * 5 : 1= set RTS hi + * 6 : 1= we are transmitting + * 7 : 1= we are receiving + * + */ + + .data +dev .byt 0 +div .byt 0 +status .byt 0 +instr .byt 0 +outstr .byt 0 +brkkey .byt 0 +smode .byt 0 +inp .byt 0 +outp .byt 0 +nmistate .byt 0 + + .zero +rmode .byt 0 +oldnmi .word 0 + + .bss +bytetab .dsb 256 +inbuf .dsb 256 + + .text + +prg1 ldx #0 + + stx dev + cmp #DC_RES + beq devini + pha + lda status + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts +prgok pla + cmp #DC_IRQ + beq devirq1 + jmp others +devirq1 jmp devirq + +/*****************************************************************/ + +devini .( + lda #0 + sta status + sta instr + sta outstr + + lda #3 + sta brkkey + + lda #$80 + sta smode ; sending mode + sta rmode ; receiving <0 = wait stop bit; >0 = wait SR + + lda #0 + sta inp + sta outp + + ; generate bit reversed data field + ldx #0 +l1 stx div + ldy #8 + txa +l0 lsr + rol div + dey + bne l0 + lda div + sta bytetab,x + inx + bne l1 + + php + sei + + ; program CIA1 timer A for sending + + lda C64CIA2+CIA_DDRA ; pa2 input + and #%11111011 + sta C64CIA2+CIA_DDRA + lda #%00000001 + sta C64CIA1+CIA_ICR ; disable IRQ for CIA1 timer A + lda #%10001000 + sta C64CIA1+CIA_ICR ; enable IRQ for CIA1 SR full + lda #<50 + sta C64CIA1+CIA_TAL + lda #>50 + sta C64CIA1+CIA_TAH + lda #%01010001 ; start timer A, force load, cont mode, SR out + sta C64CIA1+CIA_CRA + + lda #$df + sta C64CIA1+CIA_SDR ; send byte $ff + lda #$ff + sta C64CIA1+CIA_SDR ; + + lda C64CIA1+CIA_ICR ; clear actual irqs + + ; program CIA2 for receiving + + lda #%01111111 + sta C64CIA2+CIA_ICR ; disable all NMI + lda C64CIA2+CIA_CRA + and #%10111111 + sta C64CIA2+CIA_CRA ; set SDR for input + + ; program CIA2 for I/O + lda #%10000110 + sta C64CIA2+CIA_PRB + lda C64CIA2+CIA_DDRB + and #%10000110 + ora #%10000110 + sta C64CIA2+CIA_DDRB + + lda #$80 + sta rmode + + sec + lda #NMIserial + jsr SETNMI ; old NMIvector is saved by SETNMI + + plp + clc + rts + .) + +/*****************************************************************/ + +devirq .( + lda C64CIA1+CIA_ICR + bpl noirq + and #%00001000 + bne notmyirq ; due to the 6526 design, all irq flags are lost now + + lda smode + ora #$80 + sta smode + +notmyirq + lda #E_OK + .byt $2c +noirq lda #E_NOIRQ + pha + + ; try to send something + lda smode + bpl endtx + + bit status + bvc endtx ; we don't send + + bit C64CIA2+CIA_PRB + bvc endtx ; CTS hi + + ldx instr ; send new data byte + jsr GETC + bcs test2 + + tax + lda bytetab,x + lsr + sta C64CIA1+CIA_SDR ; 7 data bits, 1 start bit + ror + ora #$7f + sta C64CIA1+CIA_SDR ; 1 data bit, 7 stop bits + + lda #0 + sta smode + beq endtx + +test2 cmp #E_EOF + bne endtx + jsr txoff + + ; now let's see if there's something to receive +endtx + bit status + bpl endirq + + ldx outp + cpx inp + beq nobyt ; no byte to fetch + +fetch lda inbuf,x + ldx outstr + + cmp brkkey + bne nobrk + lda #SC_SSTAT + ldy #SCE_BRK + jsr STRCMD + lda brkkey +nobrk + jsr PUTC + bcs test + + inc outp + +nobyt ldx outstr + lda #SC_STAT + jsr STRCMD +test bcc rx2end + cmp #E_NUL + bne tstwater + jsr rxoff + jmp endirq +tstwater + cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + bne nofull + jsr rtshi + jmp endirq +nofull + cmp #E_SHWM + bne twl +wh ldx #0 + jsr rtshi + jmp rx2end +twl cmp #E_SLWM + bne rx2end +wl ldx #0 + jsr rtslo + +rx2end ldx outp + cpx inp + bne fetch + +endirq pla + lda #E_NOIRQ + rts + + .) + +/*****************************************************************/ + +ctrlnmi .( + sta nmistate + cmp #NMI_ON + bne off + lda status + and #%00100000 + bne norts + jsr rts_lo +norts lda status + and #%00010000 + beq nonmi + jsr nmi_on +nonmi rts + +off + jsr rts_hi + jsr nmi_off + rts + .) + + ; structure before NMI routine as required by SETNMI + .word oldnmi + .word ctrlnmi +NMIserial .( + pha + cld + bit rmode + bmi startbit +databyte + txa + pha + + lda #%00010010 + sta C64CIA2+CIA_CRB ; stop timer + lsr + sta C64CIA2+CIA_ICR ; disable SDR NMI + lda #%10010000 + sta C64CIA2+CIA_ICR ; enable Flag2 NMI + + inc rmode ; $7f -> $80 + + lda C64CIA2+CIA_SDR ; only SDR NMI should be set + + tax + lda bytetab,x + ldx inp + sta inbuf,x + inc inp + + pla + tax + pla + bit C64CIA2+CIA_ICR + jmp (oldnmi) + +startbit + dec rmode ; $80 -> $7f + lda C64CIA2+CIA_SDR + lda #%00010011 + sta C64CIA2+CIA_CRB ; start timer + sta C64CIA2+CIA_ICR ; disable Flag2 NMI + lda #%10001000 + sta C64CIA2+CIA_ICR ; enable SR NMI + pla + bit C64CIA2+CIA_ICR + jmp (oldnmi) + + .) + +nmion .( + lda status + ora #%00010000 + sta status + lda nmistate + cmp #NMI_ON + bne nonmi +&nmi_on + lda #<100 + sta C64CIA2+CIA_TBL + lda #>100 + sta C64CIA2+CIA_TBH + + lda #%00010010 + sta C64CIA2+CIA_CRB ; Timer B force load, stop, pulse PB7 + + lda C64CIA2+CIA_ICR ; clear NMI + lda #%10011000 ; enable IRQ for Flag2 + sta C64CIA2+CIA_ICR +nonmi + rts + .) + +nmioff .( + lda status + and #%11101111 + sta status +&nmi_off + lda #%00011000 + bit rmode + bpl nmi_off ; wait for char received + sta C64CIA2+CIA_ICR + lda C64CIA2+CIA_ICR + rts + .) + +/*****************************************************************/ + +rtshi + lda status + ora #%00100000 + sta status +rts_hi + lda C64CIA2+CIA_PRB + and #%11111101 + sta C64CIA2+CIA_PRB + rts + +rtslo + lda status + and #%11011111 + sta status + lda nmistate + cmp #NMI_ON + bne nolo +rts_lo + lda C64CIA2+CIA_PRB + ora #%00000010 + sta C64CIA2+CIA_PRB +nolo + rts + +/*****************************************************************/ + +others cmp #DC_GS ; set stream to get data from + bne o1 + lda status + and #DC_SW_TX + bne devonx + tya + sta instr + jmp ok +devonx jmp devon +o1 cmp #DC_PS ; set stream to put data to + bne o2 + lda status + and #DC_SW_RX + bne devonx + tya + sta outstr +okx jmp ok +o2 cmp #DC_RX_ON ; switch receiver on + bne o3 + ; lda #3 + ; sta brkkey + jsr nmion + jsr rtslo + ;jsr dtrlo + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON ; switch sender on + bne o4 + ;jsr dtrlo + lda #DC_SW_TX +o2a ora status + sta status + bne okx +o4 cmp #DC_RX_OFF ; switch receiver off, send eof to stream + bne o5 +rxoff ldx dev + lda status + and #DC_SW_RX + beq devoffx + jsr rtshi + jsr nmioff + lda outstr + tax + lda #SC_EOF + jsr STRCMD + ldx dev + lda status + and #255-DC_SW_RX + sta status + jmp checkdtr + +devoffx jmp devoff + +o5 cmp #DC_TX_OFF ; switch sender off, send nul to stream + bne o6 +txoff ldx dev + lda status + and #DC_SW_TX + beq devoffx + lda instr + tax + lda #SC_NUL + jsr STRCMD + ldx dev + lda status + and #255-DC_SW_TX + sta status +checkdtr + and #DC_SW_TX+DC_SW_RX + bne active + ;jsr dtrhi +active jmp ok + +o6 cmp #DC_HS ; set handshake -- currently ignored (TODO) + bne o6a + lda status + and #255-1 + sta status + tya + and #1 + ora status + sta status + jmp ok + +o6a cmp #DC_SPD ; set speed - currently ignored here + bne o7 + jmp ok + +o7 cmp #DC_ST ; get status... + beq ok + cmp #DC_EXIT ; disable everything + bne o8 ; onotimp + jsr rxoff + jsr txoff + ldx dev + lda status + ora #2 + sta status + bne ok +o8 + cmp #DC_BRKKEY + bne onotimp + lda brkkey + sty brkkey + tay + ; jmp ok + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +devend2 .) + diff --git a/dump/oa-2.0.9/arch/c64/devices/ser_acia1.a65 b/dump/oa-2.0.9/arch/c64/devices/ser_acia1.a65 new file mode 100644 index 0000000..eea51d0 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/devices/ser_acia1.a65 @@ -0,0 +1,324 @@ +/**************************************************************************** + + OS/A65 Version 1.3.3 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + * + * This device is still in the old 1.3 source format. + * It also lacks the BRKKEY feature of the 1.4 kernel + * + * To use it, you have to convert it to 1.4 source format and + * implement the brkkey feature! + */ + +/* + * This is a ACIA 6551 serial line driver for CS/A65. It uses the + * hardware installed in my personal C64. The 6551 is at address $d600. + * + * The ACIA 6551 has a real bad 'feature'. The RTS/CTS lines are not + * independent from the transmitter and receiver. Instead, making + * RTS high automatically disables receiver _and_ transmitter! + * Also an incoming CTS high immediately disables the transmitter. + * That's why I use the DSR input for the CTS modem line. This line + * can be checked independently. + */ + +#ifdef ACIABASE +#define ACIA ACIABASE +#else +#define ACIA $d600 +#endif + +#print ACIA + +#define Anzdev 1 + + .( + .word devend2 + jmp prg1 + .asc "ser", sernr ,0 +-sernr += 1 + +/* + * status: Bit 0 = 1= handshake enabled + * 1 : 1= no ACIA found + * 5 : 1= set RTS hi + * 6 : 1= we are transmitting + * 7 : 1= we are receiving + * + */ + +dev =sysmem +div =sysmem+1 +status =sysmem+2 +instr =sysmem+Anzdev*1+2 +outstr =sysmem+Anzdev*2+2 +-sysmem +=Anzdev*3+2 + +prg1 ldx #0 + + stx dev + cmp #DC_RES + beq devini + pha + lda status,x + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini lda #0 + sta status,x + sta instr,x + sta outstr,x + + STA ACIA+ACIA_SR ; programmed reset + LDA #%00011000 ; 1200 BAUD, 1 stop bit, 8 data bits + STA ACIA+ACIA_CTRL + cmp ACIA+ACIA_CTRL + bne devx + LDA #%00000101 ; no parity, normal receiver mode, + ; RTS low, Tx interrupt enabled + STA ACIA+ACIA_CMD + cmp ACIA+ACIA_CMD + bne devx + LDA ACIA+ACIA_SR ; clear interrupt + + clc + rts + +devx lda status,x + ora #2 + sta status,x + lda #E_NOTIMP + sec + rts + +devirq + .( + lda ACIA+ACIA_SR + bpl irqend ; not this ACIA + tay + bit status ; check if receiving + bpl tx ; no -> tx + and #%00001000 ; Rx data register full? + beq nobyt ; no -> nobyt + ldx outstr + lda ACIA + jsr PUTC + bcs test + +nobyt ldx outstr + lda #SC_STAT + jsr STRCMD +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx +tstwater cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh ldx #0 + jsr rtshi + jmp tx ; unbedingt +twl cmp #E_SLWM + bne tx +wl ldx #0 + jsr rtslo + +tx bit status + bvc irqhs + tya + and #%00010000 ; transmit data register empty? + beq irqhs ; no then -> irqhs + + lda #32 + bit status + bne endsend ; do not send any more to make RTS high. + + tya + and #%01000000 ; DSR high? + bne irqhs ; -> irqhs + + ldx instr ; send new data byte + jsr GETC + bcs test2 + sta ACIA + bcc irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs lda ACIA+ACIA_SR + lda #E_OK ; irq source removed + rts +irqend lda #E_NOIRQ ; no irq source found + rts + +endsend + lda ACIA+ACIA_CMD + and #%11110011 + sta ACIA+ACIA_CMD + jmp irqhs + + .) + +rtshi + lda status,x + ora #%00100000 + sta status,x + rts + +rtslo + lda ACIA+ACIA_CMD + ora #%00000100 + sta ACIA+ACIA_CMD + lda status,x + and #%11011111 + sta status,x + rts + +others cmp #DC_GS + bne o1 + lda status,x + and #DC_SW_TX + bne devonx + tya + sta instr,x + jmp ok +devonx jmp devon +o1 cmp #DC_PS + bne o2 + lda status,x + and #DC_SW_RX + bne devonx + tya + sta outstr,x +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + jsr rtslo + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + lda #DC_SW_TX +o2a ora status,x + sta status,x + bne okx +o4 cmp #DC_RX_OFF + bne o5 +rxoff ldx dev + lda status,x + and #DC_SW_RX + beq devoffx + lda outstr,x + tax + lda #SC_EOF + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_RX + sta status,x + +rx1off ;jsr rts1hi + ;bcc okx + jmp okx +devoffx jmp devoff +o5 cmp #DC_TX_OFF + bne o6 +txoff ldx dev + lda status,x + and #DC_SW_TX + beq devoffx + lda instr,x + tax + lda #SC_NUL + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_TX + sta status,x + jmp ok +o6 cmp #DC_HS + bne o6a + lda status,x + and #255-1 + sta status,x + tya + and #1 + ora status,x + sta status,x + jmp ok +o6a cmp #DC_SPD + bne o7 + tya + and #%00001111 + sta div + + lda ACIA+ACIA_CTRL + and #%11110000 + ora div + sta ACIA+ACIA_CTRL + jmp ok + +o7 cmp #DC_ST + beq ok + cmp #DC_EXIT + bne onotimp + jsr rxoff + jsr txoff + ldx dev + lda status,x + ora #2 + sta status,x + sta ACIA+ACIA_SR ; programmed reset + bne ok + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +devend2 .) + diff --git a/dump/oa-2.0.9/arch/c64/devices/siec_c64.a65 b/dump/oa-2.0.9/arch/c64/devices/siec_c64.a65 new file mode 100644 index 0000000..784927b --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/devices/siec_c64.a65 @@ -0,0 +1,415 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * C64 serial IEC bus + * hardware routines for fsiec + * + */ + +#define CIA2 $dd00 + +#include "chips/cia6526.i65" + + .zero +cnt2 .byt 0 +byte .byt 0 +bytfl .byt 0 +eoifl .byt 0 + .text + + /* when we get the IEC semaphore, we have nothing to do left, + assuming that no other program changes the I/O lines. + The timer is configured correctly in setti every time it + is needed. We also assume that any timer interrupt is + disabled by other devices when releasing the interface. */ +&getif .( + clc + ldx #SEM_CIA2TB + jsr PSEM +#ifdef NMIDEV + lda #NMI_OFF + jmp CTRLNMI +#else + rts +#endif + .) + +&freif .( +#ifdef NMIDEV + lda #NMI_ON + jsr CTRLNMI +#endif + ldx #SEM_CIA2TB + jmp VSEM + .) + +&IECINIT .( + jsr getif + /* init i/o */ + + lda CIA2+CIA_DDRA + and #%00111111 + ora #%00111000 + sta CIA2+CIA_DDRA + lda CIA2+CIA_PRA + and #%11000111 + sta CIA2+CIA_PRA + + lda %00000010 + sta CIA2+CIA_ICR ; clean timer b irq mask + + lda #0 + sta status + sta cnt2 + sta bytfl + sta eoifl + clc + .byt $24 +inix sec + php + jsr freif + plp + rts + .) + +&IECIN .( + sei + lda #0 + sta eoifl + lda #8 + sta cnt2 + jsr clkhi +; jsr datalo + +l14 ; jsr testatn + ; bcs atnin + lda CIA2+CIA_PRA ; wait clkhi + cmp CIA2+CIA_PRA + bne l14 + and #$40 + beq l14 + +l19 jsr setti + jsr datahi + +l16 jsr fragti + bne l15 ; abgelaufen + ; jsr testatn + ; bcs atnin + bit CIA2+CIA_PRA ; wait clklo + bvs l16 + bvc l17 + +l15 lda eoifl + beq l18 + lda #2 + jmp error +l18 dec eoifl + jsr datalo +jsr clkhi + jsr waitus + lda #$40 ; EOF + jsr seterror + bne l19 + +l17 +l20 + lda CIA2+CIA_PRA + asl + bpl l20 + ror byte + +l21 + bit CIA2+CIA_PRA + bvs l21 + + dec cnt2 + bne l20 + + jsr datalo + + bit status + bvc l22 + jsr endhndshk + lda byte + sec + cli + rts + +l22 lda byte + clc + cli + rts + + .) + +/* +atnin jsr datalo + jsr clkhi + sec + rts +*/ + +nodev lda #$80 +;inc $d020 +error jsr seterror + jsr atnhi +endhndshk jsr waitus +; jsr datahi + jsr clkhi +jsr datahi + sec + cli + rts + +iec0out .( + sei + jsr datahi + +cmp #$3f +bne l1xxx +jsr clkhi +l1xxx + + jsr atnlo +&iec2out sei + jsr clklo + jsr datahi + jsr waitms +&iecout sei + jsr datahi +l0 + jsr checkin + bcs nodev + + jsr clkhi + bit eoifl + bpl l3 + ; eoi senden +l4 + jsr checkin + bcc l4 +l5 + jsr checkin + bcs l5 +l3 + jsr checkin + bcc l3 + + jsr clklo + lda #8 + sta cnt2 +l6 + lda CIA2+CIA_PRA + cmp CIA2+CIA_PRA + bne l6 + asl + bcc timexout + + ror byte ; bit setzen + bcs l7 + jsr datalo + bne l8 +l7 jsr datahi + +l8 jsr clkhi +; jsr waitus +nop:nop:nop:nop +; jsr dhiclo +lda CIA2+CIA_PRA +and #%11011111 +ora #%00010000 +sta CIA2+CIA_PRA + dec cnt2 + bne l6 + + jsr waitdlo + bcs timeout +; cli + rts +timeout lda #3 + .byt $2c +timexout lda #4 +; cli + jmp error + .) + +/**************************************************************************/ + +clklo + lda CIA2+CIA_PRA + ora #%00010000 + sta CIA2+CIA_PRA + rts +clkhi + lda CIA2+CIA_PRA + and #%11101111 + sta CIA2+CIA_PRA + rts +datalo + lda CIA2+CIA_PRA + ora #%00100000 + sta CIA2+CIA_PRA + rts +datahi + lda CIA2+CIA_PRA + and #%11011111 + sta CIA2+CIA_PRA + rts +atnlo + lda CIA2+CIA_PRA + ora #%00001000 + sta CIA2+CIA_PRA + rts +atnhi + lda CIA2+CIA_PRA + and #%11110111 + sta CIA2+CIA_PRA + rts + +;dhiclo +; lda CIA2+CIA_PRA +; and #%11011111 +; ora #%00010000 +; sta CIA2+CIA_PRA +; rts + +checkin .( + lda CIA2+CIA_PRA + cmp CIA2+CIA_PRA + bne checkin + asl + rts + .) + +/* +testatn .( + lda VIA1+VIA_DRA + bmi tstatn + and #%00100000 + beq c +s sec + rts +tstatn and #%00100000 + beq s +c clc + rts + .) +*/ + + +waitdlo .( + jsr setti +w1 jsr fragti + bne w2 + lda CIA2+CIA_PRA + cmp CIA2+CIA_PRA + bne w1 + asl + bcs w1 + rts +w2 sec + rts + .) + +&setti +lda CIA2+CIA_CRB ; stop timer +and #%11111110 +sta CIA2+CIA_CRB + lda #<1000 + sta CIA2+CIA_TBL + lda #>1000 + sta CIA2+CIA_TBH +lda CIA2+CIA_ICR ; clear irq flag +; lda CIA2+CIA_CRB +; and #%10011111 ; count Phi2 +; ora #%00011001 ; start, force load and single shot. +lda #%00010001 + sta CIA2+CIA_CRB + rts +&fragti + lda CIA2+CIA_ICR + and #%00000010 + rts + +waitms txa + ldx #$b6 + bne w4 +waitus txa + ldx #8 +w4 dex + bne w4 + tax + rts + +sectalk .( + sei + sta byte + jsr iec2out + bcs st1 + jsr datalo + jsr atnhi + jsr clkhi +st2 ;bit VIA1+VIA_DRA + bit CIA2+CIA_PRA + bvs st2 +st1 cli + rts + .) + +seclisten .( + sei + sta byte + jsr iec2out + jsr atnhi + cli + rts + .) + +&UNTALK .( + sei + jsr clklo + lda #$5f + jsr atnout + jsr atnhi + jsr clkhi + jsr datahi + cli + rts + .) + +&UNLISTEN .( + lda #$3f + sei + jsr atnout + jsr atnhi + jsr clkhi + cli + rts + .) + +#undef CIA2 + + diff --git a/dump/oa-2.0.9/arch/c64/kernel/kenv.a65 b/dump/oa-2.0.9/arch/c64/kernel/kenv.a65 new file mode 100644 index 0000000..ec219e1 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/kernel/kenv.a65 @@ -0,0 +1,406 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* TODO: make stack addr computation a table lookup, which is faster */ + +/* Struct Task Environment Entry */ + +/* we have three structs now: + * TE_* for task environment handling - not needed for system without + * memory management + * TT_* task table, contains STD streams, etc + * TH_* thread table, has stack info and state + */ + +#define TE_SLEN 0 /* we don't have envs */ + +/************************************************************************ + * These routines are needed in the env section! + * inienv + * setthread + * initsp + * push + * pull + * memtask + * memsys + * + * sbrk + * getenv + * freenv + */ + +&&enmem = notimp ; to enable memory blocks to the kernel +&&setblk = notimp ; to set memory blocks in MMU mapping + +#ifdef STACKCOPY + .zero +zp .word 0 + + .data + +Stacks .dsb MAXNTHREADS * STACKSIZE + + .text +#endif + + +&inienv .( + lda #<-1 + sta actThread + sta actTask + lda #1 + sta Syscnt + clc + rts + .) + +setthread .( + .data +newThread .byt 0 + .text + + cmp actThread + bne doit + rts +doit + sta newThread + + ldx actThread + cpx #<-1 + beq nosave + + lda THREADSAVE + sta threadTab + TH_LIBSAVE,x + lda THREADSAVE+1 + sta threadTab + TH_LIBSAVE+1,x + +#ifdef STACKCOPY + txa ; stack is 8 * TH_SLEN = 64 + ldy #0 + sty zp+1 + asl + rol zp+1 + asl + rol zp+1 + asl + rol zp+1 + clc + adc #Stacks + adc zp+1 + sta zp+1 + ;bcc l1 + ;inc zp+1 +;l1 + lda threadTab + TH_SP,x + tay + iny +l2 cpy #STACKSIZE + bcs savetask + lda $100,y + sta (zp),y + iny + bne l2 +#endif +savetask + ldy threadTab + TH_TASK,x + lda TASKSAVE + sta taskTab + TT_LIBSAVE,y + lda TASKSAVE + 1 + sta taskTab + TT_LIBSAVE + 1,y +nosave +loadtask + ldx newThread + stx actThread + cpx #<-1 + bne load + stx actTask + beq noload +load + ldy threadTab + TH_TASK,x + sty actTask + + lda taskTab + TT_LIBSAVE,y + sta TASKSAVE + lda taskTab + TT_LIBSAVE + 1,y + sta TASKSAVE + 1 + +loadthread + lda threadTab + TH_LIBSAVE,x + sta THREADSAVE + lda threadTab + TH_LIBSAVE+1,x + sta THREADSAVE+1 + +#ifdef STACKCOPY + txa + ldy #0 + sty zp+1 + asl + rol zp+1 + asl + rol zp+1 + asl + rol zp+1 + clc + adc #Stacks + adc zp+1 + sta zp+1 + ;bcc l3 + ;inc zp+1 +;l3 + lda threadTab + TH_SP,x + tay + iny +l4 cpy #STACKSIZE + bcs endset + lda (zp),y + sta $100,y + iny + bne l4 +#endif +noload +endset rts + .) + +initsp .( +#ifdef STACKCOPY + lda #STACKSIZE-1 + ;ldx actThread + sta threadTab + TH_SP,x + rts +#else + .data +divsp .byt 0 + .text + + ;ldx actThread + txa + clc + adc #TH_SLEN + sta divsp + asl + asl ; split stack + clc + adc divsp + sta threadTab + TH_SP,x + dec threadTab + TH_SP,x + rts +#endif + .) + +pull .( + ldx actThread + inc threadTab + TH_SP,x + lda threadTab + TH_SP,x + tay + lda $0100,y + rts + .) + +&push .( + pha + ldx actThread + lda threadTab + TH_SP,x + tay + pla + sta $0100,y + dec threadTab + TH_SP,x + rts + .) + + .( + .zero +AC .byt 0 +XR .byt 0 +YR .byt 0 +SR .byt 0 +ADR .word 0 +&SSP .byt 0 + .text + +/* + * this one is used to return from an interrupt. We do not need to save + * any registers. so for brevity, we do it as macro + * This doesn't check for interrupted devices, as we do not have them + * without MMU (so far). + */ + +#define MEMTASK2() \ + .( :\ + sei :\ + dec Syscnt :\ + bne mtask :\ + tsx :\ + stx SSP :\ + ldy actThread :\ + ldx threadTab+TH_SP,y :\ + txs :\ +mtask .) + +/* + * This is the standard return to user space. the kernel jumps here, + * so we need not save any return address, but use the one on the + * user stack. + */ +&&memtask .( + php + sei + dec Syscnt ; wieder in Task + bne mtask ; nein dann Ende +#ifndef NO_DEVICE + bit adev ; Ruecksprung in Device + bpl mtask ; ja dann Ende +#endif + sty YR ; sonst Task-Env setzen + stx XR + sta AC + pla ; SR + + tsx + stx SSP + + ldy actThread + ldx threadTab+TH_SP,y + txs + + pha ; SR + lda AC + ldy YR + ldx XR +mtask + plp + rts + .) + +/* + * This is the kernel entry routine. It leaves all registers as they + * are, except for the stack pointer, which is set to the system stack. + * also the return address is moved from user stack to system stack, + * to allow "JSR"-ing to memsys. + */ +&&memsys php + sei + pha + lda Syscnt + inc Syscnt + cmp #0 +#ifdef NO_DEVICE + beq msys +#else + bne mse + bit adev ; called by device + bmi msys ; no then save stack +#endif +mse pla + plp + rts + +msys pla + sta AC + pla + sta SR + stx XR + ; sty YR + pla + sta ADR + pla + sta ADR+1 + tsx + txa + ldx actThread + sta threadTab+TH_SP,x + ldx SSP + txs + lda ADR+1 + pha + lda ADR + pha + lda SR + pha + lda AC + ldx XR + ; ldy YR + plp + cld + rts + .) + + +&&sbrk .( + bcc ok + sec + lda #E_NOMEM + rts +ok lda #>ROMSTART ; return available memory + clc + rts + .) + +kgetenv .( + ldx #0 + clc + rts + .) + +freenv .( + clc + rts + .) + +/* + * MAPSYSBUF() maps the PCBUF of the active task into the system memory + * at address SYSBUF. It's not needed in a C64... + */ +#undef MAPSYSBUF +#define SYSBUF $200 + +/* + * MAPENV() maps the address given in a/y in env x to somewhere in the + * kernel map. returns mapped address in a/y + * MAPAENV() does the same but for the actual task (env) + */ +#define MAPENV() +#define MAPAENV() + + +/* + * needed for GETINFO, gives RAM available for task + */ +#define GETTASKMEM lda #>ROMSTART + +/* + * copy routines for SEND/RECEIVE and FORK + */ +#undef CPPCBUFRX +#undef CPPCBUFTX +#define CPFORKBUF() + +/* + * needed in device code to get active environment in AC + */ +#define GETACTENV() lda #<-1 + + diff --git a/dump/oa-2.0.9/arch/c64/kernel/kinit.a65 b/dump/oa-2.0.9/arch/c64/kernel/kinit.a65 new file mode 100644 index 0000000..9b5779d --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/kernel/kinit.a65 @@ -0,0 +1,141 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * This file is included in the RESET routine of the kernel, + * after the "sei:cld". The routine starting at the bginning + * of this file must initialize the hardware to the system RAM + * in the beginning and the system ROM in the end of the memory + * map. Also the system stack (pointer) is setup. + * + * In addition to that the system interrupt timer (needed for + * task preemtion) must be setup. + * + * After that the file must define the following macros: + * + * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz + * LEDPORT address of LED port to signal hardware failures + * LED_LED bit of LED bit in LEDPORT address + * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces + * the LED toggle routine if needed. + * CLRTIMER() clear the system interrupt timer interrupt + * KERNELIRQ() returns if an interrupt occured in the kernel + * or outside. Is checked by "BNE IRQ_in_Kernel" + * SAVEMEM() save system mem config for interrupt + * RESTOREMEM() restore system mem config after interrupt + * STARTMEM() This is used to alloc/enable memory pages found + * during kernel init. Takes mem size in AC as given + * by the kernel init. It is called _after_ inimem! + */ + +/* Kernel routines for C64 hardware */ + +/* + * init stack pointer for system stack + */ + ldx #<-1 + txs + +/* + * init memory configuration + */ + lda #7 + sta 0 /* CPU data direction register */ + lda #5 + sta 1 /* Memory configuration */ + +/* + * C64 specific irq timer init, irq every 20ms + * We assume that the reset - or a loader program has disabled all irq + */ + lda #<20000 + sta C64CIA1+CIA_TBL ; load low byte + lda #>20000 + sta C64CIA1+CIA_TBH ; load hi byte of counter value + lda #%00010001 + sta C64CIA1+CIA_CRB ; start counter, counting system pulses + lda #%10000010 + sta C64CIA1+CIA_ICR ; allow irq + +/* + * check zeropage RAM, jump to he_zero if failure + */ +#include "kernel/zerotest.a65" + +/* + * check system RAM up to ROMSTART, jump to he_ram if failure + * returns available RAM in 256 byte blocks in AC + */ + .zero +cnt .byt 0 + .text +#include "kernel/ramtest.a65" + cmp #MIN_MEM + bcc he_ram + +/* + * originally SYSPORT specific, they have a value for the C64 also... + */ +#define GETFREQ() lda #0 + +#define LEDPORT $d020 +#define LED_LED 1 + +/* + * as we have set the CIA1 TB irq in the kernel, we have to clear the + * CIA interrupt flag. This is done with reading the ICRegister. + * With C64NEEDCIA1 one can disable reading the ICR here. But then you + * have to have a device that does it! + */ +#ifndef C64NEEDCIA1 +#define CLRTIMER() lda C64CIA1+CIA_ICR +#else +#define CLRTIMER() +#endif + +/* + * MMU systems may map task pages into kernel mem to make copying + * easier. This mapping has to be preserved during interrupt. + * SAVEMEM() saves the memory configuration, while RESTOREMEM() + * restores it, obviously. + * These routines are called _after_ "jsr memsys", so this routine + * has to preserve this mapping when called from kernel space, + * and so must memtask. + */ + +#undef SAVEMEM +#undef RESTOREMEM + +/* + * Check if we have an interrupt in the kernel + */ + +#define KERNELIRQ() lda Syscnt:cmp #1 + +/* + * no memory management... + */ +#define STARTMEM() + + diff --git a/dump/oa-2.0.9/arch/c64/test/Makefile b/dump/oa-2.0.9/arch/c64/test/Makefile new file mode 100644 index 0000000..6fdeccc --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/test/Makefile @@ -0,0 +1,75 @@ + +apps = lsh +sysapps = mon slipd +files = mkdir rmdir rm format chkdsk ls cat mv +inet = tlogin telnet httpd + +XA=xa + +all: boot c64rom ${files} ${apps} ${sysapps} ${inet} + +c64 c64rom: + (cd ..; ${MAKE};) + +boot: boot.a65 + ${XA} boot.a65 -o boot + +clean: + rm -f c64rom boot slip test test2 ktest test osa.d64 tstenv + rm -f ${files} ${sysapps} ${apps} ${inet} + rm -f vice.trace reltest + +tar ../boot.tgz: boot c64rom loader charom index.html slip howto.boot + tar czvf ../boot.tgz boot c64rom loader charom index.html slip howto.boot + +ktest: ktest.a65 + (XAINPUT=../../../; export XAINPUT; ${XA} -DSTDIOADDR=53248 -DKERNEL=61440 ktest.a65 -o ktest) + +ttest2: test2.a65 + (XAINPUT=../../../; export XAINPUT; ${XA} -DSTDIOADDR=53248 -DKERNEL=61440 test2.a65 -o test2) + +test: test.a65 + (XAINPUT=../../../include; export XAINPUT; ${XA} -R -DSTDIOADDR=53248 test.a65 -o test) + +tstenv: tstenv.a65 + ${XA} -R -I ../../../include -DSTDIOADDR=53248 tstenv.a65 -o tstenv + +reltest: reltest.a65 + ${XA} -R reltest.a65 -LOSA2KERNEL -LLIB6502 -o reltest + +############################################################################## +# +# d64 emulator disk image + run +# + +osa.d64: ${files} ${sysapps} ${apps} ${inet} c64rom boot loader charom index.html + ./mkdisk ${files} ${sysapps} ${apps} ${inet} c64rom boot loader charom index.html + +emurun: osa.d64 + x64+rs232 -1541 -8 osa.d64 + +emuslip: all + x64+rs232 -kernal ~/csa/tmp/kernalb -speed 200 + +############################################################################## +# +# lib6502 programs +# + +${apps}: + (cd ../../../apps/lsh; make lsh;) + (if test ! -r lsh; then ln -s ../../../apps/lsh/lsh lsh; fi) + +${sysapps}: + (cd ../../../sysapps/$@; make $@;) + (if test ! -r $@; then ln -s ../../../sysapps/$@/$@ $@; fi) + +${files}: + (cd ../../../apps/file; make $@;) + (if test ! -r $@; then ln -s ../../../apps/file/$@ $@; fi) + +${inet}: + (cd ../../../apps/inet; make $@;) + (if test ! -r $@; then ln -s ../../../apps/inet/$@ $@; fi) + + diff --git a/dump/oa-2.0.9/arch/c64/test/ktest.a65 b/dump/oa-2.0.9/arch/c64/test/ktest.a65 new file mode 100644 index 0000000..25ba796 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/test/ktest.a65 @@ -0,0 +1,66 @@ + +#include "include/kdefs.i65" +#include "include/kernel.i65" + + .word $2000 + *=$2000 + +/* TEST1 + lda #thread1 + jsr FORKT + rts + +thread1 inc $d020 + jsr YIELD + jmp thread1 +*/ + +/* TEST2 */ + ldx #SEM_SENDBUF + clc + jsr PSEM + + lda #STDIN + sta PCBUF+FORK_STDIN + lda #STDOUT + sta PCBUF+FORK_STDOUT + lda #STDERR + sta PCBUF+FORK_STDERR + + lda #forkaddr + sta PCBUF+FORK_ADDR+1 + + jsr FORK + rts +forkaddr + lda #sigaddr + sec + jsr SETSIG + lda #$81 + clc + jsr SETSIG + + /* if not commented, keep thread in kernel call */ +/* +repeat ldx #SEM_SENDBUF + clc + jsr PSEM + bcc task1 + cmp #E_INT + beq ok + brk +ok inc $d021 + jmp repeat +*/ +task1 + jsr YIELD + jmp task1 + +sigaddr inc $d020 + pla + rti + diff --git a/dump/oa-2.0.9/arch/c64/test/reltest.a65 b/dump/oa-2.0.9/arch/c64/test/reltest.a65 new file mode 100644 index 0000000..757c883 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/test/reltest.a65 @@ -0,0 +1,10 @@ + + .byt 2 ; jam if start from the beginning of the file +foo +main ; not at the beginning + lda LIB6502 + lda OSA2KERNEL + inc $d020 + rts + + diff --git a/dump/oa-2.0.9/arch/c64/test/test.a65 b/dump/oa-2.0.9/arch/c64/test/test.a65 new file mode 100644 index 0000000..feed51b --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/test/test.a65 @@ -0,0 +1,41 @@ + +#include "kdefs.i65" +#include "lib6502.i65" + + .zero +z .byt 0 + + .text + +ll inc $d020 + jmp ll +/* + ldy #0 + +l0 sty z + lda text,y + + sta bss,y + beq ende + + ldx #STDOUT + jsr fputc + bcs ende + + ldy z + iny + bne l0 +ende + rts + + + .data + +text .asc "the quick brown fox jumps over the lazy dog",0 + + .bss + +bss .dsb 100 + +*/ + diff --git a/dump/oa-2.0.9/arch/c64/test/test2.a65 b/dump/oa-2.0.9/arch/c64/test/test2.a65 new file mode 100644 index 0000000..8007806 --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/test/test2.a65 @@ -0,0 +1,52 @@ + + *=$2000 + +#include "include/kdefs.i65" +#include "include/fdefs.i65" + + ldx #SEM_SENDBUF + sec + jsr PSEM + + ldy #0 + + lda #5 + sta PCBUF,y + iny + + jsr GETSTR + bcs err + stx str + txa + sta PCBUF,y + + iny + lda #0 + sta PCBUF,y + +l0 iny + lda name-FS_OPEN_NAME,y + sta PCBUF,y + bne l0 + + iny + lda #FS_OPEN_RD + ldx #SEND_FM + jsr SEND + + jsr XRECEIVE + + cmp #1 + bcs err + + ldx str + jsr Loader +err + rts + +str .byt 0 +name .asc "test",0 + +#include "stdlib/stdio.a65" +#include "include/kernel.i65" + diff --git a/dump/oa-2.0.9/arch/c64/test/tstenv.a65 b/dump/oa-2.0.9/arch/c64/test/tstenv.a65 new file mode 100644 index 0000000..278ae5f --- /dev/null +++ b/dump/oa-2.0.9/arch/c64/test/tstenv.a65 @@ -0,0 +1,47 @@ + +#include "lib6502.i65" + ++main .( +.byt 2 + lda #t1 + jsr getenv +.byt 2 + lda #t2 + jsr putenv + + lda #t1 + jsr getenv + + lda #t3 + jsr putenv + + lda #t4 + jsr getenv + +.byt 2 + + lda #forkx +; jsr forkto + + lda #0 + rts + + .data +t1 .asc "AVAR",0 +t2 .asc "BVAR=test",0 +t3 .asc "AVAR2=foo",0 +t4 .asc "BVAR",0 + +forkx .byt STDIN, STDOUT, STDERR, "tstenv",0,0 + .zero + .byt 0 + + .text + .) + diff --git a/dump/oa-2.0.9/arch/cbm8x96/Makefile b/dump/oa-2.0.9/arch/cbm8x96/Makefile new file mode 100644 index 0000000..b1ec28b --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/Makefile @@ -0,0 +1,20 @@ + +TRG=boot/rom + +XAINPUT=../../include,..,../.. +XA=xa +FILE=file65 +RELOC=reloc65 + +pet ${TRG}: # $(wildcard *.a65) + ${XA} -I../../include -I../.. -R -bt 2814 -bd 768 -bz 8 -bb 61440 rom.a65 -o rom.o65 -l rom.lab; + # ${XA} -I../../include -I../.. -R -bt 2046 -bd 30720 -bz 8 -bb 61440 rom.a65 -o rom.o65 -l rom.lab; + ${FILE} rom.o65; + ${RELOC} -xt -o ${TRG} rom.o65; + + +clean: + rm -f ${TRG} rom.lab rom.o65 boot.tgz + (cd boot; ${MAKE} clean;) + # (cd apps; ${MAKE} clean;) + diff --git a/dump/oa-2.0.9/arch/cbm8x96/boot/Makefile b/dump/oa-2.0.9/arch/cbm8x96/boot/Makefile new file mode 100644 index 0000000..c75c387 --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/boot/Makefile @@ -0,0 +1,58 @@ + +apps = lsh +sysapps = mon # slipd +files = mkdir rmdir rm format chkdsk ls cat mv +inet = # tlogin telnet httpd + +XA=xa + +all: rom ${files} ${apps} ${sysapps} ${inet} + +rom: + (cd ..; ${MAKE};) + +clean: + rm -f rom osa.d64 osa.x64 + rm -f ${files} ${sysapps} ${apps} ${inet} + rm -f vice.trace reltest + +tar ../boot.tgz: rom loader howto.boot + tar czvf ../boot.tgz rom loader howto.boot + +############################################################################## +# +# d64 emulator disk image + run +# + +osa.d64: ${files} ${sysapps} ${apps} ${inet} rom loader + ./mkdisk ${files} ${sysapps} ${apps} ${inet} rom loader + dd if=osa.x64 of=osa.d64 bs=64 skip=1 + +emurun: osa.d64 + xpet -model 8096 -8 osa.d64 + +emuslip: all + x64+rs232 -kernal ~/csa/tmp/kernalb -speed 200 + +############################################################################## +# +# lib6502 programs +# + +${apps}: + (cd ../../../apps/lsh; make lsh;) + (if test ! -r lsh; then ln -s ../../../apps/lsh/lsh lsh; fi) + +${sysapps}: + (cd ../../../sysapps/$@; make $@;) + (if test ! -r $@; then ln -s ../../../sysapps/$@/$@ $@; fi) + +${files}: + (cd ../../../apps/file; make $@;) + (if test ! -r $@; then ln -s ../../../apps/file/$@ $@; fi) + +${inet}: + (cd ../../../apps/inet; make $@;) + (if test ! -r $@; then ln -s ../../../apps/inet/$@ $@; fi) + + diff --git a/dump/oa-2.0.9/arch/cbm8x96/boot/howto.boot b/dump/oa-2.0.9/arch/cbm8x96/boot/howto.boot new file mode 100644 index 0000000..e40a827 --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/boot/howto.boot @@ -0,0 +1,13 @@ + +Howto Boot the GeckOS/A65 on 8x96 +------------------------------------- + +1) transfer all files in this directory to a (1541) disk. (osa.d64) + +2) put this disk to a CBM2031/CBM4040 or other IEEE488 disk drive + connected with to the 8x96. + +3) load the file "loader" on the 8x96 and run it + After a while the new OS should come up and running + (Repeat switches between virtual terminals) + diff --git a/dump/oa-2.0.9/arch/cbm8x96/boot/index.html b/dump/oa-2.0.9/arch/cbm8x96/boot/index.html new file mode 100644 index 0000000..81d49b0 --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/boot/index.html @@ -0,0 +1,20 @@ + + OS/A65 Operating System + +

OS/A65 Operating System

+

(c) 1989-1997 +André Fachat [Mail] +[Homepage]

+

+In 1989 I started this little computer project, building an own 6502 +computer. After a long break I started working on it again in 1996. +I wrote an own operating system for it which I have also ported to the +Commodore 64. +In the meantime it has grown a lot, featuring a standard library, +relocatable files, multithreading/multitasking and much more. +

+However, this is a test file, so please go to the real +GeckOS/A65 +page.

+ + diff --git a/dump/oa-2.0.9/arch/cbm8x96/boot/loader b/dump/oa-2.0.9/arch/cbm8x96/boot/loader new file mode 100644 index 0000000..b051480 --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/boot/loader Binary files differ diff --git a/dump/oa-2.0.9/arch/cbm8x96/boot/loader11 b/dump/oa-2.0.9/arch/cbm8x96/boot/loader11 new file mode 100644 index 0000000..204dd6a --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/boot/loader11 Binary files differ diff --git a/dump/oa-2.0.9/arch/cbm8x96/boot/loaderm b/dump/oa-2.0.9/arch/cbm8x96/boot/loaderm new file mode 100644 index 0000000..c545c4f --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/boot/loaderm Binary files differ diff --git a/dump/oa-2.0.9/arch/cbm8x96/boot/mkdisk b/dump/oa-2.0.9/arch/cbm8x96/boot/mkdisk new file mode 100755 index 0000000..ddfd9b8 --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/boot/mkdisk @@ -0,0 +1,24 @@ +#!/bin/sh + +echo "set tmpfile" +tmpfile=/tmp/mkdisk.$user.$$ + +#echo "get files" +#files=`ls *` + +files="$*" + +echo "files=$files" + +echo "format osa,65 x64 osa.x64" > $tmpfile + +for i in $files; do + if test "$i" != "mkdisk" -a "$i" != "osa.d64" ; then + echo "write $i" >> $tmpfile + fi +done + +cat $tmpfile | c1541 > /dev/null + +rm -f $tmpfile + diff --git a/dump/oa-2.0.9/arch/cbm8x96/config.i65 b/dump/oa-2.0.9/arch/cbm8x96/config.i65 new file mode 100644 index 0000000..61042db --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/config.i65 @@ -0,0 +1,73 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef _PETCONFIG_ +#define _PETCONFIG_ + +#echo ******** PET config ********** + + +/* StreamData */ + +#define ANZSTRM 16 /* number of streams */ + +/* SemaphoreData */ + +#define ANZSEM 8 /* number of semaphores - multiple of 8 */ +#define SYSSEM 8 /* multiple of 8, no of system semaphores + i.e. sems from -SYSSEM to -1 */ + +/* DeviceData */ + +#define MAXDEV 16 /* maximum number of devices */ + +/* EnvData */ + +#define MAXENVS 1 /* one environment only */ + +#ifndef STACKCOPY +#define MAXNTHREADS 5 /* (Stackpage-56)/40 */ +#define MAXNTASKS 5 +#define STACKSIZE 40 /* (TH_SLEN * 5) */ +#else +#define MAXNTHREADS 12 /* (up to 16 is possible, if enough memory) */ +#define MAXNTASKS 12 +#define STACKSIZE 64 /* (TH_SLEN * 8) */ +#endif +#define ANZXENV 5 /* number of redirectable task IDs */ + +/* TaskData */ + +#define IRQCNT 3 /* default priority for ROM-started tasks */ + +/* FileManager */ + +#define MAXFS 4 /* maximum number of fileserver tasks */ + +/* we don't map any of these memory areas */ +#undef MAP_ZERO +#undef MAP_STACK +#undef MAP_MEM + +#endif /* _PETCONFIG_ */ + diff --git a/dump/oa-2.0.9/arch/cbm8x96/devices/con_pet.a65 b/dump/oa-2.0.9/arch/cbm8x96/devices/con_pet.a65 new file mode 100644 index 0000000..b204d3f --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/devices/con_pet.a65 @@ -0,0 +1,222 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#define PIO $e810 +#define VIA1 $e840 +#define vdc $e880 +#define VIDPAGE 4 + +#define MAX_SCREEN 4 /* hard limit for tables */ + +#define MAX_ASCREEN #4 /* soft limit */ + +#define SWITCHKEY 23 + +#define SET_MMU + +#define BELLIRQ jsr bellirq + +#define TRIGBELL jsr trigbell + +#define MAXSPAL #80 + +#define MAXZEIL #25 + +#define KEY_START 16 /* when does key repetition start */ + + /* screen# -> hi byte of base address in AC */ +/* #define HI_VID asl:asl:bit freq:bpl l1:asl:l1 clc:adc #VIDPAGE<<4 */ +#define HI_VID asl:asl:asl:clc:adc #$90 + +#define ACT_HI_VID .( :\ + lda screen :\ + cmp actscr :\ + beq orig :\ + asl:asl:asl :\ + clc:adc #$90 :\ + .byt $2c :\ +orig lda #$80 :\ + .) + +#define SCR_SPACE " " /* screencode space */ + + /* ASCII to PET screen code */ +#define ASC2SCR .( :\ + and #$7f :\ + cmp #64 :\ + bcc ok :\ + beq zero :\ + cmp #91 :\ + bcc ok :\ + cmp #97 :\ + bcc tab1 :\ + cmp #123 :\ + bcs tab2 :\ + sbc #95 :\ + bne ok :\ +tab2 tay :\ + lda ctab2-123,y :\ + bne ok :\ +tab1 tay :\ + lda ctab1-91,y :\ + .byt $2c :\ +zero lda #0 :\ +ok .) + +#define SCR2ASC .( :\ + and #$7f :\ + beq at :\ + cmp #27 :\ + bcs x1 :\ + adc #96 :\ + bne ok :\ +x1 cmp #32 :\ + bcc tab1 :\ + cmp #91 :\ + bcc ok :\ + tay :\ + lda atab2-91,y :\ + bcs ok :\ +tab1 tay :\ + lda atab1-27,y :\ + .byt $2c :\ +at lda #64 :\ +ok .) :\ + +&ctab1 .byt 27, 28, 29, 30, 100, 124 +&ctab2 .byt 115, 93, 107, 112, 122 +&atab1 .byt 91, 0, 93, 94, 0 +&atab2 .byt 0,0,124,0,0,0,0,0,0,95,0,0,0,0,0,0,125,0,0,0,0,126,0,0,123 + .byt 0,0,0,0,0,0,127,0,96,0,0,0 + +#define DO_IRQ .( :\ + bit actchange :\ + bpl ok :\ + cpy actscr :\ + bne ok :\ + ldx zeile :\ + jsr setzei :\ + ldy screen :\ +ok .) + + .data +&actchange .byt 0 + .text + +&console_init .( + jsr inimem + jsr inivid + jsr inikbd + jsr inicrsr + jsr inibell + rts + .) + +inimem .( + clc + rts + .) + +&inivid .( + lda screen + bne ix + +/* we assume the CRTC to be initialized... + ldx #0 +i1 bit freq + lda vdc4tab,x + stx vdc + sta vdc+1 + inx + cpx #16 + bcc i1 +*/ +ix + rts + +/* vdc8tab .byt $7e,$50,$64,6,$29,0,$19,$21,0,7,$60,7,0,0,0,0 */ + +/* vdc4tab .byt $3f,$28,$32,3,$29,0,$19,$21,0,7,$60,7,0,0,0,0 */ + + .) + +&setact .( + +scrbuf =$9000 + + .zero +p1 .word 0 +p2 .word 0 + .text + + sec + ror actchange + pha + txa + jsr getp1 + sta p1 + sty p1+1 + lda #00 + sta p2 + lda #$80 + sta p2+1 + jsr cp2to1 + pla + jsr getp1 + sta p2 + sty p2+1 + lda #00 + sta p1 + lda #$80 + sta p1+1 + jsr cp2to1 + ldx zeile + jmp setzei + +cp2to1 ldx #8 + ldy #0 +cp1 lda (p2),y + sta (p1),y + iny + bne cp1 + inc p2+1 + inc p1+1 + dex + bne cp1 + rts +getp1 + asl + asl + asl + clc + adc #>scrbuf + tay + lda #BC",0,"2",0,0,"0^B^C",0,"2",0,0,"0<^N^V^Z" + .asc "1?",0,TC_CLR,"^M ^X",0,0,0,"*",0,")&#_" + + +#else /* graphics keyboard */ + +ktab .asc TC_CRGT,TC_HOME,"~(&%#!",TC_BS,TC_CDWN,"^@)\'$":.byt $22 + .asc "97^^outeq/8^@piyrw" + .asc "64^@ljgda*5^@:khfs" + .asc "31",TC_CR,";mbcz+2^@?,nvx" + .asc "-0^@>^@]@^@=.^@",3,"< [",1 + +stab .asc TC_CLFT,TC_CLR,"|(&%#!",TC_INS,TC_CUP,"^@)\'$":.byt $22 + .asc "97^^OUTEQ/8^@PIYRW" + .asc "64^@LJGDA*5^@:KHFS" + .asc "31",TC_LF,";MBCZ+2^@?,NVX" + .asc "-0^@>^@}@^@=.^@",TC_ESC,"< {^@" + +ctab .asc TC_WRU,TC_WCLS,"~(&%#!",TC_DEL,TC_WLO,"^@)\'$",$22 + .asc "97^^^o^u^t^e^q/8^@^p^i^y^r^w" + .asc "64^@^l^j^g^d^a*5^@:^k^h^f^s" + .asc "31",TC_EOL,";^m^b^c^z+2^@?,^n^v^x" + .asc "-0^@>^@]@^@=.^@",TC_CLL,"< [^@" + +sctab .asc "^@^@|(&%#!^H^@^@)\'$":.byt $22 + .asc "97^^O^U^T^E^Q/8^@^P^I^Y^R^W" + .asc "64^@^L^J^G^D^A*5^@:^K^H^F^S" + .asc "31^m;^M^B^C^Z+2^@?,^N^V^X" + .asc "-0^@>^@}@^@=.^@@< {^@" + +#endif + + .) + diff --git a/dump/oa-2.0.9/arch/cbm8x96/devices/piec_pet.a65 b/dump/oa-2.0.9/arch/cbm8x96/devices/piec_pet.a65 new file mode 100644 index 0000000..815195a --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/devices/piec_pet.a65 @@ -0,0 +1,366 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#define VIA1 $e840 +#define PIA2 $e820 +#define PIA1 $e810 + +#include "chips/via6522.i65" +#include "chips/pia6521.i65" + +#ifdef FSIEC_USE_STDLIB +#define CHDIR Chdir +#define ASSIGN Assign +#endif + + .data +byte .byt 0 +bytfl .byt 0 +eoifl .byt 0 + .text + +&getif clc + ldx #SEM_VIAE840_T1 + jmp PSEM +&freif ldx #SEM_VIAE840_T1 + jmp VSEM + +&IECINIT .( + lda #%00111000 + sta PIA2+PIA_CRA + lda #0 + sta PIA2+PIA_PA ; DDRA + cmp PIA2+PIA_PA + bne inix + lda #%00111100 ; CA2 = NDAC hi + sta PIA2+PIA_CRA + + lda #%00111000 + sta PIA2+PIA_CRB + lda #$ff + sta PIA2+PIA_PB ; DDRB + cmp PIA2+PIA_PB + bne inix + lda #%00111100 ; CB2 = DAV hi + sta PIA2+PIA_CRB + lda #<-1 ; DRB + sta PIA2+PIA_PB + + lda #%00111000 + sta PIA2+PIA_CRA + lda PIA2+PIA_PA ; DDRA + and #%10111111 + sta PIA2+PIA_PA ; DDRA + cmp PIA2+PIA_PA + bne inix + lda #%00111100 ; CA2 = NDAC hi + sta PIA2+PIA_CRA + + lda PIA1+PIA_CRA + ora #%00111100 ; CA2 = EOI hi + sta PIA1+PIA_CRA + + lda VIA1+VIA_DDRB + and #%00111110 + ora #%00000110 + sta VIA1+VIA_DDRB + cmp VIA1+VIA_DDRB + bne inix + lda VIA1+VIA_DRB + ora #%00000110 + sta VIA1+VIA_DRB ; alle ausgaenge hi + + lda VIA1+VIA_ACR + and #%00111101 ; PB2 Latch off, T1 timed IRQ + sta VIA1+VIA_ACR + lda VIA1+VIA_PCR + ora #%11100000 ; cb2 hi out (Piezo) + sta VIA1+VIA_PCR + lda #%01011000 ; T1, CB1, CB2 -IRQ off + sta VIA1+VIA_IER + lda #0 + sta byte + sta bytfl + sta eoifl + clc + rts +inix sec + rts + .) + +/* Blocktiefe 2 */ + +#ifndef NOFS + +aout =atnout +/* +aout pha + lda #0 + sta status + jsr nrfdhi + jsr ndachi + + lda bytfl + beq oo1 + sec + ror eoifl + jsr iecout + lda #0 + sta bytfl + +oo1 pla + sta byte +*/ +iec0out sei + jsr waitdavhi + jsr atnlo + +iecout .( + sei +jsr nrfdhi +jsr ndachi + jsr davhi + jsr tstdev ;nrfdhi & ndachi = z + beq devnotpr + lda byte + jsr out +ox1 JSR setti +ox1a JSR fragti + BNE XTO + bit VIA1+VIA_DRB + bvc ox1a ; wait nrfd hi + lda eoifl + bpl o0 + jsr eoilo +o0 jsr davlo + jsr setti +o1 jsr fragti + bne timeout + jsr fragndac ; wait ndac hi + bcc o1 + jsr davhi + jsr eoihi + lsr eoifl + jsr clrdata ; alle data hi +ox2 lda VIA1+VIA_DRB + lsr + bcs ox2 ; wait ndaclo + clc +; cli + rts + +XTO JSR YIELD + SEI + JMP ox1 + .) + +&seclisten sta byte + jsr iecout + jsr atnhi + cli + rts +#endif + +timeout lda #1 + .byt $2c +devnotpr lda #128 + jsr seterr + jsr eoihi + jsr davhi + jsr ndachi + sec + cli + rts + +#ifndef NOFS + +§alk sta byte + jsr iecout + jsr nrfdlo + jsr ndaclo + jsr atnhi + cli + rts + +&UNTALK jsr atnlo + lda #95 + .byt $2c +&UNLISTEN lda #63 + jsr aout + jsr atnhi + cli + rts + +timeoutx jmp timeout + +&IECIN .( + sei + jsr ndaclo + jsr nrfdhi +i1 lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne i1 + asl + asl + bcc i1 + jsr setti +o11 jsr fragti + bne timeoutx ; c= abgelaufen + jsr fragdav ; wait dav lo + bcs o11 + jsr nrfdlo + jsr frageoi + bcs o12 + lda #64 + jsr seterr +o12 jsr bytin + pha + jsr ndachi +o12a jsr fragdav + bcc o12a + jsr ndaclo + lda status + bne o12c + pla + clc + cli + rts +o12c pla + sec + cli + rts + .) + +atnhi lda VIA1+VIA_DRB + ora #%00000100 + sta VIA1+VIA_DRB + rts +atnlo lda VIA1+VIA_DRB + and #%11111011 + sta VIA1+VIA_DRB + rts +#endif + +eoihi lda #60 + sta PIA1+PIA_CRA + rts +eoilo lda #52 + sta PIA1+PIA_CRA + rts + +ndachi lda #60 + sta PIA2+PIA_CRA + rts +ndaclo lda #52 + sta PIA2+PIA_CRA + rts + +nrfdhi lda VIA1+VIA_DRB + ora #%00000010 + sta VIA1+VIA_DRB + rts +nrfdlo lda VIA1+VIA_DRB + and #%11111101 + sta VIA1+VIA_DRB + rts + +davhi lda #60 + sta PIA2+PIA_CRB + rts +davlo lda #52 + sta PIA2+PIA_CRB + rts + +waitdavhi lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne waitdavhi + and #$80 + beq waitdavhi + rts + +tstdev lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne tstdev + and #%01000001 + cmp #%01000001 + rts + +clrdata lda #<-1 + sta PIA2+PIA_PB + rts + +out eor #$ff + sta PIA2+PIA_PB + rts + +waitnrfdhi + lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne waitnrfdhi + asl + asl + bcc waitnrfdhi + rts + +fragndac lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne fragndac + lsr + rts + +fragdav lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne fragdav + asl + rts + +seterr ora status + sta status + rts + +bytin lda PIA2+PIA_PA + eor #$ff + rts + +&setti lda #<65000 + sta VIA1+VIA_T1CL + lda #>65000 + sta VIA1+VIA_T1CH + rts +&fragti lda VIA1+VIA_IFR + and #%01000000 + rts + +frageoi lda PIA1+PIA_PA + cmp PIA1+PIA_PA + bne frageoi + asl + asl + rts + + +#undef PIA1 +#undef PIA2 +#undef VIA1 + diff --git a/dump/oa-2.0.9/arch/cbm8x96/kernel/kenv.a65 b/dump/oa-2.0.9/arch/cbm8x96/kernel/kenv.a65 new file mode 100644 index 0000000..4cd93b3 --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/kernel/kenv.a65 @@ -0,0 +1,424 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* TODO: make stack addr computation a table lookup, which is faster */ + +/* Struct Task Environment Entry */ + +/* we have three structs now: + * TE_* for task environment handling - not needed for system without + * memory management + * TT_* task table, contains STD streams, etc + * TH_* thread table, has stack info and state + */ + +#define TE_SLEN 0 /* we don't have envs */ + +/************************************************************************ + * These routines are needed in the env section! + * inienv + * setthread + * initsp + * push + * pull + * memtask + * memsys + * + * sbrk + * getenv + * freenv + */ + +&&enmem = notimp ; to enable memory blocks to the kernel +&&setblk = notimp ; to set memory blocks in MMU mapping + +#ifdef STACKCOPY + .zero +zp .word 0 + + .data + +Stacks .dsb MAXNTHREADS * STACKSIZE + + .text +#endif + + +&inienv .( + lda #<-1 + sta actThread + sta actTask + lda #1 + sta Syscnt + clc + rts + .) + +setthread .( + .data +newThread .byt 0 + .text + + cmp actThread + bne doit + rts +doit + sta newThread + + ldx actThread + cpx #<-1 + beq nosave + + lda THREADSAVE + sta threadTab + TH_LIBSAVE,x + lda THREADSAVE+1 + sta threadTab + TH_LIBSAVE+1,x + +#ifdef STACKCOPY + txa ; stack is 8 * TH_SLEN = 64 + ldy #0 + sty zp+1 + asl + rol zp+1 + asl + rol zp+1 + asl + rol zp+1 + clc + adc #Stacks + adc zp+1 + sta zp+1 + ;bcc l1 + ;inc zp+1 +;l1 + lda threadTab + TH_SP,x + tay + iny +l2 cpy #STACKSIZE + bcs savetask + lda $100,y + sta (zp),y + iny + bne l2 +#endif +savetask + ldy threadTab + TH_TASK,x + lda TASKSAVE + sta taskTab + TT_LIBSAVE,y + lda TASKSAVE + 1 + sta taskTab + TT_LIBSAVE + 1,y +nosave +loadtask + ldx newThread + stx actThread + cpx #<-1 + bne load + stx actTask + beq noload +load + ldy threadTab + TH_TASK,x + sty actTask + + lda taskTab + TT_LIBSAVE,y + sta TASKSAVE + lda taskTab + TT_LIBSAVE + 1,y + sta TASKSAVE + 1 + +loadthread + lda threadTab + TH_LIBSAVE,x + sta THREADSAVE + lda threadTab + TH_LIBSAVE+1,x + sta THREADSAVE+1 + +#ifdef STACKCOPY + txa + ldy #0 + sty zp+1 + asl + rol zp+1 + asl + rol zp+1 + asl + rol zp+1 + clc + adc #Stacks + adc zp+1 + sta zp+1 + ;bcc l3 + ;inc zp+1 +;l3 + lda threadTab + TH_SP,x + tay + iny +l4 cpy #STACKSIZE + bcs endset + lda (zp),y + sta $100,y + iny + bne l4 +#endif +noload +endset rts + .) + +initsp .( +#ifdef STACKCOPY + lda #STACKSIZE-1 + ;ldx actThread + sta threadTab + TH_SP,x + rts +#else + .data +divsp .byt 0 + .text + + ;ldx actThread + txa + clc + adc #TH_SLEN + sta divsp + asl + asl ; split stack + clc + adc divsp + sta threadTab + TH_SP,x + dec threadTab + TH_SP,x + rts +#endif + .) + +pull .( + ldx actThread + inc threadTab + TH_SP,x + lda threadTab + TH_SP,x + tay + lda $0100,y + rts + .) + +&push .( + pha + ldx actThread + lda threadTab + TH_SP,x + tay + pla + sta $0100,y + dec threadTab + TH_SP,x + rts + .) + + .( + .zero +AC .byt 0 +XR .byt 0 +YR .byt 0 +SR .byt 0 +ADR .word 0 +&SSP .byt 0 + .text + +/* + * this one is used to return from an interrupt. We do not need to save + * any registers. so for brevity, we do it as macro + * This doesn't check for interrupted devices, as we do not have them + * without MMU (so far). + */ + +#define MEMTASK2() \ + .( :\ + sei :\ + dec Syscnt :\ + bne mtask :\ + tsx :\ + stx SSP :\ + ldy actTask :\ + ldx taskTab+TT_ENV,y :\ + beq system :\ +;.byt 2 :\ + ldx #%10001100 :\ + stx $fff0 :\ +system :\ + ldy actThread :\ + ldx threadTab+TH_SP,y :\ + txs :\ +mtask .) + +/* + * This is the standard return to user space. the kernel jumps here, + * so we need not save any return address, but use the one on the + * user stack. + */ +&&memtask .( + php + sei + dec Syscnt ; wieder in Task + bne mtask ; nein dann Ende + + bit adev ; Ruecksprung in Device + bpl mtask ; ja dann Ende + + sty YR ; sonst Task-Env setzen + stx XR + sta AC + pla ; SR + + tsx + stx SSP + + ldy actThread + ldx threadTab+TH_SP,y + txs + + ldy actTask + ldx taskTab+TT_ENV,y + beq system + ldx #%10001100 ; map alternate 8x96 memory bank + stx $fff0 +system + + pha ; SR + lda AC + ldy YR + ldx XR +mtask + plp + rts + .) + +/* + * This is the kernel entry routine. It leaves all registers as they + * are, except for the stack pointer, which is set to the system stack. + * also the return address is moved from user stack to system stack, + * to allow "JSR"-ing to memsys. + */ +&&memsys php + sei + pha + + lda #%11100000 ; map system memory + sta $fff0 + + lda Syscnt + inc Syscnt + cmp #0 + bne mse + bit adev ; called by device + bmi msys ; no then save stack +mse pla + plp + rts + +msys pla + sta AC + pla + sta SR + stx XR + ; sty YR + pla + sta ADR + pla + sta ADR+1 + tsx + + txa + ldx actThread + sta threadTab+TH_SP,x + ldx SSP + txs + lda ADR+1 + pha + lda ADR + pha + lda SR + pha + lda AC + ldx XR + ; ldy YR + plp + cld + rts + .) + + +&&sbrk .( + bcc ok + sec + lda #E_NOMEM + rts +ok lda #>ROMSTART ; return available memory + clc + rts + .) + +kgetenv .( + ldx #0 + tya + bne system + inx +system clc + rts + .) + +freenv .( + clc + rts + .) + +/* + * MAPSYSBUF() maps the PCBUF of the active task into the system memory + * at address SYSBUF. It's not needed in a C64... + */ +#undef MAPSYSBUF +#define SYSBUF $200 + +/* + * MAPENV() maps the address given in a/y in env x to somewhere in the + * kernel map. returns mapped address in a/y + * MAPAENV() does the same but for the actual task (env) + */ +#define MAPENV() +#define MAPAENV() + + +/* + * needed for GETINFO, gives RAM available for task + */ +#define GETTASKMEM lda #>ROMSTART + +/* + * copy routines for SEND/RECEIVE and FORK + */ +#undef CPPCBUFRX +#undef CPPCBUFTX +#define CPFORKBUF() + +/* + * needed in device code to get active environment in AC + */ +#define GETACTENV() lda #<-1 + + diff --git a/dump/oa-2.0.9/arch/cbm8x96/kernel/kinit.a65 b/dump/oa-2.0.9/arch/cbm8x96/kernel/kinit.a65 new file mode 100644 index 0000000..7fc020a --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/kernel/kinit.a65 @@ -0,0 +1,147 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * This file is included in the RESET routine of the kernel, + * after the "sei:cld". The routine starting at the bginning + * of this file must initialize the hardware to the system RAM + * in the beginning and the system ROM in the end of the memory + * map. Also the system stack (pointer) is setup. + * + * In addition to that the system interrupt timer (needed for + * task preemtion) must be setup. + * + * After that the file must define the following macros: + * + * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz + * LEDPORT address of LED port to signal hardware failures + * LED_LED bit of LED bit in LEDPORT address + * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces + * the LED toggle routine if needed. + * CLRTIMER() clear the system interrupt timer interrupt + * KERNELIRQ() returns if an interrupt occured in the kernel + * or outside. Is checked by "BNE IRQ_in_Kernel" + * SAVEMEM() save system mem config for interrupt + * RESTOREMEM() restore system mem config after interrupt + * STARTMEM() This is used to alloc/enable memory pages found + * during kernel init. Takes mem size in AC as given + * by the kernel init. It is called _after_ inimem! + */ + +/* Kernel routines for C64 hardware */ + +/* + * init stack pointer for system stack + */ + ldx #<-1 + txs + +/* + * init memory configuration + */ + + /* check if it's really a 8x96 */ + lda #%10001100 ; memory config plain bank 1 + sta $fff0 ; no I/O and screen peek through (prg bank) + + ldx #11 +ll0 lda eok_addr,x ; set interrupt etc vectors + sta $fff4,x + dex + bpl ll0 + + lda #%11100000 ; memory config plain bank 0 + sta $fff0 ; I/O and screen peek through (system bank) + + ldx #11 +ll1 lda eok_addr,x ; set interrupt etc vectors + sta $fff4,x + dex + bpl ll1 +/* + * C64 specific irq timer init, irq every 20ms + * We assume that the reset - or a loader program has disabled all irq + */ + + lda #%00000001 ; enable PIA1 CB1 screen retrace timer + sta PETPIA1+PIA_CRA + +/* + * check zeropage RAM, jump to he_zero if failure + * clears zeropage - at least 2-7 is a _must_! + */ +#include "kernel/zerotest.a65" + +/* + * check system RAM from RAMSTAT up to RAMEND, jump to he_ram if failure + * returns available RAM in 256 byte blocks in AC + */ + .zero +cnt .byt 0 + .text +#include "kernel/ramtest.a65" + cmp #MIN_MEM + bcs ok + lda #0 + sta $fff0 + jmp ($fffc) +ok +/* + * originally SYSPORT specific, they have a value for the C64 also... + */ +#define GETFREQ() lda #0 + +#undef LEDPORT +#undef LED_LED + +/* + * We have to clear the interrupt timer + */ + +#define CLRTIMER() lda PETPIA1+PIA_PA + +/* + * MMU systems may map task pages into kernel mem to make copying + * easier. This mapping has to be preserved during interrupt. + * SAVEMEM() saves the memory configuration, while RESTOREMEM() + * restores it, obviously. + * These routines are called _after_ "jsr memsys", so this routine + * has to preserve this mapping when called from kernel space, + * and so must memtask. + */ + +#undef SAVEMEM +#undef RESTOREMEM + +/* + * Check if we have an interrupt in the kernel + */ + +#define KERNELIRQ() lda Syscnt:cmp #1 + +/* + * no memory management... + */ +#define STARTMEM() + diff --git a/dump/oa-2.0.9/arch/cbm8x96/petdef.i65 b/dump/oa-2.0.9/arch/cbm8x96/petdef.i65 new file mode 100644 index 0000000..2fe226b --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/petdef.i65 @@ -0,0 +1,34 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * These are the C64 specific defines + */ + +#define PETPIA1 $e810 +#define PETPIA2 $e820 +#define PETVIA $e840 + +#include "chips/pia6521.i65" +#include "chips/via6522.i65" + diff --git a/dump/oa-2.0.9/arch/cbm8x96/rom.a65 b/dump/oa-2.0.9/arch/cbm8x96/rom.a65 new file mode 100644 index 0000000..c4ba131 --- /dev/null +++ b/dump/oa-2.0.9/arch/cbm8x96/rom.a65 @@ -0,0 +1,186 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM +#undef EMUTEST + +/* These are necessary for PET kernel **************************************/ + +#define NOMMU +#define NOSYSPORT +#undef CLK2MHZ /* we only have approx. 1 MHz ... */ +#undef CMOSCPU /* ... and no CMOS cpu */ +#define VIDPAGE 8 +#undef SHORTLINE /* prepare for 80 col screen */ + +#define RAMTEST +#define RAMSTART 128 +#define RAMEND $e8 +#define NOMIRRORMEM + +#define MIN_MEM $e8 /* RAM up to I/O -> 8x96 */ + +#undef NMIDEV /* there is no NMI in the PET machine */ +#define EOK_NOFILL /* do not fill kernel to end of mem */ + +#define LIB6502_SHAREDZERO /* lib6502 fork sets FORK_SHARED to 0 */ + +#define OSA_CPU "6502" +#define OSA_ARCH "PET" + +/* These are changeable ****************************************************/ + +#define ROMSTART $0b03 /* where the ROM starts */ + +#define MEMINIVAL $0 /* Clear memory to 0 on boot */ + +#define STACKCOPY /* if defined, save stack area in memory + when context switching, otherwise divide + stack area and give each task a part. + It's faster without, but allows more + tasks with */ + +#define NEED_CHECKCHLD /* this is necessary if using "init" or + lib6502 */ +#define NEED_GETINFO +#define NEED_SLOCK +#define NEED_RENICE + +#define BOOTDRV "c" /* where are the boot files (IEC device 8) */ + +#define ROOTPATH "c:" /* where lsh chdirs into on boot */ + + +/*************************************************************************** + * + * Here comes the ROM content + */ + +#include "config.i65" +#include "kdefs.i65" +#include "fdefs.i65" +#include "petdef.i65" + +#include "kernel.i65" + +#define SEM_VIAE840_T1 SEM_SERIEC +#undef SEM_SERIEC +#undef SEM_PARIEC + + .word *+2 /* load address */ + jmp RESET + ; ROMSTART is here! +.( + +/************* ROM entries */ + +/************* devices */ + +#include "devices/devices.a65" + +/************* init process */ + + +#define INIT_VERBOSE +#define INIT_RESTART +#define INIT_MERGE +#define INIT_LIB6502 +/* #define INIT_USE_STDLIB */ +/* #define INIT_OUTDEV 2*/ +#include "sysapps/init/init.a65" + + +/************* fsdev - converts devices into files */ + + +#include "sysapps/fs/fsdev.a65" + + +/************* fsiec - IEEE488/IEC bus filesystem */ + +/* both, the parallel and serial iec bus use the same timer */ +#define SEM_CIA2TB SEM_SERIEC +#undef SEM_PARIEC +#undef SEM_SERIEC + +#define NOLOOP +#define FSIEC_DEVICE "devices/piec_pet.a65" +#include "sysapps/fs/fsiec.a65" +#undef FSIEC_DEVICE +#print * + + +/************* mon - OS/A 1 old style monitor/shell */ + +#define MON_SHEXE $c0 /* ROM executable flag */ +#define MON_MONEXE 0 /* ROM executable flag */ +#define MON_SHDEV 1 /* start on device 0 = video1 */ +#define SHORTMON /* no assembler/disassembler */ +#undef NOSH +#include "sysapps/mon/mon.a65" + + +/************* boot lsh from BOOTDRV */ + +#if 1 + /* add autostart of lib6502 program 'lsh' */ + + .( + .word end_auto + .byt PK_LIB+PK_AUTOEXEC+PK_RESTART ; is lib6502 program + .word 0 ; P_ADDR ignored + .byt 16 ; P_RAM + .byt 128 ; P_SHARED + .byt 0 ; P_PRIORITY + .byt 0,0 ; P_DEV + .byt BOOTDRV,":lsh",0,"-d",0,ROOTPATH,0,0 +end_auto + .) + +#endif + +/************* end of ROM executables */ + + .word -1 + +/************* lib6502 code */ + +#include "lib6502/lib6502.a65" + +/************* Kernel */ + +#include "kernel\kernel.a65" + +/************* Constants for lib6502 memory handling */ + +Memstart =$6800 +Memend =$ff00 +Zerostart =$70 + +.) + diff --git a/dump/oa-2.0.9/arch/csa65/Makefile b/dump/oa-2.0.9/arch/csa65/Makefile new file mode 100644 index 0000000..ab1e287 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/Makefile @@ -0,0 +1,33 @@ + + +XA=xa #-2.1.4h + +FILE=file65 +RELOC=reloc65 + +all: boot/csarom boot/csarom2 + +redo: + rm -f boot/csarom + make + cp boot/csarom /site/mystuff/var/lptiec + cat foo + +boot/csaold: csarom.old + ${XA} -I../.. -I../../include -bt 32768 \ + csarom.old -o boot/csaold -l csaold.lab + +csa boot/csarom: csarom.a65 + ${XA} -I../.. -I../../include -bt 32768 \ + csarom.a65 -o boot/csarom -l csarom.lab + +boot/csarom2: csarom2.a65 + ${XA} -I../.. -I../../include -bt 32768 \ + csarom2.a65 -o boot/csarom2 -l csarom2.lab + +clean: + rm -f csarom.lab csarom2.lab csaold.lab + (cd boot; ${MAKE} clean ;) + (cd apps; ${MAKE} clean ;) + (cd sysapps; ${MAKE} clean ;) + diff --git a/dump/oa-2.0.9/arch/csa65/apps/Makefile b/dump/oa-2.0.9/arch/csa65/apps/Makefile new file mode 100644 index 0000000..2548acc --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/apps/Makefile @@ -0,0 +1,16 @@ + + +XAINPUT=../../../include,../../.. +XA=xa + +irtx.o65: irtx.a65 + xa -I../../../include -I../../.. -R -LLIB6502 -LOSA2KERNEL $< -o $@ + +# irtx.o65: irtx.a65 +# (XAINPUT=${XAINPUT}; export XAINPUT;\ +# ${XA} -DKERNEL=61440 -c irtx.a65 -o irtx.o65 ;\ +# if [ $$? -ne 0 ]; then rm -f irtx.o65; fi; ) + +clean: + rm -f irtx.o65 + diff --git a/dump/oa-2.0.9/arch/csa65/apps/irtx.a65 b/dump/oa-2.0.9/arch/csa65/apps/irtx.a65 new file mode 100644 index 0000000..6debeef --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/apps/irtx.a65 @@ -0,0 +1,7 @@ + +#define CLK1MHZ +#define VIA $e830 + +#include "sysapps/irtx/irtx.a65" + + diff --git a/dump/oa-2.0.9/arch/csa65/boot/Makefile b/dump/oa-2.0.9/arch/csa65/boot/Makefile new file mode 100644 index 0000000..af40e4f --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/boot/Makefile @@ -0,0 +1,20 @@ + +XAINPUT=../../../include +XA=xa + +all: inirom csarom csarom2 + +csarom: + (cd ..; ${MAKE} boot/csarom;) + +csarom2: + (cd ..; ${MAKE} boot/csarom2;) + +inirom: inirom.a65 + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -DOSA2KERNEL=61440 inirom.a65 -o inirom;\ + if [ $$? -ne 0 ]; then rm -f inirom; fi) + +clean: + rm -f csarom csarom2 inirom + diff --git a/dump/oa-2.0.9/arch/csa65/boot/README b/dump/oa-2.0.9/arch/csa65/boot/README new file mode 100644 index 0000000..c608b57 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/boot/README @@ -0,0 +1,5 @@ + +When using the patched-up VICE xcsa emulator, use the commandline: + + ~/vice/src/vice-0.12.0.16-csa-22/src/xcsa -kernal ./csaold -speed 200 + diff --git a/dump/oa-2.0.9/arch/csa65/boot/charom b/dump/oa-2.0.9/arch/csa65/boot/charom new file mode 100644 index 0000000..834938e --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/boot/charom Binary files differ diff --git a/dump/oa-2.0.9/arch/csa65/boot/csaold b/dump/oa-2.0.9/arch/csa65/boot/csaold new file mode 100644 index 0000000..8599ace --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/boot/csaold Binary files differ diff --git a/dump/oa-2.0.9/arch/csa65/boot/fsibm b/dump/oa-2.0.9/arch/csa65/boot/fsibm new file mode 120000 index 0000000..931cf6d --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/boot/fsibm @@ -0,0 +1 @@ +../sysapps/fsibm \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/csa65/boot/inirom.a65 b/dump/oa-2.0.9/arch/csa65/boot/inirom.a65 new file mode 100644 index 0000000..cd4c613 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/boot/inirom.a65 @@ -0,0 +1,80 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + + +#include "kdefs.i65" +#include "kernel.i65" +#include "../csa65.i65" + + .word $400 + *=$400 + +l1 =$0 + ; exit all devices + lda #0 + sta l1 +l2 ldx l1 + lda #DC_EXIT +; jsr DEVCMD +;.byt 2 + inc l1 + lda l1 + cmp #16 + bcc l2 + ; disable timer interrupt + + lda SYSPORT + and #$ff-SYS_IRQEN + sta SYSPORT + + sei ; remap MMU pages 8-15 with values from + ldx #7 ; 4 to b +l3 lda $eff2,x + sta $eff8,x + dex + bpl l3 + + ldx #1 ; set MMU pages 1-7 to 1-7 +l4 txa + sta $eff0,x + inx + cpx #$8 + bcc l4 + + ldx #0 ; copy program to valid RAM +l5 lda data,x + sta $1000,x + inx + bne l5 + + lda SYSPORT + and #$ff-SYS_LED + sta SYSPORT + + jmp $1000 ; and jump there + +data lda #0 ; remap page 0 + sta $eff0 + jmp RESET + diff --git a/dump/oa-2.0.9/arch/csa65/boot/ramdisk b/dump/oa-2.0.9/arch/csa65/boot/ramdisk new file mode 120000 index 0000000..1567a03 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/boot/ramdisk @@ -0,0 +1 @@ +/m/sdb8/tmp/dev.image \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/csa65/config.i65 b/dump/oa-2.0.9/arch/csa65/config.i65 new file mode 100644 index 0000000..a419307 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/config.i65 @@ -0,0 +1,72 @@ +/**************************************************************************** + + OS/A65 Version 1.3.9 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1996 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef ANZSTRM + +#include "csa65.i65" + +/************************* Daten for Computer mit MMU *********************/ + +/* StreamData */ + +#define ANZSTRM 18 + +/* SemaphoreData */ + +#define ANZSEM 16 /* multiple of 8 */ +#define SYSSEM 16 /* multiple of 8, sem-nr von -SYSSEM bis -1 */ + +/* DeviceData */ + +#define MAXDEV 32 + +/* EnvData */ + +#define MAXENVS 15 +#define MAXNTASKS 15 +#define MAXNTHREADS 16 + +#define ANZXENV 16 /* Anzahl umleitbarer Tasks */ + +/* TaskData */ + +#define IRQCNT 3 + +/* FileManager */ + +#define MAXFS 8 + +#define BLKSIZ $1000 + +/* + * this is the address of the task's remapped PCBUF in kernel memory + * see also MAPSYSBUF() in kenv.a65 + */ +/* #define SYSBUF BLKSIZ+PCBUF*/ + +#define MAP_ZERO +#define MAP_STACK +#define MAP_MEM + +#endif + diff --git a/dump/oa-2.0.9/arch/csa65/csa65.i65 b/dump/oa-2.0.9/arch/csa65/csa65.i65 new file mode 100644 index 0000000..54fa646 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/csa65.i65 @@ -0,0 +1,65 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef _CSA65_H_ +#define _CSA65_H_ + +#include "chips/via6522.i65" +#include "chips/pia6521.i65" + +/* System-Defs */ + +#ifndef SYSPORT +#define SYSPORT $efe0 +#endif +#ifndef NOMMU +#define MMU $eff0 +#endif +#define BLKSIZ $1000 +#define BLKLOG 12 /* number of addressbits valid in one BLKSIZ */ + +#ifndef SYSPAGE +#define SYSPAGE $0 /* $12 zum testen, wenn System nicht startet */ +#endif + + +/*********************** Hardware structs *******************************/ +/* SysIO */ + +#define SYS_TIRQ %10000000 /* bmi/bpl */ +#define SYS_KEY %01000000 +#define SYS_IOINH %00100000 +#define SYS_EXTIO %00010000 +#define SYS_LED %00001000 +#define SYS_RTS %00000100 +#define SYS_IRQEN %00000010 +#define SYS_IRQ %00000001 + +#ifndef LEDPORT +#define LEDPORT SYSPORT +#define LED_LED SYS_LED +#endif + +#endif + diff --git a/dump/oa-2.0.9/arch/csa65/csarom.a65 b/dump/oa-2.0.9/arch/csa65/csarom.a65 new file mode 100644 index 0000000..84952d1 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/csarom.a65 @@ -0,0 +1,381 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM + +/* These are necessary for CS/A65 kernel ***********************************/ + +#define OSA_ARCH "CS/A65" + +/* These are changeable ****************************************************/ + +#define DEBUGFS /* FSIBM debug */ +#define FSIBM_SECTOR24BIT + +#define CSA_CONSOLE 0 /* device to output debug/log messages */ + +#undef FSIEC_PARALLEL +#undef FSIEC_SERIAL +#define FSIBM +#undef MONSH +#define USE_LIB6502 + +#define NEED_CHECKCHLD /* this is necessary if using "init" or + lib6502 */ +#define NEED_GETINFO + +#undef ROMTEST /* debug option */ +/* #define EMUTEST */ /* debug option */ +/* #define SYSPAGE $12 */ /* debug option */ + +#define NOMIRRORMEM /* ramtest kernel options */ +#define SHORTRAMTEST + +#define NMIRESET + +#undef CMOSCPU +#undef NOSYSPORT + +#define RAMEND $80 /* 32k in bank 0 */ + +#define CLK2MHZ + +#undef BOOTDRV "c" + + +/*************************************************************************** + * + * Better not change anything below + */ + +#ifdef CMOSCPU +#define OSA_CPU "6502" +#else +#define OSA_CPU "65C02" +#endif + +/*************************************************************************** + * + * Here comes the ROM content + */ + +#include "config.i65" +#include "kdefs.i65" +#include "fdefs.i65" +#include "kernel.i65" + +#define SEM_VIAE840_T1 SEM_SERIEC +#undef SEM_SERIEC +#undef SEM_PARIEC + +#define ROMSTART $8000 +#define RAMSIZE (ROMSTART>>8) +#define MIN_MEM $20 /* 8 kbyte */ + + .( +; .word $2000 ; load address + *=ROMSTART + +/************* ROM entries */ +/* + + The lib6502 needs to use addresses in each of the environments. + Devices (normally) use the kernel address space. + All other tasks, including the kernel have their own environment. + Therefore they all get their own zero, data and bss addresses. + +*/ + + +#echo ############ magic + +/* so that init recognizes a ROM */ +#include "sysapps/magic/magic.a65" + +/************* devices */ + +#echo ############ devices +.data:*=$f00:.zero:*=$d0:.bss:*=$400:.text +.zero +#echo zero: +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + +#include "devices/csadev.a65" +.zero +#echo zero: +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + +/************* init process */ + +.data:*=$3c0:.zero:*=$20:.bss:*=$400:.text +#define INIT_VERBOSE +#define INIT_OUTDEV CSA_CONSOLE +#define INIT_MERGE +#define INIT_RESTART +#define INIT_LIB6502 +#define INIT_MMU +#define INIT_MMU_BANK 3 +#ifdef ROMTEST +#define INIT_ROM2TEST /* $0-$7 instead of $8-$f in INIT_MMU_BANK */ +#endif + +#echo ############ init: +#include "sysapps/init/init.a65" +.data +#echo data (<1024): +#print * +.bss +#echo bss: +#print * +.text + +/************* fsdev - converts devices into files */ + +.data:*=$300:.zero:*=$10:.bss:*=$400:.text +#echo ############ fsdev: +#include "sysapps/fs/fsdev.a65" +.data +#echo data (<=1024): +#print * +.bss +#echo bss: +#print * +.text + +/************* fsiec - as IEEE488 bus filesystem */ + +#ifdef FSIEC_PARALLEL + +#undef NOLOOP +#undef NOFS +#undef NOCMD + +.data:*=$300:.zero:*=$10:.bss:*=$500:.text +#echo ############ fsiec (parallel): + +#undef FSIEC_AS_INIT +#define FSIEC_DEVICE "devices/piec_csa.a65" + +#include "sysapps/fs/fsiec.a65" + +.data +#echo data (<=1280): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* fsiec - as IEC bus filesystem */ + +#ifdef FSIEC_SERIAL + +#define NOLOOP +#undef NOFS +#undef NOCMD + +.data:*=$300:.zero:*=$10:.bss:*=$400:.text +#echo ############ fsiec (serial): + +#undef FSIEC_AS_INIT +#define FSIEC_DEVICE "devices/siec_csa.a65" + +#include "sysapps/fs/fsiec.a65" + +.data +#echo data (<=1024): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* fsibm - PC-style disks filesystem */ + +#ifdef FSIBM + +.data:*=$300:.zero:*=$10:.bss:*=$500:.text +#echo ############ fsibm: + +#define FSIBM_OUTDEV CSA_CONSOLE +/* #define FSIBM_DEVICE_DRV "arch/csa65/devices/drv_wd1770.a65" */ +#define FSIBM_DEVICE_DRV "devices/scsi.a65" +/* #define FSIBM_DEVICE_DRV "sysapps/fs/fsibm/drv_ramd1.a65" */ +#include "sysapps/fs/fsibm.a65" + +.data +#echo data (<=1280): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* mon - OS/A 1 old style monitor/shell */ + +#ifdef MONSH + +.data:*=$3c0:.zero:*=$20:.bss:*=$400:.text +#echo ############ shell: + +#ifdef CLK1MHZ +#define SHORTMON +#else +#undef SHORTMON +#endif + +#undef NOSH +#undef NOSYSFKT + +#define MON_SHDEV 0 +#define MON_MONDEV 7 +#define MON_SHEXE $c0 +#define MON_MONEXE $c0 +#include "sysapps/mon/mon.a65" + +.zero +#echo zero +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* boot lsh from BOOTDRV */ + +#ifdef BOOTDRV + +#echo ************ lsh + + /* add autostart of lib6502 program 'lsh' */ + + .( + .word end_auto + .byt PK_LIB+PK_AUTOEXEC+PK_RESTART ; is lib6502 program + .word 0 ; P_ADDR ignored + .byt 16 ; P_RAM + .byt 128 ; P_SHARED + .byt 0 ; P_PRIORITY + .byt 1,1 ; P_DEV + .byt BOOTDRV,":lsh",0,"-d",0,0 +end_auto + .) + +#endif + +/************* end of ROM executables */ + + .word -1 + +/************* lib6502 code */ + +#ifdef USE_LIB6502 + +/* lib6502 jmp table is below STDIOADDR */ + +#echo "############ lib6502" +.data:*=$300:.zero:*=8:.bss:*=$400:.text + +#include "lib6502/lib6502.a65" +/* #include "stdlib/stdio.a65" */ + +.zero +#echo zero: +#print * +/* Zerostart must keep save the sh/mon and init variables */ +Zerostart =$40 ; * ; only lib6502 and prg - that's it +#print Zerostart +.data +#echo data: +#print * +.bss +#echo bss: +#print * +/* Memstart must keep save the sh/mon and init variables */ +Memstart =$500 ; * ; only lib6502 and prg +#print Memstart +.text + +Memend = $3000 + +#endif + +/************* fill not used area (I/O, screens) */ + +#if *>$e7ff +#echo "program too long!, should be $e800 (59392), is" +#print * +ldx ,x +#endif + .dsb $f000-*,<-1 + +/************* Kernel */ + +.data:*=$300:.zero:*=8:.bss:*=$600:.text +#echo ############ kernel: + +#include "kernel/kernel.a65" + +.zero +#echo zero: +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + + .) + + diff --git a/dump/oa-2.0.9/arch/csa65/csarom.old b/dump/oa-2.0.9/arch/csa65/csarom.old new file mode 100644 index 0000000..8afb322 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/csarom.old @@ -0,0 +1,362 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM + +/* These are necessary for CS/A65 kernel ***********************************/ + +#define OSA_ARCH "CS/A65" + +/* These are changeable ****************************************************/ + +#define FSIEC_PARALLEL +#undef FSIEC_SERIAL +#undef FSIBM +#define USE_LIB6502 + +#define NEED_CHECKCHLD /* this is necessary if using "init" or + lib6502 */ +#define NEED_GETINFO + +#undef ROMTEST /* debug option */ +/* #define EMUTEST */ /* debug option */ +/* #define SYSPAGE $12 */ /* debug option */ + +#define NOMIRRORMEM /* ramtest kernel options */ +#define SHORTRAMTEST + +#define NMIRESET + +#undef CMOSCPU +#undef NOSYSPORT + +#define RAMEND $80 /* 32k in bank 0 */ + +#define CLK1MHZ + +#undef BOOTDRV "c" + +/*************************************************************************** + * + * Better not change anything below + */ + +#ifdef CMOSCPU +#define OSA_CPU "6502" +#else +#define OSA_CPU "65C02" +#endif + +/*************************************************************************** + * + * Here comes the ROM content + */ + +#include "config.i65" +#include "kdefs.i65" +#include "fdefs.i65" +#include "kernel.i65" + +#define SEM_VIAE840_T1 SEM_SERIEC +#undef SEM_SERIEC +#undef SEM_PARIEC + +#define ROMSTART $8000 +#define RAMSIZE (ROMSTART>>8) +#define MIN_MEM $20 /* 8 kbyte */ + + .( +; .word $2000 ; load address + *=ROMSTART + +/************* ROM entries */ +/* + + The lib6502 needs to use addresses in each of the environments. + Devices (normally) use the kernel address space. + All other tasks, including the kernel have their own environment. + Therefore they all get their own zero, data and bss addresses. + +*/ + +#echo ############ magic + +/************* devices */ + +#include "sysapps/magic/magic.a65" + +#echo ############ devices +.data:*=$f00:.zero:*=$d0:.bss:*=$400:.text +.zero +#echo zero: +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + +#include "devices/csadev.a65" +.zero +#echo zero: +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + +/************* init process */ + +.data:*=$3c0:.zero:*=$20:.bss:*=$400:.text +#define INIT_VERBOSE +#define INIT_MERGE +#define INIT_RESTART +#define INIT_LIB6502 +#define INIT_MMU +#define INIT_MMU_BANK 2 +#echo ############ init: +#include "sysapps/init/init.a65" +.data +#echo data (<1024): +#print * +.bss +#echo bss: +#print * +.text + +/************* fsdev - converts devices into files */ + +.data:*=$300:.zero:*=$10:.bss:*=$400:.text +#echo ############ fsdev: +#include "sysapps/fs/fsdev.a65" +.data +#echo data (<=1024): +#print * +.bss +#echo bss: +#print * +.text + +/************* fsiec - as IEEE488 bus filesystem */ + +#ifdef FSIEC_PARALLEL + +#undef NOLOOP +#undef NOFS +#undef NOCMD + +.data:*=$300:.zero:*=$10:.bss:*=$500:.text +#echo ############ fsiec (parallel): + +#undef FSIEC_AS_INIT +#define FSIEC_DEVICE "devices/piec_csa.a65" + +#include "sysapps/fs/fsiec.a65" + +.data +#echo data (<=1280): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* fsiec - as IEC bus filesystem */ + +#ifdef FSIEC_SERIAL + +#define NOLOOP +#undef NOFS +#undef NOCMD + +.data:*=$300:.zero:*=$10:.bss:*=$400:.text +#echo ############ fsiec (serial): + +#undef FSIEC_AS_INIT +#define FSIEC_DEVICE "devices/siec_csa.a65" + +#include "sysapps/fs/fsiec.a65" + +.data +#echo data (<=1024): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* fsibm - PC-style disks filesystem */ + +#ifdef FSIBM + +.data:*=$300:.zero:*=$10:.bss:*=$500:.text +#echo ############ fsibm: + +#define FSIBM_DEVICE_DRV "arch/csa65/devices/drv_wd1770.a65" +#include "sysapps/fs/fsibm.a65" + +.data +#echo data (<=1280): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* mon - OS/A 1 old style monitor/shell */ + +.data:*=$3c0:.zero:*=$20:.bss:*=$400:.text +#echo ############ shell: + +#ifdef CLK1MHZ +#define SHORTMON +#else +#undef SHORTMON +#endif + +/* +#define NOSH +#define NOSYSFKT +*/ + +#define MON_SHDEV 0 +#define MON_MONDEV 1 /* 7 */ +#define MON_SHEXE $c0 +#define MON_MONEXE $80 +#include "sysapps/mon/mon.a65" + +.zero +#echo zero +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + +/************* boot lsh from BOOTDRV */ + +#ifdef BOOTDRV + +#echo ************ lsh + + /* add autostart of lib6502 program 'lsh' */ + + .( + .word end_auto + .byt PK_LIB+PK_AUTOEXEC+PK_RESTART ; is lib6502 program + .word 0 ; P_ADDR ignored + .byt 16 ; P_RAM + .byt 128 ; P_SHARED + .byt 0 ; P_PRIORITY + .byt 1,1 ; P_DEV + .byt BOOTDRV,":lsh",0,"-d",0,0 +end_auto + .) + +#endif + +/************* end of ROM executables */ + + .word -1 + +/************* lib6502 code */ + +#ifdef USE_LIB6502 + +/* lib6502 jmp table is below STDIOADDR */ + +#echo "############ lib6502" +.data:*=$300:.zero:*=8:.bss:*=$400:.text + +#include "lib6502/lib6502.a65" +/* #include "stdlib/stdio.a65" */ + +.zero +#echo zero: +#print * +/* Zerostart must keep save the sh/mon and init variables */ +Zerostart =$40 ; * ; only lib6502 and prg - that's it +#print Zerostart +.data +#echo data: +#print * +.bss +#echo bss: +#print * +/* Memstart must keep save the sh/mon and init variables */ +Memstart =$500 ; * ; only lib6502 and prg +#print Memstart +.text + +Memend = $3000 + +#endif + +/************* fill not used area (I/O, screens) */ + +#if *>$e7ff +#echo "program too long!, should be $e800 (59392), is" +#print * +ldx ,x +#endif + .dsb $f000-*,<-1 + +/************* Kernel */ + +.data:*=$300:.zero:*=8:.bss:*=$600:.text +#echo ############ kernel: + +#include "kernel/kernel.a65" + +.zero +#echo zero: +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + + .) + + diff --git a/dump/oa-2.0.9/arch/csa65/csarom2.a65 b/dump/oa-2.0.9/arch/csa65/csarom2.a65 new file mode 100644 index 0000000..c50e5f5 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/csarom2.a65 @@ -0,0 +1,266 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM + +/* These are necessary for CS/A65 kernel ***********************************/ + +#define OSA_ARCH "CS/A65" + +#define OSA2KERNEL $f000 + +#ifdef CMOSCPU +#define OSA_CPU "6502" +#else +#define OSA_CPU "65C02" +#endif + +/* These are changeable ****************************************************/ + +#define FSIEC_PARALLEL +#undef FSIEC_SERIAL +#undef FSIBM +#define USE_LIB6502 + +#define CLK2MHZ + +#undef BOOTDRV "c" + + +/*************************************************************************** + * + * Better not change anything below + */ + +/*************************************************************************** + * + * Here comes the ROM content + */ + +#include "config.i65" +#include "kdefs.i65" +#include "fdefs.i65" +#include "kernel.i65" + +#define SEM_VIAE840_T1 SEM_SERIEC +#undef SEM_SERIEC +#undef SEM_PARIEC + +#define ROMSTART $8000 + + .( +; .word $2000 ; load address + *=ROMSTART + +/************* ROM entries */ +/* + + The lib6502 needs to use addresses in each of the environments. + Devices (normally) use the kernel address space. + All other tasks, including the kernel have their own environment. + Therefore they all get their own zero, data and bss addresses. + +*/ + +#echo ############ magic + +/* so that init recognizes this as second ROM */ +#include "sysapps/magic/magic.a65" + +/************* fsiec - as IEEE488 bus filesystem */ + +#ifdef FSIEC_PARALLEL + +#undef NOLOOP +#undef NOFS +#undef NOCMD + +.data:*=$300:.zero:*=$10:.bss:*=$500:.text +#echo ############ fsiec (parallel): + +#undef FSIEC_AS_INIT +#define FSIEC_DEVICE "devices/piec_csa.a65" + +#include "sysapps/fs/fsiec.a65" + +.data +#echo data (<=1280): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* fsiec - as IEC bus filesystem */ + +#ifdef FSIEC_SERIAL + +#define NOLOOP +#undef NOFS +#undef NOCMD + +.data:*=$300:.zero:*=$10:.bss:*=$400:.text +#echo ############ fsiec (serial): + +#undef FSIEC_AS_INIT +#define FSIEC_OUTDEV 7 +#define FSIEC_DEVICE "devices/siec_csa.a65" + +#include "sysapps/fs/fsiec.a65" + +.data +#echo data (<=1024): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* fsibm - PC-style disks filesystem */ + +#ifdef FSIBM + +.data:*=$300:.zero:*=$10:.bss:*=$500:.text +#echo ############ fsibm: + +#define FSIBM_OUTDEV 7 +#define FSIBM_DEVICE_DRV "arch/csa65/devices/drv_wd1770.a65" +#include "sysapps/fs/fsibm.a65" + +.data +#echo data (<=1280): +#print * +.bss +#echo bss: +#print * +.text + +#endif + +/************* mon - OS/A 1 old style monitor/shell */ + +.data:*=$3c0:.zero:*=$20:.bss:*=$400:.text +#echo ############ shell: + +#ifdef CLK1MHZ +#define SHORTMON +#else +#undef SHORTMON +#endif + +#undef NOSH +#undef NOSYSFKT + +#define MON_SHDEV 0 +#define MON_MONDEV 7 +#define MON_SHEXE $c0 +#define MON_MONEXE $c0 +#include "sysapps/mon/mon.a65" + +.zero +#echo zero +#print * +.data +#echo data: +#print * +.bss +#echo bss: +#print * +.text + +/************* boot lsh from BOOTDRV */ + +#ifdef BOOTDRV + +#echo ************ lsh + + /* add autostart of lib6502 program 'lsh' */ + + .( + .word end_auto + .byt PK_LIB+PK_AUTOEXEC+PK_RESTART ; is lib6502 program + .word 0 ; P_ADDR ignored + .byt 16 ; P_RAM + .byt 128 ; P_SHARED + .byt 0 ; P_PRIORITY + .byt 1,1 ; P_DEV + .byt BOOTDRV,":lsh",0,"-d",0,0 +end_auto + .) + +#endif + +/************* end of ROM executables */ + + .word -1 + +/************* lib6502 code */ + +#ifdef USE_LIB6502 + +/* lib6502 jmp table is below STDIOADDR */ + +#echo "############ lib6502" +.data:*=$300:.zero:*=8:.bss:*=$400:.text + +#include "lib6502/lib6502.a65" +/* #include "stdlib/stdio.a65" */ + +.zero +#echo zero: +#print * +/* Zerostart must keep save the sh/mon and init variables */ +Zerostart =$40 ; * ; only lib6502 and prg - that's it +#print Zerostart +.data +#echo data: +#print * +.bss +#echo bss: +#print * +/* Memstart must keep save the sh/mon and init variables */ +Memstart =$500 ; * ; only lib6502 and prg +#print Memstart +.text + +Memend = $3000 + +#endif + +/************* fill not used area (I/O, screens) */ + + + .dsb $fffe-*,<-1 + + .word -1 + .) + + diff --git a/dump/oa-2.0.9/arch/csa65/devices/con_csa.a65 b/dump/oa-2.0.9/arch/csa65/devices/con_csa.a65 new file mode 100644 index 0000000..d8efe2a --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/devices/con_csa.a65 @@ -0,0 +1,384 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#define PIO $e810 +#define VIA1 $e840 +#define vdcctrl $e888 +#define vdc $e880 +#define VIDPAGE 4 + +#define MAX_SCREEN 4 /* hard limit for tables */ + +#define MAX_ASCREEN maxscr /* soft limit */ + +#define SWITCHKEY $46 + +#define SET_MMU ldy #$10:sty MMU+VIDPAGE + +#define BELLIRQ jsr bellirq + +#define TRIGBELL jsr trigbell + +#define MAXSPAL maxspal + +#define MAXZEIL #25 + +#define KEY_START 16 /* when does key repetition start */ + +#define SCR_SPACE " " + + /* screen# -> hi byte of base address in AC */ +#define HI_VID asl:asl:bit freq:bpl l1:asl:l1 clc:adc #VIDPAGE<<4 + +#define ACT_HI_VID lda hivid + + .data +&maxspal .byt 0 +&maxscr .byt 0 + .text + +&console_init .( + ldx #4 + bit freq + bpl c1mhz + ldx #2 +c1mhz stx maxscr + + jsr inimem + jsr inivid + jsr inikbd + jsr inibell + rts + .) + +inimem .( +#ifdef ROM + ldx #$11 +l1m stx maxspal + stx MMU+1 + + lda #16 + sta zei2+1 + ldy #0 + sty zei2 + ldx #>BLKSIZ +im1 lda (zei2),y + pha + lda #$55 + sta (zei2),y + cmp (zei2),y + bne next + asl + sta (zei2),y + cmp (zei2),y + bne next + lda #0 + sta (zei2),y + cmp (zei2),y + bne next + pla + sta (zei2),y + inc zei2+1 + dex + bne im1 + + ldx maxspal + jsr ENMEM + pha +next pla + ldx maxspal + inx +#ifndef ROMTEST + cpx #$20 +#else + cpx #$18 +#endif + bcc l1m +#endif /* ROM */ + clc + rts + .) + +&inivid .( + lda screen + bne ix + + lda #$0c ; set charrom and video base + sta vdcctrl + + ldx #0 +i1 bit freq + bpl onemhz + lda vdc8tab,x + jmp nex +onemhz lda vdc4tab,x +nex stx vdc + sta vdc+1 + inx + cpx #16 + bcc i1 +ix + lda #40 + bit freq + bpl i2 + lda #80 +i2 sta maxspal + rts + +vdc8tab .byt $7e,$50,$64,6,$29,0,$19,$21,0,7,$60,7,0,0,0,0 + +vdc4tab .byt $3f,$28,$32,3,$29,0,$19,$21,0,7,$60,7,0,0,0,0 + + .) + +&setact .( + sta actscr + asl + asl + bit freq + bpl s1 + asl +s1 and #%00001111 + ldx #12 + stx vdc + sta vdc+1 + rts + .) + +/************************************************************************** + * Cursor handling + */ + +&crsron .( + ldx #15 + lda spalte + clc + adc vzei + stx vdc + sta vdc+1 + lda vzei+1 + adc #0 + dex + stx vdc + and #%00001111 + sta vdc+1 +&&crsroff rts + .) + +/************************************************************************** + * Bell handling + */ + + .( + + .data +pnt .byt 0 +cnt .byt 0 + .text + +&inibell + lda #%00100100 + sta VIA1+VIA_IER + lda VIA1+VIA_ACR + and #%11000011 + ora #%00010000 + sta VIA1+VIA_ACR +&&trigbell + lda #0 + sta pnt + sta cnt + lda #15 + sta VIA1+VIA_SR +&&bellirq + lda cnt + bne endirq + ldy pnt + lda tcnt,y + beq endbell + sta cnt + lda tfrq,y + sta VIA1+VIA_T2CL + lda #0 + sta VIA1+VIA_T2CH + inc pnt +endirq dec cnt + rts +endbell lda #0 + sta VIA1+VIA_SR + rts + +tcnt .byt 2,2,2,2,2,2,2,0 +tfrq .byt 32,64,128,32,64,128,32 + + .) + +/**************************************************************************/ + + .( + +kcnt =zei2 + .data +rcnt .byt 0 +shiftfl .byt 0 +prev .byt 0 + .zero +tzei .word 0 + .text + +&inikbd .( + lda PIO+PIA_CRA + and #255-4 + sta PIO+PIA_CRA + ldx #15 + stx PIO+PIA_PA + ora #4 + sta PIO+PIA_CRA + lda PIO+PIA_CRB + and #255-4 + sta PIO+PIA_CRB + ldx #0 + stx PIO+PIA_PB + ora #4 + sta PIO+PIA_CRB + lda #4 + sta rcnt + sta rspd + rts + .) + +&&getkey .( + lda PIO + and #$f0 + ora #8 + sta PIO +ix1 + lda PIO+2 + cmp PIO+2 + bne ix1 + ldy #0 + and #%00100001 + cmp #%00100001 + beq nshift + iny +nshift inc PIO +x0 lda PIO+2 + cmp PIO+2 + bne x0 + and #%00000001 + bne nctrl + iny + iny +nctrl sty shiftfl + + tya + asl + tax + lda ttab+1,x + tay + lda ttab,x + sta tzei + sty tzei+1 + ldy #0 + ldx #0 +lx1 stx kcnt + lda PIO + and #$f0 + ora kcnt + sta PIO + ldx #8 +l2 lda PIO+2 + cmp PIO+2 + bne l2 +l3 asl + bcs lc + pha + lda (tzei),y + bne le + pla +lc iny + dex + bne l3 + ldx kcnt + inx + cpx #10 + bcc lx1 + + ldy #<-1 + sty prev +nokey +/* TODO: check keyboard code - C64 works different */ +; ldx #KEY_START +; stx rcnt + ldx shiftfl + sec + rts + +le tax + pla + txa + cpy prev + sty prev + bne lx + + dec rcnt + bne nokey + ldx rspd + .byt $2c + +lx ldx #KEY_START + stx rcnt + + ldx shiftfl + clc + rts + .) + +ttab .word ktab,stab,ctab,sctab + +ktab .asc TC_CRGT,TC_HOME,"~(&%#!",TC_BS,TC_CDWN,"^@)\'$":.byt $22 + .asc "97^^outeq/8^@piyrw" + .asc "64^@ljgda*5^@:khfs" + .asc "31",TC_CR,";mbcz+2^@?,nvx" + .asc "-0^@>^@]@^@=.^@@< [^@" + +stab .asc TC_CLFT,TC_CLR,"|(&%#!",TC_INS,TC_CUP,"^@)\'$":.byt $22 + .asc "97^^OUTEQ/8^@PIYRW" + .asc "64^@LJGDA*5^@:KHFS" + .asc "31",TC_LF,";MBCZ+2^@?,NVX" + .asc "-0^@>^@}@^@=.^@",TC_ESC,"< {^@" + +ctab .asc TC_WRU,TC_WCLS,"~(&%#!",TC_DEL,TC_WLO,"^@)\'$",$22 + .asc "97^^^o^u^t^e^q/8^@^p^i^y^r^w" + .asc "64^@^l^j^g^d^a*5^@:^k^h^f^s" + .asc "31",TC_EOL,";^m^b^c^z+2^@?,^n^v^x" + .asc "-0^@>^@]@^@=.^@",TC_CLL,"< [^@" + +sctab .asc "^@^@|(&%#!^H^@^@)\'$":.byt $22 + .asc "97^^O^U^T^E^Q/8^@^P^I^Y^R^W" + .asc "64^@^L^J^G^D^A*5^@:^K^H^F^S" + .asc "31^m;^M^B^C^Z+2^@?,^N^V^X" + .asc "-0^@>^@}@^@=.^@@< {^@" + + + .) + diff --git a/dump/oa-2.0.9/arch/csa65/devices/csadev.a65 b/dump/oa-2.0.9/arch/csa65/devices/csadev.a65 new file mode 100644 index 0000000..55028a9 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/devices/csadev.a65 @@ -0,0 +1,66 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ROM + +#include "kdefs.def" +#include "kernel.i65" + + ;.word $700 + *=$700 + +/*#define NOPRG*/ + +#endif + + +/* Device-Block */ + + .( + + .word endd + .byt PK_DEV+$80 + .word devstart + .dsb P_NAME - P_RAM, $ff + .asc "devices",0,0 + +devstart + +#define CONSOLE_DEVICE "devices/con_csa.a65" +#include "devices/console.a65" + +#include "devices/par.a65" +#include "devices/nulldev.a65" +#include "devices/spooler.a65" + +-sernr = "1" +#include "devices/oa1ds.a65" + +#define UARTBASE $e830 +/*#include "devices/ser_uart.a65"*/ + + .word $ffff + +endd .) + diff --git a/dump/oa-2.0.9/arch/csa65/devices/drv_wd1770.a65 b/dump/oa-2.0.9/arch/csa65/devices/drv_wd1770.a65 new file mode 100644 index 0000000..4ed58e1 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/devices/drv_wd1770.a65 @@ -0,0 +1,1296 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* + * Driver for a memory-mapped WD1770 + * + * Exports + * + * GETDPB + * DLOOP + * DINIT + * RWSEC + * DFORMAT + * + * Imports (calls): + * + * dchanged + */ + + .( + +#include "chips/wd1770.i65" +#include "chips/via6522.i65" + +#define WD1770 $e8e0 +#define WDVIA $e8f0 + +#define ERRCNT 4 + + .zero +zei .word 0 +zeid .word 0 +ddzei .word 0 +divers .byt 0 +sect .byt 0 +tr .byt 0 +errcnt .byt 0 +actdrv .byt 0 +side .byt 0 +cmd .byt 0 +data .dsb 6 +drvst .dsb ANZDRV ; drivestatus z.b. Step-Zeit +tracks .dsb ANZDRV ; Track, auf dem jeweiliges Laufwerk steht +hd .dsb ANZDRV ; High-Density-Flag =bit7 , 6= motor an flag + ; bit0=1 disk changed, bit1=1 double stepping +mcnt .dsb ANZDRV ; motor-aus-zaehler +blen .dsb ANZDRV ; Anzahl 256-Byte-Bloecke in einem Sektor + + .text + +/* + jmp DINIT + jmp exit + jmp seldrv ; a=drv + jmp desel + jmp selside ; a=side + jmp go2track ; a=track + jmp setadr ; a/y=adr + jmp read ; a=sect + jmp write ; " + jmp verify ; " + jmp DREAD ; a/y=*Struct + jmp DWRITE ; " + ;jmp DVERIFY ; " + jmp ftrack ; a=virgin, zeid=*seclist + jmp DFORMAT ; a/y=*Struct +*/ + +#if D_SLEN=32 +setddzei /* AC=Drv-Nr */ + asl + asl + asl + asl + asl + clc + adc #dpb + sta ddzei+1 + clc + rts +#endif + +INVDPB .( ; x ist Drive + txa + jsr setddzei + ldy #D_ST + lda #DS_INV + sta (ddzei),y + clc + rts + .) + +INIDPB .( + ldx #0 +il stx zei + jsr INVDPB + ldx zei + inx + cpx #ANZDRV + bcc il + clc + rts + .) + +&GETDPB .( ; x is drive number + jsr setdzei + + jsr boot2dpb + bcs er + + ldx drive + lda hd,x + and #255-2 + sta hd,x + + ldy #D_SECS + lda (dzei),y + sta ar1 + iny + lda (dzei),y + sta ar1+1 + ldy #D_SPTS+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr div + cmp #41 + bcs ge + txa + bne ge +#ifdef SHOWD + lda #"d" + jsr SEROUT + lda drive + jsr HEXOUT +#endif + ldx drive + lda hd,x + ora #2 + sta hd,x +ge + ldy #D_ST + lda #DS_OK + sta (dzei),y + ldy #D_BFLAG + lda #0 ; 0 -> 12 bit FAT + sta (dzei),y + clc +er + rts + .) + + +sec2rw .( + ldy #RW_DRV + lda (zei),y + jsr setddzei + + ldy #RW_TRCK+1 + lda (zei),y + sta ar1+1 + dey + lda (zei),y + sta ar1 + ora ar1+1 + bne notboot + + ;lda #0 + ldy #RW_SIDE +s2rl sta (zei),y + iny + cpy #RW_ADR + bcc s2rl + ldy #RW_SEC + lda #1 + sta (zei),y + clc + rts + +notboot ldy #D_SECS+1 + txa + cmp (ddzei),y + bcc sok + bne serr + dey + lda ar1 + cmp (ddzei),y + bcs serr +sok + ldy #D_SPTS+1 + lda (ddzei),y + tax + dey + lda (ddzei),y + jsr div + bcs serr + ldy #RW_TRCK + sta (zei),y + iny + txa + sta (zei),y + ldy #D_SPT+1 + lda (ddzei),y + tax + dey + lda (ddzei),y + jsr div + bcs serr + ldy #RW_SIDE + sta (zei),y + txa + bne serr + clc + lda ar1 + adc #1 + ldy #RW_SEC + sta (zei),y + iny + lda ar1+1 + adc #0 + sta (zei),y + rts +serr sec + rts + .) + +#ifndef SHOWD +&RWSEC bcs DWRITE +#endif + +DREAD ldx #1 + .byt $2c +DWRITE ldx #2 + stx cmd + .( + sta zei + sty zei+1 + + jsr sec2rw ; change from sector number to track/side/sector + + ldy #RW_ADR + lda (zei),y + pha + iny + lda (zei),y + tay + pla + jsr setadr + ldy #RW_DRV + lda (zei),y + jsr seldrv + bcs rx + ldy #RW_SIDE + lda (zei),y + jsr selside + ldy #RW_TRCK + lda (zei),y + jsr go2track + bcs rx + ldx actdrv + lda blen,x + tax ; Anzahl 256-Byte-Blocks (wird bei seldrv gesetzt) + ldy #RW_SEC + lda (zei),y + dec cmd + bne r2 + jmp read +r2 dec cmd + bne r3 + jmp write +r3 sec + lda #E_CMD +rx rts + .) + +&DFORMAT .( + .data +fpar .byt 0 + .text + + cmp #ANZFORM + bcc f1 + lda #E_ILLPAR + sec + rts +f1 sta fpar + asl + tay + lda fadr,y + sta zei + lda fadr+1,y + sta zei+1 + txa ; x= drive + pha + jsr desel + pla + sta actdrv + + jsr setdrv ; a=drive + + ldy #FMT_HDFL + lda (zei),y + ldx actdrv + sta hd,x + jsr setdens + + jsr motoron + + ldy #FMT_BLEN + lda (zei),y + sta data+5 + tax + lda POT2-1,x + ldx actdrv + sta blen,x + + jsr restore + bcs fx + + lda #0 + sta tr + lda #FMT_SCLST + clc + adc zei + pha + lda zei+1 + adc #0 + tay + pla + jsr setadr ; sektor-Liste setzen + +floop lda #0 + sta side + +sideloop jsr selside + + ldx data+5 ; Block-L�nge 0=128,1=256,2=512,3=1024 + ldy #FMT_VIRG + lda (zei),y + jsr ftrack + bcs fx + + inc side + lda side + ldy #FMT_SIDES + cmp (zei),y + bcc sideloop + + inc tr + lda tr + ldy #FMT_TRCKS + cmp (zei),y + bcs wrboot + + ldx actdrv + lda hd,x + and #2 + beq fnd + + jsr lowdens + + lda #$50 + jsr setstep + bcs fx +fnd + lda #$50 ; step-in ohne verify + jsr setstep + bcs fx + jsr highdens + jmp floop + +fx pha + jsr highdens + pla + ldx #<-1 + stx actdrv + sec + rts + +wrboot lda #0 + jsr selside + lda #0 + jsr go2track + bcs fx + lda fpar ; Format mal 32 als Zeiger f�r + asl ; Boot-Sektor-Daten + asl + asl + asl + asl + clc + adc #bootsektor + tay + pla + jsr setadr + + ldx actdrv + lda blen,x + tax + lda #1 + jsr write + ldx #<-1 + stx actdrv + rts + +ANZFORM =6 +fadr .word ssdd,dsdd,dshd3,dshd5,dshh5,dsdd40 + + ; single sided double density +ssdd .byt $e5,1,80,$01,2,10, 1,3,5,7,9,2,4,6,8 + ; double sided double density +dsdd .byt $e5,2,80,$01,2,10, 1,3,5,7,9,2,4,6,8 + ; double sided high density 3 1/2 zoll +dshd3 .byt $e5,2,80,$81,2,19, 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18 + ; double sided high density 5.25" +dshd5 .byt $e5,2,80,$81,2,16, 1,3,5,7,9,11,13,15,2,4,6,8,10,12,14 + ; double sided higher density 5.25" +dshh5 .byt $e5,2,80,$81,3,9, 1,3,5,7,2,4,6,8 + ; double sided double density 40 Tracks (360k) +dsdd40 .byt $e5,2,40,$03,2,10, 1,3,5,7,9,2,4,6,8 + +bootsektor ; single sided double density + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 2 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 112 ; DIR + .word 720 ; SECs + .byt 248 ; Media + .word 3 ; SPF + .word 9 ; SPT + .word 1 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided double density + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 2 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 112 ; DIR + .word 1440 ; SECs + .byt 249 ; Media + .word 3 ; SPF + .word 9 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided high density 3.5 zoll + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 224 ; DIR + .word 2880 ; SECs + .byt 240 ; Media + .word 9 ; SPF + .word 18 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided high density 5.25 zoll + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 224 ; DIR + .word 2400 ; SECs + .byt 249 ; Media + .word 7 ; SPF + .word 15 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided higher density 5.25 zoll (BPS=1024) + .byt $eb,$34,$90,"OS/A 1.2" + .word $400 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 128 ; DIR + .word 1280 ; SECs + .byt 255 ; Media + .word 2 ; SPF + .word 8 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided double density 5.25 zoll 40 Tracks (360k) + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 112 ; DIR + .word 720 ; SECs + .byt 255 ; Media + .word 3 ; SPF + .word 9 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + .) + +&DINIT .( + jsr INIDPB + + lda #%00001111 + sta WDVIA+VIA_DRA ; + + lda #0 + sta WDVIA+VIA_DDRA ;Ertmal testen ob IC da + cmp WDVIA+VIA_DDRA + bne xini + lda #%00101111 + sta WDVIA+VIA_DDRA + cmp WDVIA+VIA_DDRA + bne xini + + lda WDVIA+VIA_ACR + and #%11011110 ;t2 timed irq, pa latch disabled + sta WDVIA+VIA_ACR + lda WDVIA+VIA_PCR + and #%11110000 ;pa + ora #%00001110 ;ca2 hi (side), ca1 neg edge + sta WDVIA+VIA_PCR + lda #%00100011 ;ca1, ca2, t2 irq off + sta WDVIA+VIA_IER + +/* lda #0 ; der Controller braucht zulange, um das Register + sta WD1770+WD_TRCK ; upzudaten + cmp WD1770+WD_TRCK + bne xini +*/ + ldx #0 +i1 lda #00000011 ; 6ms Step-Zeit + sta drvst,x + lda #<-1 + sta tracks,x + inx + cpx #ANZDRV + bcc i1 + sta actdrv + clc + rts +xini sec + rts + .) + +&DLOOP .( + .data +dcnt .byt 0 + .text + + lda #0 + sta dcnt + sta divers +dl jsr setdrv ; a=drive + + ldx divers + lda hd,x + and #%01000000 + beq dl1 + inc dcnt ; motor an + dec mcnt,x + bne dl1 + lda hd,x + and #%10111111 + sta hd,x + lda #%00000100 + dex + bmi dl1a + asl +dl1a ora WDVIA+VIA_DRA + sta WDVIA+VIA_DRA +dl1 + ldx divers + lda WDVIA+VIA_DRA ; test auf Disk Change + and #%00010000 + bne dl2 ; not changed -> dl2 + + lda hd,x /* FIXME: move head to track 0? */ + and #1 + bne dl2 + lda hd,x + ora #1 + and #255-2 ; double-stepping aus + sta hd,x + lda #<-1 + sta tracks,x + jsr INVDPB + jsr dchanged +dl2 + inc divers + lda divers + cmp #ANZDRV + bcc dl + jsr desel + + lda WDVIA+VIA_DRA + and #%00001100 ; motor-bits + eor #%00001100 ; sind beide aus + bne dlx ; nein dann ende + jsr lowdens +dlx lda dcnt ; mit z-flag �bergeben + rts + .) + + +forcend .( + lda WD1770+WD_ST + and #1 + beq fer + lda #%11010000 ; Force Interrupt + sta WD1770+WD_CMD + jsr wloop +fer rts + .) + +selside .( + clc + and #1 + sta side + bne side1 + lda WDVIA+VIA_PCR + ora #%00000010 + sta WDVIA+VIA_PCR + rts +side1 lda #%11111101 + and WDVIA+VIA_PCR + sta WDVIA+VIA_PCR + rts + .) + +wloop .( + txa + ldx #13 +wl1 dex + bne wl1 + tax + rts + .) + +wcmd .( + pha +#ifdef NMIDEV + lda #NMI_OFF + jsr CTRLNMI +#endif + sei + jsr wloop + pla + sta WD1770+WD_CMD + lda #1 +wcl bit WD1770+WD_ST + beq wcl + rts + .) + +setstep .( + ldx actdrv + and #%11111100 + ora #%00001000 ; ohne Motor-On-Time + sta divers + lda drvst,x + and #3 + ora divers + php + ;sei + jsr wcmd + ldx #128 +wc2 jsr setti +wc1 bit WDVIA+VIA_DRA + bmi wcok + jsr fragti + beq wc1 + dex + bne wc2 + plp + lda #E_CMD + sec + .byt $2c ; plp,clc �berspringen +wcok plp + clc + ldx WD1770+WD_ST + rts + .) + +setti lda #255 + sta WDVIA+VIA_T2CL + sta WDVIA+VIA_T2CH + rts + +fragti lda WDVIA+VIA_IFR + and #%00100000 + rts + +seldrv .( + pha + ldx actdrv + bmi sd1 + lda WD1770+WD_TRCK + sta tracks,x +sd1 pla + sta actdrv + + jsr setdrv ; a=drv + jsr setdens + jsr motoron + + ldx actdrv + lda tracks,x + bpl sd2 + jsr query + bcs sde +sd2 sta WD1770+WD_TRCK + tay + ldx actdrv + lda hd,x + and #1 + beq sd3 + tya + eor #1 ; da track von 0-79 kann das nicht aus bereich raus + jsr go2track ; um disk-change zu l�schen + bcs sder + ldx actdrv + lda hd,x + and #%11111110 + sta hd,x +sd3 clc +sder rts +sde sta actdrv + rts + .) + +motoron .( + lda actdrv + and #1 + beq drva + lda WDVIA+VIA_DRA + and #%11110111 ; Motor on + bne drvs +drva lda WDVIA+VIA_DRA + and #%11111011 +drvs sta WDVIA+VIA_DRA + ldx actdrv + lda hd,x + and #%01000000 + bne mok ; motor war schon an + sta mcnt,x ; motor-aus-z�hler auf null + lda hd,x + ora #%01000000 + sta hd,x +#ifdef SHOWD + lda #"m" + jsr SEROUT +#endif + +&mdelay + lda WDVIA+VIA_DRA + and #%00001100 ; beide Motoren + eor #%00001100 ; aus ? + beq mok ; ja dann ende + +#ifdef SHOWD + lda #"M" + jsr SEROUT +#endif + ldx #40 +ml jsr setti +ml2 jsr YIELD + jsr fragti + beq ml2 + dex + bne ml +mok rts + .) + +setdrv .( + and #1 + beq drva + lda WDVIA+VIA_DRA + and #%11111101 ; drive select + ora #%00000001 + bne drvs +drva lda WDVIA+VIA_DRA + and #%11111110 + ora #%00000010 +drvs sta WDVIA+VIA_DRA +&densok rts + .) + +setdens .( + ldx actdrv + lda hd,x ; high-Density-Bit + lsr ; auf Portbit schieben + lsr + eor WDVIA+VIA_DRA ; vergleichen + and #%00100000 ; maskieren + beq densok ; gleich dann fertig + + lda hd,x + bpl lodens + lda WDVIA+VIA_DRA + ora #%00100000 + bne denset +lodens lda WDVIA+VIA_DRA + and #%11011111 +denset sta WDVIA+VIA_DRA + jmp mdelay + .) + +lowdens lda WDVIA+VIA_DRA + and #%11011111 + sta WDVIA+VIA_DRA + rts +highdens ldx actdrv + lda hd,x + bpl lowdens + lda WDVIA+VIA_DRA + ora #%00100000 + sta WDVIA+VIA_DRA +#ifdef SHOWD + lda #"H" + jsr SEROUT +#endif + jmp mdelay + +query .( + jsr restore + bcs qx + lda #4 ; hd-count + sta divers + + lda #0 + jsr selside + +q ldx #40 ; bis 5.25" auf Drehzahl nach Density-Wechsel + lda #ERRCNT*2 + sta errcnt + .byt $2c +qloop ldx #16 ; 8*32ms=256ms <> 1 umdrehung bei 234 upm + lda #%11000000 ; Read Adress + ldy #5 + ;sei + jsr wcmd +q1 jsr setti + lda #%00100000 +q2 bit WDVIA+VIA_IFR + bne qn + bit WDVIA+VIA_DRA + bvc q2 + ldx WD1770+WD_DATA + stx data,y + dey + bpl q2 + lda WD1770+WD_ST + and #%00001100 + bne q3 + lda data+2 ; Sektor Length + and #3 + beq q3 ; Sektoren mit 128 Byte gehen nicht + tax + lda POT2-1,x ; dann Anzahl 256-Byte-Blocks im Sektor + ldx actdrv + sta blen,x + cli +#ifdef NMIDEV + lda #NMI_ON + jsr CTRLNMI +#endif + lda data+5 + clc + rts + +qn lda WD1770+WD_ST + dex + bne q1 + +q3 dec errcnt + bne qloop + cli +#ifdef NMIDEV + lda #NMI_ON + jsr CTRLNMI +#endif + dec divers + beq qe + + ldx actdrv + lda hd,x + eor #%10000000 + sta hd,x + jsr setdens + + lda divers + pha + cmp #2 + bcs q4 + jsr restore +q4 pla + sta divers + jmp q + +qe lda #E_Q +qx sec + rts + +&POT2 .byt 1,2,4 + .) + +desel .( + ldx actdrv + bmi sd1 + lda WD1770+WD_TRCK + sta tracks,x +sd1 lda #<-1 + sta actdrv + lda WDVIA+VIA_DRA + ora #%00000011 + sta WDVIA+VIA_DRA + clc + rts + .) + +go2track .( + sta tr + cmp WD1770+WD_TRCK + beq gtr + + jsr lowdens + + jsr findtr + bcc gtc + + lda #$04 ; restore mit verify + jsr setstep + bcs gts + + jsr findtr + bcs gts +gtc and #%00011000 + bne gts + + jsr highdens +gtr clc + rts + +gts jsr highdens + lda #E_GT + sec + rts + .) + +findtr .( + lda tr + sta WD1770+WD_DATA + + ldx actdrv + lda hd,x + and #2 + beq gnd + + lda WD1770+WD_TRCK + pha + lda #$10 ; stepping ohne verify + jsr setstep + pla + sta WD1770+WD_TRCK ; und das ganze nochmal mit verify + lda tr + sta WD1770+WD_DATA ; das sind dann doppelt so viele steps + +gnd lda #$14 ; seek track + jmp setstep + .) + +restore .( + jsr forcend + jsr lowdens + lda #$00 ; restore + jsr setstep + pha + jsr highdens + lda #0 + sta tr + pla + rts + .) + +setadr sta zeid + sty zeid+1 + clc + rts + +read .( + sta sect + stx data +#ifdef BSHOW + lda #"R" + jsr SEROUT + txa + jsr HEXOUT +#endif + jsr forcend + lda #ERRCNT + sta errcnt +rdloop lda sect + sta WD1770+WD_SECT + ;sei + ldx data ; Anzahl 256-Byte-Bl�cke + ldy #0 + lda #%10001000 + jsr wcmd + lda WD1770+WD_ST +rd1 bit WDVIA+VIA_DRA + bmi rde + bvc rd1 + lda WD1770+WD_DATA + sta (zeid),y + iny + bne rd1 + inc zeid+1 + dex + bne rd1 + clc + ldx WD1770+WD_ST + ldy errcnt + ;cli + ;rts + bcc rdee ; always +rde dec errcnt + bne rdloop + lda #E_RD + sec + ldx WD1770+WD_ST +rdee + cli +#ifdef NMIDEV + php + pha + lda #NMI_ON + jsr CTRLNMI + pla + plp +#endif + rts + .) + +write .( + sta sect ; ( x-reg die Anzahl 256-Byte-Bl�cke ) + stx data +#ifdef BSHOW + lda #"W" + jsr SEROUT + txa + jsr HEXOUT +#endif + jsr forcend + lda #ERRCNT + sta errcnt +wrloop lda sect + sta WD1770+WD_SECT + ;sei + ldx data ; Anzahl 256-Byte-Bl�cke + ldy #0 + lda #%10101000 + jsr wcmd + lda WD1770+WD_ST +rd1 bit WDVIA+VIA_DRA + bmi rde + bvc rd1 + lda (zeid),y + sta WD1770+WD_DATA + iny + bne rd1 + inc zeid+1 + dex + bne rd1 + clc + lda WD1770+WD_ST + ;cli + ;rts + bcc rdee ; always +rde dec errcnt + bne wrloop + lda #E_WR + sec + ldx WD1770+WD_ST +rdee cli +#ifdef NMIDEV + php + pha + lda #NMI_ON + jsr CTRLNMI + pla + plp +#endif + rts + .) + +ftrack .( + sta divers ; virgin + stx data+4 ; Sektor-L�nge + lda POT2-1,x + sta data ; Anzahl 256-Byte-Bl�cke + lda #ERRCNT + sta errcnt +errloop ldy #0 + lda (zeid),y + sta data+2 ; endsector + iny + sty sect + jsr forcend + ;sei + lda #%11110100 + jsr wcmd + lda WD1770+WD_ST ; intrq loeschen + ldy #80 + ldx #$4e +f1a bit WDVIA+VIA_DRA + bmi fey + bvc f1a + stx WD1770+WD_DATA + dey + bne f1a +sloop lda data + sta data+1 + ldx #0 + ldy #12 +f2 bit WDVIA+VIA_DRA + bmi fey + bvc f2 + stx WD1770+WD_DATA + dey + bne f2 + ldx #$f5 + ldy #3 +f3 bit WDVIA+VIA_DRA + bmi fey + bvc f3 + stx WD1770+WD_DATA + dey + bne f3 + ldx #$fe +f4 bit WDVIA+VIA_DRA +fey bmi fex + bvc f4 + stx WD1770+WD_DATA + ldx tr +f5 bit WDVIA+VIA_DRA + bmi fex + bvc f5 + stx WD1770+WD_DATA + ldx side +f6 bit WDVIA+VIA_DRA + bmi fex + bvc f6 + stx WD1770+WD_DATA + ldy sect + lda (zeid),y + tax +f7 bit WDVIA+VIA_DRA + bmi fex + bvc f7 + stx WD1770+WD_DATA + ldx data+4 ; l�nge des Sektors +f8 bit WDVIA+VIA_DRA + bmi fex + bvc f8 + stx WD1770+WD_DATA + ldx #$f7 +f9 bit WDVIA+VIA_DRA + bmi fex + bvc f9 + stx WD1770+WD_DATA + ldy #22 + ldx #$4e +f10 bit WDVIA+VIA_DRA + bmi fex + bvc f10 + stx WD1770+WD_DATA + dey + bne f10 + ldy #12 + ldx #0 +f11 bit WDVIA+VIA_DRA + bmi fex + bvc f11 + stx WD1770+WD_DATA + dey + bne f11 + ldy #3 + ldx #$f5 +f12 bit WDVIA+VIA_DRA +fex bmi fe + bvc f12 + stx WD1770+WD_DATA + dey + bne f12 + ldx #$fb +f13 bit WDVIA+VIA_DRA + bmi fe + bvc f13 + stx WD1770+WD_DATA + ldx divers ; virgin +f15 ldy #0 +f14 bit WDVIA+VIA_DRA ; 256 Byte + bmi fe + bvc f14 + stx WD1770+WD_DATA + dey + bne f14 + dec data+1 + bne f15 + ldx #$f7 ; end of sektor +f16 bit WDVIA+VIA_DRA + bmi fe + bvc f16 + stx WD1770+WD_DATA + ldy #24 + ldx #$4e ; pause nach sektor +f20 bit WDVIA+VIA_DRA + bmi fe + bvc f20 + stx WD1770+WD_DATA + dey + bne f20 + inc sect + dec data+2 + beq f18a + jmp sloop +f18a ldx #$4e +f18 bit WDVIA+VIA_DRA + bmi fr + bvc f18 + stx WD1770+WD_DATA + jmp f18 ; absolut +fe dec errcnt + beq fee + jmp errloop +fee sec + lda #E_FT + ldx WD1770+WD_ST + .byt $24 +fr sec + cli +#ifdef NMIDEV + php + pha + lda #NMI_ON + jsr CTRLNMI + pla + plp +#endif +/* + cli + rts +fr cli + clc + rts +*/ + .) + .) + + diff --git a/dump/oa-2.0.9/arch/csa65/devices/oa1ds.a65 b/dump/oa-2.0.9/arch/csa65/devices/oa1ds.a65 new file mode 100644 index 0000000..719aabb --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/devices/oa1ds.a65 @@ -0,0 +1,401 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * Double ACIA serial line device driver + * for CS/A65 architecture. + * It uses other peripheral lines then the ones of the 6551 for rts/cts + */ + +#define ACIA $efe8 +#define ACIA2 $e818 +#define PIA2 $e810 +#define Anzdev 2 + + .( + .word devend1 + jmp prg1 + .asc "ser",sernr, 0 + +-sernr += 1 + +devend1 .word devend2 + jmp prg2 + .asc "ser",sernr, 0 + +-sernr += 1 + + .data +dev .byt 0 +div .byt 0 +status .dsb Anzdev +instr .dsb Anzdev +outstr .dsb Anzdev +brkkey .dsb Anzdev + .text + +prg1 ldx #0 + .byt $2c +prg2 ldx #1 + stx dev + cmp #DC_RES + beq devini + pha + lda status,x + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini lda #0 + sta status,x + sta instr,x + sta outstr,x + + lda #3 + sta brkkey,x + + cpx #1 + beq iniser2 + + STA ACIA+1 + LDA #%00011000; 1200 BAUD + STA ACIA+3 + cmp ACIA+3 + bne devx + LDA #%00000101 + STA ACIA+2 + cmp ACIA+2 + bne devx + LDA ACIA+1 +rts1hi lda SYSPORT /* RTS hi */ + ora #SYS_RTS + sta SYSPORT + clc + rts + +iniser2 STA ACIA2+1 + LDA #%00011000; 1200 BAUD + STA ACIA2+3 + cmp ACIA2+3 + bne devx + LDA #%00000101 + STA ACIA2+2 + cmp ACIA2+2 + bne devx + LDA ACIA2+1 +rts2hi lda PIA2+PIA_CRA /* CA2 output hi =RTS Hi */ + ora #%00111000 + ;and #%11110111 + sta PIA2+PIA_CRA + clc + rts + +devx lda status,x + ora #2 + sta status,x + lda #E_NOTIMP + sec + rts + +devirq + cpx #1 + bne irqser1 + jmp irqser2 +irqser1 + .( + lda ACIA+1 + bpl irqend + sta div + bit status + bpl tx + and #%00001000 + beq nobyt + ldx outstr + lda ACIA + + cmp brkkey + bne nobrk + lda #SC_SSTAT + ldy #SCE_BRK + jsr STRCMD + lda brkkey +nobrk + jsr PUTC + bcs test + +nobyt ldx outstr + lda #SC_STAT + jsr STRCMD +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx + +irqend lda #E_NOIRQ + rts + +tstwater cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh jsr rts1hi + bcc tx ; unbedingt +twl cmp #E_SLWM + bne tx +wl lda SYSPORT + and #255-SYS_RTS ; IO freigeben + sta SYSPORT + +tx bit status + bvc irqhs + lda div + and #%01010000 + eor #%00010000 + bne irqhs + ldx instr + jsr GETC + bcs test2 + sta ACIA + bcc irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs lda ACIA+1 + lda #E_OK + rts + .) + +irqser2 .( + lda ACIA2+1 + bpl irqend + sta div + bit status+1 + bpl tx + and #%00001000 + beq nobyt + ldx outstr+1 + lda ACIA2 + + cmp brkkey+1 + bne nobrk + lda #SC_SSTAT + ldy #SCE_BRK + jsr STRCMD + lda brkkey+1 +nobrk + jsr PUTC + bcs test + +nobyt ldx outstr+1 + lda #SC_STAT + jsr STRCMD +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx +tstwater cmp #E_SEMPTY + beq wl + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh jsr rts2hi + bcc tx ; unbedingt +twl cmp #E_SLWM + bne tx +wl lda PIA2+PIA_CRA + and #%11110111 + sta PIA2+PIA_CRA + +tx bit status+1 + bvc irqhs + lda div + and #%01010000 + eor #%00010000 + bne irqhs + ldx instr+1 + jsr GETC + bcs test2 + sta ACIA2 + bcc irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs lda ACIA2+1 + lda #E_OK + rts +irqend lda #E_NOIRQ + rts + .) + +others cmp #DC_GS + bne o1 + lda status,x + and #DC_SW_TX + bne devonx + tya + sta instr,x + jmp ok +devonx jmp devon +o1 cmp #DC_PS + bne o2 + lda status,x + and #DC_SW_RX + bne devonx + tya + sta outstr,x +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + ; lda #3 + ; sta brkkey,x + lda #DC_SW_TX +o2a ora status,x + sta status,x + bne okx +o4 cmp #DC_RX_OFF + bne o5 +rxoff ldx dev + lda status,x + and #DC_SW_RX + beq devoffx + lda outstr,x + tax + lda #SC_EOF + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_RX + sta status,x + txa + beq rx1off + jsr rts2hi + bcc okx +rx1off jsr rts1hi + bcc okx +devoffx jmp devoff +o5 cmp #DC_TX_OFF + bne o6 +txoff ldx dev + lda status,x + and #DC_SW_TX + beq devoffx + lda instr,x + tax + lda #SC_NUL + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_TX + sta status,x + jmp ok +o6 cmp #DC_HS + bne o6a + lda status,x + and #255-1 + sta status,x + tya + and #1 + ora status,x + sta status,x + jmp ok +o6a cmp #DC_SPD + bne o7 + tya + and #%00001111 + sta div + ldx dev + bne o6b + lda ACIA+3 + and #%11110000 + ora div + sta ACIA+3 + jmp ok +o6b lda ACIA2+3 + and #%11110000 + ora div + sta ACIA2+3 + jmp ok + +o7 cmp #DC_ST + beq ok + cmp #DC_EXIT + bne o9 ; onotimp + jsr rxoff + jsr txoff + ldx dev + lda status,x + ora #2 + sta status,x + txa + bne o8a + sta ACIA+1 + beq ok +o8a sta ACIA2+1 + beq ok +o9 + cmp #DC_BRKKEY + bne onotimp + lda brkkey,x + pha + tya + sta brkkey,x + pla + tay + ; jmp ok + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +devend2 .) + diff --git a/dump/oa-2.0.9/arch/csa65/devices/par.a65 b/dump/oa-2.0.9/arch/csa65/devices/par.a65 new file mode 100644 index 0000000..a4d86fc --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/devices/par.a65 @@ -0,0 +1,144 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#define WD_VIA $e8f0 + + .( + .word cntrend + jmp centrprg + .asc "par",0 + + .data +instr .byt 0 +status .byt 0 + .text + +centrprg cmp #DC_RES + bne sp1 + + ldx #0 + stx status + dex + stx WD_VIA+VIA_DDRB + cpx WD_VIA+VIA_DDRB + beq ct1 + inc status + sec + rts +ct1 lda WD_VIA+VIA_PCR + and #%00001111 ;port b + ora #%11100000 ;cb2 hi out, cb1 neg. edge + sta WD_VIA+VIA_PCR + lda WD_VIA+VIA_ACR + and #%11100001 ;shift off, pb latch disabled + sta WD_VIA+VIA_ACR + lda #%00011100 ;cb2, shift, cb1 irq off + sta WD_VIA+VIA_IFR + sta WD_VIA+VIA_IER + clc + rts + +sp1 pha + lda status + lsr + pla + bcs nlnotimp +; and #1 +; beq ct2 +; pla +; lda #E_NOTIMP +; sec +; rts +ct2 ;pla + cmp #DC_IRQ + bne sp2 + + lda status + and #DC_SW_TX + beq spe + + lda WD_VIA+VIA_IFR + and #%00010000 + beq spe + + ldx instr + jsr GETC + bcc spil + cmp #E_EOF + bne spe + jsr txoff + bcc spe ; always + +spil sta WD_VIA+VIA_DRB + lda WD_VIA+VIA_PCR + and #%11011111 ;ora #%11100000 + sta WD_VIA+VIA_PCR + ora #%11100000 ;and #%11011111 + sta WD_VIA+VIA_PCR +spe clc + lda #E_NOIRQ ; no irq source has been removed + rts + +sp2 cmp #DC_RX_OFF + beq nlnotimp + cmp #DC_TX_OFF + bne sp3 +txoff ldx instr + lda #SC_NUL + jsr STRCMD + lda status + and #255-DC_SW_TX + sta status + jmp ok + +sp3 cmp #DC_RX_ON + beq nlnotimp + cmp #DC_TX_ON + bne sp5 + lda #DC_SW_TX + ora status + sta status + +ok lda #0 + .byt $2c +nlnotimp lda #E_NOTIMP + .byt $2c +nldevon lda #E_DON + cmp #1 + rts + +sp5 cmp #DC_GS + bne sp6 ;nlnotimp + lda status + and #DC_SW_TX + bne nldevon + sty instr + beq ok + +sp6 cmp #DC_EXIT + bne nlnotimp + inc status + bne ok +cntrend .) + diff --git a/dump/oa-2.0.9/arch/csa65/devices/piec_csa.a65 b/dump/oa-2.0.9/arch/csa65/devices/piec_csa.a65 new file mode 100644 index 0000000..c995b12 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/devices/piec_csa.a65 @@ -0,0 +1,2290 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#define VIA1 $e840 +#define PIA1 $e820 + +#include "chips/via6522.i65" +#include "chips/pia6521.i65" + +#ifdef FSIEC_USE_STDLIB +#define CHDIR Chdir +#define ASSIGN Assign +#endif + + .data +byte .byt 0 +bytfl .byt 0 +eoifl .byt 0 + .text + +#ifndef NOLOOP + .data +filetab .dsb FT_SLEN*ANZ_FT + .text +#endif + +&getif clc + ldx #SEM_VIAE840_T1 + jmp PSEM +&freif ldx #SEM_VIAE840_T1 + jmp VSEM + +&IECINIT .( +#ifdef INVERT + lda #%00110000 + sta PIA1+PIA_CRA + lda #0 + sta PIA1+PIA_PA + cmp PIA1+PIA_PA + bne inix + lda #%00110100 + sta PIA1+PIA_CRA + + lda #%00110000 + sta PIA1+PIA_CRB + lda #$ff + sta PIA1+PIA_PB + cmp PIA1+PIA_PB + bne inix + lda #%00110100 + sta PIA1+PIA_CRB + lda #0 + sta PIA1+PIA_PB + + lda #%00111100 + sta VIA1+VIA_DDRB + cmp VIA1+VIA_DDRB + bne inix + + lda #0 + sta VIA1+VIA_DRB + + lda VIA1+VIA_ACR + and #%00111101 + sta VIA1+VIA_ACR + lda VIA1+VIA_PCR + ora #%11100000 ; cb2 hi out + sta VIA1+VIA_PCR + lda #%01011000 + sta VIA1+VIA_IER + lda #0 + sta byte + sta bytfl + sta eoifl + clc + rts +inix sec + rts +#else + lda #%00111000 + sta PIA1+PIA_CRA + lda #0 + sta PIA1+PIA_PA ; DDRA + cmp PIA1+PIA_PA + bne inix + lda #%00111100 ; DAV hi + sta PIA1+PIA_CRA + + lda #%00111000 + sta PIA1+PIA_CRB + lda #$ff + sta PIA1+PIA_PB ; DDRB + cmp PIA1+PIA_PB + bne inix + lda #%00111100 ; NRFD hi + sta PIA1+PIA_CRB + lda #<-1 ; DRB + sta PIA1+PIA_PB + + lda #%00111100 + sta VIA1+VIA_DDRB + cmp VIA1+VIA_DDRB + bne inix + sta VIA1+VIA_DRB ; alle ausgaenge hi + + lda VIA1+VIA_ACR + and #%00111101 ; PB2 Latch off, T1 timed IRQ + sta VIA1+VIA_ACR + lda VIA1+VIA_PCR + ora #%11100000 ; cb2 hi out (Piezo) + sta VIA1+VIA_PCR + lda #%01011000 ; T1, CB1, CB2 -IRQ off + sta VIA1+VIA_IER + lda #0 + sta byte + sta bytfl + sta eoifl + clc + rts +inix sec + rts +#endif + .) + +#ifndef NOLOOP + .( + +&&&iniftab .( + ldx #0 + lda #FT_MOD_FRE +i1 sta filetab+ANZ_FT*FT_MOD,x + ;lda #0 + sta filetab+ANZ_FT*FT_ST,x + inx + cpx #15 + bcc i1 + ldx #0 + stx reterr + stx outpos + stx outlen + clc + rts + .) + + .data +cmdfl .byt 0 +listenfl .byt 0 +talkfl .byt 0 +reterr .byt 0 +bufpos .byt 0 +outpos .byt 0 +outlen .byt 0 +lstnadr .byt 0 +talkadr .byt 0 +&filenr .byt 0 + +INBUF .dsb MAXLEN + +OUTBUF .dsb MAXLEN + + .text + +RETLOOP cli + lda #0 + sta cmdfl + jsr clrdata + jsr davhi + jsr eoihi + jsr ndachi + jmp nrfdhi + +&&INLOOP cli +lx lda VIA1+VIA_DRA + cmp VIA1+VIA_DRA + bne lx + and #%00010000 + bne RETLOOP ; wait atnlo +atndet sei + lda #0 + sta cmdfl + jsr clrdata + jsr davhi + jsr eoihi + jsr ndaclo + jsr nrfdlo + jsr atnalo +inext jsr ndaclo + jsr nrfdhi + lda #$10 +ix1 bit VIA1+VIA_DRA + bne iende ; atn hi + bit VIA1+VIA_DRB + bvs ix1 ; dav hi + jsr nrfdlo + jsr bytin + pha + jsr ndachi + pla + cmp #$3f ; unlisten + bne il2 + lda #0 + sta listenfl + sta cmdfl + beq weiter +il2 cmp #$5f ; untalk + bne il3 + lda #0 + sta talkfl + sta cmdfl + beq weiter +il3 cmp lstnadr ; listen + bne il4 + sta cmdfl + lda #1 + sta listenfl + lda #0 + sta talkfl + beq weiter +il4 cmp talkadr ; talk + bne il5 + sta cmdfl + lda #1 + sta talkfl + lda #0 + sta listenfl + beq weiter +il5 ldx cmdfl + beq weiter + tax + and #$60 + cmp #$60 + bne weiter + txa + sta secadr + and #$f0 + cmp #$e0 + bne weiter + jsr iclose + lda #0 + sta listenfl + +weiter bit VIA1+VIA_DRB + bvc weiter ; wait davhi + jmp inext + +iende lda listenfl + bne listenloop + jsr ndachi + jsr atnahi + lda talkfl + bne talkloopx + jmp RETLOOP + +talkloopx jmp talkloop +atndet1 jmp atndet + +listenloop + jsr nrfdlo + jsr atnahi + lda #0 + sta status + + lda secadr + and #15 + sta filenr + tax + cmp #15 + beq incbuf ; secadr 15 + lda secadr + and #$f0 + cmp #$f0 + beq inbuf ; open + cmp #$e0 + beq inul + lda filetab+ANZ_FT*FT_MOD,x + and #127 + cmp #FT_MOD_IN + bne inerr + +lstnlp jsr liecin + bit status + bvs ll + bcs atndet1 +ll +#ifdef SHOW + jsr OUT +#endif + ldy filenr + ldx filetab+ANZ_FT*FT_STR,y + jsr SOUT + bcs clnul + bit status + bvc lstnlp ; kein eoi +retloop jmp RETLOOP ; gibt beim naechsten Schreibversuch time-out + +clnul jsr iclose + ldx #8 + stx reterr + jmp inulx + +inerr ldx #2 + cmp #FT_MOD_OUT + bne inerr1 + .byt $2c +inerr4 ldx #4 + .byt $2c +inerr5 ldx #5 + .byt $2c +inerr1 ldx #1 + stx reterr +inul jsr liecin +atndet3 bcs atndet1 +inulx bit status + bvc inul + bvs retloop + + ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_FRE + beq inerr1 +inbuf ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_FRE + bne inerr4 +incbuf ldy #0 + sty bufpos +inbufl jsr liecin + bit status + bvs il + bcs atndet3 +il ldy bufpos + jsr CBM2ASC + sta INBUF,y + inc bufpos + lda bufpos + cmp #MAXLEN-1 + bcs inerr5 + bit status + bvc inbufl + lda #0 + ldy bufpos + sta INBUF,y + ; get SENDBUF and try to execute command. + ; locks if request from outside ends here and + ; request from inside has locked SENDBUF + ; and fsiec is supposed to serve...! +#ifdef NOMMU + clc + ldx #SEM_SENDBUF + jsr PSEM +#endif + lda secadr + and #15 + cmp #15 + beq cmd2 + lda secadr + and #$f0 + cmp #$f0 + bne cmd2 + jsr open +#ifdef NOMMU + jmp RetLoop +#else + jmp RETLOOP +#endif +cmd2 jsr sendcmd ; cmd ausf�hren +RetLoop +#ifdef NOMMU + ldx #SEM_SENDBUF + jsr VSEM +#endif + jmp RETLOOP + + +iclose lda secadr + and #15 + sta filenr + cmp #15 + beq clerr0 + tay + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_FRE + beq clerr1 + + ldx filetab+ANZ_FT*FT_BUF,y + bmi clx + jsr setzei + ldy #F_FL + lda #F_FL_FRE + sta (fzei),y + +clx ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + ldx filetab+ANZ_FT*FT_STR,y + cmp #FT_MOD_DIR + beq clout + cmp #FT_MOD_OUT + beq clout + cmp #FT_MOD_EOF + beq clout + lda #SC_EOF + .byt $2c +clout lda #SC_NUL + jsr STRCMD + lda #FT_MOD_FRE + sta filetab+ANZ_FT*FT_MOD,y +clerr0 ldx #0 + .byt $2c +clerr1 ldx #1 + .byt $2c +operr4 ldx #4 + stx reterr + rts + +open .( + .data +owfl .byt 0 + .text + + ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_FRE + bne operr4 + lda #<-1 + sta filetab+ANZ_FT*FT_BUF,y + lda #0 + sta filetab+ANZ_FT*FT_ST,y + cpy #1 + beq os2 + cpy #0 + bne os1 + lda #FT_MOD_OUT + .byt $2c +os2 lda #FT_MOD_IN + sta filetab+ANZ_FT*FT_MOD,y +os1 ldy #0 + jsr fgetdrv ; a=drv, x=cmd + bcs operr3x + sta PCBUF+FS_OPEN_DRV + stx owfl + cpx #1 + bne nodir + sty bufpos + ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_IN + beq operr9 + jsr getbuf + bcs operr6 +operr3x bcs operr3 + ldy filenr + txa + sta filetab+ANZ_FT*FT_BUF,y + lda #FT_MOD_DIR + sta filetab+ANZ_FT*FT_MOD,y + ldy #F_FL + lda #F_FL_DO + sta (fzei),y + ldy #F_LEN + lda #0 + sta (fzei),y + ldy bufpos +nodir ldx #FS_OPEN_NAME + jsr inspfad ; nach PCBUF,x +o1 lda INBUF,y + sta PCBUF,x + beq onex + inx + iny + cmp #"," + bne o1 + lda #0 + stx bufpos + dex + sta PCBUF,x +o2 lda INBUF,y + beq one + iny + cmp #" " + beq o2 + cmp #"," + beq operr3 + cmp #"R" + beq opout + cmp #"W" + beq opin +o3 lda INBUF,y + beq one + iny + cmp #"," + bne o3 + beq o2 + +operr7 ldy filenr + ldx filetab+ANZ_FT*FT_STR,y + jsr FRESTR + ldx #7 + .byt $2c +operr6 ldx #6 + .byt $2c +operr9 ldx #9 + .byt $2c +operr3 ldx #3 + .byt $2c +operr2 ldx #2 + stx reterr + ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_DIR + bne ope + ldy #F_FL + lda #F_FL_FRE + sta (fzei),y + ldy filenr +ope lda #FT_MOD_FRE + sta filetab+ANZ_FT*FT_MOD,y + rts + +onex inx + stx bufpos + bne one + +opout ldx #FT_MOD_OUT + lda owfl + cmp #2 ; ow = overwrite + beq operr9 ; notreadfile + .byt $2c +opin ldx #FT_MOD_IN + ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_DIR + bne opx + cpx #FT_MOD_OUT + beq one + bne operr2 +opx txa + sta filetab+ANZ_FT*FT_MOD,y + +one ldy filenr + + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_FRE + beq operr3 + jsr GETSTR + bcs operr6 + ldy filenr + txa + sta PCBUF+FS_OPEN_STR + sta filetab+ANZ_FT*FT_STR,y + lda #0 + sta PCBUF+FS_OPEN_PFAD + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_OUT + beq oo + cmp #FT_MOD_DIR + beq od + lda owfl + cmp #2 + bne owr + lda #FS_OPEN_OW + .byt $2c +owr lda #FS_OPEN_WR + .byt $2c +oo lda #FS_OPEN_RD + .byt $2c +od lda #FS_OPEN_DR + ldx PCBUF+FS_OPEN_DRV + jsr assigndrv + stx PCBUF+FS_OPEN_DRV + pha + txa + ldy filenr + sta filetab+ANZ_FT*FT_DRV,y + pla + ldx #SEND_FM + ldy bufpos + jsr SEND + bcs operr7x + sec + jsr RECEIVE + cmp #1 + bcs operr7xx + sta reterr + ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_IN + beq oe + jsr getobuf + ldy filenr + sta filetab+ANZ_FT*FT_BYT,y + lda #2 + bcc ow + ora #128 +ow sta filetab+ANZ_FT*FT_ST,y +oe rts +operr7xx jsr fse2rete +operr7x jmp operr7 + .) + +fgetdrv .( + .data +drv .byt 0 +gcmd .byt 0 +bufpos2 .byt 0 +xfl .byt 0 + .text + + ldx #0 + .byt $2c +&cgetdrv ldx #<-1 + stx xfl + + sty bufpos + + lda #<-1 ; stddrv + sta drv + lda #0 + sta gcmd + +g1 lda INBUF,y + beq nixxx + iny + cmp #":" + beq dp1x + + cmp #"0" + bcc g1a + cmp #"9"+1 + bcs g1a + and #%00001111 + sta drv + lda INBUF,y + cmp #"0" + bcc g1x + cmp #"9"+1 + bcs g1x + iny + pha + asl drv + lda drv + asl + asl + clc + adc drv + sta drv + pla + and #%00001111 + clc + adc drv + sta drv +g1x jmp gwend + +nixxx beq nixx +dp1x beq dp1 + +g1a cmp #" " + beq g1 + + lda gcmd + bne gerr + + dey + sty bufpos2 + ldx #1 +g2 stx gcmd + lda cmda-1,x + beq gerr + tax + ldy bufpos2 +g2a lda cmdt-1,x + beq found + cmp INBUF,y + bne g2b + inx + iny + bne g2a + +g2b cpy bufpos2 + beq g2bq + + lda INBUF,y + cmp #"a" + bcc found + cmp #"z"+1 + bcs found + +g2bq ldx gcmd + inx + cpx #3 + bcc g2 + bit xfl + bmi g2 + ldx #0 + stx gcmd + ldy bufpos2 +g2c lda INBUF,y + beq nix +dp1 beq dp + iny + cmp #":" + bne g2c + +gerr sec + rts + +found jmp g1 + +gwend lda INBUF,y +nixx beq nix + iny + cmp #":" + beq dp + cmp #" " + beq gwend + bne gerr + +nix lda gcmd + cmp #1 ; $ + beq dp + bit xfl + bmi dp + lda #<-1 ; stddrv + ldx #0 + ldy bufpos + clc + rts + +dp lda drv + ldx gcmd + clc + rts + +cmda .byt cmdt-c0,cow-c0,c2-c0,c3-c0,c4-c0,c5-c0,c6-c0,c7-c0 /*,c8-c0*/ + .byt /*c9-c0,c10-c0,*/ c11-c0,c12-c0,c13-c0,c14-c0,c15-c0,0 + +c0 =*-1 +cmdt .asc "$",0 +cow .asc "@",0 +c2 .asc "rename",0 +c3 .asc "scratch",0 +c4 .asc "copy",0 +c5 .asc "new",0 +c6 .asc "validate",0 +c7 .asc "initialize",0 +;c8 .asc "rmdir",0 +;c9 .asc "mkdir",0 +;c10 .asc "chdir",0 +c11 .asc "assign",0 +c12 .asc "cd",0 +c13 .asc "rd",0 +c14 .asc "md",0 +c15 .asc "drv",0 ; iec-bus-unit + +&fsctab .byt $ff,$ff,$ff,FS_RENAME,FS_DELETE,"c" + .byt FS_FORMAT,FS_CHKDSK,"i" /*,FS_RMDIR,FS_MKDIR,"d"*/ + .byt "a","d",FS_RMDIR,FS_MKDIR,"u" + .) + +atndet2 jmp atndet + +talkloop .( + lda #0 + sta status + sta eoifl + lda secadr + and #15 + sta filenr + cmp #15 + beq tl1 + tay + lda filetab+ANZ_FT*FT_MOD,y + and #127 + cmp #FT_MOD_OUT + beq tl1 + cmp #FT_MOD_DIR + beq tl1 + cmp #FT_MOD_EOF + bne outerr9 + beq tlx +tl1 jsr tiecout + bcs atndet2 + bit eoifl + bvc tl1 + ldy filenr + lda #FT_MOD_EOF + sta filetab+ANZ_FT*FT_MOD,y +tlx jmp RETLOOP + +outerr9 lda #9 + sta reterr + jmp RETLOOP + .) + +&getobuf .( + .data +pos .byt 0 +pos2 .byt 0 +pcnt .byt 0 + .text + + ldy filenr + cpy #15 + bne gofile + ldy outpos + cpy outlen + bcc tl3 + jsr makeds +tl3 ldy outpos + lda OUTBUF,y + iny + sty outpos + cpy outlen + rts + +gofile + ldy filenr + lda filetab+ANZ_FT*FT_MOD,y + cmp #FT_MOD_DIR + beq godir + +gfx ldy filenr + lda filetab+ANZ_FT*FT_BYT3,y + ldx filetab+ANZ_FT*FT_STR,y + tay + jsr GETC + bcc gf1 + cmp #E_EOF + beq gf2 + jsr YIELD + jmp gfx +gf2 tya + sec + rts +gf1 tax + tya + pha + ldy filenr + txa + sta filetab+ANZ_FT*FT_BYT3,y + pla + ldx filetab+ANZ_FT*FT_MOD,y + bmi gfok + txa + ora #128 + sta filetab+ANZ_FT*FT_MOD,y + jmp gfx +gfok clc + rts + +godir + ldx filetab+ANZ_FT*FT_BUF,y + jsr setzei + ldy #F_LEN + lda (fzei),y + bne g1 ; Laenge gleich 0, dann wars das erste mal + jsr gnew1 ; erste Zeile holen + jmp g2 +g1 ldy #F_BYT + cmp (fzei),y ; auslesen am ende + bne g2 ; nein dann weiter + jsr gnew ; sonst naechste Zeile holen + bcs ge +g2 ldy #F_BYT + lda (fzei),y + tay + lda (bzei),y + pha + iny + tya + ldy #F_BYT + sta (fzei),y + pla + clc +ge rts + +gnew1 ldy #64 ; Startadresse in den Puffer + lda #1 + sta (bzei),y + iny + lda #4 + sta (bzei),y + iny + jmp gnewend ; und ende + +gnew ldy #F_FL + lda (fzei),y + cmp #F_FL_DOX ; ende schon gewesen + bne gn1 + lda #0 ; ja dann nullbyte + sec + rts +gn1 ldy #F_BYT + lda #0 + sta (fzei),y ; Anzahl Bytes erstmal auf null + +gg ldy filenr + lda filetab+ANZ_FT*FT_STR,y + tax + jsr GETC + bcc gok + cmp #E_EOF + beq geof + jsr YIELD + jmp gg + +geof ldy #F_FL ; ende des Dirs + lda #F_FL_DOX + sta (fzei),y + ldy #64 + lda #0 + sta (bzei),y + iny + jmp gnewend + +gok tax ; byte geholt + ldy #F_BYT + lda (fzei),y + tay + txa + sta (bzei),y + iny + tya + ldy #F_BYT + sta (fzei),y + cmp #FS_DIR_NAME+1 + bcc gg + cpx #0 + bne gg + ; ab hier wird in neue Struktur umgewandelt + + ldy #FS_DIR_LEN + lda (bzei),y + beq gs1 + iny + lda (bzei),y + clc + adc #1 + sta (bzei),y +gs1 ldy #64 ; link-adresse + lda #4 + sta (bzei),y + iny + sta (bzei),y + ldy #FS_DIR_LEN+1 ; Datei-Laenge + lda (bzei),y + sta pos + ldy #66 + sta (bzei),y + ldy #FS_DIR_LEN+2 + lda (bzei),y + sta pos2 + ldy #67 + sta (bzei),y + + ldy #FS_DIR_MODE + lda (bzei),y + ldy #68 + cmp #FS_DIR_MOD_FIL + beq dirfil + cmp #FS_DIR_MOD_DIR + beq dirfil + jmp dirother +dirfil lda #0 + sta pcnt + ldx pos + lda pos2 + cmp #>10000 + bcc d1b + bne d1 + cpx #<10000 + bcs d1 +d1b inc pcnt + cmp #>1000 + bcc d1c + bne d1 + cpx #<1000 + bcs d1 +d1c inc pcnt + cmp #>100 + bne d1 + cpx #100 + bcs d1 + inc pcnt + cpx #10 + bcs d1 + inc pcnt +d1 ldx pcnt + ; y=schreibposition in Puffer + lda #" " +gs2 dex + bmi gs2x + sta (bzei),y + iny + bne gs2 +gs2x lda #34 + sta (bzei),y + iny + sty pos + ldy #FS_DIR_NAME + sty pos2 + ldx #17 +gs4 ldy pos2 + lda (bzei),y + beq gs3 + dex + inc pos2 + ldy pos + jsr ASC2CBM + sta (bzei),y + inc pos + cpy #66+24 ; sicherheitshalber range test + bcc gs4 +gs3 ldy pos + lda #34 + sta (bzei),y + iny + lda #" " +gs5 dex + bmi gs5x + sta (bzei),y + iny + bne gs5 +gs5x ldx #0 + tya + pha + ldy #FS_DIR_MODE + lda (bzei),y + cmp #FS_DIR_MOD_DIR + beq gs6d + pla + tay +gs6a lda prgtxt,x + sta (bzei),y + iny + inx + cpx #3 + bcc gs6a + bcs gs6b +gs6d pla + tay +gs6c lda dirtxt,x + sta (bzei),y + iny + inx + cpx #3 + bcc gs6c +gs6b lda #0 + sta (bzei),y + iny + +gnewend tya + ldy #F_LEN + sta (fzei),y + lda #64 + ldy #F_BYT + sta (fzei),y + clc + rts + +prgtxt .asc "PRG" +dirtxt .asc "DIR" + +dirother cmp #FS_DIR_MOD_NAM + bne dirfre + .( + ldy #66 + ldx filenr + lda filetab+ANZ_FT*FT_DRV,x + sta (bzei),y + iny + lda #0 + sta (bzei),y + iny + lda #18 + sta (bzei),y + iny + lda #34 + sta (bzei),y + iny + sty pos + lda #FS_DIR_NAME + sta pos2 + ldx #15 +l1 ldy pos2 + lda (bzei),y + beq l2 + inc pos2 + ldy pos + jsr ASC2CBM + sta (bzei),y + inc pos + dex + bpl l1 + bmi l3 +l2 lda #32 + ldy pos + sta (bzei),y + inc pos + dex + bpl l2 +l3 ldy pos + lda #34 + sta (bzei),y + iny + ldx #6 + lda #32 +l4 sta (bzei),y + iny + dex + bpl l4 + lda #0 + sta (bzei),y + iny + jmp gnewend + .) + +dirfre .( + ldx #0 +l1 lda fretxt,x + sta (bzei),y + iny + inx + cmp #0 + bne l1 + jmp gnewend + +fretxt .asc " BLOCKS FREE",0 + .) + + .) + +makeds .( + lda reterr + beq m0 + clc + adc #19 +m0 ldx #"0" +m1 cmp #10 + bcc m2 + sec + sbc #10 + inx + bne m1 +m2 clc + adc #$30 + sta OUTBUF+1 + stx OUTBUF + lda #"," + sta OUTBUF+2 + lda #" " + sta OUTBUF+3 + ldy reterr + ldx #4 + lda tadr,y + tay +m3 lda dstxt,y + sta OUTBUF,x + beq m4 + iny + inx + bne m3 +m4 ldy #0 +m4b lda stdtxt,y + sta OUTBUF,x + beq m5 + iny + inx + bne m4b +m5 stx outlen + ldx #0 + stx reterr + stx outpos + rts + +tadr .byt t0-t,t1-t,t2-t,t3-t,t4-t,t5-t,t6-t,t7-t,t8-t,t9-t,t10-t + .byt t11-t,t12-t,t13-t,t14-t,t7-t,t15-t,t16-t,t17-t,t18-t + +stdtxt .asc ",00,00",13,0 + +dstxt t t0 .asc "OK",0 +t1 .asc "FILE NOT OPEN",0 +t2 .asc "NOT WRITE FILE",0 +t3 .asc "SYNTAX",0 +t4 .asc "FILE OPEN",0 +t5 .asc "CMD TO LONG",0 +t6 .asc "NO BUFFER",0 +t7 .asc "FILE NOT FOUND",0 +t8 .asc "WRITE ERROR",0 +t9 .asc "NOT READ FILE",0 +t10 .asc "NO DRIVE",0 +t11 .asc "WRITE PROTECT",0 +t12 .asc "DRIVE NOT READY",0 +t13 .asc "NO VALID PATH",0 +t14 .asc "NO VALID NAME",0 +t15 .asc "INVALID DATA",0 +t16 .asc "FILE EXIST",0 +t17 .asc "DISK FULL",0 +t18 .asc "DIR NOT EMPTY",0 + .) + +sendcmd .( + .data +drv .byt 0 +pos .byt 0 +ccmd .byt 0 +str .byt 0 +dy .byt 0 + .text + + ldy #0 + jsr cgetdrv + bcs scerr3 + sta drv + sta PCBUF+FS_CMD_DRV + sty pos + lda fsctab,x + sta ccmd +#ifdef SHOW + pha + jsr HEXOUT + pla +#endif + cmp #"a" + bcs xcmd + cmp #FS_FORMAT + bne nof + jmp fformat +nof ldx INBUF,y + beq noname + cmp #FS_RENAME + bne nam + jmp doubnam +nam ldy pos + ldx #FS_CMD_NAME + jsr inspfad +nl lda INBUF,y + sta PCBUF,x +#ifdef SHOW + jsr OUT + cmp #0 +#endif + beq ne + inx + iny + bne nl +ne inx +n1x txa + tay + jmp n1 +noname lda #0 + sta PCBUF+FS_CMD_NAME + ldy #FS_CMD_NAME+1 +n1 +#ifdef SHOW + jsr CRLFOUT +#endif + lda #0 + sta PCBUF+FS_CMD_PFAD +n4 ldx PCBUF+FS_CMD_DRV + jsr assigndrv + stx PCBUF+FS_CMD_DRV + ldx #SEND_FM + lda ccmd + jsr SEND + bcs scerr10 + sec + jsr RECEIVE + cmp #1 + bcc scerr0 +scerrfs jsr fse2rete + tax + .byt $2c +scerr0 ldx #0 + .byt $2c +scerr6 ldx #6 + .byt $2c +scerr3 ldx #3 + .byt $2c +scerr10 ldx #10 + stx reterr + rts + +xcmd .( + cmp #"i" + beq scerr0 + cmp #"c" + bne o1 + jmp copy +o1 cmp #"a" + bne o2 + jmp assign +o2 cmp #"d" + bne o3 + jmp cdir +o3 cmp #"u" + bne o4 + jmp unit +o4 jmp scerr3 ; syntax + + .( + .data +assigntab .dsb 10 + .text + +&assign ldy pos +a1 lda INBUF,y + beq scerr3 + iny + cmp #" " + beq a1 + cmp #"0" + bcc scerr3 + cmp #"9"+1 + bcs scerr3 + and #$0f + + ldx PCBUF+FS_CMD_DRV + sec + jsr ASSIGN + bcs scerr10 +/* + ldy PCBUF+FS_CMD_DRV + cpy #10 + bcs scerr10 + sta assigntab,y +*/ + jmp scerr0 + +&&&&&iniass + sec + ldx #<-1 + jmp ASSIGN +/* + ldx #0 +ai txa + sta assigntab,x + inx + cpx #10 + bcc ai + clc + rts +*/ + +&&&assigndrv + clc + jmp ASSIGN +/* + pha + cpx #10 + bcs ae + lda assigntab,x + tax +ae pla + rts +*/ + .) + +scerr6x bcs scerr6 + +copy .( + ldy pos +cn1 lda INBUF,y + beq scerr3 + cmp #"=" + beq infile + iny + bne cn1 +scerr3z jmp scerr3 +infile iny + jsr fgetdrv + bcs scerr3z + cpx #0 + bne scerr3z + sta PCBUF+FS_OPEN_DRV + ldx #FS_OPEN_NAME + jsr inspfad +i3 lda INBUF,y + sta PCBUF,x + inx + iny + cmp #0 + bne i3 + stx dy + lda #0 + sta PCBUF+FS_OPEN_PFAD + jsr GETSTR + bcs scerr6x + ldy dy + stx str + stx PCBUF+FS_OPEN_STR + ldx PCBUF+FS_OPEN_DRV + jsr assigndrv + stx PCBUF+FS_OPEN_DRV + ldx #SEND_FM + lda #FS_OPEN_RD + jsr SEND + bcs i4a + sec + jsr RECEIVE + cmp #1 + bcc i4 +i4a pha + ldx str + jsr FRESTR + pla + jmp scerrfs +i4 lda drv + sta PCBUF+FS_OPEN_DRV + lda str + sta PCBUF+FS_OPEN_STR + lda #0 + sta PCBUF+FS_OPEN_PFAD + ldy pos + ldx #FS_OPEN_NAME + jsr inspfad +i5 lda INBUF,y + cmp #"=" + beq ie + sta PCBUF,x + inx + iny + bne i5 +ie lda #0 + sta PCBUF,x + inx + txa + tay + ldx PCBUF+FS_OPEN_DRV + jsr assigndrv + stx PCBUF+FS_OPEN_DRV + lda #FS_OPEN_WR + ldx #SEND_FM + jsr SEND + bcs i6 + sec + jsr RECEIVE + cmp #1 + bcc i7 +i6 pha + ldx str + lda #SC_NUL + jsr STRCMD + pla + jmp scerrfs +i7 rts + .) + + +&&&&&iniunit + .( + lda #10+$20 + sta lstnadr + eor #$60 + sta talkadr + clc + rts + .) + +unit .( + lda PCBUF+FS_OPEN_DRV + cmp #31 + bcs scerr3u + ora #$20 + sta lstnadr + eor #$60 + sta talkadr + clc + rts + .) +scerr3u jmp scerr3 + +cdir .( + .data +pdrv .byt 0 +pfad .dsb MAXLEN + .text + + ldy pos + ldx #FS_CMD_NAME +p1 lda INBUF,y + sta PCBUF,x + beq p2 + inx + iny + bne p1 +p2 lda #pdrv + ldx #MAXLEN + jsr CHDIR + jmp scerr0 +/* + lda drv + bmi cderr10 + sta pdrv + ldy pos + ldx #0 +p1 lda INBUF,y + sta pfad,x +#ifdef SHOW + jsr OUT + cmp #0 +#endif + beq endp + inx + iny + cpx #MAXLEN-2 + bcc p1 + lda #0 + sta pfad +*/ +&&scerr3x jmp scerr3 +/* +endp dex + bmi set + lda pfad,x + cmp #DIRSIGN + beq sc0 +set inx + lda #DIRSIGN + sta pfad,x + lda #0 + sta pfad+1,x +sc0 jmp scerr0 +cderr10 jmp scerr10 +*/ + +&&&&&inipfad + lda #0 + sta pdrv + sta pfad + rts + +&&&inspfad + sty dy + lda PCBUF+FS_OPEN_DRV + bpl nopfad + lda pdrv + sta PCBUF+FS_OPEN_DRV + + lda INBUF,y + cmp #DIRSIGN + beq nopfad + + ldy #0 +ip1 lda pfad,y + beq ipe + sta PCBUF,x + inx + iny + bne ip1 +ipe lda #DIRSIGN + sta PCBUF,x + inx +nopfad ldy dy + rts + .) + + .) + +/*scerr3x jmp scerr3*/ + +doubnam .( + ldy pos +dn lda INBUF,y + beq scerr3x + cmp #"=" + beq nextnam + iny + bne dn +nextnam iny + ldx #FS_CMD_NAME + jsr inspfad +n2 lda INBUF,y + sta PCBUF,x + beq secnam + inx + iny + bne n2 +secnam inx + ldy pos +n3 lda INBUF,y + cmp #"=" + beq endnam + sta PCBUF,x + iny + inx + bne n3 +endnam lda #0 + sta PCBUF,x + inx + jmp n1x + .) + +fformat .( + lda #0 + sta PCBUF+FS_CMD_PFAD ; format + ldx #FS_CMD_NAME +f1 lda INBUF,y + sta PCBUF,x + beq fe + inx + iny + cmp #"," + bne f1 + dex + lda #0 + sta PCBUF,x +f2 lda INBUF,y + beq scerr3y + iny + cmp #" " + beq f2 + cmp #"0" + bcc scerr3y + cmp #"9"+1 + bcs scerr3y + and #15 + sta PCBUF+FS_CMD_PFAD +#ifdef SHOW + pha + lda #"X" + jsr OUT + pla + jsr HEXOUT +#endif +fe inx + txa + tay + jmp n4 +scerr3y jmp scerr3 + .) + + .) + +fse2rete .( + ldy #11 +f1 cmp fsetab,y + beq rete + dey + bpl f1 + lda #7 + rts +rete lda retetab,y + rts + +fsetab .byt E_OK,E_FNODRV,E_FNOPATH,E_FILLNAM,E_FNOFIL,E_FWPROT + .byt E_FLOGICAL /*NOCLUS*/,E_FLOGICAL, E_FILEXIST, E_FDISKFULL + .byt E_FDNEMPTY, E_FLOCKED +retetab .byt 0,12,13,14,15,11 + .byt 13,16,17,18,19,4 + .) + +#ifndef FSIEC_USE_STDLIB + .( + .zero +assigntab .dsb 10 + .text + +&ASSIGN bcc xassigndrv + cpx #<-1 + bne a +iniassign + ldx #0 +ai txa + sta assigntab,x + inx + cpx #10 + bcc ai + clc + rts +xassigndrv + pha + cpx #10 + bcs ae + lda assigntab,x + tax +ae pla + rts + +a cpx #10 + bcs ar + sta assigntab,x +ar rts + .) + + .( + .zero +zp .word 0 +d .byt 0 +maxpath .byt 0 + .text + +&CHDIR sta zp + sty zp+1 + stx maxpath + lda PCBUF+FS_CMD_DRV + bmi nodrive + ldy #0 + cmp (zp),y + beq nodrive + sta (zp),y + iny + lda #0 + sta (zp),y +nodrive inc zp + bne nd1 + inc zp+1 + ldy #0 + ; Name untersuchen +nd1 ldx #FS_CMD_NAME + lda PCBUF,x + bne ndrx ; kein Name dann Pfad loeschen + sta (zp),y + clc + rts +ndrx + cmp #DIRSIGN ; Name beginnt mit DIRSIGN + bne nd2 + lda #0 ; dann Pfad loeschen + sta (zp),y + +nd2a inx +nd2 lda PCBUF,x ; weiter Name anschauen + beq ndr ; kein Name dann Ende + cmp #DIRSIGN + beq nd2a ; DIRSIGN ~Aberlesen + cmp #"." + bne nameok ; kein '.' dann ok + inx + lda PCBUF,x ; hier mindestens ein '.' + beq ndr ; Null dann Ende + cmp #DIRSIGN ; DIRSIGN, + beq nd2a ; dann '.' ignorieren + cmp #"." ; noch'n Punkt ? + bne nerrx ; nein, dann + jsr getpos + ldy d ; Position des letzten DIRSIGNs + lda #0 + sta (zp),y ; loeschen = eine Verzeichnis-Ebene hoeher + beq nd2a ; (absolut) + +nerrx dex +nameok jsr getpos ; y=Laenge des alten Pfads + sty d ; hier Verzeichnis-Name an Pfad anhaengen +no iny + cpy maxpath + bcs nerr + lda PCBUF,x + beq nr + cmp #DIRSIGN + beq nr + sta (zp),y + inx + bne no +nr lda #0 + sta (zp),y + ldy d + lda #DIRSIGN ; alles ok, dann Nullbyte (Ende alter Pfad) mit + sta (zp),y ; DIRSIGN ~Aberschreiben + lda PCBUF,x ; Ende des neuen Verzeichnisses + bne nd2a ; nein, dann wieder nach oben +ndr clc + rts +nerr sec + rts +getpos ldy #0 ; holt y=L~Dnge des alten Pfadnamens + sty d ; und d=Position des letzten DIRSIGNs +no0 lda (zp),y + beq no1 + cmp #DIRSIGN + bne no2 + sty d +no2 iny + bne no0 +no1 rts + .) + +#endif /* FSIEC_USE_STDLIB */ + .) + +#endif /* NOLOOP */ + +/* Blocktiefe 2 */ + +#ifndef NOFS + +aout =atnout +/* +aout pha + lda #0 + sta status + jsr nrfdhi + jsr ndachi + + lda bytfl + beq oo1 + sec + ror eoifl + jsr iecout + lda #0 + sta bytfl + +oo1 pla + sta byte +*/ +iec0out sei + jsr waitdavhi + jsr atnlo + +iecout .( + sei +jsr nrfdhi +jsr ndachi + jsr davhi + jsr tstdev ;nrfdhi & ndachi = z + beq devnotpr + lda byte + jsr out +ox1 JSR setti +ox1a JSR fragti + BNE XTO + lda VIA1+VIA_DRB + bpl ox1a ; wait nrfd hi + lda eoifl + bpl o0 + jsr eoilo +o0 jsr davlo + jsr setti +o1 jsr fragti + bne timeout + jsr fragndac ; wait ndac hi + bcc o1 + jsr davhi + jsr eoihi + lsr eoifl + jsr clrdata ; alle data hi +ox2 lda VIA1+VIA_DRB + lsr + bcs ox2 ; wait ndaclo + clc +; cli + rts + +XTO JSR YIELD + SEI + JMP ox1 + .) + +&seclisten sta byte + jsr iecout + jsr atnhi + cli + rts +#endif + +timeout lda #1 + .byt $2c +devnotpr lda #128 + jsr seterr + jsr eoihi + jsr davhi + jsr ndachi + sec + cli + rts + +#ifndef NOLOOP +tiecout .( + ldy filenr + lda filetab+ANZ_FT*FT_ST,y + tax + and #2 + bne to1 + cli + jsr getobuf + sei + ldy filenr + sta filetab+ANZ_FT*FT_BYT,y + lda #2 + bcc to2 + ora #128 +to2 ora filetab+ANZ_FT*FT_ST,y + sta filetab+ANZ_FT*FT_ST,y + tax +to1 txa + and #128 + sta eoifl + lda filetab+ANZ_FT*FT_BYT,y + sta byte + sei + jsr davhi + jsr tstdev ;nrfdhi & ndachi = z + beq devnotpr + lda byte + jsr out +ox1 jsr fragatn + bcs atnin + lda VIA1+VIA_DRB + bpl ox1 ; wait nrfd hi + bit eoifl + bpl o0 + jsr eoilo +o0 jsr davlo + +/* naechstes Byte holen zur Ausgabe */ +/* Verhindert time out beim naechsten IECIN des */ +/* Listeners */ + + ldy filenr + lda filetab+ANZ_FT*FT_ST,y + and #1+128 + bne o3 + cli + jsr getobuf + sei + ldy filenr + sta filetab+ANZ_FT*FT_BYT2,y + lda #1 + bcc o3x + ora #64 +o3x ora filetab+ANZ_FT*FT_ST,y + sta filetab+ANZ_FT*FT_ST,y + +o3 jsr setti +o1 jsr fragti + bne timeouty + jsr fragatn + bcs atnin + jsr fragndac ; wait ndac hi + bcc o1 + + ldy filenr + lda filetab+ANZ_FT*FT_ST,y + asl + and #%10000010 + sta filetab+ANZ_FT*FT_ST,y + lda filetab+ANZ_FT*FT_BYT2,y + sta filetab+ANZ_FT*FT_BYT,y + lsr eoifl + + jsr davhi + jsr eoihi + + jsr clrdata ; alle data hi +ox2 jsr fragatn + bcs atnin + lda VIA1+VIA_DRB + lsr + bcs ox2 ; wait ndaclo + clc + ;cli + rts + +atnin sec + cli + rts + +timeouty jmp timeout + +&liecin .( + sei + jsr ndaclo + jsr nrfdhi +i1 jsr fragatn ; wait nrfd hi + bcs atnin + lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne i1 + asl + bcc i1 + jsr setti +o11 jsr fragatn ; atn testen + bcs atnin + jsr fragti + bne timeouty ; c= abgelaufen + jsr fragdav ; wait dav lo + bcs o11 + jsr nrfdlo + jsr frageoi + bcs o12 + lda #64 + jsr seterr +o12 jsr bytin + pha + jsr ndachi +o12a jsr fragatn + bcs atnin + jsr fragdav + bcc o12a + jsr ndaclo + lda status + bne o12c + pla + clc + CLI + rts +o12c pla + sec + cli + rts + .) + +fragatn .( + lda VIA1+VIA_DRA +; cmp VIA1+VIA_DRA +; bne fragatn + asl + eor VIA1+VIA_DRB + and #%00100000 +#ifdef INVERT + beq s ; bei inverted umdrehen +#else + bne s +#endif + clc + rts +s sec + rts + .) + .) +#endif + +#ifndef NOFS + +§alk sta byte + jsr iecout + jsr nrfdlo + jsr ndaclo + jsr atnhi + cli + rts + +&UNTALK jsr atnlo + lda #95 + .byt $2c +&UNLISTEN lda #63 + jsr aout + jsr atnhi + cli + rts + +timeoutx jmp timeout + +&IECIN .( + sei + jsr ndaclo + jsr nrfdhi +i1 lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne i1 + asl + bcc i1 + jsr setti +o11 jsr fragti + bne timeoutx ; c= abgelaufen + jsr fragdav ; wait dav lo + bcs o11 + jsr nrfdlo + jsr frageoi + bcs o12 + lda #64 + jsr seterr +o12 jsr bytin + pha + jsr ndachi +o12a jsr fragdav + bcc o12a + jsr ndaclo + lda status + bne o12c + pla + clc + cli + rts +o12c pla + sec + cli + rts + .) + +#ifdef INVERT +atnlo lda VIA1+VIA_DRB + ora #%00100100 + sta VIA1+VIA_DRB + rts +atnhi lda VIA1+VIA_DRB + and #%11011011 + sta VIA1+VIA_DRB + rts +#else +atnhi lda VIA1+VIA_DRB + ora #%00100100 + sta VIA1+VIA_DRB + rts +atnlo lda VIA1+VIA_DRB + and #%11011011 + sta VIA1+VIA_DRB + rts +#endif +#endif + +#ifdef INVERT +#ifndef NOLOOP +atnalo lda VIA1+VIA_DRB + ora #%00100000 + sta VIA1+VIA_DRB + rts +atnahi lda VIA1+VIA_DRB + and #%11011111 + sta VIA1+VIA_DRB + rts +#endif + +eoilo lda VIA1+VIA_DRB + ora #%00010000 + sta VIA1+VIA_DRB + rts +eoihi lda VIA1+VIA_DRB + and #%11101111 + sta VIA1+VIA_DRB + rts + +ndaclo lda VIA1+VIA_DRB + ora #%00001000 + sta VIA1+VIA_DRB + rts +ndachi lda VIA1+VIA_DRB + and #%11110111 + sta VIA1+VIA_DRB + rts + +nrfdlo lda #60 + sta PIA1+PIA_CRB + rts +nrfdhi lda #52 + sta PIA1+PIA_CRB + rts + +davlo lda #60 + sta PIA1+PIA_CRA + rts +davhi lda #52 + sta PIA1+PIA_CRA + rts +#else +#ifndef NOLOOP +atnahi lda VIA1+VIA_DRB + ora #%00100000 + sta VIA1+VIA_DRB + rts +atnalo lda VIA1+VIA_DRB + and #%11011111 + sta VIA1+VIA_DRB + rts +#endif + +eoihi lda VIA1+VIA_DRB + ora #%00010000 + sta VIA1+VIA_DRB + rts +eoilo lda VIA1+VIA_DRB + and #%11101111 + sta VIA1+VIA_DRB + rts + +ndachi lda VIA1+VIA_DRB + ora #%00001000 + sta VIA1+VIA_DRB + rts +ndaclo lda VIA1+VIA_DRB + and #%11110111 + sta VIA1+VIA_DRB + rts + +nrfdhi lda #60 + sta PIA1+PIA_CRB + rts +nrfdlo lda #52 + sta PIA1+PIA_CRB + rts + +davhi lda #60 + sta PIA1+PIA_CRA + rts +davlo lda #52 + sta PIA1+PIA_CRA + rts +#endif + +waitdavhi lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne waitdavhi + and #$40 + beq waitdavhi + rts + +tstdev lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne tstdev + and #%10000001 + cmp #%10000001 + rts + +#ifdef INVERT +clrdata lda #0 + sta PIA1+PIA_PB + rts + +out sta PIA1+PIA_PB + rts +#else +clrdata lda #<-1 + sta PIA1+PIA_PB + rts + +out eor #$ff + sta PIA1+PIA_PB + rts +#endif + +waitnrfdhi + lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne waitnrfdhi + asl + bcc waitnrfdhi + rts + +fragndac lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne fragndac + lsr + rts + +fragdav lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne fragdav + asl + asl + rts + +seterr ora status + sta status + rts + +bytin lda PIA1+PIA_PA + eor #$ff + rts + +&setti lda #<65000 + sta VIA1+VIA_T1CL + lda #>65000 + sta VIA1+VIA_T1CH + rts +&fragti lda VIA1+VIA_IFR + and #%01000000 + rts + +frageoi lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne frageoi + lsr + lsr + rts + + +#undef PIA1 +#undef VIA1 + diff --git a/dump/oa-2.0.9/arch/csa65/devices/siec_csa.a65 b/dump/oa-2.0.9/arch/csa65/devices/siec_csa.a65 new file mode 100644 index 0000000..8be925d --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/devices/siec_csa.a65 @@ -0,0 +1,416 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#define VIA1 $e840 + +#include "chips/via6522.i65" + + .zero +cnt2 .byt 0 +byte .byt 0 +bytfl .byt 0 +eoifl .byt 0 + .text + +&getif clc + ldx #SEM_VIAE840_T1 + jmp PSEM +&freif ldx #SEM_VIAE840_T1 + jmp VSEM + +&IECINIT .( + lda #%00101110 + sta VIA1+VIA_DDRA + cmp VIA1+VIA_DDRA + bne inix +#ifndef INVERT + lda #0 +#endif + sta VIA1+VIA_DRA + lda VIA1+VIA_PCR + and #%11110000 + ora #%00000001 + sta VIA1+VIA_PCR + lda VIA1+VIA_ACR + and #%00111110 + sta VIA1+VIA_ACR + lda #%01000011 + sta VIA1+VIA_IER + + lda #0 + sta status + sta cnt2 + sta bytfl + sta eoifl + clc + rts +inix sec + rts + .) + +&IECIN .( + sei + lda #0 + sta eoifl + lda #8 + sta cnt2 + jsr clkhi + jsr datalo + +l14 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRA ; wait clkhi + cmp VIA1+VIA_DRA + bne l14 + and #$40 + beq l14 + +l19 jsr setti + jsr datahi + +l16 jsr fragti + bne l15 ; abgelaufen + ; jsr testatn + ; bcs atnin + bit VIA1+VIA_DRA ; wait clklo + bvs l16 + bvc l17 + +l15 lda eoifl + beq l18 + lda #2 + jmp error +l18 dec eoifl + jsr datalo + jsr waitus + lda #$40 + jsr seterror + bne l19 + +l17 +l20 lda VIA1+VIA_DRA + asl + bpl l20 + lsr + lsr + ror byte + +l21 bit VIA1+VIA_DRA + bvs l21 + + dec cnt2 + bne l20 + + jsr datalo + + bit status + bvc l22 + jsr endhndshk + lda byte + sec + cli + rts + +l22 lda byte + clc + cli + rts + + .) + +/* +atnin jsr datalo + jsr clkhi + sec + rts +*/ + +nodev lda #$80 +error jsr seterror + jsr atnhi +endhndshk jsr waitus + jsr datahi + jsr clkhi + sec + rts + +/* +atnout + pha + bit bytfl + bpl l1 ; noch ein byte zu senden + + sec + ror cnt2 ; dann mit eoi senden + jsr iecout + lsr bytfl ; flags ruecksetzen + +l1 pla + sta byte +*/ +iec0out .( + sei + jsr datahi + jsr atnlo +&iec2out sei + jsr clklo + jsr datahi + jsr waitms +&iecout sei + jsr datahi + +l0 lda VIA1+VIA_DRA + cmp VIA1+VIA_DRA + bne l0 + lsr ; data in c + bcs nodev + + jsr clkhi + bit eoifl + bpl l3 + ; eoi senden +l4 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRA ; wait data hi + cmp VIA1+VIA_DRA + bne l4 + lsr + bcc l4 + +l5 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRA ; wait data lo + cmp VIA1+VIA_DRA + bne l5 + lsr + bcs l5 + +l3 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRA ; wait data hi + cmp VIA1+VIA_DRA + bne l3 + lsr + bcc l3 + + jsr clklo + lda #8 + sta cnt2 + +l6 lda VIA1+VIA_DRA + cmp VIA1+VIA_DRA + bne l6 + lsr + bcc timexout + + ror byte ; bit setzen + bcs l7 + jsr datalo + bne l8 +l7 jsr datahi + +l8 jsr clkhi + jsr waitus + + jsr dhiclo + + dec cnt2 + bne l6 + + jsr waitdlo + bcs timeout + rts +timeout lda #3 + .byt $2c +timexout lda #4 + jmp error + + .) + +/* +testatn .( + lda VIA1+VIA_DRA + bmi tstatn + and #%00100000 + beq c +s sec + rts +tstatn and #%00100000 + beq s +c clc + rts + .) +*/ + +#ifndef INVERT +clkhi lda VIA1+VIA_DRA + ora #%00000100 + sta VIA1+VIA_DRA + rts +clklo lda VIA1+VIA_DRA + and #%11111011 + sta VIA1+VIA_DRA + rts +datahi lda VIA1+VIA_DRA + ora #%00000010 + sta VIA1+VIA_DRA + rts +datalo lda VIA1+VIA_DRA + and #%11111101 + sta VIA1+VIA_DRA + rts +atnhi lda VIA1+VIA_DRA + ora #%00101000 + sta VIA1+VIA_DRA + rts +atnlo lda VIA1+VIA_DRA + and #%11010111 + sta VIA1+VIA_DRA + rts +atnahi lda VIA1+VIA_DRA + and #%11011111 + sta VIA1+VIA_DRA + rts +atnalo lda VIA1+VIA_DRA + ora #%00100000 + sta VIA1+VIA_DRA + rts +dhiclo lda VIA1+VIA_DRA + and #%11111011 + ora #%00000010 + sta VIA1+VIA_DRA + rts +#else +clklo lda VIA1+VIA_DRA + ora #%00000100 + sta VIA1+VIA_DRA + rts +clkhi lda VIA1+VIA_DRA + and #%11111011 + sta VIA1+VIA_DRA + rts +datalo lda VIA1+VIA_DRA + ora #%00000010 + sta VIA1+VIA_DRA + rts +datahi lda VIA1+VIA_DRA + and #%11111101 + sta VIA1+VIA_DRA + rts +atnlo lda VIA1+VIA_DRA + ora #%00101000 + sta VIA1+VIA_DRA + rts +atnhi lda VIA1+VIA_DRA + and #%11010111 + sta VIA1+VIA_DRA + rts +atnalo lda VIA1+VIA_DRA + and #%11011111 + sta VIA1+VIA_DRA + rts +atnahi lda VIA1+VIA_DRA + ora #%00100000 + sta VIA1+VIA_DRA + rts +dhiclo lda VIA1+VIA_DRA + and #%11111101 + ora #%00000100 + sta VIA1+VIA_DRA + rts +#endif + +waitdlo + jsr setti +w1 jsr fragti + bne w2 + lda VIA1+VIA_DRA + cmp VIA1+VIA_DRA + bne w1 + lsr + bcs w1 + rts +w2 sec + rts + +&setti lda #<1000 + sta VIA1+VIA_T1CL + lda #>1000 + sta VIA1+VIA_T1CH + rts +&fragti lda VIA1+VIA_IFR + and #%01000000 + rts + +waitms txa + ldx #$b6 + bne w4 +waitus txa + ldx #8 +w4 dex + bne w4 + tax + rts + +sectalk + sei + sta byte + jsr iec2out + bcs st1 + jsr datalo + jsr atnhi + jsr clkhi +st2 bit VIA1+VIA_DRA + bvs st2 +st1 cli + rts + + +seclisten sei + sta byte + jsr iec2out + jsr atnhi + cli + rts + +&UNTALK sei + jsr clklo + lda #$5f + jsr atnout + jsr atnhi + jsr clkhi + jsr datahi + cli + rts + +&UNLISTEN lda #$3f + sei + jsr atnout + jsr atnhi + jsr clkhi + cli + rts + + +#undef VIA1 + diff --git a/dump/oa-2.0.9/arch/csa65/foo b/dump/oa-2.0.9/arch/csa65/foo new file mode 100644 index 0000000..de9706e --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/foo @@ -0,0 +1,20 @@ + +If "ROMTEST" is defined: + +p 02 +e 2 18 +e 3 19 +e 4 1a +e 5 1b +e 6 1c +e 7 1d +e 8 1e +e 9 1f +yc +l"csarom" 2000 +l"inirom" 3fe + +or otherwise: + +~/vice/src/vice-0.12.0.16-csa-22/bin/xcsa -kernal ./csarom -basic ./csarom2 + diff --git a/dump/oa-2.0.9/arch/csa65/kernel/kenv.a65 b/dump/oa-2.0.9/arch/csa65/kernel/kenv.a65 new file mode 100644 index 0000000..ca2cd5f --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/kernel/kenv.a65 @@ -0,0 +1,780 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* Struct Task Environment Entry */ + +/* we have three structs now: + * TE_* for task environment handling - not needed for system without + * memory management + * TT_* task table, contains STD streams, etc + * TH_* thread table, has stack info and state + */ + +/************************************************************************ + * These routines are needed in the env section! + * inienv + * savethread + * loadthread + * initsp + * push + * pull + * memtask + * memsys + * + * sbrk + * getenv + * freenv + */ + + +#define TE_NTASKS 0 +#define TE_MMU 1 /* must be at least 1 - see getenv */ +#define TE_MMU_LEN 15 /* allow up to 15 pages being mapped */ +#define TE_RAMLEN 16 /* the number of RAM blocks allocated */ +#define TE_SLEN 17 + + .data +&actEnv .byt 0 +&envTab .dsb MAXENVS * TE_SLEN + .text + + +/* + * Maps PCBUF to a place reachable by the kernel (called several times). + * The new address of PCBUF in kernel space is then called SYSBUF. + * MAPSYSBUF must preserve xr + */ +#define MAPSYSBUF jsr mapsysbuf + +&mapsysbuf + .( :\ + ldy actEnv :\ + cpy #<-1 :\ + beq map1 :\ + lda envTab+TE_MMU,y :\ + .byt $2c :\ +map1 lda #SYSPAGE :\ + sta MMU+1 :\ + rts :\ + .) + +#define SYSBUF $1200 + +/* + * copies PCBUF from another (thread id in y) task to actual task + * length in TH_PAR+1(actThread) + */ +#define CPPCBUFRX() \ + ldx actTask :\ + lda taskTab + TT_ENV,x :\ + tax :\ + lda envTab + TE_MMU,x :\ + sta MMU+2 :\ + lda threadTab + TH_TASK,y :\ + tax :\ + lda taskTab + TT_ENV,x :\ + tax :\ + lda envTab + TE_MMU,x :\ + sta MMU+1 :\ + lda threadTab + TH_PAR+1,y :\ + jsr cploop + +/* + * copies PCBUF from actual task to another (thread id in y) + * length in TH_PAR+1(actThread) + */ +#define CPPCBUFTX() \ + jsr setmmu12 :\ + ldx actThread :\ + lda threadTab + TH_PAR+1,x :\ + jsr cploop + +/* + * copies PCBUF from actual task to another (thread id in y) + * length in TH_PAR+1(actThread) + */ +#define CPFORKBUF() \ + .( :\ + ldy actThread :\ + cpy #<-1 :\ + beq nocopy :\ + ldy div :\ + jsr setmmu12 :\ + lda #0 :\ + jsr cploop :\ +nocopy .) + +cploop .( + tay +l_0 dey + lda PCBUF+(BLKSIZ),y + sta PCBUF+(BLKSIZ*2),y + tya + bne l_0 + rts + .) + +setmmu12 .( + ldx actEnv + lda envTab + TE_MMU,x + sta MMU+1 + lda threadTab + TH_TASK,y + tax + lda taskTab + TT_ENV,x + tax + lda envTab + TE_MMU,x + sta MMU+2 + rts + .) + +&inienv .( + jsr inimem + lda #<-1 + sta actThread + sta actTask + sta actEnv + lda #1 + sta Syscnt + ;clc + rts + .) + +setthread .( + .data +newThread .byt 0 + .text + + cmp actThread + bne doit + rts +doit + sta newThread + + ldx actThread + cpx #<-1 + beq nosave + + ldy actEnv + lda envTab + TE_MMU,y + sta MMU+3 + + lda BLKSIZ*3 + THREADSAVE + sta threadTab + TH_LIBSAVE,x + lda BLKSIZ*3 + THREADSAVE+1 + sta threadTab + TH_LIBSAVE+1,x + +;savetask + ldy threadTab + TH_TASK,x + lda BLKSIZ*3 + TASKSAVE + sta taskTab + TT_LIBSAVE,y + lda BLKSIZ*3 + TASKSAVE + 1 + sta taskTab + TT_LIBSAVE + 1,y +nosave +;loadtask + ldx newThread + stx actThread + cpx #<-1 + bne load + stx actTask + stx actEnv + beq noload +load + ldy threadTab + TH_TASK,x + sty actTask + lda taskTab + TT_ENV,y + sta actEnv + tay + lda envTab + TE_MMU,y + sta MMU+3 +;loadtask + ldy actTask + lda taskTab + TT_LIBSAVE,y + sta BLKSIZ*3 + TASKSAVE + lda taskTab + TT_LIBSAVE + 1,y + sta BLKSIZ*3 + TASKSAVE + 1 + +;loadthread + lda threadTab + TH_LIBSAVE,x + sta BLKSIZ*3 + THREADSAVE + lda threadTab + TH_LIBSAVE+1,x + sta BLKSIZ*3 + THREADSAVE+1 +noload +endset rts + .) + +initsp .( + lda #<-1 ;STACKSIZE-1 + ;ldx actThread + sta threadTab + TH_SP,x + rts + .) + +pull .( + MAPSYSBUF + ldx actThread + inc threadTab + TH_SP,x + lda threadTab + TH_SP,x + tay + lda SYSBUF - PCBUF + $0100,y + rts + .) + +push .( + pha + MAPSYSBUF + ldx actThread + lda threadTab + TH_SP,x + tay + pla + sta SYSBUF - PCBUF + $0100,y + dec threadTab + TH_SP,x + rts + .) + +/***************************************************************************/ + +#define MAPENV() jsr mapenv +#define MAPAENV() jsr mapaenv + +&mapaenv + ldx actEnv +&mapenv .( + cpx #<-1 + beq system + rts +system pha + tya + lsr + lsr + lsr + lsr + tax +#ifdef ROMTEST + ora #$10 +#endif + sta MMU,x + pla + rts + .) + +/***************************************************************************/ + +/* + * we have changed the memtask call from jsr to jmp, but we need + * the jsr routine (or an equivalent) for the return from interrupt + */ + +#define MEMTASK2() jsr memtask2 + +&memtask jsr memtask2 + rts + + .( + +mempage = 3 + + .data +AC .byt 0 +XR .byt 0 +YR .byt 0 +SR .byt 0 +ADR .word 0 +SSP .byt 0 +mmu .byt 0 + .text + +&&memtask2 + php + sei + dec Syscnt ; back to thread? + bne mtask ; no then end + + bit adev + bpl mtask + + sty YR ; otherwise set thread env + stx XR + sta AC + pla + sta SR + pla + sta ADR + pla + sta ADR+1 + tsx + stx SSP ; save all regs + + ldy actEnv + + ldx #1 +tm1 lda envTab+TE_MMU+1,y + sta MMU,x + iny + inx + cpx #TE_MMU_LEN + bcc tm1 + + ldy actThread + ldx threadTab + TH_SP,y + txs + + ldy actEnv + lda envTab+TE_MMU+mempage,y + sta mmu + lda envTab+TE_MMU,y + sta MMU + +mt2 + lda #SYSPAGE + sta MMU+mempage + + lda BLKSIZ*mempage+ADR+1 + pha + lda BLKSIZ*mempage+ADR + pha + lda BLKSIZ*mempage+SR + pha + lda BLKSIZ*mempage+AC + pha + lda BLKSIZ*mempage+mmu + ldy BLKSIZ*mempage+YR + ldx BLKSIZ*mempage+XR + sta MMU+mempage + pla +mtask plp + rts + +&&memsys php + sei + pha + lda #SYSPAGE + sta MMU+mempage + lda BLKSIZ*mempage+Syscnt + inc BLKSIZ*mempage+Syscnt + cmp #0 + beq msys +devr pla + plp + rts +msys + bit BLKSIZ*mempage+adev + bpl devr + + pla + sta BLKSIZ*mempage+AC + pla + sta BLKSIZ*mempage+SR + stx BLKSIZ*mempage+XR + sty BLKSIZ*mempage+YR +#ifdef CMOSCPU + ply +#else + pla + tay +#endif + pla ; y/a hold the return address now + + tsx + stx BLKSIZ*mempage + mmu + ldx #SYSPAGE + stx MMU + ldx SSP + txs + + pha ; save return address +#ifdef CMOSCPU + phy +#else + tya + pha +#endif + lda mmu + ldy actThread + sta threadTab + TH_SP,y + + lda SR + pha + lda AC + ldx XR + ldy YR + plp + cld + rts + + .) + +/***************************************************************************/ + + .( + .data +gdiv .byt 0 +gdiv2 .byt 0 +gdiv3 .byt 0 + .text + +&&kgetenv .( + sta gdiv ; number of 256-byte blocks as RAM from lo of mem + sty gdiv2 ; number of shared 256-byte blocks from top of mem + ldx #0 +l0 lda envTab + TE_NTASKS,x + beq found + txa + clc + adc #TE_SLEN + tax + cmp #TE_SLEN * MAXENVS + bcc l0 + rts +found stx gdiv3 + ; first clean table + lda #$0f ; kernel ROM page, read-only + ldy #TE_MMU_LEN +l0a sta envTab + TE_MMU,x + inx + dey + bne l0a + ; then copy shared + lda gdiv2 + beq noshared + ; a memory page has 16 blocks - be sure to map all + ; also already shorten to length of MMU table +#if 15-(16-TE_MMU_LEN)*16 + clc + adc #< 15-(16-TE_MMU_LEN)*16 +#endif + lsr + lsr + lsr + lsr + sta gdiv2 ; number of 4k blocks + + lda actEnv + + cmp #<-1 + bne valid + ldy #TE_MMU_LEN - 1 +l11 lda MMU,y + sta envTab + TE_MMU - 1, x + dex + dey + dec gdiv2 + bne l11 + beq l12 + +valid clc + adc #TE_MMU_LEN + tay +l1 + lda envTab + TE_MMU - 1, y ; TE_MMU is at least 1, so no + sta envTab + TE_MMU - 1, x ; wraparound + dex + dey + dec gdiv2 + bne l1 +noshared +l12 + + ; now alloc the requested memory blocks + lda gdiv + beq end + clc + adc #15 + lsr + lsr + lsr + lsr + sta gdiv ; number memory blocks to allocate + + ldx gdiv3 + stx gdiv2 + sta envTab + TE_RAMLEN,x ; save length of RAM + +l2 jsr getmem + bcs release + txa + ldx gdiv2 + sta envTab + TE_MMU,x + inc gdiv2 + dec gdiv + bne l2 + + ldx gdiv3 + + lda envTab + TE_MMU,x ; needs to work with MAPSYSBUF of current + sta MMU+3 ; thread -> not page 1 + lda #0 + sta ENVSAVE+(3*BLKSIZ) + sta ENVSAVE+(3*BLKSIZ)+1 + + lda #1 + sta envTab + TE_NTASKS,x + clc + rts +release + ldy gdiv2 + cpy gdiv3 + beq end + dey + sty gdiv2 + ldx envTab + TE_MMU,y + jsr fremem + jmp release +end sec + rts + .) + +&&freenv .( + stx gdiv + lda envTab + TE_NTASKS,x + sec + sbc #1 + sta envTab + TE_NTASKS,x + beq last + rts +last + lda #TE_MMU_LEN + sta gdiv2 + +l1 ldy gdiv + ldx envTab + TE_MMU,y + jsr fremem + bcs error + inc gdiv + dec gdiv2 + bne l1 +error rts + .) + +&&sbrk .( + jsr memsys + bcc read + clc + adc #15 + lsr + lsr + lsr + lsr + ldx actEnv + sec + sbc envTab + TE_RAMLEN,x + sta gdiv + beq read + bcs more +less + dec envTab + TE_RAMLEN,x + lda envTab + TE_RAMLEN,x + clc + adc actEnv + tay + lda envTab + TE_MMU,y + tax + lda #$0f + sta envTab + TE_MMU,y + jsr fremem + inc gdiv + bne less + beq read +more + jsr getmem + bcs read + txa + pha + ldx actEnv + lda envTab + TE_RAMLEN,x + inc envTab + TE_RAMLEN,x + clc + adc actEnv + tax + pla + sta envTab + TE_MMU,x + dec gdiv + bne more + +read ldx actEnv + lda envTab + TE_RAMLEN,x ; return available memory + asl + asl + asl + asl + clc + jmp memtask + .) + + .) + +/*************************************************************************** + * + * This code handles the setblk kernel call. It is used to change the + * MMU mapping by a task itself. It is for debugging puposes (monitor) + * only. It is reduced from the 1.3 kernel call, as it only allows writing, + * and also only for the own task. + * Handle with care! + */ + +&&setblk .( + jsr memsys + cpy #TE_MMU_LEN + bcs indexerr + pha + tya + clc + adc actEnv + tay + pla + sta envTab + TE_MMU,y + clc +indexerr + jmp memtask + .) + +/*************************************************************************** + * + * The code below is the memory handling code previously located in + * oa1sm.a65. It is not needed for computer w/o MMU, so it moved here + */ + +#define MBLOCKS 256 + + .( +#ifndef MAP_ZERO + .data +#else + .zero +#endif +MEMVAL .dsb MBLOCKS/8 +MEMFRE .dsb MBLOCKS/8 +mdiv .byt 0 + .text + +&inimem .( + ldy #MBLOCKS/8 + lda #0 +l1 sta MEMVAL,y + sta MEMFRE,y + dey + bpl l1 + ;clc + rts + .) + +&getmem .( + ; jsr memsys + ldx #0 +l2 lda MEMVAL,x + and MEMFRE,x + beq gnext + ldy #7 +l3 asl + bcs found + dey + bpl l3 +found lda POT2,y + eor #$FF + and MEMFRE,x + sta MEMFRE,x + txa + asl + asl + asl + sta mdiv + tya + ora mdiv + tax + jmp gne +gnext inx + cpx #MBLOCKS/8 + bcc l2 +notfre lda #E_NOMEM + .byt $2c +gne lda #E_OK + cmp #1 + ;jsr memtask + rts + .) + +&fremem .( + ; jsr memsys +#if MBLOCKS - 256 + cpx #MBLOCKS + bcs notfre +#endif + jsr gsetxy + ora MEMFRE,x + and MEMVAL,x + sta MEMFRE,x + lda #E_OK + clc + ;jsr memtask + rts + .) + +&&enmem jsr memsys +#if MBLOCKS - 256 + cpx #MBLOCKS + bcs notfre +#endif + jsr gsetxy + ora MEMVAL,x + sta MEMVAL,x + lda POT2,y + ora MEMFRE,x + sta MEMFRE,x + lda #E_OK + clc + jmp memtask + ;jsr memtask + ;rts + +/* +&getblk jsr memsys +#if MBLOCKS - 256 + cpx #MBLOCKS + bcs notfre +#endif + jsr gsetxy + and MEMFRE,x + and MEMVAL,x + beq notfre + lda POT2,y + eor #$ff + and MEMFRE,x + sta MEMFRE,x + lda #E_OK + clc + jmp memtask + ;jsr memtask + ;rts +*/ + .) + +/* + * needed for GETINFO, gives mem available for task + */ +#define GETTASKMEM ldx taskTab + TT_ENV,y: lda envTab + TE_RAMLEN,x: asl: asl: asl: asl + +/* + * needed in device code to get active environment in AC + */ +#define GETACTENV() lda actEnv + diff --git a/dump/oa-2.0.9/arch/csa65/kernel/kinit.a65 b/dump/oa-2.0.9/arch/csa65/kernel/kinit.a65 new file mode 100644 index 0000000..1a40f37 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/kernel/kinit.a65 @@ -0,0 +1,211 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * This file is included in the RESET routine of the kernel, + * after the "sei:cld". The routine starting at the bginning + * of this file must initialize the hardware to the system RAM + * in the beginning and the system ROM in the end of the memory + * map. Also the system stack (pointer) is setup. + * + * In addition to that the system interrupt timer (needed for + * task preemtion) must be setup. + * + * After that the file must define the following macros: + * + * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz + * LEDPORT address of LED port to signal hardware failures + * LED_LED bit of LED bit in LEDPORT address + * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces + * the LED toggle routine if needed. + * CLRTIMER() clear the system interrupt timer interrupt + * KERNELIRQ() returns if an interrupt occured in the kernel + * or outside. Is checked by "BNE IRQ_in_Kernel" + * SAVEMEM() save system mem config for interrupt + * RESTOREMEM() restore system mem config after interrupt + * STARTMEM() This is used to alloc/enable memory pages found + * during kernel init. Takes mem size in AC as given + * by the kernel init. It is called _after_ inimem! + */ + +/* + * init stack pointer for system stack + */ + ldx #<-1 + txs + +/* + * init memory configuration + */ + .( +#ifdef ROMTEST + ldx #7 ; only set RAM mapping, keep running ROM mapping +#else + ldx #15 +#endif +res1 txa ;lda mmu,x + sta MMU,x + dex +#if SYSPAGE + bne res1 + lda #SYSPAGE + sta MMU +#else + bpl res1 +#endif /* SYSPAGE */ + .) + +/* + * CSA65 specific irq timer init, 50 Hz irq (well, i.e. line freq. irq) + * We assume that the reset - or a loader program has disabled all irq + */ + lda #SYS_IRQEN+SYS_EXTIO + sta SYSPORT + +/* + * check zeropage RAM, jump to he_zero if failure + */ +#include "kernel/zerotest.a65" + +/* + * check system RAM up to ROMSTART, jump to he_ram if failure + * returns available RAM in 256 byte blocks in AC + */ + .( + .zero +&cnt .byt 0 + .text +#include "kernel/ramtest.a65" + cmp #MIN_MEM ; memory size at least needed + bcc he_ram + sta cnt + .) + + jmp endmem + +/* + * here we enable the memory pages found to be mapped by the MMU + * TODO: currently maximum 32k!!!! + */ +startmem .( + lsr + lsr + lsr + lsr + sta cnt +xl dec cnt + ldx cnt +#if SYSPAGE + cpx #SYSPAGE + beq x1 +#else + bmi x1 +#endif +/* +#ifdef ROMTEST + txa + ora #$10 + tax +#endif +*/ + jsr ENMEM + jmp xl +x1 + rts + .) + +#define STARTMEM() jsr startmem + +/* + * determine the speed the CPU is running with. We use the 50 Hz toggle + * line for it. + */ +getfreq .( + sei + lda #SYS_IRQEN + sta SYSPORT +gf1 lda SYSPORT + bpl gf1 + sta SYSPORT + bit SYSPORT + bmi gf1 + lda #0 + tay + tax +gf2 bit SYSPORT + bmi gfe + clc + adc #1 + bne gf2 + inx + bne gf2 + iny + bne gf2 +gfe cpx #8 ; more, then 2 MHZ + bcc gf3 + lda #128 ; 2 MHz + rts +gf3 lda #0 ; 1 MHz + rts + .) + +#define GETFREQ() jsr getfreq + +/* + * system LED to indicate hardware failures + */ +#ifndef LEDPORT +#define LEDPORT SYSPORT +#define LED_LED SYS_LED +#endif + +/* + * clear the scheduler preemption timer + */ +#define CLRTIMER() lda SYSPORT:sta SYSPORT + +/* + * MMU systems may map task pages into kernel mem to make copying + * easier. This mapping has to be preserved during interrupt. + * SAVEMEM() saves the memory configuration, while RESTOREMEM() + * restores it, obviously. + * These routines are called _after_ "jsr memsys", so this routine + * has to preserve this mapping when called from kernel space, + * and so must memtask. + */ +/* +#define SAVEMEM lda MMU+1:pha:lda MMU+2:pha +#define RESTOREMEM() pla:sta MMU+2:pla:sta MMU+1 +*/ +#undef SAVEMEM +#undef RESTOREMEM + +/* + * Check if we have an interrupt in the kernel + */ + +#define KERNELIRQ() lda Syscnt:cmp #1 + +endmem + diff --git a/dump/oa-2.0.9/arch/csa65/sysapps/Makefile b/dump/oa-2.0.9/arch/csa65/sysapps/Makefile new file mode 100644 index 0000000..e5dad92 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/sysapps/Makefile @@ -0,0 +1,46 @@ + +apps = lsh +sysapps = mon slipd +files = mkdir rmdir rm format chkdsk ls cat mv +inet = tlogin telnet httpd + +XA=xa + +all: osa.d64 + +redo: + rm -f fsibm.o65 + make + cat foo + +fsibm.o65: fsibm.a65 + ${XA} -bz 32 -bt 1280 -bd 768 -bb 12288 -l fsibm.lab -r -I.. -I../../../include -I../../.. -R -DOSA2KERNEL=\$$f000 $< -o $@ + file65 -V fsibm.o65 + reloc65 -xt -o fsibm fsibm.o65 + +osa.d64: ${files} ${sysapps} ${apps} fsibm.o65 + ./mkdisk ${files} ${sysapps} ${apps} ${inet} fsibm.o65 + dd if=osa.x64 of=osa.d64 bs=64 skip=1 + +clean: + rm -f fsibm.o65 fsibm.lab fsibm + rm -f ${files} ${sysapps} ${apps} ${inet} + rm -f osa.d64 osa.x64 + +${apps}: + (cd ../../../apps/lsh; make lsh;) + (if test ! -r lsh; then ln -s ../../../apps/lsh/lsh lsh; fi) + +${sysapps}: + (cd ../../../sysapps/$@; make $@;) + (if test ! -r $@; then ln -s ../../../sysapps/$@/$@ $@; fi) + +${files}: + (cd ../../../apps/file; make $@;) + (if test ! -r $@; then ln -s ../../../apps/file/$@ $@; fi) + +${inet}: + (cd ../../../apps/inet; make $@;) + (if test ! -r $@; then ln -s ../../../apps/inet/$@ $@; fi) + + diff --git a/dump/oa-2.0.9/arch/csa65/sysapps/foo b/dump/oa-2.0.9/arch/csa65/sysapps/foo new file mode 100644 index 0000000..3af0bf3 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/sysapps/foo @@ -0,0 +1,4 @@ +monitor +p 05 +e 1 18 19 1a +l"fsibm" 500 diff --git a/dump/oa-2.0.9/arch/csa65/sysapps/fsibm.a65 b/dump/oa-2.0.9/arch/csa65/sysapps/fsibm.a65 new file mode 100644 index 0000000..1fc9fe8 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/sysapps/fsibm.a65 @@ -0,0 +1,9 @@ + +/* #define FSIBM_DEVICE_DRV "devices/drv_wd1770.a65" */ +/* #define FSIBM_DEVICE_DRV "sysapps/fs/fsibm/drv_ramd1.a65" */ +#define FSIBM_DEVICE_DRV "devices/scsi.a65" + +#define DEBUGFS + +#include "sysapps/fs/fsibm.a65" + diff --git a/dump/oa-2.0.9/arch/csa65/sysapps/mkdisk b/dump/oa-2.0.9/arch/csa65/sysapps/mkdisk new file mode 120000 index 0000000..243e029 --- /dev/null +++ b/dump/oa-2.0.9/arch/csa65/sysapps/mkdisk @@ -0,0 +1 @@ +../../c64/boot/mkdisk \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/embedded/Makefile b/dump/oa-2.0.9/arch/embedded/Makefile new file mode 100644 index 0000000..ee5f4ce --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/Makefile @@ -0,0 +1,19 @@ + +TRG=boot/rom + +XAINPUT=../../include,..,../.. +XA=XAINPUT=${XAINPUT} xa +FILE=file65 +RELOC=reloc65 + +rom ${TRG}: + ${XA} -R -bt 61438 -bd 768 -bz 8 -bb 2560 rom.a65 -o rom.o65 -l rom.lab ; + ${FILE} rom.o65; + ${RELOC} -xt -o ${TRG} rom.o65; + + +clean: + rm -f ${TRG} rom.lab rom.o65 boot.tgz + (cd boot; ${MAKE} clean;) + # (cd apps; ${MAKE} clean;) + diff --git a/dump/oa-2.0.9/arch/embedded/README b/dump/oa-2.0.9/arch/embedded/README new file mode 100644 index 0000000..c6a96a1 --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/README @@ -0,0 +1,25 @@ + +This is a sample implementation of an embedded version of the GeckOS. +It is reduced to basic scheduling and interrupt handling and has +thus removed the + +- streams + +- memory management + +- file manager + +- send/receive + +- semaphores + +This shortens the kernel to almost 2k in size. +Also the used amount of RAM is $bc = 188 byte normal RAM, +plus $e = 14 byte zeropage (not counting the environment, task and +thread save 6 bytes from addresses 2-8), also not counting +the possible use of PCBUF by fork and devcmd. +1k RAM total should be sufficient for simple applications. + +Using the PCBUF without locking with a semaphore should be handled with +care. + diff --git a/dump/oa-2.0.9/arch/embedded/boot/Makefile b/dump/oa-2.0.9/arch/embedded/boot/Makefile new file mode 100644 index 0000000..bd8b636 --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/boot/Makefile @@ -0,0 +1,12 @@ + +XA=xa + +all: rom + +rom: + (cd ..; ${MAKE};) + +clean: + rm -f rom + + diff --git a/dump/oa-2.0.9/arch/embedded/config.i65 b/dump/oa-2.0.9/arch/embedded/config.i65 new file mode 100644 index 0000000..8e6656f --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/config.i65 @@ -0,0 +1,71 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#echo ******** c64 config ********** + + +#ifndef ANZSTR + +/* StreamData */ + +#define ANZSTRM 8 + +/* SemaphoreData */ + +#define ANZSEM 8 /* vielfaches von 8 */ +#define SYSSEM 8 /* vielfaches von 8, sem-nr von -SYSSEM bis -1 */ + +/* DeviceData */ + +#define MAXDEV 16 + +/* EnvData */ + +#define MAXENVS 1 /* one environment only */ + +#ifndef STACKCOPY +#define MAXNTHREADS 5 /* (Stackpage-56)/40 */ +#define MAXNTASKS 5 +#define STACKSIZE 40 /* (TH_SLEN * 5) */ +#else +#define MAXNTHREADS 8 /* (up to 16 is possible, if enough memory) */ +#define MAXNTASKS 5 +#define STACKSIZE 64 /* (TH_SLEN * 8) */ +#endif +#define ANZXENV 5 /* number of redirectable task IDs */ + +/* TaskData */ + +#define IRQCNT 3 + +/* FileManager */ + +#define MAXFS 4 + +/* we don't map any of these memory areas */ +#undef MAP_ZERO +#undef MAP_STACK +#undef MAP_MEM + +#endif + diff --git a/dump/oa-2.0.9/arch/embedded/devices/oa1std.a65 b/dump/oa-2.0.9/arch/embedded/devices/oa1std.a65 new file mode 100644 index 0000000..729127e --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/devices/oa1std.a65 @@ -0,0 +1,297 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/**************************************************************************/ +/* */ +/* Standard-Device-Programm zur einfachen Erstellung einer anderen Device */ +/* */ +/**************************************************************************/ + + .( + .word devend + jmp prg1 + .asc "name",0 + + .data +status .byt 0 +instr .byt 0 +outstr .byt 0 + .text + +prg1 cmp #DC_RES + beq devini + + pha + lda status + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts + +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini lda #0 + sta status + sta instr + sta outstr + +/************************ Reset ************************************/ + +/******* go on here, or on error go to devx ************************/ + +rts1hi + +/***************** here if stream over highwatermark ***************/ + +/*******************************************************************/ + + clc + rts + +devx lda status + ora #2 + sta status + lda #E_NOTIMP + sec + rts + +devirq .( + +/********************* is IRQ for device? no, then irqend **********/ + +/************************ here if irq for device *******************/ + + lda status + bpl tx + +/**** receive byte to ac, no byte then nobyt ***********************/ + +/*******************************************************************/ + + ldx outstr + jsr PUTC + bcs test + +nobyt ldx outstr + lda #SC_STAT + jsr STRCMD + +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx + +tstwater cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh jsr rts1hi + bcc tx ; unbedingt +twl cmp #E_SLWM + bne tx + +wl +/******** here if stream below lowwatermark ************************/ + +/*******************************************************************/ + +tx lda status + rol + bpl irqhs + +/******* hardware ready to send? if not then irqhs *****************/ + +/*******************************************************************/ + + ldx instr + jsr GETC + bcs test2 + +/***************** send byte ***************************************/ + +/*******************************************************************/ + + jmp irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs + +/**************** remove IRQ and clean up **************************/ + +/*******************************************************************/ + + lda #E_OK ; interrupt source removed + rts +irqend + lda #E_NOIRQ ; no interrupt source removed + rts + + .) + +others cmp #DC_GS + bne o1 + lda status + and #DC_SW_TX + bne devonx + sty instr + jmp ok +devonx jmp devon +o1 cmp #DC_PS + bne o2 + lda status + and #DC_SW_RX + bne devonx + sty outstr +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + +/********************* check if receive possible ******************/ + +/************************ if not then onotimp *********************/ + + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + +/********************* check if send possible ********************/ + +/************************ if not then onotimp ********************/ + + lda #DC_SW_TX +o2a ora status + sta status + bne okx +o4 cmp #DC_RX_OFF + bne o5 + +rxoff lda status + and #DC_SW_RX + beq devoffx + ldx outstr + lda #SC_EOF + jsr STRCMD + lda status + and #255-DC_SW_RX + sta status + jsr rts1hi + bcc okx +devoffx jmp devoff +o5 cmp #DC_TX_OFF + bne o6 + +txoff lda status + and #DC_SW_TX + beq devoffx + ldx instr + lda #SC_NUL + jsr STRCMD + lda status + and #255-DC_SW_TX + sta status + jmp ok + +o6 cmp #DC_HS + bne o6a + +/******************** here Handshake ************************/ + + lda status + and #255-1 + sta status + tya + and #1 + ora status + sta status + +/***********************************************************/ + + jmp ok + +o6a cmp #DC_SPD + bne o7 + +/****************** here speed *****************************/ + +/***********************************************************/ + + jmp ok + +o7 cmp #DC_ST + bne o8 + + lda status + and #2 + bne onotimp + +/****************** here state request *********************/ + +/***********************************************************/ + + jmp ok + +o8 cmp #DC_EXIT + bne onotimp + jsr rxoff + jsr txoff + lda status + ora #2 + sta status + +/****************** disable device ************************/ + +/*********************************************************************/ + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +/******************** subprograms, includes, etc *********************/ + +/*********************************************************************/ + +devend .) + diff --git a/dump/oa-2.0.9/arch/embedded/devices/oa1stds.a65 b/dump/oa-2.0.9/arch/embedded/devices/oa1stds.a65 new file mode 100644 index 0000000..2ead320 --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/devices/oa1stds.a65 @@ -0,0 +1,330 @@ +/**************************************************************************** + + OS/A65 Version 1.3.3 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/**************************************************************************/ +/* */ +/* Standard-Device-Programm zur einfachen Erstellung von anderen Devices */ +/* */ +/**************************************************************************/ + +#define Anzdev 1 + + .( + .word devend + jmp prg1 + .asc "name1",0 +/* +devend1 .word devend + jmp prg2 + .asc "name2",0 +*/ +dev =sysmem +status =sysmem+1 +instr =sysmem+Anzdev+1 +outstr =sysmem+Anzdev*2+1 +-sysmem +=Anzdev*3+1 + +prg1 ldx #0 +/* + .byt $2c +prg2 ldx #1 +*/ + stx dev + cmp #DC_RES + beq devini + + pha + lda status,x + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts + +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini lda #0 + sta status,x + sta instr,x + sta outstr,x + +/************************ Reset ************************************/ + +/******* hier weiter oder bei Fehler devx **************************/ + +rts1hi + +/***************** hier falls Stream �ber highwatermark ************/ + +/*******************************************************************/ + + clc + rts + +devx ldx dev + lda status,x + ora #2 + sta status,x + lda #E_NOTIMP + sec + rts + +devirq .( + ldx dev + +/********************* ist irq f�r device? nein dann irqend **********/ + +/************************ hier falls irq f�r device ******************/ + + ldx dev + lda status,x + bpl tx + +/**** Byte empfangen in ac, kein Byte dann nobyt *********************/ + +/*********************************************************************/ + + pha + ldx dev + lda outstr,x + tax + pla + jsr PUTC + bcs test + +nobyt ldx dev + lda outstr,x + tax + lda #SC_STAT + jsr STRCMD + +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx + +tstwater cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh jsr rts1hi + bcc tx ; unbedingt +twl cmp #E_SLWM + bne tx + +wl +/******** hier Aktion falls Stream unter Lowwatermark ****************/ + +/*********************************************************************/ + +tx ldx dev + lda status,x + rol + bpl irqhs + +/******* Hardware sendebereit? falls nicht irqhs ********************/ + +/*********************************************************************/ + + ldx dev + lda instr + tax + jsr GETC + bcs test2 + +/***************** Byte senden **************************************/ + +/********************************************************************/ + + jmp irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs + +/**************** Irq l�schen oder so am Ende des Device-Irqs ******/ + +/*******************************************************************/ + + lda #E_OK ; interrupt source removed + rts + +irqend lda #E_NOIRQ ; no interrupt source removed + rts + + .) + +others cmp #DC_GS + bne o1 + lda status,x + and #DC_SW_TX + bne devonx + tya + sta instr,x + jmp ok +devonx jmp devon +o1 cmp #DC_PS + bne o2 + lda status,x + and #DC_SW_RX + bne devonx + tya + sta outstr,x +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + +/********************* hier test, ob Receive erlaubt **************/ + +/************************ falls nicht onotimp *********************/ + + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + +/********************* hier test, ob send erlaubt *****************/ + +/************************ falls nicht onotimp *********************/ + + lda #DC_SW_TX +o2a ora status,x + sta status,x + bne okx +o4 cmp #DC_RX_OFF + bne o5 + +rxoff ldx dev + lda status,x + and #DC_SW_RX + beq devoffx + lda outstr,x + tax + lda #SC_EOF + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_RX + sta status,x + jsr rts1hi + bcc okx +devoffx jmp devoff +o5 cmp #DC_TX_OFF + bne o6 + +txoff ldx dev + lda status,x + and #DC_SW_TX + beq devoffx + lda instr,x + tax + lda #SC_NUL + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_TX + sta status,x + jmp ok + +o6 cmp #DC_HS + bne o6a + +/******************** hier Handshake ************************/ + + lda status,x + and #255-1 + sta status,x + tya + and #1 + ora status,x + sta status,x + +/***********************************************************/ + + jmp ok + +o6a cmp #DC_SPD + bne o7 + +/****************** hier Geschwindigkeit *******************/ + +/***********************************************************/ + + jmp ok + +o7 cmp #DC_ST + bne o8 + + lda status,x + and #2 + bne onotimp + +/****************** hier Statusabfrage *********************/ + +/***********************************************************/ + + jmp ok + +o8 cmp #DC_EXIT + bne onotimp + jsr rxoff + jsr txoff + ldx dev + lda status,x + ora #2 + sta status,x + +/****************** hier Irq abschalten (Exit) ***********************/ + +/*********************************************************************/ + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +/******************** hier Unterprogramme, includes etc **************/ + +/*********************************************************************/ + +devend .) + diff --git a/dump/oa-2.0.9/arch/embedded/devices/romdev.a65 b/dump/oa-2.0.9/arch/embedded/devices/romdev.a65 new file mode 100644 index 0000000..54b097f --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/devices/romdev.a65 @@ -0,0 +1,87 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ROM + +#include "kdefs.def" +#include "kernel.i65" + + ;.word $700 + *=$700 + +#endif + + +/* Device-Block */ + + .( + +#ifdef ROM + .word endd + .byt PK_DEV+$80 + .word devstart + .dsb P_NAME - P_RAM, $ff + .asc "devices",0 +#else +/* Note: this is obsolete! */ +#ifndef NOPRG + .word 0 + .byt PK_DEV + .byt 0 + .word 0 + .word devstart + .byt 0,0,<-1 +#endif +#endif + +devstart + +-sernr = "1" + +/* + +#define CONSOLE_DEVICE "devices/con_c64.a65" +#include "devices/console.a65" ; video device is merged with OS/A now... + +#include "devices/oa1dnl.a65" ; null device +#include "devices/oa1dsp.a65" ; spooler device +#include "devices/ser_9600.a65" ; fast serial interface by Daniel Dallmann + +#ifdef UARTBASE +#include "devices/ser_uart.a65" ; standard UART 16550A driver +#endif + +*/ + +#include "devices/oa1std.a65" + + .word $ffff + +#if 0 +#print sysmem +#print syszp +#endif + +endd .) + diff --git a/dump/oa-2.0.9/arch/embedded/kernel/kenv.a65 b/dump/oa-2.0.9/arch/embedded/kernel/kenv.a65 new file mode 120000 index 0000000..1239cfb --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/kernel/kenv.a65 @@ -0,0 +1 @@ +../../c64/kernel/kenv.a65 \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/embedded/kernel/kinit.a65 b/dump/oa-2.0.9/arch/embedded/kernel/kinit.a65 new file mode 100644 index 0000000..9188cb1 --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/kernel/kinit.a65 @@ -0,0 +1,147 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * This file is included in the RESET routine of the kernel, + * after the "sei:cld". The routine starting at the bginning + * of this file must initialize the hardware to the system RAM + * in the beginning and the system ROM in the end of the memory + * map. Also the system stack (pointer) is setup. + * + * In addition to that the system interrupt timer (needed for + * task preemtion) must be setup. + * + * After that the file must define the following macros: + * + * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz + * LEDPORT address of LED port to signal hardware failures + * LED_LED bit of LED bit in LEDPORT address + * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces + * the LED toggle routine if needed. + * CLRTIMER() clear the system interrupt timer interrupt + * KERNELIRQ() returns if an interrupt occured in the kernel + * or outside. Is checked by "BNE IRQ_in_Kernel" + * SAVEMEM() save system mem config for interrupt + * RESTOREMEM() restore system mem config after interrupt + * STARTMEM() This is used to alloc/enable memory pages found + * during kernel init. Takes mem size in AC as given + * by the kernel init. It is called _after_ inimem! + */ + +/* Kernel routines for embedded hardware */ + +/* + * init stack pointer for system stack + */ + ldx #<-1 + txs + +/* + * init memory configuration + */ + +/* + lda #7 + sta 0 /* CPU data direction register */ + lda #5 + sta 1 /* Memory configuration */ +*/ + +/* + * C64 specific irq timer init, irq every 20ms + * We assume that the reset - or a loader program has disabled all irq + */ + +/* + lda #<20000 + sta C64CIA1+CIA_TBL ; load low byte + lda #>20000 + sta C64CIA1+CIA_TBH ; load hi byte of counter value + lda #%00010001 + sta C64CIA1+CIA_CRB ; start counter, counting system pulses + lda #%10000010 + sta C64CIA1+CIA_ICR ; allow irq +*/ + +/* + * check zeropage RAM, jump to he_zero if failure + */ +#include "kernel/zerotest.a65" + +/* + * check system RAM up to RAMEND, jump to he_ram if failure + * returns available RAM in 256 byte blocks in AC + */ + .( + .zero +cnt .byt 0 + .text +#include "kernel/ramtest.a65" + .) + +/* + * originally SYSPORT specific, they have a value for the C64 also... + */ +#define GETFREQ() lda #0 + +#define LEDPORT $d020 +#define LED_LED 1 + +/* + * as we have set the CIA1 TB irq in the kernel, we have to clear the + * CIA interrupt flag. This is done with reading the ICRegister. + * With C64NEEDCIA1 one can disable reading the ICR here. But then you + * have to have a device that does it! + */ +#if 0 /* ndef C64NEEDCIA1 */ +#define CLRTIMER() lda C64CIA1+CIA_ICR +#else +#define CLRTIMER() +#endif + +/* + * MMU systems may map task pages into kernel mem to make copying + * easier. This mapping has to be preserved during interrupt. + * SAVEMEM() saves the memory configuration, while RESTOREMEM() + * restores it, obviously. + * These routines are called _after_ "jsr memsys", so this routine + * has to preserve this mapping when called from kernel space, + * and so must memtask. + */ + +#undef SAVEMEM +#undef RESTOREMEM + +/* + * Check if we have an interrupt in the kernel + */ + +#define KERNELIRQ() lda Syscnt:cmp #1 + +/* + * no memory management... + */ +#define STARTMEM() + + diff --git a/dump/oa-2.0.9/arch/embedded/rom.a65 b/dump/oa-2.0.9/arch/embedded/rom.a65 new file mode 100644 index 0000000..2ba0380 --- /dev/null +++ b/dump/oa-2.0.9/arch/embedded/rom.a65 @@ -0,0 +1,112 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM + +/* These are necessary for embedded kernel *********************************/ + +#define NOMMU +#define NOSYSPORT +#undef CLK2MHZ /* we only have approx. 1 MHz ... */ +#undef CMOSCPU /* ... and CMOS cpu ? not if we keep save */ +#define RAMTEST +#define NOMIRRORMEM + +/* These are changeable ****************************************************/ + +#define MIN_MEM $04 /* minimum memory we need in system env. to + work ok, in pages */ + +#define RAMEND $20 /* where the ROM starts (in pages) */ + +#define MEMINIVAL 0 /* Clear memory to 0 on boot */ + +#undef STACKCOPY /* if defined, save stack area in memory + when context switching, otherwise divide + stack area and give each task a part. + It's faster without, but allows more + tasks with */ + +#undef NMIDEV /* necessary for fast RS232 */ + +#define NO_STREAMS /* no stream handling code included */ + +#define NO_FSM /* no filesystem manager code included */ + +#define NO_SEM /* no semaphore code */ + +#define NO_SEND /* no SEND/RECEIVE/XRECEIVE calls */ + +#define NO_DEVICE /* no DEVICE handling */ + +#define EOK_SEPARATE /* include kernel/end.a65 separately */ + +#undef EOK_NOFILL /* don't fill ROM till $ffff */ + +/***************************************************************************/ +/* You should include your application files below */ +/* */ + +#include "config.i65" +#include "kdefs.i65" + +#include "kernel.i65" + + .word $2000 + +.( + +/* + * This inverses the order in which the kernel is assembled. + * This need not be but is working when EOK_SEPARATE is set. + */ + + +#include "kernel/kernel.a65" + + .dsb 64,0 ; this is only to identify the kernel end in hexdump + ; and can be removed + +/* + * Here come the application files. + */ + +ROMSTART =* + +#include "devices/romdev.a65" + + .word -1 + +/* + * This ends the kernel by filling till $fff* and putting the reset vectors + */ + +#include "kernel/end.a65" + +.) + diff --git a/dump/oa-2.0.9/arch/gecko/Makefile b/dump/oa-2.0.9/arch/gecko/Makefile new file mode 100644 index 0000000..fb32c25 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/Makefile @@ -0,0 +1,24 @@ + +TRG=boot/geckorom + +XAINPUT=../../include,../.. +XA=xa +FILE=file65 +RELOC=reloc65 + +gecko ${TRG}: geckorom.o65 + ${RELOC} -xt -o ${TRG} geckorom.o65 + +geckorom.o65: gecko.a65 config.i65 gecko.i65 + ${XA} -I../.. -I../../include -R -bt 32768 -bd 768 -bz 8 -bb 2048 gecko.a65 -o geckorom.o65 -l gecko.lab ; + ${FILE} geckorom.o65; + +fsiectst: fsiectst.a65 + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -DKERNEL=61440 -bt 6144 -bz 128 -bd 4096 -bb 4352 fsiectst.a65 -o fsiectst ;\ + if [ $$? -ne 0 ]; then rm -f fsiectst; fi; ) + +clean: + rm -f ${TRG} geckorom gecko.lab geckorom.o65 fsiectst + (cd boot; ${MAKE} clean;) + diff --git a/dump/oa-2.0.9/arch/gecko/boot/Makefile b/dump/oa-2.0.9/arch/gecko/boot/Makefile new file mode 100644 index 0000000..06e4567 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/boot/Makefile @@ -0,0 +1,26 @@ + +XAINPUT=../../../include +XA=xa + +all: inigecko geckorom inig2 inig3 + +gecko geckorom: + (cd ..; ${MAKE} ;) + +inigecko: inigecko.a65 + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -DKERNEL=61440 inigecko.a65 -o inigecko;\ + if [ $$? -ne 0 ]; then rm -f inigecko; fi) + +inig2: inig2.a65 + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -DKERNEL=61440 inig2.a65 -o inig2;\ + if [ $$? -ne 0 ]; then rm -f inig2; fi) + +inig3: inig3.a65 + ${XA} -DXCSA -I../../../include -DKERNEL=61440 inig3.a65 -o inig3; + +clean: + rm -f geckorom inigecko inig2 inig3 + + diff --git a/dump/oa-2.0.9/arch/gecko/boot/inig2.a65 b/dump/oa-2.0.9/arch/gecko/boot/inig2.a65 new file mode 100644 index 0000000..2a41d37 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/boot/inig2.a65 @@ -0,0 +1,84 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This little program starts the Gecko with the builtin ROM when + * it is connected to the emulator board + * It does not map anything else. + */ + +#include "kdefs.i65" +#include "kernel.i65" +#include "../../csa65/csa65.i65" + + .word $400 + *=$400 + +l1 =$0 + ; exit all devices + lda #0 + sta l1 +l2 ldx l1 + lda #DC_EXIT + jsr DEVCMD + inc l1 + lda l1 + cmp #16 + bcc l2 + ; disable timer interrupt + lda SYSPORT + and #$ff-SYS_IRQEN + sta SYSPORT + + sei ; remap MMU pages + ldy #$21 + ldx #1 +l3 tya + sta $eff0,x + inx + iny + cpx #16 + bcc l3 + + ldx #0 ; copy program to valid RAM +l5 lda data,x + sta $1000,x + inx + bne l5 + + jmp $1000 ; and jump there + +data + lda #$20 ; remap page 0 + sta $eff0 +; lda #$0b +; sta $eff7 ; map $0e000 to $07000 for ext. I/O +; lda #$2e +; sta $effe + lda SYSPORT + ora #%00100000 ; ioinh + and #%11101111 ; extio + sta SYSPORT + + jmp RESET + diff --git a/dump/oa-2.0.9/arch/gecko/boot/inig3.a65 b/dump/oa-2.0.9/arch/gecko/boot/inig3.a65 new file mode 100644 index 0000000..97e8fb4 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/boot/inig3.a65 @@ -0,0 +1,138 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * this little program starts the gecko when it is plugged in + * the CSA computer itself, setup for external CPU and I/O + * from the CPU + * The ROM is mapped from pages 4-c. The RAM is mapped from the + * Gecko card itself. + */ + +#ifndef XCSA +#define GSEGMENT $40 /* where the gecko lives in CS/A memory */ + /* i.e. $40000-$4ffff */ +#else +#define GSEGMENT 0 +#endif + +#include "kdefs.i65" +#include "kernel.i65" +#include "../../csa65/csa65.i65" ; we boot from a csa system + +; .word $400 + *=$400 + +l1 =$0 + ; exit all devices + lda #0 + sta l1 +l2 ldx l1 + lda #DC_EXIT + jsr DEVCMD + inc l1 + lda l1 + cmp #16 + bcc l2 + ; disable timer interrupt + lda SYSPORT + and #$ff-SYS_IRQEN + sta SYSPORT + + sei ; remap MMU pages 8-15 with values from +.byt 2 + ldx #8 ; 4 to c +#ifdef XCSA +l3 lda $eff1,x +#else +l3 lda $eff4,x +#endif + sta $eff8,x + dex + bpl l3 + + ldx #1 ; set MMU pages 1-7 to 1-7 +l4 txa + ora #GSEGMENT + sta $eff0,x + inx + cpx #$8 + bcc l4 + + ldx #8 +l3a lda $eff0,x ; copy to write-protect-MMU if available + sta $ef70,x + inx + cpx #16 + bcc l3a + + ldx #0 ; copy program to valid RAM +l5 lda data,x + sta $1000,x + inx + bne l5 + + jmp $1000 ; and jump there + +data + lda #GSEGMENT ; remap page 0 + sta $eff0 + +; lda #$0b +; sta $eff7 ; map $0e000 to $07000 for ext. I/O +; lda #$2e +; sta $effe +; lda SYSPORT +; ora #%00100000 ; ioinh +; and #%11101111 ; extio +; sta SYSPORT + + lda SYSPORT ;$7fe0 + eor #%00001000 + sta SYSPORT ;$7fe0 + + ldx #0 + ldy #0 +x0 dey + bne x0 + dex + bne x0 + + lda SYSPORT ;$7fe0 + eor #%00001000 + sta SYSPORT ;$7fe0 + + ldx #0 + ldy #0 +x1 dey + bne x1 + dex + bne x1 + +;lda #$0f +;sta $7fff +;lda #%00100000 +;sta $7fe0 + + jmp RESET + diff --git a/dump/oa-2.0.9/arch/gecko/boot/inigecko.a65 b/dump/oa-2.0.9/arch/gecko/boot/inigecko.a65 new file mode 100644 index 0000000..6ef2cef --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/boot/inigecko.a65 @@ -0,0 +1,130 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* + * this little program starts the gecko when its CPU is replaced by + * the 40 pin connection to the CSA emulator board. + * The gecko must be setup for internal CPU. + * + * The ROM is mapped from pages 4-c. The RAM is mapped from the + * Gecko card itself. + * + * The I/O is mapped from the gecko obviously, + * i.e. we set ioinh on the BIOS board. + * + * As the I/O is mapped from the gecko, the whole page $exxx must + * not have any data/code in it, as it is remapped from the original + * gecko ROM, not from the pages 4-c like the rest of the ROM! + */ + +#define GSEGMENT $20 + +#include "kdefs.i65" +#include "kernel.i65" +#include "../../csa65/csa65.i65" ; we boot from a csa system + + .word $400 + *=$400 + +l1 =$0 + ; exit all devices + lda #0 + sta l1 +l2 ldx l1 + lda #DC_EXIT + jsr DEVCMD + inc l1 + lda l1 + cmp #16 + bcc l2 + ; disable timer interrupt + lda SYSPORT + and #$ff-SYS_IRQEN + sta SYSPORT + + sei ; remap MMU pages 8-15 with values from + ldx #8 ; 4 to c +l3 lda $eff4,x + sta $eff8,x + dex + bpl l3 + + ldx #1 ; map pages 1-7 from gecko +l4 txa + ora #GSEGMENT + sta $eff0,x + inx + cpx #$8 + bcc l4 + + ldx #0 ; copy program to valid RAM +l5 lda data,x + sta $1000,x + inx + bne l5 + + jmp $1000 ; and jump there + +data + lda #GSEGMENT ; remap page 0 + sta $eff0 + + lda #$0b ; extio is on page $0b000 + sta $eff7 ; map I/O to $07000 for ext. I/O + lda #GSEGMENT + $e ; gecko I/O page + sta $effe + lda SYSPORT + ora #%00100000 ; ioinh + and #%11101111 ; extio + sta SYSPORT + + lda $7fe0 + eor #%00001000 + sta $7fe0 + + ldx #0 + ldy #0 +x0 dey + bne x0 + dex + bne x0 + + lda $7fe0 + eor #%00001000 + sta $7fe0 + + ldx #0 + ldy #0 +x1 dey + bne x1 + dex + bne x1 + +;lda #$0f +;sta $7fff +;lda #%00100000 +;sta $7fe0 + + jmp RESET + diff --git a/dump/oa-2.0.9/arch/gecko/config.i65 b/dump/oa-2.0.9/arch/gecko/config.i65 new file mode 100644 index 0000000..d3fe2ea --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/config.i65 @@ -0,0 +1,73 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ANZSTR + +#include "gecko.i65" + +/************************ Daten f�r Computer ohne MMU *********************/ + +/* StreamData */ + +#define ANZSTRM 8 + +/* SemaphoreData */ + +#define ANZSEM 8 /* multiple of 8 */ +#define SYSSEM 8 /* multiple of 8, sem-no from -SYSSEM to -1 */ + +/* DeviceData */ + +#define MAXDEV 16 + +/* EnvData */ + +#ifndef STACKCOPY +#define MAXNTHREADS 5 /* (Stackpage-56)/40 */ +#define MAXNTASKS 5 +#define STACKSIZE 40 /* (TH_SLEN * 5) */ +#else +#define MAXNTHREADS 8 /* (up to 16 is possible, if enough memory) */ +#define MAXNTASKS 8 +#define STACKSIZE 64 /* (TH_SLEN * 8) */ +#endif +#define ANZXENV 5 /* number of redirectable task IDs */ + +/* TaskData */ + +#define IRQCNT 3 + +/* FileManager */ + +#define MAXFS 4 + +/* Memory handling */ + +#undef MAP_ZERO +#undef MAP_STACK +#undef MAP_MEM +#define NOMMU + +#endif + diff --git a/dump/oa-2.0.9/arch/gecko/devices/keydev.a65 b/dump/oa-2.0.9/arch/gecko/devices/keydev.a65 new file mode 100644 index 0000000..8f67515 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/devices/keydev.a65 @@ -0,0 +1,356 @@ + + +#define VIA $ec10 +#define IRQTIME 50000 + + .( + .word devend + jmp prg1 + .asc "keys",0 + + .data +status .byt 0 +outstr .byt 0 + .text + +prg1 + cmp #DC_RES + beq devini + + pha + lda status + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts + +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini lda #0 + sta status +/* sta instr*/ + sta outstr + +/************************ Reset ************************************/ + + jsr inikeys + lda VIA+VIA_ACR + and #%11011111 + sta VIA+VIA_ACR + lda #%00100000 + sta VIA+VIA_IFR + lda #%10100000 + sta VIA+VIA_IER + lda #IRQTIME + sta VIA+VIA_T2CH + +/******* go on here or on error goto devx **************************/ + +rts1hi + +/***************** here if stream over highwatermark ***************/ + +/*******************************************************************/ + + clc + rts + +devx lda status + ora #2 + sta status + lda #E_NOTIMP + sec + rts + +devirq .( + +/*************** Is interrupt for device? no, then irqend **********/ + + lda VIA+VIA_IFR + and #%00100000 + beq irqend + lda #>IRQTIME + sta VIA+VIA_T2CH + +/************************ here if irq for device *******************/ + + lda status + bpl tx + +/**** get byte to ac - if non rx'd, goto nobyt **********************/ + + jsr getkey + bcs nobyt + txa + +/*********************************************************************/ + + ldx outstr + jsr PUTC + bcs test + +nobyt ldx outstr + lda #SC_STAT + jsr STRCMD + +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx + +tstwater /* + cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh jsr rts1hi + bcc tx ; always +twl cmp #E_SLWM + bne tx + +wl +/******** here action if stream below lowwatermark *******************/ + +/*********************************************************************/ +*/ +tx/* + lda status + rol + bpl irqhs + +/******* hardware ready to send? if not goto irqhs *******************/ + + jmp irqhs + +/*********************************************************************/ + + ldx instr + jsr GETC + bcs test2 + +/***************** send byte in ac **********************************/ + +/********************************************************************/ + + jmp irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff +*/ +irqhs + +/**************** clear interrupt at end of irq service ************/ + +/*******************************************************************/ + +irqend rts + + .) + +devonx jmp devon +others /* + cmp #DC_GS + bne o1 + lda status + and #DC_SW_TX + bne devonx + tya + sta instr + jmp ok */ + +o1 cmp #DC_PS + bne o2 + lda status + and #DC_SW_RX + bne devonx + sty outstr +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + +/********************* test if receive allowed ********************/ + +/************************ if not, goto onotimp ********************/ + + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + +/********************* test if send allowed ***********************/ + + jmp onotimp + +/************************ if not, goto onotimp ********************/ + + lda #DC_SW_TX +o2a ora status + sta status + bne okx +o4 cmp #DC_RX_OFF + bne o5 + +rxoff lda status + and #DC_SW_RX + beq devoffx + ldx outstr + lda #SC_EOF + jsr STRCMD + lda status + and #255-DC_SW_RX + sta status + jsr rts1hi + bcc okx +devoffx jmp devoff + +o5 /* + cmp #DC_TX_OFF + bne o6 + +txoff lda status + and #DC_SW_TX + beq devoffx + ldx instr + lda #SC_NUL + jsr STRCMD + lda status + and #255-DC_SW_TX + sta status + jmp ok + +o6 + cmp #DC_HS + bne o6a + +/******************** here handshake ************************/ + + lda status + and #255-1 + sta status + tya + and #1 + ora status + sta status + +/***********************************************************/ + + jmp ok + +o6a cmp #DC_SPD + bne o7 + +/****************** here speed *****************************/ + +/***********************************************************/ + + jmp ok +*/ +o7 cmp #DC_ST + bne o8 + + lda status,x + and #2 + bne onotimp + +/****************** here status report *********************/ + +/***********************************************************/ + + jmp ok + +o8 cmp #DC_EXIT + bne onotimp + jsr rxoff +/* jsr txoff*/ + lda status + ora #2 + sta status + +/****************** disable irq (Exit) *********************/ + + lda #%00100000 + sta VIA+VIA_IER + +/*********************************************************************/ + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +/************** other device code **********************************/ + + .data +lastkey .byt 0 + .text + +inikeys .( + lda #<-1 + sta lastkey + lda #%00001111 + sta VIA+VIA_DDRA + cmp VIA+VIA_DDRA + bne novia + lda #0 + sta VIA+VIA_DRA + clc + rts +novia sec + rts + .) + +getkey .( + ldx #0 + +g0 txa + lsr + lsr + sta VIA+VIA_DRA +g1 lda VIA+VIA_DRA + cmp VIA+VIA_DRA + bne g1 + + ldy #4 +g2 rol + bcc pressed + inx + dey + bne g2 + + cpx #64 + bcc g0 + stx lastkey +nokey sec + rts + +pressed cpx lastkey + stx lastkey + beq nokey + clc + rts + .) + +/*********************************************************************/ + +devend .) + diff --git a/dump/oa-2.0.9/arch/gecko/devices/oadev.a65 b/dump/oa-2.0.9/arch/gecko/devices/oadev.a65 new file mode 100644 index 0000000..766a1ad --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/devices/oadev.a65 @@ -0,0 +1,94 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ROM + +#include "kdefs.i65" +#include "kernel.i65" + + ;.word $700 + *=$700 + +/*#define NOPRG*/ + +#endif + + +/* Device-Block */ + + .( +#if 0 +#ifndef NOMMU +-sysmem =$300 /* werte um mit OS/A 1.33 nicht zu kollidieren */ +-syszp =$d0 +#endif + +#echo devices: +#print sysmem +#print syszp + +#endif + +#ifdef ROM + .word endd + .byt PK_DEV+$80 + .word devstart + .dsb P_NAME - P_RAM, $ff + .asc "devices",0 +#else +#ifndef NOPRG + .word 0 + .byt PK_DEV + .byt 0 + .word 0 + .word devstart + .byt 0,0,<-1 +#endif +#endif + +devstart + +/*#include "c:eigene\eigene.a65\osarom3\oadev\oa1dt.a65"*/ + + +-sernr = "1" + +#include "devices/keydev.a65" +#include "devices/nulldev.a65" +#include "devices/spooler.a65" + +#ifdef GECKO_CSAEMU +#include "chips/pia6521.i65" +#define SYSPORT $efe0 +#define SYS_RTS %00000100 +#include "../csa65/devices/oa1ds.a65" +#endif + +#define UARTBASE $ec00 +#include "devices/ser_uart.a65" + + .word $ffff + +endd .) + diff --git a/dump/oa-2.0.9/arch/gecko/devices/siec_gecko.a65 b/dump/oa-2.0.9/arch/gecko/devices/siec_gecko.a65 new file mode 100644 index 0000000..dae84dc --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/devices/siec_gecko.a65 @@ -0,0 +1,527 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#define VIA1 $ec10 + +#include "chips/via6522.i65" + +#define DATAO %00000001 +#define DATAI %00000100 +#define CLKO %00001000 +#define CLKI %01000000 /* must be bit 6 -> bvc/bvs */ +#define ATNO %00000010 +#define ATNI %00010000 +#define ATNA %00100000 + + .zero +cnt2 .byt 0 +byte .byt 0 +bytfl .byt 0 +eoifl .byt 0 + .text + + ++IECINIT +#ifdef SEM_T1 + clc + ldx #SEM_T1 + jsr PSEM +#endif + sei + + lda VIA1+VIA_DDRB + and #%10000000 + ora #%00101011 + sta VIA1+VIA_DDRB + cmp VIA1+VIA_DDRB + bne inix + lda VIA1+VIA_DRB + and #$80 + sta VIA1+VIA_DRB + lda #%01010000 ; T1, CB1 disable IRQ + sta VIA1+VIA_IER + sta VIA1+VIA_IFR + lda VIA1+VIA_PCR + ora #%00010000 ; CB1 positive edge + sta VIA1+VIA_PCR + lda VIA1+VIA_ACR + and #%00111111 ; T1 timed IRQ + sta VIA1+VIA_ACR + + lda #0 + sta status + sta cnt2 + sta bytfl + sta eoifl + clc + .byt $24 +inix sec + cli +#ifdef SEM_T1 + php + ldx #SEM_T1 + jsr VSEM + plp +#endif + rts + +&getif .( /* we need timer 1, as well as irtx */ +#ifdef SEM_T1 + clc + ldx #SEM_T1 + jsr PSEM +#endif +#ifdef NMIDEV + lda #NMI_OFF + jsr CTRLNMI +#endif + php + sei + lda VIA1+VIA_ACR + and #%00111111 + sta VIA1+VIA_ACR + lda VIA1+VIA_PCR + lda #%01010000 ; T1, CB1 disable IRQ + sta VIA1+VIA_IER + sta VIA1+VIA_IFR + plp + + rts + .) + +&freif .( +#ifdef NMIDEV + lda #NMI_ON + jsr CTRLNMI +#endif +#ifdef SEM_T1 + ldx #SEM_T1 + jmp VSEM +#else + rts +#endif + .) + +&IECIN .( + sei + lda #0 + sta eoifl + lda #8 + sta cnt2 + jsr clkhi + jsr datalo + +l14 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRB ; wait clkhi + cmp VIA1+VIA_DRB + bne l14 + and #CLKI + bne l14 + +l19 jsr setti + jsr datahi + +l16 jsr fragti + bne l15 ; abgelaufen + ; jsr testatn + ; bcs atnin + bit VIA1+VIA_DRB ; wait clklo + bvc l16 + bvs l17 + +l15 lda eoifl + beq l18 + lda #2 + jmp error +l18 dec eoifl + jsr datalo + jsr waitus + lda #$40 + jsr seterror + bne l19 + +l17 sec + lda #DATAI +l20 bit VIA1+VIA_DRB + bvs l20 + bne l20a + clc +l20a + ror byte + +l21 bit VIA1+VIA_DRB + bvc l21 + + dec cnt2 + bne l17 + + jsr datalo + bit status + bvc l22 + jsr endhndshk +#ifdef SHOW +php +cli +lda #"x" +jsr OUT +lda status +jsr HEXOUT +plp +#endif + lda byte + eor #$ff + sec + rts + +l22 lda byte + eor #$ff + clc + rts + + +&nodev lda #$80 +&error jsr seterror + jsr atnhi +endhndshk jsr waitus + jsr datahi + jsr clkhi +#ifdef SHOW + lda #"y" + jsr OUT + lda status + jsr HEXOUT +#endif + sec + rts + .) + +#ifdef CLK1MHZ +/**************************** start of 1MHz section ************************/ + + +&setti lda #<1000 + sta VIA1+VIA_T1CL + lda #>1000 + sta VIA1+VIA_T1CH + rts +&fragti lda VIA1+VIA_IFR + and #%01000000 + rts + +waitms txa + ldx #$b6 + bne w4 +waitus txa + ldx #8 +w4 dex + bne w4 + tax + rts + + +/****************************** end of 1MHz section ************************/ +#else +/**************************** start of 2MHz section ************************/ + + +&setti lda #<2000 + sta VIA1+VIA_T1CL + lda #>2000 + sta VIA1+VIA_T1CH + rts +&fragti lda VIA1+VIA_IFR + and #%01000000 + rts + +waitms txa + ldx #$b6 + jsr w4 + ldx #$b6 + bne w4 +waitus3 txa + ldx #8 + bne w4 +waitus2 txa + ldx #16 + bne w4 +waitus txa + ldx #16 +w4 dex + bne w4 + tax + rts + + +/****************************** end of 2MHz section ************************/ +#endif + +/* +atnout .( + pha +lda #0 +sta status + bit bytfl + bpl l1 ; noch ein byte zu senden + + sec + ror eoifl ; dann mit eoi senden + jsr iecout + lda #0 + sta bytfl + ;lsr bytfl ; flags ruecksetzen + +l1 pla + sta byte +*/ +iec0out .( + sei + jsr datahi + jsr atnlo +&iec2out sei + jsr clklo + jsr datahi + jsr waitms +&iecout sei + jsr datahi + +l0 lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne l0 + ;lsr ; data in c + ;bcs nodev + and #DATAI + beq nodev + + jsr clkhi + bit eoifl + bpl l3 + ; eoi senden +l4 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRB ; wait data hi + cmp VIA1+VIA_DRB + bne l4 + ;lsr + ;bcc l4 + and #DATAI + bne l4 + +l5 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRB ; wait data lo + cmp VIA1+VIA_DRB + bne l5 + ;lsr + ;bcs l5 + and #DATAI + beq l5 + +l3 ; jsr testatn + ; bcs atnin + lda VIA1+VIA_DRB ; wait data hi + cmp VIA1+VIA_DRB + bne l3 + ;lsr + ;bcc l3 + and #DATAI + bne l3 + + jsr clklo + lda #8 + sta cnt2 + +#ifndef CLK1MHZ + jsr waitus2 +#endif + +l6 lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne l6 + ;lsr + ;bcc timexout + and #DATAI + bne timexout + + ror byte ; bit setzen + bcs l7 + jsr datalo + bne l8 +l7 jsr datahi + +l8 jsr clkhi + jsr waitus + + jsr dhiclo +#ifndef CLK1MHZ + jsr waitus3 +#endif + dec cnt2 + bne l6 + + jsr waitdlo + bcs timeout + rts +timeout lda #3 + .byt $2c +timexout lda #4 + jmp error + .) + /* +atnin jsr datalo + jsr clkhi + sec + rts +*/ +/* +testatn .( + lda VIA1+VIA_DRB + bmi tstatn + and #%00100000 + beq c +s sec + rts +tstatn and #%00100000 + beq s +c clc + rts + .) +*/ + + +clklo lda VIA1+VIA_DRB + ora #CLKO + sta VIA1+VIA_DRB + rts +clkhi lda VIA1+VIA_DRB + and #255-CLKO + sta VIA1+VIA_DRB + rts +datalo lda VIA1+VIA_DRB + ora #DATAO + sta VIA1+VIA_DRB + rts +datahi lda VIA1+VIA_DRB + and #255-DATAO + sta VIA1+VIA_DRB + rts +atnlo lda VIA1+VIA_DRB + ora #ATNA+ATNO + sta VIA1+VIA_DRB + rts +atnhi lda VIA1+VIA_DRB + and #255-ATNA-ATNO + sta VIA1+VIA_DRB + rts +atnalo lda VIA1+VIA_DRB + ;and #%11011111 + ora #ATNA + sta VIA1+VIA_DRB + rts +atnahi lda VIA1+VIA_DRB + ;ora #%00100000 + and #255-ATNA + sta VIA1+VIA_DRB + rts +dhiclo lda VIA1+VIA_DRB + ;and #%11111101 + ;ora #%00000100 + ora #CLKO + and #255-DATAO + sta VIA1+VIA_DRB + rts + +waitdlo + jsr setti +w1 jsr fragti + bne w2 + lda VIA1+VIA_DRB + cmp VIA1+VIA_DRB + bne w1 + ;lsr + ;bcs w1 + and #DATAI + beq w1 + clc + rts +w2 sec + rts + + +sectalk .( + sei + sta byte + jsr iec2out + bcs st1 + jsr datalo + jsr atnhi + jsr clkhi +st2 bit VIA1+VIA_DRB + ;bvs st2 + bvc st2 +st1 cli + rts + .) + +seclisten .( + sei + sta byte + jsr iec2out + jsr atnhi + cli + rts + .) + +&UNTALK .( + sei + jsr clklo + lda #$5f + jsr atnout + jsr atnhi + jsr clkhi + jsr datahi + cli + rts + .) + +&UNLISTEN .( + lda #$3f + sei + jsr atnout + jsr atnhi + jsr clkhi + cli + rts + .) + + +#undef VIA1 +#undef DATAO +#undef DATAI +#undef CLKO +#undef CLKI +#undef ATNO +#undef ATNI +#undef ATNA + + diff --git a/dump/oa-2.0.9/arch/gecko/fsiectst.a65 b/dump/oa-2.0.9/arch/gecko/fsiectst.a65 new file mode 100644 index 0000000..22bdbbb --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/fsiectst.a65 @@ -0,0 +1,4 @@ + +#define FSIEC_DEVICE "devices/siec_gecko.a65" +#include "apps/fs/fsiec.a65" + diff --git a/dump/oa-2.0.9/arch/gecko/gecko.a65 b/dump/oa-2.0.9/arch/gecko/gecko.a65 new file mode 100644 index 0000000..db0ce71 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/gecko.a65 @@ -0,0 +1,166 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM + +/* These are necessary for Gecko kernel ************************************/ + +#define NOSYSPORT +/*#define SYSPORT $7fe0*/ /* if mapped */ + +#define OSA_CPU "6502" +#define OSA_ARCH "Gecko" + +/* These are changeable ****************************************************/ + +#define GECKO_CSAEMU /* use CSA 6551 serial... */ +#define DEBUG + +#undef STACKCOPY + +#define RAMEND $80 +#define MIN_MEM $20 + +#define CLK2MHZ + +#undef CMOSCPU + +#define NEED_CHECKCHLD /* this is necessary if using "init" or + lib6502 */ +#define NEED_GETINFO +#define NEED_SLOCK +#define NEED_RENICE + +#define BOOTDRV "c" /* where are the boot files */ + +#define ROMSTART $8000 + +/***************************************************************************/ +/* Better not change anything below */ +/* */ + +#include "kdefs.i65" +#include "fdefs.i65" +#include "config.i65" +#include "kernel.i65" + +#define STDIOADDR $e000 + +/* Semaphore is needed to keep irtx and fsiec from interfering */ +#define SEM_T1 SEM_SERIEC + + .( + +/************* ROM entries */ + +/************* devices */ + +#include "devices/oadev.a65" + +/************* fsdev - converts devices into files */ + +#define FSDEV_AS_INIT +#include "sysapps/fs/fsdev.a65" + +/************* fsiec - IEEE488/IEC bus filesystem */ + +#define FSIEC_AS_INIT +#define FSIEC_DEVICE "devices/siec_gecko.a65" +#define NOLOOP +/* +#define NOFS +#define INVERT +#define NOCMD +*/ +#include "sysapps/fs/fsiec.a65" + +/************* mon - OS/A 1 old style monitor/shell */ + +#define MON_MONDEV 3 +#define MON_MONEXE $83 /* init-like, autostart */ +#define MON_SHDEV 0 +#define MON_SHEXE 0 +#undef SHORTMON +#undef NOSYSFKT +#define NOSH + +#include "sysapps/mon/mon.a65" + +/************* mon - OS/A 1 old style monitor/shell */ + +#ifdef DEBUG + +#define MON_MONDEV 5 +#define MON_MONEXE $83 /* init-like, autostart */ +#define MON_SHDEV 0 +#define MON_SHEXE 0 +#undef SHORTMON +#undef NOSYSFKT +#define NOSH + +#include "sysapps/mon/mon.a65" + +#endif + +/************* payload - irtx stereo control menu.. :-) */ + +#if 0 + +#define VIA $ec10 /* VIA for irtx */ +#include "sysapps/irtx/irtx.a65" + +#endif + +/************* end of ROM executables */ + + .word -1 + +/************* lib6502 code */ + +/* lib6502 jmp table is below STDIOADDR */ + +#include "lib6502/lib6502.a65" + +/*#include "oldlib/stdio.a65"*/ + +/************* fill not used area (I/O, screens) */ + + .dsb $f000-*,<-1 + +/************* Kernel */ + +#include "kernel/kernel.a65" + +/************* Constants for lib6502 memory handling */ + +Memstart = $1000 +Memend = ROMSTART +Zerostart= $60 + + .) + diff --git a/dump/oa-2.0.9/arch/gecko/gecko.i65 b/dump/oa-2.0.9/arch/gecko/gecko.i65 new file mode 100644 index 0000000..e2011a4 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/gecko.i65 @@ -0,0 +1,3 @@ + +#include "chips/via6522.i65" + diff --git a/dump/oa-2.0.9/arch/gecko/kernel/kenv.a65 b/dump/oa-2.0.9/arch/gecko/kernel/kenv.a65 new file mode 120000 index 0000000..1239cfb --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/kernel/kenv.a65 @@ -0,0 +1 @@ +../../c64/kernel/kenv.a65 \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/gecko/kernel/kinit.a65 b/dump/oa-2.0.9/arch/gecko/kernel/kinit.a65 new file mode 100644 index 0000000..e502a49 --- /dev/null +++ b/dump/oa-2.0.9/arch/gecko/kernel/kinit.a65 @@ -0,0 +1,135 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#define MEMCONFIG + +/*************************************************************************** + * + * This file is included in the RESET routine of the kernel, + * after the "sei:cld". The routine starting at the bginning + * of this file must initialize the hardware to the system RAM + * in the beginning and the system ROM in the end of the memory + * map. Also the system stack (pointer) is setup. + * + * In addition to that the system interrupt timer (needed for + * task preemtion) must be setup. + * + * After that the file must define the following macros: + * + * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz + * LEDPORT address of LED port to signal hardware failures + * LED_LED bit of LED bit in LEDPORT address + * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces + * the LED toggle routine if needed. + * CLRTIMER() clear the system interrupt timer interrupt + * KERNELIRQ() returns if an interrupt occured in the kernel + * or outside. Is checked by "BNE IRQ_in_Kernel" + * SAVEMEM() save system mem config for interrupt + * RESTOREMEM() restore system mem config after interrupt + * STARTMEM() This is used to alloc/enable memory pages found + * during kernel init. Takes mem size in AC as given + * by the kernel init. It is called _after_ inimem! + */ + +/* Kernel routines for C64 hardware */ + +/* + * init stack pointer for system stack + */ + ldx #<-1 + txs + +/* + * init memory configuration + */ + +/* ... none needed for Gecko */ + +/* + * C64 specific irq timer init, irq every 20ms + * We assume that the reset - or a loader program has disabled all irq + */ + +/* ... none for the Gecko - keydev provides us with a preemption irq */ + +/* + * check zeropage RAM, jump to he_zero if failure + */ +#include "kernel/zerotest.a65" + +/* + * check system RAM up to ROMSTART, jump to he_ram if failure + * returns available RAM in 256 byte blocks in AC + */ + .zero +cnt .byt 0 + .text +#include "kernel/ramtest.a65" + +/* + * originally SYSPORT specific, they have a value for the Gecko also... + */ +#ifdef CLK2MHZ +#define GETFREQ() lda #$80 +#else +#define GETFREQ() lda #$00 +#endif + +#define LEDPORT $ec04 +#define LED_LED %00001000 + +/* + * as we have set the CIA1 TB irq in the kernel, we have to clear the + * CIA interrupt flag. This is done with reading the ICRegister. + * With C64NEEDCIA1 one can disable reading the ICR here. But then you + * have to have a device that does it! + */ +/* ... none for the gecko - keydev provides the preemption irq */ + +#define CLRTIMER() + +/* + * MMU systems may map task pages into kernel mem to make copying + * easier. This mapping has to be preserved during interrupt. + * SAVEMEM() saves the memory configuration, while RESTOREMEM() + * restores it, obviously. + * These routines are called _after_ "jsr memsys", so this routine + * has to preserve this mapping when called from kernel space, + * and so must memtask. + */ + +#undef SAVEMEM +#define RESTOREMEM() + +/* + * Check if we have an interrupt in the kernel + */ + +#define KERNELIRQ() lda Syscnt:cmp #1 + +/* + * no memory management... + */ +#define STARTMEM() + + diff --git a/dump/oa-2.0.9/arch/pet32k/Makefile b/dump/oa-2.0.9/arch/pet32k/Makefile new file mode 100644 index 0000000..19522d8 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/Makefile @@ -0,0 +1,23 @@ + +TRG=boot/rom + +XAINPUT=../../include,..,../.. +XA=xa +FILE=file65 +RELOC=reloc65 + +pet ${TRG}: + ${XA} -I../../include -I../.. -R -bt 4862 -bd 768 -bz 8 -bb 2432 rom.a65 -o rom.o65 -l rom.lab; + ${FILE} rom.o65; + ${RELOC} -xt -o ${TRG} rom.o65; + +rom2 ${TRG}2: + ${XA} -DHAVE_MON -I../../include -I../.. -R -bt 5030 -bd 768 -bz 8 -bb 2656 rom.a65 -o rom.o65 -l rom.lab; + ${FILE} rom.o65; + ${RELOC} -xt -o ${TRG}2 rom.o65; + +clean: + rm -f ${TRG} rom.lab rom.o65 boot.tgz + (cd boot; ${MAKE} clean;) + # (cd apps; ${MAKE} clean;) + diff --git a/dump/oa-2.0.9/arch/pet32k/boot/Makefile b/dump/oa-2.0.9/arch/pet32k/boot/Makefile new file mode 100644 index 0000000..fe04266 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/boot/Makefile @@ -0,0 +1,56 @@ + +apps = lsh +sysapps = mon # slipd +files = mkdir rmdir rm format chkdsk ls cat mv +inet = # tlogin telnet httpd + +XA=xa + +all: rom ${files} ${apps} ${sysapps} ${inet} + +rom rom2: + (cd ..; ${MAKE} boot/$@;) + +clean: + rm -f rom rom2 osa.d64 osam.d64 osa.x64 + rm -f ${files} ${sysapps} ${apps} ${inet} + rm -f vice.trace reltest + +tar ../boot.tgz: rom loader howto.boot + tar czvf ../boot.tgz rom loader howto.boot + +############################################################################## +# +# d64 emulator disk image + run +# + +osa.d64: ${files} ${sysapps} ${apps} ${inet} rom loader rom2 loaderm + ./mkdisk ${files} ${sysapps} ${apps} ${inet} rom loader rom2 loaderm + dd if=osa.x64 of=osa.d64 bs=64 skip=1 + rm osa.x64 + +emurun: osa.d64 + xpet -8 osa.d64 + +############################################################################## +# +# lib6502 programs +# + +${apps}: + (cd ../../../apps/lsh; make lsh;) + (if test ! -r lsh; then ln -s ../../../apps/lsh/lsh lsh; fi) + +${sysapps}: + (cd ../../../sysapps/$@; make $@;) + (if test ! -r $@; then ln -s ../../../sysapps/$@/$@ $@; fi) + +${files}: + (cd ../../../apps/file; make $@;) + (if test ! -r $@; then ln -s ../../../apps/file/$@ $@; fi) + +${inet}: + (cd ../../../apps/inet; make $@;) + (if test ! -r $@; then ln -s ../../../apps/inet/$@ $@; fi) + + diff --git a/dump/oa-2.0.9/arch/pet32k/boot/howto.boot b/dump/oa-2.0.9/arch/pet32k/boot/howto.boot new file mode 100644 index 0000000..e40a827 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/boot/howto.boot @@ -0,0 +1,13 @@ + +Howto Boot the GeckOS/A65 on 8x96 +------------------------------------- + +1) transfer all files in this directory to a (1541) disk. (osa.d64) + +2) put this disk to a CBM2031/CBM4040 or other IEEE488 disk drive + connected with to the 8x96. + +3) load the file "loader" on the 8x96 and run it + After a while the new OS should come up and running + (Repeat switches between virtual terminals) + diff --git a/dump/oa-2.0.9/arch/pet32k/boot/loader b/dump/oa-2.0.9/arch/pet32k/boot/loader new file mode 100644 index 0000000..ded4580 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/boot/loader Binary files differ diff --git a/dump/oa-2.0.9/arch/pet32k/boot/loader11 b/dump/oa-2.0.9/arch/pet32k/boot/loader11 new file mode 100644 index 0000000..dd018ba --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/boot/loader11 Binary files differ diff --git a/dump/oa-2.0.9/arch/pet32k/boot/loaderm b/dump/oa-2.0.9/arch/pet32k/boot/loaderm new file mode 100644 index 0000000..c545c4f --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/boot/loaderm Binary files differ diff --git a/dump/oa-2.0.9/arch/pet32k/boot/loaderm11 b/dump/oa-2.0.9/arch/pet32k/boot/loaderm11 new file mode 100644 index 0000000..6e5f27f --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/boot/loaderm11 Binary files differ diff --git a/dump/oa-2.0.9/arch/pet32k/boot/mkdisk b/dump/oa-2.0.9/arch/pet32k/boot/mkdisk new file mode 100755 index 0000000..ddfd9b8 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/boot/mkdisk @@ -0,0 +1,24 @@ +#!/bin/sh + +echo "set tmpfile" +tmpfile=/tmp/mkdisk.$user.$$ + +#echo "get files" +#files=`ls *` + +files="$*" + +echo "files=$files" + +echo "format osa,65 x64 osa.x64" > $tmpfile + +for i in $files; do + if test "$i" != "mkdisk" -a "$i" != "osa.d64" ; then + echo "write $i" >> $tmpfile + fi +done + +cat $tmpfile | c1541 > /dev/null + +rm -f $tmpfile + diff --git a/dump/oa-2.0.9/arch/pet32k/config.i65 b/dump/oa-2.0.9/arch/pet32k/config.i65 new file mode 100644 index 0000000..597aac0 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/config.i65 @@ -0,0 +1,76 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef _PETCONFIG_ +#define _PETCONFIG_ + +#echo ******** PET config ********** + + +/* StreamData */ + +#define ANZSTRM 16 /* number of streams */ + +/* SemaphoreData */ + +#define ANZSEM 8 /* number of semaphores - multiple of 8 */ +#define SYSSEM 8 /* multiple of 8, no of system semaphores + i.e. sems from -SYSSEM to -1 */ + +/* DeviceData */ + +#define MAXDEV 16 /* maximum number of devices */ + +/* EnvData */ + +#define MAXENVS 1 /* one environment only */ + +#ifndef STACKCOPY +#define MAXNTHREADS 5 /* (Stackpage-56)/40 */ +#define MAXNTASKS 5 +#define STACKSIZE 40 /* (TH_SLEN * 5) */ +#else +#define MAXNTHREADS 12 /* (up to 16 is possible, if enough memory) */ +#define MAXNTASKS 12 +#define STACKSIZE 64 /* (TH_SLEN * 8) */ +#endif +#define ANZXENV 5 /* number of redirectable task IDs */ + +/* TaskData */ + +#define IRQCNT 3 /* default priority for ROM-started tasks */ + +/* FileManager */ + +#define MAXFS 4 /* maximum number of fileserver tasks */ + +/* we don't map any of these memory areas */ +#undef MAP_ZERO +#undef MAP_STACK +#undef MAP_MEM + +/* graphics keyboard */ +#define PET_KEYB_GRAPHICS + +#endif /* _PETCONFIG_ */ + diff --git a/dump/oa-2.0.9/arch/pet32k/devices/con_pet.a65 b/dump/oa-2.0.9/arch/pet32k/devices/con_pet.a65 new file mode 100644 index 0000000..1486bd4 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/devices/con_pet.a65 @@ -0,0 +1,235 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#define PIO $e810 +#define VIA1 $e840 +#define vdcctrl $e888 +#define vdc $e880 +#define VIDPAGE 4 + +#define MAX_SCREEN 2 /* hard limit for tables */ + +#define MAX_ASCREEN #2 /* soft limit */ + +;#define SWITCHKEY 23 +#define SWITCHKEY 79 + +#define SET_MMU + +#define BELLIRQ jsr bellirq + +#define TRIGBELL jsr trigbell + +#define MAXSPAL numcols + +#define MAXZEIL #25 +;#define MAXZEIL #23 /* debug */ + +#define KEY_START 16 /* when does key repetition start */ + + /* screen# -> hi byte of base address in AC */ +/* #define HI_VID asl:asl:bit freq:bpl l1:asl:l1 clc:adc #VIDPAGE<<4 */ +/* #define HI_VID asl:asl:asl:clc:adc #$90 */ +#define HI_VID + +#define ACT_HI_VID .( :\ + lda screen :\ + cmp actscr :\ + beq orig :\ + lda #$78 :\ + .byt $2c :\ +orig lda #$80 :\ + .) + +#define SCR_SPACE " " /* screencode space */ + + /* ASCII to PET screen code */ +#define ASC2SCR .( :\ + and #$7f :\ + cmp #64 :\ + bcc ok :\ + beq zero :\ + cmp #91 :\ + bcc ok :\ + cmp #97 :\ + bcc tab1 :\ + cmp #123 :\ + bcs tab2 :\ + sbc #95 :\ + bne ok :\ +tab2 tay :\ + lda ctab2-123,y :\ + bne ok :\ +tab1 tay :\ + lda ctab1-91,y :\ + .byt $2c :\ +zero lda #0 :\ +ok .) + +#define SCR2ASC .( :\ + and #$7f :\ + beq at :\ + cmp #27 :\ + bcs x1 :\ + adc #96 :\ + bne ok :\ +x1 cmp #32 :\ + bcc tab1 :\ + cmp #91 :\ + bcc ok :\ + tay :\ + lda atab2-91,y :\ + bcs ok :\ +tab1 tay :\ + lda atab1-27,y :\ + .byt $2c :\ +at lda #64 :\ +ok .) :\ + +&ctab1 .byt 27, 28, 29, 30, 100, 124 +&ctab2 .byt 115, 93, 107, 112, 122 +&atab1 .byt 91, 0, 93, 94, 0 +&atab2 .byt 0,0,124,0,0,0,0,0,0,95,0,0,0,0,0,0,125,0,0,0,0,126,0,0,123 + .byt 0,0,0,0,0,0,127,0,96,0,0,0 + +#define DO_IRQ .( :\ + bit actchange :\ + bpl ok :\ + cpy actscr :\ + bne ok :\ + ldx zeile :\ + jsr setzei :\ + ldy screen :\ +ok .) + + .data +&actchange .byt 0 +&numcols .byt 0 + .text + +&console_init .( + jsr inimem + jsr inivid + jsr inikbd + jsr inicrsr + jsr inibell + rts + .) + +inimem .( + clc + rts + .) + +&inivid .( + lda screen + bne ix + + lda #0 + sta $8000 + sta $8400 + inc $8000 + lda $8400 + bne col40 + lda #80 + .byt $2c +col40 lda #40 + sta numcols + + lda PETVIA+VIA_PCR + and #%11111111 + ora #%00001110 + sta PETVIA+VIA_PCR + +/* we assume the CRTC to be initialized... + ldx #0 +i1 bit freq + lda vdc4tab,x + stx vdc + sta vdc+1 + inx + cpx #16 + bcc i1 +*/ +ix + rts + +/* vdc8tab .byt $7e,$50,$64,6,$29,0,$19,$21,0,7,$60,7,0,0,0,0 */ + +/* vdc4tab .byt $3f,$28,$32,3,$29,0,$19,$21,0,7,$60,7,0,0,0,0 */ + + .) + +&setact .( + +scrbuf =$7800 + + .zero +p1 .word 0 +p2 .word 0 + .text + + cpx actscr + bne doit + rts +doit + sec + ror actchange + + lda #0 + sta p1 + sta p2 + lda #$78 + sta p1+1 + lda #$80 + sta p2+1 + + lda numcols + cmp #40 + beq dohalf + ldx #8 + .byt $2c +dohalf ldx #4 + + ldy #0 +cp1 lda (p2),y + pha + lda (p1),y + sta (p2),y + pla + sta (p1),y + iny + bne cp1 + inc p2+1 + inc p1+1 + dex + bne cp1 + + ldx zeile + jmp setzei + + .) + +#include "devices/kbd_pet.a65" + + diff --git a/dump/oa-2.0.9/arch/pet32k/devices/devices.a65 b/dump/oa-2.0.9/arch/pet32k/devices/devices.a65 new file mode 100644 index 0000000..d45a6d5 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/devices/devices.a65 @@ -0,0 +1,71 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ROM + +#include "kdefs.def" +#include "kernel.i65" + + ;.word $700 + *=$700 + +/*#define NOPRG*/ + +#endif + + +/* Device-Block */ + + .( + +#ifdef ROM + .word endd + .byt PK_DEV+$80 + .word devstart + .dsb P_NAME - P_RAM, $ff + .asc "devices",0 +#else +#ifndef NOPRG + .word 0 + .byt PK_DEV + .byt 0 + .word 0 + .word devstart + .byt 0,0,<-1 +#endif +#endif + +devstart + + +#define CONSOLE_DEVICE "devices/con_pet.a65" +#include "devices/console.a65" ; video device is merged with OS/A now... + +#include "devices/nulldev.a65" ; null device +#include "devices/spooler.a65" ; spooler device + + .word $ffff + +endd .) + diff --git a/dump/oa-2.0.9/arch/pet32k/devices/kbd_pet.a65 b/dump/oa-2.0.9/arch/pet32k/devices/kbd_pet.a65 new file mode 120000 index 0000000..afae968 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/devices/kbd_pet.a65 @@ -0,0 +1 @@ +../../cbm8x96/devices/kbd_pet.a65 \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/pet32k/devices/piec_pet.a65 b/dump/oa-2.0.9/arch/pet32k/devices/piec_pet.a65 new file mode 120000 index 0000000..cd8b6d7 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/devices/piec_pet.a65 @@ -0,0 +1 @@ +../../cbm8x96/devices/piec_pet.a65 \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/pet32k/kernel/kenv.a65 b/dump/oa-2.0.9/arch/pet32k/kernel/kenv.a65 new file mode 100644 index 0000000..418405d --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/kernel/kenv.a65 @@ -0,0 +1,424 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* TODO: make stack addr computation a table lookup, which is faster */ + +/* Struct Task Environment Entry */ + +/* we have three structs now: + * TE_* for task environment handling - not needed for system without + * memory management + * TT_* task table, contains STD streams, etc + * TH_* thread table, has stack info and state + */ + +#define TE_SLEN 0 /* we don't have envs */ + +/************************************************************************ + * These routines are needed in the env section! + * inienv + * setthread + * initsp + * push + * pull + * memtask + * memsys + * + * sbrk + * getenv + * freenv + */ + +&&enmem = notimp ; to enable memory blocks to the kernel +&&setblk = notimp ; to set memory blocks in MMU mapping + +#ifdef STACKCOPY + .zero +zp .word 0 + + .data + +Stacks .dsb MAXNTHREADS * STACKSIZE + + .text +#endif + + +&inienv .( + lda #<-1 + sta actThread + sta actTask + lda #1 + sta Syscnt + clc + rts + .) + +setthread .( + .data +newThread .byt 0 + .text + + cmp actThread + bne doit + rts +doit + sta newThread + + ldx actThread + cpx #<-1 + beq nosave + + lda THREADSAVE + sta threadTab + TH_LIBSAVE,x + lda THREADSAVE+1 + sta threadTab + TH_LIBSAVE+1,x + +#ifdef STACKCOPY + txa ; stack is 8 * TH_SLEN = 64 + ldy #0 + sty zp+1 + asl + rol zp+1 + asl + rol zp+1 + asl + rol zp+1 + clc + adc #Stacks + adc zp+1 + sta zp+1 + ;bcc l1 + ;inc zp+1 +;l1 + lda threadTab + TH_SP,x + tay + iny +l2 cpy #STACKSIZE + bcs savetask + lda $100,y + sta (zp),y + iny + bne l2 +#endif +savetask + ldy threadTab + TH_TASK,x + lda TASKSAVE + sta taskTab + TT_LIBSAVE,y + lda TASKSAVE + 1 + sta taskTab + TT_LIBSAVE + 1,y +nosave +loadtask + ldx newThread + stx actThread + cpx #<-1 + bne load + stx actTask + beq noload +load + ldy threadTab + TH_TASK,x + sty actTask + + lda taskTab + TT_LIBSAVE,y + sta TASKSAVE + lda taskTab + TT_LIBSAVE + 1,y + sta TASKSAVE + 1 + +loadthread + lda threadTab + TH_LIBSAVE,x + sta THREADSAVE + lda threadTab + TH_LIBSAVE+1,x + sta THREADSAVE+1 + +#ifdef STACKCOPY + txa + ldy #0 + sty zp+1 + asl + rol zp+1 + asl + rol zp+1 + asl + rol zp+1 + clc + adc #Stacks + adc zp+1 + sta zp+1 + ;bcc l3 + ;inc zp+1 +;l3 + lda threadTab + TH_SP,x + tay + iny +l4 cpy #STACKSIZE + bcs endset + lda (zp),y + sta $100,y + iny + bne l4 +#endif +noload +endset rts + .) + +initsp .( +#ifdef STACKCOPY + lda #STACKSIZE-1 + ;ldx actThread + sta threadTab + TH_SP,x + rts +#else + .data +divsp .byt 0 + .text + + ;ldx actThread + txa + clc + adc #TH_SLEN + sta divsp + asl + asl ; split stack + clc + adc divsp + sta threadTab + TH_SP,x + dec threadTab + TH_SP,x + rts +#endif + .) + +pull .( + ldx actThread + inc threadTab + TH_SP,x + lda threadTab + TH_SP,x + tay + lda $0100,y + rts + .) + +&push .( + pha + ldx actThread + lda threadTab + TH_SP,x + tay + pla + sta $0100,y + dec threadTab + TH_SP,x + rts + .) + + .( + .zero +AC .byt 0 +XR .byt 0 +YR .byt 0 +SR .byt 0 +ADR .word 0 +&SSP .byt 0 + .text + +/* + * this one is used to return from an interrupt. We do not need to save + * any registers. so for brevity, we do it as macro + * This doesn't check for interrupted devices, as we do not have them + * without MMU (so far). + */ + +#define MEMTASK2() \ + .( :\ + sei :\ + dec Syscnt :\ + bne mtask :\ + tsx :\ + stx SSP :\ +; ldy actTask :\ +; ldx taskTab+TT_ENV,y :\ +; beq system :\ +; ldx #%10001100 :\ +; stx $fff0 :\ +;system :\ + ldy actThread :\ + ldx threadTab+TH_SP,y :\ + txs :\ +mtask .) + +/* + * This is the standard return to user space. the kernel jumps here, + * so we need not save any return address, but use the one on the + * user stack. + */ +&&memtask .( + php + sei + dec Syscnt ; wieder in Task + bne mtask ; nein dann Ende + + bit adev ; Ruecksprung in Device + bpl mtask ; ja dann Ende + + sty YR ; sonst Task-Env setzen + stx XR + sta AC + pla ; SR + + tsx + stx SSP + + ldy actThread + ldx threadTab+TH_SP,y + txs + +; ldy actTask +; ldx taskTab+TT_ENV,y +; beq system +; ldx #%10001100 ; map alternate 8x96 memory bank +; stx $fff0 +;system + + pha ; SR + lda AC + ldy YR + ldx XR +mtask + plp + rts + .) + +/* + * This is the kernel entry routine. It leaves all registers as they + * are, except for the stack pointer, which is set to the system stack. + * also the return address is moved from user stack to system stack, + * to allow "JSR"-ing to memsys. + */ +&&memsys php + sei + pha + +; lda #%11100000 ; map system memory +; sta $fff0 + + lda Syscnt + inc Syscnt + cmp #0 + bne mse + bit adev ; called by device + bmi msys ; no then save stack +mse pla + plp + rts + +msys pla + sta AC + pla + sta SR + stx XR + ; sty YR + pla + sta ADR + pla + sta ADR+1 + tsx + + txa + ldx actThread + sta threadTab+TH_SP,x + ldx SSP + txs + lda ADR+1 + pha + lda ADR + pha + lda SR + pha + lda AC + ldx XR + ; ldy YR + plp + cld + rts + .) + + +&&sbrk .( + bcc ok + sec + lda #E_NOMEM + rts +ok lda #>ROMSTART ; return available memory + clc + rts + .) + +kgetenv .( + ldx #0 +; tya +; bne system +; inx +system + clc + rts + .) + +freenv .( + clc + rts + .) + +/* + * MAPSYSBUF() maps the PCBUF of the active task into the system memory + * at address SYSBUF. It's not needed in a C64... + */ +#undef MAPSYSBUF +#define SYSBUF $200 + +/* + * MAPENV() maps the address given in a/y in env x to somewhere in the + * kernel map. returns mapped address in a/y + * MAPAENV() does the same but for the actual task (env) + */ +#define MAPENV() +#define MAPAENV() + + +/* + * needed for GETINFO, gives RAM available for task + */ +#define GETTASKMEM lda #>ROMSTART + +/* + * copy routines for SEND/RECEIVE and FORK + */ +#undef CPPCBUFRX +#undef CPPCBUFTX +#define CPFORKBUF() + +/* + * needed in device code to get active environment in AC + */ +#define GETACTENV() lda #<-1 + + diff --git a/dump/oa-2.0.9/arch/pet32k/kernel/kinit.a65 b/dump/oa-2.0.9/arch/pet32k/kernel/kinit.a65 new file mode 100644 index 0000000..0bb9bcc --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/kernel/kinit.a65 @@ -0,0 +1,142 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * This file is included in the RESET routine of the kernel, + * after the "sei:cld". The routine starting at the bginning + * of this file must initialize the hardware to the system RAM + * in the beginning and the system ROM in the end of the memory + * map. Also the system stack (pointer) is setup. + * + * In addition to that the system interrupt timer (needed for + * task preemtion) must be setup. + * + * After that the file must define the following macros: + * + * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz + * LEDPORT address of LED port to signal hardware failures + * LED_LED bit of LED bit in LEDPORT address + * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces + * the LED toggle routine if needed. + * CLRTIMER() clear the system interrupt timer interrupt + * KERNELIRQ() returns if an interrupt occured in the kernel + * or outside. Is checked by "BNE IRQ_in_Kernel" + * SAVEMEM() save system mem config for interrupt + * RESTOREMEM() restore system mem config after interrupt + * STARTMEM() This is used to alloc/enable memory pages found + * during kernel init. Takes mem size in AC as given + * by the kernel init. It is called _after_ inimem! + */ + +/* Kernel routines for C64 hardware */ + +/* + * init stack pointer for system stack + */ + ldx #<-1 + txs + +/* + * check zeropage RAM, jump to he_zero if failure + * clears zeropage - at least 2-7 is a _must_! + */ +#include "kernel/zerotest.a65" + +/* + * init memory configuration - set IRQ vector on 32k PETs + * (must be after zerotest... ) + */ + lda #petirqjmp + sta $91 + lda #petbrkjmp + sta $93 + +/* + * C64 specific irq timer init, irq every 20ms + * We assume that the reset - or a loader program has disabled all irq + */ + + lda #%00000001 ; enable PIA1 CB1 screen retrace timer + sta PETPIA1+PIA_CRA + + +/* + * check system RAM from RAMSTAT up to RAMEND, jump to he_ram if failure + * returns available RAM in 256 byte blocks in AC + */ +#if 0 /* we don't need it - assume normal boot did it already */ + .zero +cnt .byt 0 + .text +#include "kernel/ramtest.a65" + cmp #MIN_MEM + bcs ok + lda #0 + sta $fff0 + jmp ($fffc) +ok +#endif + +/* + * originally SYSPORT specific, they have a value for the C64 also... + */ +#define GETFREQ() lda #0 + +#undef LEDPORT +#undef LED_LED + +/* + * We have to clear the interrupt timer + */ + +#define CLRTIMER() lda PETPIA1+PIA_PA + +/* + * MMU systems may map task pages into kernel mem to make copying + * easier. This mapping has to be preserved during interrupt. + * SAVEMEM() saves the memory configuration, while RESTOREMEM() + * restores it, obviously. + * These routines are called _after_ "jsr memsys", so this routine + * has to preserve this mapping when called from kernel space, + * and so must memtask. + */ + +#undef SAVEMEM +#undef RESTOREMEM + +/* + * Check if we have an interrupt in the kernel + */ + +#define KERNELIRQ() lda Syscnt:cmp #1 + +/* + * no memory management... + */ +#define STARTMEM() + diff --git a/dump/oa-2.0.9/arch/pet32k/petdef.i65 b/dump/oa-2.0.9/arch/pet32k/petdef.i65 new file mode 100644 index 0000000..2fe226b --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/petdef.i65 @@ -0,0 +1,34 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * These are the C64 specific defines + */ + +#define PETPIA1 $e810 +#define PETPIA2 $e820 +#define PETVIA $e840 + +#include "chips/pia6521.i65" +#include "chips/via6522.i65" + diff --git a/dump/oa-2.0.9/arch/pet32k/rom.a65 b/dump/oa-2.0.9/arch/pet32k/rom.a65 new file mode 100644 index 0000000..fe63f37 --- /dev/null +++ b/dump/oa-2.0.9/arch/pet32k/rom.a65 @@ -0,0 +1,190 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM +#undef EMUTEST + +/* These are necessary for PET kernel **************************************/ + +#define NOMMU +#define NOSYSPORT +#undef CLK2MHZ /* we only have approx. 1 MHz ... */ +#undef CMOSCPU /* ... and no CMOS cpu */ +#define VIDPAGE 8 +#undef SHORTLINE /* prepare for 80 col screen */ + +#undef NMIDEV /* there is no NMI in the PET machine */ +#define EOK_NOFILL /* do not fill kernel to end of mem */ + +#undef PET_KEYB_GRAPHICS /* en business keyboard is default */ + +#define OSA_CPU "6502" +#define OSA_ARCH "PET32K" + +/* These are changeable ****************************************************/ + +#ifdef HAVE_MON +#define ROMSTART $13ab /* where the ROM starts */ +#else +#define ROMSTART $1303 /* where the ROM starts */ +#endif + +#define STACKCOPY /* if defined, save stack area in memory + when context switching, otherwise divide + stack area and give each task a part. + It's faster without, but allows more + tasks with */ + +#define NEED_CHECKCHLD /* this is necessary if using "init" or + lib6502 */ +#define NEED_GETINFO +#define NEED_SLOCK +#define NEED_RENICE + +#define BOOTDRV "b" /* where are the boot files */ + +#define ROOTPATH "b:" /* where lsh chdirs into on boot */ + + +/*************************************************************************** + * + * Here comes the ROM content + */ + +#include "config.i65" +#include "kdefs.i65" +#include "fdefs.i65" +#include "petdef.i65" + +#include "kernel.i65" + +#define SEM_VIAE840_T1 SEM_SERIEC +#undef SEM_SERIEC +#undef SEM_PARIEC + + .word *+2 /* load address */ + jmp RESET + ; ROMSTART is here! +.( + +/************* ROM entries */ + +/************* devices */ + +#include "devices/devices.a65" + +/************* init process */ + + +#define INIT_VERBOSE +#define INIT_RESTART +#define INIT_MERGE +#define INIT_LIB6502 +/* #define INIT_USE_STDLIB */ +/* #define INIT_OUTDEV 2*/ +#include "sysapps/init/init.a65" + + +/************* fsdev - converts devices into files */ + +#define FSDEV_NOROM +#include "sysapps/fs/fsdev.a65" + + +/************* fsiec - IEEE488/IEC bus filesystem */ + +/* both, the parallel and serial iec bus use the same timer */ +#define SEM_CIA2TB SEM_SERIEC +#undef SEM_PARIEC +#undef SEM_SERIEC + +#define NOLOOP +#define FSIEC_DEVICE "devices/piec_pet.a65" +#include "sysapps/fs/fsiec.a65" +#undef FSIEC_DEVICE +#print * + + +/************* mon - OS/A 1 old style monitor/shell */ + +#ifdef HAVE_MON + +#define MON_SHEXE $c0 /* executable flag -> autostart+restart*/ +/*#define MON_SHEXE $83*/ /* executable flag -> init process+autostart*/ +#define MON_MONEXE 0 /* ROM executable flag */ +#define MON_SHDEV 1 /* start on device 0 = video1 */ +#define SHORTMON /* no assembler/disassembler */ +#define NOSH +#include "sysapps/mon/mon.a65" + +#endif + +/************* boot lsh from BOOTDRV */ + +#if 1 + /* add autostart of lib6502 program 'lsh' */ + + .( + .word end_auto + .byt PK_LIB+PK_AUTOEXEC+PK_RESTART ; is lib6502 program + .word 0 ; P_ADDR ignored + .byt 16 ; P_RAM + .byt 128 ; P_SHARED + .byt 0 ; P_PRIORITY + .byt 0,0 ; P_DEV + .byt BOOTDRV,":lsh",0,"-v", 0, "-d", 0,ROOTPATH,0,0 +end_auto + .) + +#endif + +/************* end of ROM executables */ + + .word -1 + +/************* lib6502 code */ + +#define LIB6502_NONET +#include "lib6502/lib6502.a65" + +/************* Kernel */ + +#include "kernel\kernel.a65" + +/************* Constants for lib6502 memory handling */ + +#ifdef HAVE_MON +Memstart =$6400 +#else +Memstart =$5440 +#endif +Memend =$7800 +Zerostart =$94 /* PET ROM irq vectors at $90-$93 */ + +.) + diff --git a/dump/oa-2.0.9/arch/proto/Makefile b/dump/oa-2.0.9/arch/proto/Makefile new file mode 100644 index 0000000..3360ef9 --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/Makefile @@ -0,0 +1,19 @@ + +TRG=boot/rom + +XAINPUT=../../include,..,../.. +XA=XAINPUT=${XAINPUT} xa +FILE=file65 +RELOC=reloc65 + +rom ${TRG}: + ${XA} -R -bt 32766 -bd 768 -bz 8 -bb 2560 rom.a65 -o rom.o65 -l rom.lab ; + ${FILE} rom.o65; + ${RELOC} -xt -o ${TRG} rom.o65; + + +clean: + rm -f ${TRG} rom.lab rom.o65 boot.tgz + (cd boot; ${MAKE} clean;) + # (cd apps; ${MAKE} clean;) + diff --git a/dump/oa-2.0.9/arch/proto/boot/Makefile b/dump/oa-2.0.9/arch/proto/boot/Makefile new file mode 100644 index 0000000..bd8b636 --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/boot/Makefile @@ -0,0 +1,12 @@ + +XA=xa + +all: rom + +rom: + (cd ..; ${MAKE};) + +clean: + rm -f rom + + diff --git a/dump/oa-2.0.9/arch/proto/config.i65 b/dump/oa-2.0.9/arch/proto/config.i65 new file mode 100644 index 0000000..8e6656f --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/config.i65 @@ -0,0 +1,71 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#echo ******** c64 config ********** + + +#ifndef ANZSTR + +/* StreamData */ + +#define ANZSTRM 8 + +/* SemaphoreData */ + +#define ANZSEM 8 /* vielfaches von 8 */ +#define SYSSEM 8 /* vielfaches von 8, sem-nr von -SYSSEM bis -1 */ + +/* DeviceData */ + +#define MAXDEV 16 + +/* EnvData */ + +#define MAXENVS 1 /* one environment only */ + +#ifndef STACKCOPY +#define MAXNTHREADS 5 /* (Stackpage-56)/40 */ +#define MAXNTASKS 5 +#define STACKSIZE 40 /* (TH_SLEN * 5) */ +#else +#define MAXNTHREADS 8 /* (up to 16 is possible, if enough memory) */ +#define MAXNTASKS 5 +#define STACKSIZE 64 /* (TH_SLEN * 8) */ +#endif +#define ANZXENV 5 /* number of redirectable task IDs */ + +/* TaskData */ + +#define IRQCNT 3 + +/* FileManager */ + +#define MAXFS 4 + +/* we don't map any of these memory areas */ +#undef MAP_ZERO +#undef MAP_STACK +#undef MAP_MEM + +#endif + diff --git a/dump/oa-2.0.9/arch/proto/devices/oa1std.a65 b/dump/oa-2.0.9/arch/proto/devices/oa1std.a65 new file mode 100644 index 0000000..729127e --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/devices/oa1std.a65 @@ -0,0 +1,297 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/**************************************************************************/ +/* */ +/* Standard-Device-Programm zur einfachen Erstellung einer anderen Device */ +/* */ +/**************************************************************************/ + + .( + .word devend + jmp prg1 + .asc "name",0 + + .data +status .byt 0 +instr .byt 0 +outstr .byt 0 + .text + +prg1 cmp #DC_RES + beq devini + + pha + lda status + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts + +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini lda #0 + sta status + sta instr + sta outstr + +/************************ Reset ************************************/ + +/******* go on here, or on error go to devx ************************/ + +rts1hi + +/***************** here if stream over highwatermark ***************/ + +/*******************************************************************/ + + clc + rts + +devx lda status + ora #2 + sta status + lda #E_NOTIMP + sec + rts + +devirq .( + +/********************* is IRQ for device? no, then irqend **********/ + +/************************ here if irq for device *******************/ + + lda status + bpl tx + +/**** receive byte to ac, no byte then nobyt ***********************/ + +/*******************************************************************/ + + ldx outstr + jsr PUTC + bcs test + +nobyt ldx outstr + lda #SC_STAT + jsr STRCMD + +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx + +tstwater cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh jsr rts1hi + bcc tx ; unbedingt +twl cmp #E_SLWM + bne tx + +wl +/******** here if stream below lowwatermark ************************/ + +/*******************************************************************/ + +tx lda status + rol + bpl irqhs + +/******* hardware ready to send? if not then irqhs *****************/ + +/*******************************************************************/ + + ldx instr + jsr GETC + bcs test2 + +/***************** send byte ***************************************/ + +/*******************************************************************/ + + jmp irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs + +/**************** remove IRQ and clean up **************************/ + +/*******************************************************************/ + + lda #E_OK ; interrupt source removed + rts +irqend + lda #E_NOIRQ ; no interrupt source removed + rts + + .) + +others cmp #DC_GS + bne o1 + lda status + and #DC_SW_TX + bne devonx + sty instr + jmp ok +devonx jmp devon +o1 cmp #DC_PS + bne o2 + lda status + and #DC_SW_RX + bne devonx + sty outstr +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + +/********************* check if receive possible ******************/ + +/************************ if not then onotimp *********************/ + + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + +/********************* check if send possible ********************/ + +/************************ if not then onotimp ********************/ + + lda #DC_SW_TX +o2a ora status + sta status + bne okx +o4 cmp #DC_RX_OFF + bne o5 + +rxoff lda status + and #DC_SW_RX + beq devoffx + ldx outstr + lda #SC_EOF + jsr STRCMD + lda status + and #255-DC_SW_RX + sta status + jsr rts1hi + bcc okx +devoffx jmp devoff +o5 cmp #DC_TX_OFF + bne o6 + +txoff lda status + and #DC_SW_TX + beq devoffx + ldx instr + lda #SC_NUL + jsr STRCMD + lda status + and #255-DC_SW_TX + sta status + jmp ok + +o6 cmp #DC_HS + bne o6a + +/******************** here Handshake ************************/ + + lda status + and #255-1 + sta status + tya + and #1 + ora status + sta status + +/***********************************************************/ + + jmp ok + +o6a cmp #DC_SPD + bne o7 + +/****************** here speed *****************************/ + +/***********************************************************/ + + jmp ok + +o7 cmp #DC_ST + bne o8 + + lda status + and #2 + bne onotimp + +/****************** here state request *********************/ + +/***********************************************************/ + + jmp ok + +o8 cmp #DC_EXIT + bne onotimp + jsr rxoff + jsr txoff + lda status + ora #2 + sta status + +/****************** disable device ************************/ + +/*********************************************************************/ + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +/******************** subprograms, includes, etc *********************/ + +/*********************************************************************/ + +devend .) + diff --git a/dump/oa-2.0.9/arch/proto/devices/oa1stds.a65 b/dump/oa-2.0.9/arch/proto/devices/oa1stds.a65 new file mode 100644 index 0000000..2ead320 --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/devices/oa1stds.a65 @@ -0,0 +1,330 @@ +/**************************************************************************** + + OS/A65 Version 1.3.3 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/**************************************************************************/ +/* */ +/* Standard-Device-Programm zur einfachen Erstellung von anderen Devices */ +/* */ +/**************************************************************************/ + +#define Anzdev 1 + + .( + .word devend + jmp prg1 + .asc "name1",0 +/* +devend1 .word devend + jmp prg2 + .asc "name2",0 +*/ +dev =sysmem +status =sysmem+1 +instr =sysmem+Anzdev+1 +outstr =sysmem+Anzdev*2+1 +-sysmem +=Anzdev*3+1 + +prg1 ldx #0 +/* + .byt $2c +prg2 ldx #1 +*/ + stx dev + cmp #DC_RES + beq devini + + pha + lda status,x + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts + +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini lda #0 + sta status,x + sta instr,x + sta outstr,x + +/************************ Reset ************************************/ + +/******* hier weiter oder bei Fehler devx **************************/ + +rts1hi + +/***************** hier falls Stream �ber highwatermark ************/ + +/*******************************************************************/ + + clc + rts + +devx ldx dev + lda status,x + ora #2 + sta status,x + lda #E_NOTIMP + sec + rts + +devirq .( + ldx dev + +/********************* ist irq f�r device? nein dann irqend **********/ + +/************************ hier falls irq f�r device ******************/ + + ldx dev + lda status,x + bpl tx + +/**** Byte empfangen in ac, kein Byte dann nobyt *********************/ + +/*********************************************************************/ + + pha + ldx dev + lda outstr,x + tax + pla + jsr PUTC + bcs test + +nobyt ldx dev + lda outstr,x + tax + lda #SC_STAT + jsr STRCMD + +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx + +tstwater cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh jsr rts1hi + bcc tx ; unbedingt +twl cmp #E_SLWM + bne tx + +wl +/******** hier Aktion falls Stream unter Lowwatermark ****************/ + +/*********************************************************************/ + +tx ldx dev + lda status,x + rol + bpl irqhs + +/******* Hardware sendebereit? falls nicht irqhs ********************/ + +/*********************************************************************/ + + ldx dev + lda instr + tax + jsr GETC + bcs test2 + +/***************** Byte senden **************************************/ + +/********************************************************************/ + + jmp irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs + +/**************** Irq l�schen oder so am Ende des Device-Irqs ******/ + +/*******************************************************************/ + + lda #E_OK ; interrupt source removed + rts + +irqend lda #E_NOIRQ ; no interrupt source removed + rts + + .) + +others cmp #DC_GS + bne o1 + lda status,x + and #DC_SW_TX + bne devonx + tya + sta instr,x + jmp ok +devonx jmp devon +o1 cmp #DC_PS + bne o2 + lda status,x + and #DC_SW_RX + bne devonx + tya + sta outstr,x +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + +/********************* hier test, ob Receive erlaubt **************/ + +/************************ falls nicht onotimp *********************/ + + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + +/********************* hier test, ob send erlaubt *****************/ + +/************************ falls nicht onotimp *********************/ + + lda #DC_SW_TX +o2a ora status,x + sta status,x + bne okx +o4 cmp #DC_RX_OFF + bne o5 + +rxoff ldx dev + lda status,x + and #DC_SW_RX + beq devoffx + lda outstr,x + tax + lda #SC_EOF + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_RX + sta status,x + jsr rts1hi + bcc okx +devoffx jmp devoff +o5 cmp #DC_TX_OFF + bne o6 + +txoff ldx dev + lda status,x + and #DC_SW_TX + beq devoffx + lda instr,x + tax + lda #SC_NUL + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_TX + sta status,x + jmp ok + +o6 cmp #DC_HS + bne o6a + +/******************** hier Handshake ************************/ + + lda status,x + and #255-1 + sta status,x + tya + and #1 + ora status,x + sta status,x + +/***********************************************************/ + + jmp ok + +o6a cmp #DC_SPD + bne o7 + +/****************** hier Geschwindigkeit *******************/ + +/***********************************************************/ + + jmp ok + +o7 cmp #DC_ST + bne o8 + + lda status,x + and #2 + bne onotimp + +/****************** hier Statusabfrage *********************/ + +/***********************************************************/ + + jmp ok + +o8 cmp #DC_EXIT + bne onotimp + jsr rxoff + jsr txoff + ldx dev + lda status,x + ora #2 + sta status,x + +/****************** hier Irq abschalten (Exit) ***********************/ + +/*********************************************************************/ + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +/******************** hier Unterprogramme, includes etc **************/ + +/*********************************************************************/ + +devend .) + diff --git a/dump/oa-2.0.9/arch/proto/devices/romdev.a65 b/dump/oa-2.0.9/arch/proto/devices/romdev.a65 new file mode 100644 index 0000000..54b097f --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/devices/romdev.a65 @@ -0,0 +1,87 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ROM + +#include "kdefs.def" +#include "kernel.i65" + + ;.word $700 + *=$700 + +#endif + + +/* Device-Block */ + + .( + +#ifdef ROM + .word endd + .byt PK_DEV+$80 + .word devstart + .dsb P_NAME - P_RAM, $ff + .asc "devices",0 +#else +/* Note: this is obsolete! */ +#ifndef NOPRG + .word 0 + .byt PK_DEV + .byt 0 + .word 0 + .word devstart + .byt 0,0,<-1 +#endif +#endif + +devstart + +-sernr = "1" + +/* + +#define CONSOLE_DEVICE "devices/con_c64.a65" +#include "devices/console.a65" ; video device is merged with OS/A now... + +#include "devices/oa1dnl.a65" ; null device +#include "devices/oa1dsp.a65" ; spooler device +#include "devices/ser_9600.a65" ; fast serial interface by Daniel Dallmann + +#ifdef UARTBASE +#include "devices/ser_uart.a65" ; standard UART 16550A driver +#endif + +*/ + +#include "devices/oa1std.a65" + + .word $ffff + +#if 0 +#print sysmem +#print syszp +#endif + +endd .) + diff --git a/dump/oa-2.0.9/arch/proto/kernel/kenv.a65 b/dump/oa-2.0.9/arch/proto/kernel/kenv.a65 new file mode 120000 index 0000000..1239cfb --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/kernel/kenv.a65 @@ -0,0 +1 @@ +../../c64/kernel/kenv.a65 \ No newline at end of file diff --git a/dump/oa-2.0.9/arch/proto/kernel/kinit.a65 b/dump/oa-2.0.9/arch/proto/kernel/kinit.a65 new file mode 100644 index 0000000..8eda2b0 --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/kernel/kinit.a65 @@ -0,0 +1,138 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/*************************************************************************** + * + * This file is included in the RESET routine of the kernel, + * after the "sei:cld". The routine starting at the bginning + * of this file must initialize the hardware to the system RAM + * in the beginning and the system ROM in the end of the memory + * map. Also the system stack (pointer) is setup. + * + * In addition to that the system interrupt timer (needed for + * task preemtion) must be setup. + * + * After that the file must define the following macros: + * + * GETFREQ() returns a=0 for 1Mhz, a=128 for 2MHz + * LEDPORT address of LED port to signal hardware failures + * LED_LED bit of LED bit in LEDPORT address + * H_ERROR() if LEDPORT is not defined, then H_ERROR replaces + * the LED toggle routine if needed. + * CLRTIMER() clear the system interrupt timer interrupt + * KERNELIRQ() returns if an interrupt occured in the kernel + * or outside. Is checked by "BNE IRQ_in_Kernel" + * SAVEMEM() save system mem config for interrupt + * RESTOREMEM() restore system mem config after interrupt + * STARTMEM() This is used to alloc/enable memory pages found + * during kernel init. Takes mem size in AC as given + * by the kernel init. It is called _after_ inimem! + */ + +/* Kernel routines for ??? hardware */ + +/* + * init stack pointer for system stack + */ + ldx #<-1 + txs + +/* + * init memory configuration + */ +/* + lda #7 + sta 0 /* CPU data direction register */ + lda #5 + sta 1 /* Memory configuration */ +*/ +/* + * C64 specific irq timer init, irq every 20ms + * We assume that the reset - or a loader program has disabled all irq + */ +/* + lda #<20000 + sta C64CIA1+CIA_TBL ; load low byte + lda #>20000 + sta C64CIA1+CIA_TBH ; load hi byte of counter value + lda #%00010001 + sta C64CIA1+CIA_CRB ; start counter, counting system pulses + lda #%10000010 + sta C64CIA1+CIA_ICR ; allow irq +*/ +/* + * check zeropage RAM, jump to he_zero if failure + */ +#include "kernel/zerotest.a65" + +/* + * check system RAM up to ROMSTART, jump to he_ram if failure + * returns available RAM in 256 byte blocks in AC + */ +#include "kernel/ramtest.a65" + +/* + * originally SYSPORT specific, they have a value for the C64 also... + */ +#define GETFREQ() lda #0 + +#define LEDPORT $d020 +#define LED_LED 1 + +/* + * as we have set the CIA1 TB irq in the kernel, we have to clear the + * CIA interrupt flag. This is done with reading the ICRegister. + * With C64NEEDCIA1 one can disable reading the ICR here. But then you + * have to have a device that does it! + */ +#if 0 /* ndef C64NEEDCIA1 */ +#define CLRTIMER() lda C64CIA1+CIA_ICR +#else +#define CLRTIMER() +#endif + +/* + * MMU systems may map task pages into kernel mem to make copying + * easier. This mapping has to be preserved during interrupt. + * SAVEMEM() saves the memory configuration, while RESTOREMEM() + * restores it, obviously. + * These routines are called _after_ "jsr memsys", so this routine + * has to preserve this mapping when called from kernel space, + * and so must memtask. + */ + +#undef SAVEMEM +#undef RESTOREMEM + +/* + * Check if we have an interrupt in the kernel + */ + +#define KERNELIRQ() lda Syscnt:cmp #1 + +/* + * no memory management... + */ +#define STARTMEM() + + diff --git a/dump/oa-2.0.9/arch/proto/rom.a65 b/dump/oa-2.0.9/arch/proto/rom.a65 new file mode 100644 index 0000000..5ff1252 --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/rom.a65 @@ -0,0 +1,140 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/***************************************************************************/ +/* These defines control the ROM build */ +/* */ + +#define ROM + +/* These are necessary for ??? kernel **************************************/ + +#define NOMMU +#define NOSYSPORT +#undef CLK2MHZ /* we only have approx. 1 MHz ... */ +#undef CMOSCPU /* ... and no CMOS cpu */ +#define VIDPAGE 14 +#define SHORTLINE /* prepare for 40 col screen */ +#define RAMTEST +#define NOMIRRORMEM + +/* These are changeable ****************************************************/ + +#define RAMSIZE $80 /* The size of the RAM we allow to be used. + Size in pages (256 bytes). Must be below + ROMSTART */ + +#define MIN_MEM $80 /* minimum memory we need in system env. to + work ok, in pages */ + +#define ROMSTART $8000 /* where the ROM starts */ + +#define MEMINIVAL 0 /* Clear memory to 0 on boot */ + +#define STACKCOPY /* if defined, save stack area in memory + when context switching, otherwise divide + stack area and give each task a part. + It's faster without, but allows more + tasks with */ + +#define NMIDEV /* necessary for fast RS232 */ + +/***************************************************************************/ +/* Better not change anything below */ +/* */ + +#include "config.i65" +#include "kdefs.i65" +#include "fdefs.i65" + +#include "kernel.i65" + + .word $2000 + +.( + + +#include "devices/romdev.a65" + + +#define INIT_VERBOSE +#define INIT_MERGE +/* #define INIT_USE_STDLIB */ +/* #define INIT_OUTDEV 2*/ +#include "sysapps/init/init.a65" + +#include "sysapps/fs/fsdev.a65" + +#if 0 + +/* both, the parallel and serial iec bus use the same timer */ +#define SEM_CIA2TB SEM_SERIEC +#undef SEM_PARIEC +#undef SEM_SERIEC + +#define NOLOOP +#ifdef PARALLEL +#define FSIEC_DEVICE "devices/piec_c64.a65" +#else +#define FSIEC_DEVICE "devices/siec_c64.a65" +#endif +#include "sysapps/fs/fsiec.a65" +#undef FSIEC_DEVICE +#print * + +#define MON_SHEXE $80 /* ROM executable flag */ +#define MON_MONEXE 0 /* ROM executable flag */ +#define MON_SHDEV 0 /* start on device 0 = video1 */ +/* #define MON_USE_STDLIB */ +#include "sysapps/mon/sh.a65" + +#if 0 +#define NOSH +#undef MON_MONEXE +#define MON_MONEXE $80 /* ROM executable flag */ +#undef MON_MONDEV +#define MON_MONDEV 1 /* start on device 1 = video2 */ +#include "apps/sh/sh.a65" +#undef MON_NOSH +#endif + .text + .word -1 + +/* relocated STDIO to get more space (because I/O is at $d000 */ +/* +#define STDIOADDR $d000 +#include "stdlib/stdio.a65" +*/ + +#endif + +.dsb $d000-*,<-1 +.dsb $2000, <-1 /* from d000 to f000 */ + + .dsb $f000-*,<-1 + +#include "kernel\kernel.a65" + +.) + diff --git a/dump/oa-2.0.9/arch/proto/sysapps/fstst.a65 b/dump/oa-2.0.9/arch/proto/sysapps/fstst.a65 new file mode 100644 index 0000000..922ffe3 --- /dev/null +++ b/dump/oa-2.0.9/arch/proto/sysapps/fstst.a65 @@ -0,0 +1,234 @@ +/**************************************************************************** + + OS/A65 Version 1.3.3 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#define NOPRG + + .( +#ifdef ROM + .word ende + .byt PK_PRG+$80 + .byt 4 + .word 0 + .word PRG + .byt 8,$c,9,$d,$a,$e,<-1 + .asc "fsdev",0 +#else + +#include "oa1\oa1con.def" +#include "oa1\oa1str.def" +#include "oa1\oa1sj.a65" +#include "oafs\oa1fs.def" + +#ifdef NOPRG + .word $800 + *=$800 + jmp PRG +#else + .word $800 + *=$800 + .word 0 + .byt PK_PRG + .byt 4 + .word 0 + .word PRG + .byt <-1 +#endif +#endif + +-syszp =$10 +-sysmem =$300 +-sysblk =$800 + +owntask =sysmem +ac =sysmem+1 +xr =sysmem+2 +yr =sysmem+3 +-sysmem +=4 + +PRG .( + stx owntask + + clc + ldx #SEM_SENDBUF + jsr PSEM + + lda #1 ; 1 Drive + sta PCBUF+FM_REG_DRVS + lda owntask + sta PCBUF+FM_REG_ENV + lda #FM_REG + ldx #SEND_FM + ldy #2 + jsr SEND + + php + ldx #SEM_SENDBUF + jsr VSEM + plp + + bcc loop + jmp TERM + +loop sec + jsr RECEIVE + bcs loop + + sta ac + stx xr + sty yr + + ldy #ta-t + jsr tout + lda ac + jsr HEXOUT + ldy #ty-t + jsr tout + lda yr + jsr HEXOUT + ldy #tx-t + jsr tout + lda xr + jsr HEXOUT + ldy #td-t + jsr tout + lda PCBUF+FS_OPEN_DRV + jsr HEXOUT + ldy #ts-t + jsr tout + lda PCBUF+FS_OPEN_STR + jsr HEXOUT + ldy #tp-t + jsr tout + lda PCBUF+FS_OPEN_PFAD + jsr HEXOUT + ldy #tt-t + jsr tout + ldy #FS_OPEN_NAME +l1 lda PCBUF,y + bne l2 + lda #"@" +l2 jsr SEROUT + iny + cpy yr + bcc l1 + ldy #te-t + jsr tout + + lda #<-1 + sta PCBUF+FS_X_ERR + ldx xr + ldy #FS_X_SLEN + jsr SEND + + jmp loop + +HEXOUT .( + pha + lsr + lsr + lsr + lsr + jsr NIBOUT + pla + and #$0f +NIBOUT clc + adc #"0" + cmp #"9"+1 + bcc nout + adc #6 +nout jmp SEROUT + .) + + .( +dxr =sysmem +dyr =sysmem+1 +str =sysmem+2 +-sysmem +=3 + +&SERIN stx dxr + ldx #STDIN + bne s0 +&IN stx dxr +s0 sty dyr + stx str +s1 ldx str + jsr GETC + bcc s1a + cmp #E_EOF + beq s1b + jsr YIELD + jmp s1 +s1b sec +s1a ldx dxr + ldy dyr + rts + +&SEROUT stx dxr + ldx #STDOUT + bne o0 +&OUT stx dxr +o0 sty dyr +s2 pha + jsr PUTC + pla + bcc s2a + jsr YIELD + jmp s2 +s2a ldx dxr + ldy dyr + cmp #0 + rts + +&SERBRK stx dxr + sty dyr + lda #SC_STAT + ldx #STDIN + jsr STRCMD + ldx dxr + ldy dyr + cmp #E_SEMPTY + bne s3 + clc + rts +s3 sec + rts + .) + +tout lda t,y + beq tend + jsr SEROUT + iny + bne tout +tend rts + +t ta .asc "AC=",0 +tx .asc " XR=",0 +ty .asc " YR=",0 +td .asc 13,10,"DRV=",0 +ts .asc " STR=",0 +tp .asc " PATH=",0 +tt te .asc 13,10,0 + +ende .) + diff --git a/dump/oa-2.0.9/devices/README b/dump/oa-2.0.9/devices/README new file mode 100644 index 0000000..3f1911b --- /dev/null +++ b/dump/oa-2.0.9/devices/README @@ -0,0 +1,10 @@ + +Here are the more or less hardware independent devices. + +They are either completely architecture independent or they +include files from the arch/`arch` directory. + +If they only need a single base address for a chip which could +be defined elsewhere (like the UART serial device), then +they should also go here. + diff --git a/dump/oa-2.0.9/devices/console.a65 b/dump/oa-2.0.9/devices/console.a65 new file mode 100644 index 0000000..7bb38bb --- /dev/null +++ b/dump/oa-2.0.9/devices/console.a65 @@ -0,0 +1,929 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + Generic console device + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + .( + + .( +#define DC_SW_MOD $20 +#define DC_SW_EXIT $10 + + .word devend1 + jmp prg1 + .asc "video1",0 + +devend1 .word devend2 + jmp prg2 + .asc "video2",0 + +devend2 .word devend3 + jmp prg3 + .asc "video3",0 + +devend3 .word devend + jmp prg4 + .asc "video4",0 + +#include CONSOLE_DEVICE + +prg4 ldx #3 + .byt $2c +prg3 ldx #2 + .byt $2c +prg2 ldx #1 + .byt $2c +prg1 ldx #0 + .) + + .data +screen .byt 0 ; screen the device is working on +actscr .byt 0 ; visible screen +freq .byt 0 ; hardware status byte from kernel (1/2 MHz bit) +#ifndef NOSYSPORT +syscnt .byt 0 ; reentrance semaphore when IRQ can be checked +#endif +shfl .byt 0 ; shift flag for typed char +rspd .byt 0 ; key repeat speed +status .dsb MAX_SCREEN +outstr .dsb MAX_SCREEN +getstr .dsb MAX_SCREEN +brkkey .dsb MAX_SCREEN +ctrlst .dsb MAX_SCREEN + + .zero +zei2 .word 0 + + .text + + .( + pha + tya + pha + txa + jsr setscr + ldx screen + pla + tay + pla + cmp #DC_RES + bne p1 + sty freq + + txa + beq foo ; screen 0 is always reset, to set MAX_SCREEN + cmp #MAX_SCREEN + bcs max_err +foo + lda #3 ; ^C + sta brkkey,x + + lda #0 ; linein off ; DC_SW_MOD ; linein ein + sta status,x + sta ctrlst,x + + sta outstr,x + sta getstr,x + +#ifndef NOSYSPORT + sta syscnt +#endif + sta actscr + + txa + bne re ; only the first is hw-initialized + jsr console_init ; init hardware (called with y=hardware byte) +&re + jsr inivscr + clc + rts + +max_err sec + rts + .) + + .( +p2x jmp p2 + +#if 0 /*ndef NOSYSPORT */ +noirq lda #E_NOIRQ + .byt $2c +#endif +&max_err lda #E_NODEV + sec + rts +#if 0 /*ndef NOSYSPORT */ +wasirq lda #E_OK + rts +#endif + +&p1 cpx #MAX_SCREEN + bcs max_err + + pha + lda status,x + and #DC_SW_EXIT + beq p1ok + pla + sec + rts +p1ok pla + cmp #DC_IRQ + bne p2x + +#if 1 /*def NOSYSPORT*/ /* allows interruptable devices! */ + jsr do_irq + sec + rts +#else + bit SYSPORT + bpl noirq /* not my (50 Hz) irq */ + lda SYSPORT + sta SYSPORT /* clear 50 Hz interrupt */ + + lda syscnt /* this devices has already been interrupted */ + bmi wasirq /* then return */ + lda SYSPORT + and #1 + beq do_irq /* CPU irq line active -> no cli */ + + dec syscnt /* signal that devices is interrupted */ + cli + + lda #0 +x3 jsr setscr + jsr do_irq + lda screen + clc + adc #1 + cmp MAX_ASCREEN + bcc x3 + +xe sei + inc syscnt + lda #E_NOIRQ + rts +#endif /* NOSYSPORT */ + .) + +do_irq .( + ldy screen + DO_IRQ + lda status,y + and #DC_SW_RX + beq nocheck + + ldx outstr,y + lda #SC_STAT + jsr STRCMD + cmp #E_NUL + bne nocheck + jsr rxoff +nocheck + lda screen ; get keyboard only for visible screen + cmp actscr + bne notact + jsr getkey ; returns x=shiftfl, y=index in keytable, a=ascii code + bcs notact + cpy #SWITCHKEY + bne gotchar + jsr crsroff ; must preserve xr + jsr do_switch + jmp notact +gotchar + sta zei2 + ldy screen ; first check if we are receiving (from keyboard) + lda status,y + and #DC_SW_RX + beq notact + lda zei2 + cmp brkkey,y + bne nobrk + ldx outstr,y + lda #SC_SSTAT + ldy #SCE_BRK + jsr STRCMD +nobrk + ldx zei2 + ldy screen + lda status,y + and #DC_SW_RX+DC_SW_TX+DC_SW_MOD + cmp #DC_SW_RX+DC_SW_TX+DC_SW_MOD + bne direct ; indirect mode -> print char and send line on cr + cpx #TC_CR + bne print ; no cr, then just print it + jsr crsroff + jsr sendline ; otherwise send the whole line + ldx #TC_CR +print + jsr crsroff + txa + jsr printchar + jmp notact + +direct and #DC_SW_RX ; direct mode -> send the char directly + beq notact + txa + ldx outstr,y + jsr PUTC +notact ; output stuff + ldx screen + lda status,x + and #DC_SW_TX ; do we send? + beq endirq + + lda getstr,x + tax + lda #SC_STAT + jsr STRCMD ; check stream state + cmp #E_EOF + bne txok + jsr txoff + jmp endirq +txok + cmp #E_SEMPTY + beq endirq + + lda screen + cmp actscr + bne txloop + jsr crsroff + +txloop ldy screen + ldx getstr,y + jsr GETC + bcs endirq + jsr printchar + jmp txloop +endirq + lda screen + cmp actscr + bne end1 + jsr crsron +end1 + BELLIRQ + lda #E_NOIRQ + rts + .) + +do_switch .( + dex + bpl p1c2 ; without shift or ctrl + +p1c1b ldx actscr ; needed to tell setact the old screen number + inc actscr ; then switch screen + lda actscr + cmp MAX_ASCREEN + bcc p1c1a + lda #0 + sta actscr +p1c1a + tay + lda status,y + and #DC_SW_EXIT + bne p1c1b + tya + jsr setact + jmp p1b + +p1c2 dex + bmi p1b ; shift only, then ignore + dex + bpl p1c3 ; Ctrl only, then mode switch + ldy screen + lda status,y + eor #DC_SW_MOD + sta status,y + jmp p1b + +p1c3 dex + bpl p1b ; Ctrl and Shift then close stream + jsr rxoff + ;jmp p1b +p1b rts + .) + +/*************************************************************************/ + +p2 .( + cmp #DC_TX_ON + bne ox1q + ldy screen + lda #0 + sta ctrlst,y + jsr towcl + lda #DC_SW_TX + bne ox1q1 +ox1q cmp #DC_RX_ON + bne ox1 + ; ldy screen + ; lda #3 + ; sta brkkey,y + lda #DC_SW_RX +ox1q1 ldy screen + ora status,y + sta status,y + jmp ok +ox1 cmp #DC_TX_OFF + bne ox2x +&txoff ldy screen + lda status,y + and #DC_SW_TX + beq devoff + ldx getstr,y + lda #SC_NUL + jsr STRCMD + lda status,y + and #255-DC_SW_TX + sta status,y + jmp ok +ox2x cmp #DC_RX_OFF + bne ox2 +&rxoff ldy screen + lda status,y + and #DC_SW_RX + beq devoff + ldx outstr,y + lda #SC_EOF + jsr STRCMD + lda status,y + and #255-DC_SW_RX + sta status,y + jmp ok +ox2 cmp #DC_EXIT + bne ox2a + jsr rxoff + jsr txoff + ldy screen + lda #DC_SW_EXIT + ora status,y + sta status,y + bne ok +ox2a cmp #DC_ST + bne o3 +ok lda #E_OK + .byt $2c +devoff lda #E_DOFF + .byt $2c +devon lda #E_DON + .byt $2c +notimp lda #E_NOTIMP + cmp #1 + rts +o3 cmp #DC_PS + bne o4 + ldx screen + lda status,x + and #DC_SW_RX + bne devon + tya + sta outstr,x + jmp ok +o4 cmp #DC_SPD + bne o5 + sty rspd + beq ok +o5 cmp #DC_GS + bne o6 ; notimp + ldx screen + lda status,x + and #DC_SW_TX + bne devon + tya + sta getstr,x + jmp ok +o6 cmp #DC_BRKKEY + bne notimp + ldx screen + lda brkkey,x + pha + tya + sta brkkey,x + pla + tay + jmp ok + .) + +/**************************************************************************/ + + .( + + .data +&spalte .byt 0 +&zeile .byt 0 +wx .byt 0 +wy .byt 0 +wr .byt 0 +wh .byt 0 +hivid .byt 0 +iz .byt 0 +is .byt 0 +#if is-spalte+2 > 12 +#echo Warning: illegal struct length for vtab +#else +vtab .dsb MAX_SCREEN*12 +#endif + .zero +&vzei .word 0 + + .text + +&inivscr .( + + lda screen + jsr iniscr + + lda #TC_FF ; form feed + jsr printchar + jsr setlin + + clc + rts + .) + +setlin .( + lda zeile + sta iz + lda spalte + sta is + rts + .) + +&sendline .( + SET_MMU + ldy zeile + cpy iz + bne liex + ldy is + cpy spalte + bcc liex2 + beq liex2 +liex ldy wx +liex2 sty spalte + sty zei2 + ldy wr +lie2 cpy spalte + beq lie1 + dey + lda (vzei),y + cmp #SCR_SPACE + beq lie2 + iny +lie1 sty zei2+1 +lie3 ldy zei2 + cpy zei2+1 + bcs lie4 + lda (vzei),y + SCR2ASC + ldy screen + ldx outstr,y + jsr PUTC + SET_MMU + inc zei2 + bne lie3 +lie4 lda #TC_CR + ldy screen + ldx outstr,y + jsr PUTC + lda #SC_SSTAT + ldy #SCE_PUSH + jmp STRCMD + .) + + /* handle multi-byte sequences - pretty simple now. */ +extra .( + dey + beq crsrrow + +crsrcol clc + adc wx + cmp wr + bcc colok + lda wr + sbc #1 +colok sta spalte + +clrctrl lda #0 + sta ctrlst,x + rts + +crsrrow cmp wh + bcc rowok + lda wh + sbc #1 +rowok sta zeile +inccst inc ctrlst,x + rts + + .) + + /* print all characters on screen */ +&printchar .( + SET_MMU + + ldx screen + ldy ctrlst,x + bne extra + + tay + bmi x1 + cmp #32 + bcs outc + jmp xout +x1 cmp #128+32 + bcs outc + jmp xcode + +outc ASC2SCR + ldy spalte + sta (vzei),y + +&nextc ldy spalte + iny + cpy wr + bcc o1 + jsr nextz + ldy wx +o1 sty spalte + rts + +&nextz ldx zeile + inx + cpx wh + bcc o2 + jsr scrollup + ldx wh + dex +o2 ;stx zeile + +&&setzei stx zeile + txa + clc + adc wy + tax + lda #0 + sta vzei + sta vzei+1 + sta zei2+1 + lda MAXSPAL + sta zei2 +szmul txa + beq sz1 + lsr + tax + bcc szm1 + lda zei2:clc:adc vzei:sta vzei + lda zei2+1:adc vzei+1:sta vzei+1 +szm1 asl zei2:rol zei2+1 + jmp szmul +sz1 ACT_HI_VID + clc + adc vzei+1 + sta vzei+1 + ldx zeile + rts + +scrollup ldx #0 + jsr setzei + +su2 inx + cpx wh + bcs su3 + lda vzei + clc + adc MAXSPAL + sta zei2 + lda vzei+1 + adc #0 + sta zei2+1 + ldy wx +su1 lda (zei2),y + sta (vzei),y + iny + cpy wr + bcc su1 + + lda zei2 + sta vzei + lda zei2+1 + sta vzei+1 + jmp su2 + +su3 ldy wx + lda #SCR_SPACE +su4 sta (vzei),y + iny + cpy wr + bcc su4 + +&clrli ldx #<-1 + stx iz + rts + .) + +iniscr .( ; screen number in AC + HI_VID + sta hivid + + lda #0 + sta wx + sta wy + sta spalte + lda MAXSPAL + sta wr + lda MAXZEIL + sta wh + + ldx #0 + jmp setzei + .) + +&setscr .( + ldx screen + cpx #MAX_SCREEN + bcs nosave + cmp screen + beq setmmu ; same screen as current + pha + ; save screen + lda screen + asl + asl + sta zei2+1 ; screen# times 4 + asl + clc + adc zei2+1 + tax ; screen# times 12 + ldy #0 +s1 lda spalte,y ; copy screen control struct + sta vtab,x ; to buffer + inx + iny + cpy #is-spalte+1 + bcc s1 + lda vzei + sta vtab,x + lda vzei+1 + sta vtab+1,x + pla +nosave sta screen + ; restore screen + asl + asl + sta zei2+1 + asl + clc + adc zei2+1 + tax + ldy #0 +s2 lda vtab,x ; copy screen control struct from buffer + sta spalte,y ; to struct + inx + iny + cpy #is-spalte+1 + bcc s2 + lda vtab,x + sta vzei + lda vtab+1,x + sta vzei+1 +setmmu + SET_MMU + rts + .) + +xout .( + cmp #TC_CR + bne x1 + lda wx + sta spalte + rts +x1 cmp #TC_LF + bne x2 + jmp nextz +x2 cmp #TC_BEL + bne x3a + TRIGBELL + rts +x3a .( + cmp #TC_FF + bne x3 +&&toclr ldx #0 +c2b jsr setzei + ldy wx + lda #SCR_SPACE +c2a sta (vzei),y + iny + cpy wr + bcc c2a + inx + cpx wh + bcc c2b + jsr clrli +&&tohome lda wx + sta spalte + ldx #0 + jmp setzei + .) +x3 .( + cmp #TC_BS + bne x4 + ldy spalte + cpy wx + beq c7 + dec spalte +bslp lda (vzei),y + dey + sta (vzei),y + iny + iny + cpy wr + bcc bslp + dey + lda #SCR_SPACE + sta (vzei),y +&x4 c7 rts + .) + .) + +xcode .( + and #$7f + cmp #maxcode + bcs xe + asl + tax + lda xadr+1,x + pha + lda xadr,x + pha +xe rts + +maxcode =16 +xadr .word tocl-1,nextc-1,tocu-1,nextz-1 + .word tohome-1,toclr-1,todel-1,toins-1 + .word towlo-1,towru-1,towcl-1 + .word toeol-1,toclrl-1 + .word toecho-1, tonoecho-1, tocpos-1 + +tocpos .( + ldx screen + lda #1 + sta ctrlst,x + rts + .) + +toecho .( + ldx screen + lda status,x + ora #DC_SW_MOD + sta status,x + rts + .) + +tonoecho .( + ldx screen + lda status,x + and #$ff-DC_SW_MOD + sta status,x + rts + .) + +todel .( + ldy spalte +td0 iny + cpy wr + bcs td1 + lda (vzei),y + dey + sta (vzei),y + iny + bne td0 +td1 dey + lda #SCR_SPACE + sta (vzei),y + rts + .) + +toins .( + ldy wr + dey + lda (vzei),y + cmp #SCR_SPACE + bne tie + cpy spalte + beq tie +ti1 dey + lda (vzei),y + iny + sta (vzei),y + dey + cpy spalte + bne ti1 + lda #SCR_SPACE + sta (vzei),y +tie rts + .) + +toeol .( + ldy wr +l dey + bmi e + lda (vzei),y + cmp #SCR_SPACE + beq l +e iny + cpy wr + bcs x + sty spalte +x rts + .) + +toclrl .( + lda #SCR_SPACE + ldy spalte +c sta (vzei),y + iny + cpy wr + bcc c + rts + .) + +tocl .( + ldy spalte + cpy wx + beq c4 + dec spalte + rts +c4 ldy wr + dey + sty spalte +&tocu ldx zeile + beq c5 + dex +c5 jsr setzei + rts + .) + +towlo .( + lda spalte + sta wx + lda wh + sec + sbc zeile + sta wh + lda zeile + clc + adc wy + sta wy + lda #0 + sta zeile + jmp clrli + .) + +towru .( + ldy spalte + iny + sty wr + ldx zeile + inx + stx wh + jmp clrli + .) + +&&towcl .( + lda zeile + clc + adc wy + sta zeile + lda #0 + sta wx + sta wy + lda MAXSPAL + sta wr + lda MAXZEIL + sta wh + jmp clrli + .) + .) + + .) +devend .) + diff --git a/dump/oa-2.0.9/devices/nulldev.a65 b/dump/oa-2.0.9/devices/nulldev.a65 new file mode 100644 index 0000000..2b50d21 --- /dev/null +++ b/dump/oa-2.0.9/devices/nulldev.a65 @@ -0,0 +1,120 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + Generic nulldevice + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#define ANZINSTR 16 + + .( + .word nulend + jmp nulprg + .asc "nuldev",0 + + .data +anzinstr .byt 0 +instr .dsb ANZINSTR + .text + +nulprg cmp #DC_RES + bne sp1 + + ldy #0 + sty anzinstr + lda #<-1 +ni1 sta instr,y + iny + cpy #ANZINSTR + bcc ni1 + clc + rts + +sp1 cmp #DC_IRQ + bne sp2 + + ldy #0 +spil ldx instr,y + bmi spiln + jsr GETC + bcc spil + cmp #E_EOF + bne spiln + + ldx instr,y + lda #SC_NUL + jsr STRCMD + lda #<-1 + sta instr,y + +spiln iny + cpy #ANZINSTR + bcc spil + clc + lda #E_NOIRQ + rts + +sp2 cmp #DC_RX_OFF + beq nlnotimp + cmp #DC_TX_OFF + bne sp3 + ldy #0 ; rxoff +rxo1 ldx instr,y + lda #SC_NUL + jsr STRCMD + lda #<-1 + sta instr,y + iny + cpy #ANZINSTR + bcc rxo1 + bcs ok + +sp3 cmp #DC_RX_ON + beq nlnotimp + cmp #DC_TX_ON + bne sp5 + +ok lda #0 + .byt $2c +nlnotimp lda #E_NOTIMP + .byt $2c +nldevon lda #E_DON + cmp #1 + rts + +sp5 cmp #DC_GS + bne nlnotimp + ldx #0 +sp5a lda instr,x + bpl sp5n + tya + sta instr,x + clc + rts +sp5n inx + cpx #ANZINSTR + bcc sp5a + bcs nldevon + +#undef ANZINSTR + +nulend .) + diff --git a/dump/oa-2.0.9/devices/scsi.a65 b/dump/oa-2.0.9/devices/scsi.a65 new file mode 100644 index 0000000..0e2ddb8 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi.a65 @@ -0,0 +1,304 @@ + + +#ifdef DEBUGFS +#define PRINT +#define PRINT2 +#echo "SCSI PRINT MODE" +#endif +#undef DEBUG + +/* + * Sample SCSI + PC-style partition manager program + */ + +;-------------------------------------------------------------- +; CS/A65 specific code + +#ifndef SCSIBASE +#define SCSIBASE $e870 +#endif + + +;-------------------------------------------------------------- + +#include "devices/scsi/part.i65" + + .( + .data +prwpar .dsb PRW_SLEN + .text + +INVDPB .( ; x ist Drive + txa + jsr setdzei + ldy #D_ST + lda #DS_INV + sta (dzei),y + clc + rts + .) + +&DINIT .( +;.byt 2 + clc ; oh, what shall we do.... + ldx #0 +il stx prwpar + jsr INVDPB + ldx prwpar + inx + cpx #ANZDRV + bcc il + clc + + lda #buffer + ldx #>BUFLEN + jsr scanpart + rts + .) + +&GETDPB .( + jsr boot2dpb + ldy #D_ST + lda #DS_OK + sta (dzei),y + ldy #D_BFLAG + lda #1 ; 0 -> 12 bit FAT, 1 -> 16 bit FAT + sta (dzei),y + clc + rts +illpar lda #E_ILLPAR + sec + rts + .) + +&RWSEC .( + php + sta dp + sty dp+1 + +#ifdef DEBUGFS +.( +lda #":" +jsr SEROUT +lda dp+1 +jsr HEXOUT +lda dp +jsr HEXOUT +lda #"." +jsr SEROUT +ldy #0 +ll lda (dp),y +jsr HEXOUT +iny +cpy #RW_SLEN +bcc ll +jsr CRLFOUT +.) +#endif + ldy #RW_DRV + lda (dp),y + sta prwpar+PRW_PART + lda #1 + sta prwpar+PRW_NSEC + + ldy #RW_SECTOR + lda (dp),y + sta prwpar+PRW_SECTOR + iny + lda (dp),y + sta prwpar+PRW_SECTOR+1 + iny + lda (dp),y + sta prwpar+PRW_SECTOR+2 + iny + lda (dp),y + sta prwpar+PRW_SECTOR+3 + + ldy #RW_ADR + lda (dp),y + sta prwpar+PRW_BUF + iny + lda (dp),y + sta prwpar+PRW_BUF+1 + + lda #prwpar + + plp + bcs pwr + + jmp pread +pwr + jmp pwrite + .) + +&DLOOP rts + +&DFORMAT .( +; .data +; dfa .byt 0,0,0,0 +; .text +;dfa =ar1 + + ldy drive + jsr CLBUF + + ldy drive + lda #0 + sta ar2 + sta ar2+1 + sta ar2+2 + sta ar2+3 + jsr RDBUF + + ldx drive + jsr setpadr + sta dp + stx dp+1 + + ldy #D_ST + lda #DS_INV + sta (dzei),y + + ldy #BS_SLEN +df1 lda bootsector,y + sta (dp),y + dey + bpl df1 + + /* modify boot sector to fit partition size */ + lda drive + asl + asl + asl + asl + tax + + ; BS_BPS ; bytes per sector + ldy #BS_BPS + lda parts+PT_BSIZE,x + sta (dp),y + iny + lda parts+PT_BSIZE+1,x + sta (dp),y + + /* TODO: this is buggy - old bootsector only allows 2-byte # of sec + * but we misuse the MEDIA byte as third byte of the sector # */ + ; BS_SEC ; total number of sectors + ldy #BS_SEC + lda parts+PT_LEN,x + sta (dp),y + sta ar1-BS_SEC,y + iny + lda parts+PT_LEN+1,x + sta (dp),y + sta ar1-BS_SEC,y + iny + lda parts+PT_LEN+2,x + sta (dp),y + sta ar1-BS_SEC,y + iny + lda parts+PT_LEN+3,x + ; sta (dp),y + sta ar1-BS_SEC,y + + ; BS_SPC ; 1 byte sectors per cluster + ldy #BS_SPC + lda #1 + sta (dp),y +spc1 + lda ar1+2 + ora ar1+3 + beq spf + + lsr ar1+3 + ror ar1+2 + ror ar1+1 + ror ar1 + + lda (dp),y + asl + sta (dp),y + jmp spc1 +spf +#ifdef DEBUGFS +lda #"+":jsr SEROUT +ldy #0:sss1 lda ar1,y:jsr HEXOUT:iny:cpy #4:bcc sss1 +#endif + ; BS_SPF ; sectors per FAT = (BS_SEC/BS_SPC * BS_BPS/2) + ldy #BS_BPS+1 + lda (dp),y + lsr + tax + dey + lda (dp),y + ror + jsr div32 + ldy #BS_SPF + clc + adc #1 + sta (dp),y + iny + txa + adc #0 + sta (dp),y +#ifdef DEBUGFS +dey:lda (dp),y:jsr HEXOUT:iny:lda (dp),y:jsr HEXOUT +jsr CRLFOUT +#endif + ; BS_SPT ; sectors per track ??? -> not needed + + ; BS_SIDE ; sides ??? -> not needed +#ifdef DEBUGFS +lda "*":jsr SEROUT +ldy #0:ffoo1 lda (dp),y:jsr HEXOUT:lda #" ":jsr SEROUT:iny +cpy #BS_SLEN:bcc ffoo1:jsr CRLFOUT +#endif +/* + txa + clc + adc #3 + tay +lda #"x":jsr SEROUT + ldx #3 +df2 lda parts+PT_LEN,y + sta ar1,x +jsr HEXOUT + dey + dex + bpl df2 +*/ + ldy drive + jsr WABUF + + ldy drive + jsr FRBUF + + clc + rts + +bootsector ; is modified after having been copied to the buffer. + .byt $eb,$34,$90,"OS/A 2.1" + .word $200 ; BPS + .byt 2 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 112 ; DIR + .word 720 ; SECs + .byt 248 ; Media + .word 3 ; SPF + .word 9 ; SPT + .word 1 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + .) + +#include "devices/scsi/pcpart.a65" +#include "devices/scsi/paccess.a65" +/*#include "devices/scsi/csascsi1.a65"*/ /* needs SCSIBASE */ +#include "devices/scsi/ramdscsi.a65" +#include "devices/scsi/printcsa.a65" + + .) + diff --git a/dump/oa-2.0.9/devices/scsi/COPYING b/dump/oa-2.0.9/devices/scsi/COPYING new file mode 100644 index 0000000..6d2b1ca --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/COPYING @@ -0,0 +1,353 @@ + +All files in this directory are copyrighted by me. However, only +the driver (i.e. all files _except_ csascsi1.gif and csascsi1.ps) +are distributed under the GPL (see below). The schematics, i.e. +csascsi1.gif and csascsi1.ps are under a more restrictive copyright. +You may only use them for non-commercial purposes and may not +be changed without notice. GPL sections 11 and 12 (No Warranty!) +cover _all_ files. + + Andre fachat +----------------------------------------------------------- + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/dump/oa-2.0.9/devices/scsi/Makefile b/dump/oa-2.0.9/devices/scsi/Makefile new file mode 100644 index 0000000..c30fa2d --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/Makefile @@ -0,0 +1,24 @@ + +c64: main.a65 csascsi1.a65 pcpart.a65 printc64.a65 paccess.a65 part.i65 + xa -DC64 -l main.lab -I../oa-2.0.0a/include \ + -bz 250 -bb 4096 \ + main.a65 -o mainc64 + +csa: main.a65 csascsi1.a65 pcpart.a65 printcsa.a65 paccess.a65 part.i65 + xa -DCSA -R -l main.lab -I../oa-2.0.0a/include -DOSA2KERNEL=\$$f000 -bz 128 -bt 1024 -bb 3072 main.a65 -o main.o65 + file65 main.o65 + reloc65 -xt -o maincsa main.o65 + +clean: + rm -f *.o65 *.lab main maincsa + +dist: c64 clean + (cd ..; tar czv --exclude=scsi/csascsi1.fig -f scsidist.tar.gz scsi ; ) + +mrproper: clean + rm -f mainc64 + +arc: mrproper + (cd ..; tar czvf scsi.tar.gz scsi ; ) + + diff --git a/dump/oa-2.0.9/devices/scsi/README b/dump/oa-2.0.9/devices/scsi/README new file mode 100644 index 0000000..b5419e4 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/README @@ -0,0 +1,136 @@ + +Generic driver for the CS/A65 SCSI interface +-------------------------------------------- + +This is the generic driver for the CS/A SCSI interface, written for +the 6502 CPU. + +The hardware is derived from a very old SASI interface described +in the german elektor magazin. +The schematics can be found in csascsi1.{gif|ps} +A description and parts list are in csascsi1{desc|parts}.txt. + +The software runs on the C64 with the C64-CS/A65 bus adaptor +(See http://www.tu-chemnitz.de/~fachat/8bit/c64/csa/index.html) +as well as on a CS/A65 computer. +(See http://www.tu-chemnitz.de/~fachat/8bit/hardware/csa/index.html) + +To build the driver you need the xa65 6502 cross assembler. +(See http://www.tu-chemnitz.de/~fachat/8bit/cross/xa/index.html) +It should be easy to patch the source for another assembler. + +New with 1.1: +------------- + +- the pc partition scanner handles extended partions better +- a C64 binary is included (as "mainc64"). Simply LOAD and RUN it + if you have the SCSI-interface at $de00. + (It doesn't check if it's there!) + +Driver Description +------------------ + +The driver is divided into several parts: + +csascsi1.a65 contains the low-level routines to scan the SCSI bus + and to read/write sectors for the CS/A65 SCSI card. + To use another hardware this module can be replaced. + +part.i65 defines a general interface to read and write blocks in a + partition. Also the partition table format is defined here. + +pcpart.a65 uses the low-level routines to scan the devices for + PC-style partition tables. They are registered in the partition + table. To use a different type of partition tables + (Amiga for example), replace this file. + +paccess.a65 implements the pread and pwrite functions to read and + write blocks in a partition with the use of the partition table. + +print*.a65 are some help routines to print debugging output when + the routines are used in an OS/A65 1.3 or C64 environment. + It is not needed without output or has to be replaced for + another operating environment. + +main.a65 is a simple test program. It also includes the driver for + assembling with the xa65 crosscompiler and the OS-specific + startup code. + + +Comments +-------- + +This is the very first version. There are sure some bugs. +Error handling is miserable. +The hardware only works as single controller and only as ID 7. +There is no fdisk program - it would be partition-style dependent +and would use the low-level driver. +If in doubt, read the source :-) + +Here is the sample output of the main program: + +------------------------------------------------------------------------- +>l"maincsa" 400:0B14 +>g 400 +CS/A65 SCSI driver + +Resetting SCSI bus +Device select timeout 00 +Device select timeout 01 +Device found 02 +SEAGATE ST1096N [Type 00, SCSI Rev. 01] + [Blocks: 00028091, Byte/Block: 00000200] +Device select timeout 03 +Device found 04 +IBM DCAS-34330W [Type 00, SCSI Rev. 02] + [Blocks: 008132FF, Byte/Block: 00000200] +Device select timeout 05 +Device select timeout 06 + +Scanning for PC-type partitions + +Found Direct Access Device 02 +Partition Type 04, Device 02, First 00000020, Len 0000F7E0 +Partition Type 05, Device 02 (extended) +Partition Type 06, Device 02, First 0000F820, Len 000187E0 + +Found Direct Access Device 04 +Partition Type 06, Device 04, First 00000020, Len 001DB7E0 +Partition Type 05, Device 04 (extended) +Partition Type 83, Device 04, First 001DB820, Len 0000A7E0 +Partition Type 05, Device 04 (extended) +Partition Type 83, Device 04, First 001E6020, Len 001F47E0 +Partition Type 05, Device 04 (extended) +Partition Type 82, Device 04, First 003DA820, Len 0003C7E0 +Partition Type 05, Device 04 (extended) +Partition Type 83, Device 04, First 00417020, Len 003FBFE0 + +>m e1e e5e +>,0E1E 04 00 02 00 00 02 00 00 20 00 00 00 E0 F7 00 00:........ ...a/.. +>,0E2E 06 00 02 00 00 02 00 00 20 F8 00 00 E0 87 01 00:........ 0..a... +>,0E3E 06 00 04 00 00 02 00 00 20 00 00 00 E0 B7 1D 00:........ ...ao.. +>,0E4E 00 00 04 00 00 02 00 00 00 70 43 30 08 04 71 00:.........pC0..q. +> +------------------------------------------------------------------------- + +As you can see the driver is pretty small (the whole text segment is +about 1k without print + about 180 byte for partition tables etc. +(Of course it needs buffers to read & store the sectors read from disk) + +It can also handle multiple devices as well. The IBM 4G Ultra-Wide SCSI-II +(with Wide-SCSI -> SCSI adapter) is handled as well as the old Seagate +ST1096N SCSI-I at the same time. + +The partition table shows three usable partitions, of types 4 +(FAT 16 bit < 32M) and 6 (FAT 16 bit >= 32M) and +on (SCSI-) devices 2 and 4. the 4th to 7th byte are the bytes/block, +then the first block and the length of the partition on the device. +The other partitions found but written to the partition table are +Linux partitions :-) + +There will be a binding to the fsibm 12/16 Bit filesystem for OS/A65. + +Have fun +Andre Fachat 13 June 1998 + + diff --git a/dump/oa-2.0.9/devices/scsi/csascsi1.a65 b/dump/oa-2.0.9/devices/scsi/csascsi1.a65 new file mode 100644 index 0000000..207aa32 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/csascsi1.a65 @@ -0,0 +1,778 @@ + +/* + * Generic SCSI driver for CS/A SCSI card + * + * Modified SASI interface from german "Elektor Computing" magazin, + * special issue "Hardware", year unknown, probably around 1988-1989. + * + * Modified hardware and rewritten driver by A. Fachat in may 1998. + * + * Hardware: + * + * 2 addresses, $e870-$e871 + * + * $e870 : read SCSI data bus; write data for SCSI data bus + * + * $e871 : read status + * bit 0: I/O (SCSI in) + * 1: -ACK (SCSI out, from latch) + * 2: -RST (SCSI out, from latch) + * 3: BSY (SCSI in) + * 4: MSG (SCSI in) + * 5: + * 6: REQ (SCSI in) + * 7: C/D (SCSI in) + * write control + * bit 0: 1 = -SEL active + * 1: 1 = activate ID bit for arbitration + * 2: 1 = -BSY active + * 3: 1 = -ATN active + * 4: + * 5: + * 6: + * 7: 1 = /RST active + * + * $e872 : write any value -> pulse on /SEL (SCSI out) + * + * Software: + * + * This is a stateless SCSI driver with the following routines: + * + * initscsi <- a/y address of buffer (>=256 byte) + * -> a/y address of (static) table with device type + * of each device in it (0=disk, ff=none) + * also available as "devtype" + * x = number of table entries + * + * inquiry <- a/y address of buffer (>=256 byte) + * x = device SCSI ID + * -> buffer contains SCSI return + * + * getsize <- a/y address of buffer (>=8 byte) + * x = device SCSI ID + * -> buffer contains 4 byte # of blocks (hi-low format) + * and 4 byte byte/blocks (hi-lo) + * + * readblock <- a/y address of buffer (>= N * byte/block) + * x = SCSI device address + * lba (4 byte) LBA of first block to read (hi-lo) + * nsec (2 byte) # of blocks to read (consecutively) + * -> buffer contains data + * writeblock <- see readblock, buffer contains data + * + * + * $Log$ + * + */ + +#undef DEBUG +/* #undef PRINT */ +/* #undef STANDALONE */ + +#ifndef SCSIBASE +#define SCSIBASE $e870 +#endif + +#ifdef DEBUG +#define PRINT +#endif + +#ifdef PRINT2 +#define PRINT +#endif + +/********************************************************************** + * system defines + */ +/* +#define DATA $e870 +#define CTRL $e871 +#define STATUS $e871 + +#define DATA $de70 +#define CTRL $de71 +#define STATUS $de71 +*/ + +#define DATA 0+SCSIBASE +#define CTRL 1+SCSIBASE +#define STATUS 1+SCSIBASE + +#define S_IO %00000001 +#define S_ACK %00000010 +#define S_RST %00000100 +#define S_BSY %00001000 +#define S_MSG %00010000 +#define S_REQ %01000000 /* check BVC/BVS */ +#define S_CD %10000000 /* check BMI/BPL */ + +#define S_PHASEMASK S_IO+S_CD+S_MSG +#define S_DATAIN S_IO +#define S_MSGIN S_IO+S_CD+S_MSG +#define S_STATUS S_IO+S_CD +#define S_COMMAND S_CD + +#define C_RST %10000000 +#define C_SEL %00001000 +#define C_BSY %00000100 +#define C_IDENT %00000010 +#define C_ATN %00000001 + +#define MYID 7 /* hardcoded in controller */ + +#ifdef PRINT +#define log(a) ldx #a:jsr logout +#define hout(a) lda a:jsr hexout +#define crlf() jsr crlfout +#else +#define log(a) +#define hout(a) +#define crlf(a) +#endif + +#ifdef DEBUG +#define lc(a) php:pha:lda #a:jsr cout:pla:plp +#else +#define lc(a) +#endif + +/************************************************************************* + * load addr and Jump table + */ + +#ifdef STANDALONE + + lda #buffer + jsr initscsi + + lda #0 + sta task+2 + sta task+3 + sta task+4 + sta task+5 + + sta task+7 + lda #1 + sta task+8 + + lda #buffer + ldx #0 + jsr readblock + rts + +#endif + + .( + +/************************************************************************* + * globals + */ + + ; powers of 2 + +pow2 .byt 1, 2, 4, 8, 16, 32, 64, 128 + + + .zero +&dp .word 0 + .text + +/************************************************************************* + * SCSI Subroutines + */ + +; reqwait waits for request from device + +reqwait lda #S_BSY +reqw bit STATUS + beq reqend + bvc reqw +reqend rts + +; waitbsy waits until the device is busy + +waitbsy lda STATUS + and #S_BSY + beq waitbsy + rts + +; waitrdy waits until the device is ready + +waitrdy lda STATUS + and #S_BSY + bne waitrdy + rts + +; clrtask clears the command buffer + +clrtask ldy #0 + tya +gs1 sta task,y + iny + cpy #10 + bcc gs1 + rts + +; selcntr selects the default controller + +selcntr + lc("A") + sei + lda #0 + sta CTRL + jsr waitrdy + + ldy #MYID + lda pow2,y + sta DATA ; own ID + ldy #C_BSY | C_IDENT ; sets ID bit and disables normal bus driver + sty CTRL ; arbitrate + nop +#if 0 /* if MYID != 7 */ + cmp DATA ; TODO - must check against e.g. %00111111 for ID=5 + beq gotit +lost + lc("L") + lda #0 + sta CTRL + sta DATA + jmp selcntr +#endif +gotit + lc("S") + ldy #C_SEL | C_BSY | C_IDENT + sty CTRL + ldy actdev ; controller select code + ora pow2,y + sta DATA ; write to data latch + lda #C_SEL | C_BSY | C_ATN + sta CTRL + and #$ff-C_BSY + sta CTRL + + ; now wait for busy, but only a defined time + ldy #5 +sel1 lda STATUS + and #S_BSY + bne busyok + tya + jsr wait30us + tay + lc(".") + dey + bne sel1 + lda #0 + sta DATA + sta CTRL + sec + rts +busyok lc(":") + clc + lda #0 + sta DATA + sta CTRL + rts + +error2 jmp error + +; taskout sends the command held in AC to the controller + +taskAout + ldy #10 + .byt $2c +taskout ldy #6 ; byte count + cmp #2 ; check for illegal code + beq error + sta task ; store command in table + ldx #0 +t1 jsr reqwait ; wait for request from device + lda task,x + sta DATA + inx + dey + bne t1 + rts + +; getstat retrieves the status byte and the null byte from the device +; at the end of a command. AC is returned with a non-zero value if +; an error has occured. + +getstat jsr reqwait + lda STATUS + and #S_PHASEMASK + beq gsend +#ifdef DEBUG + cmp #S_DATAIN + beq gsdatin + cmp #S_STATUS + beq gsst + cmp #S_MSGIN + beq gsmsgin + pha + lda #"*" + jsr cout + pla + jsr hexout + jmp gsget +gsdatin lda #"D" + .byt $2c +gsst lda #"S" + .byt $2c +gsmsgin lda #"M" + jsr cout +gsget +#endif +; jsr reqwait + lda DATA + tay +#ifdef DEBUG + jsr hexout +#endif + jmp getstat +gsend + cli +#ifdef DEBUG + lda #"-" + jsr cout + jsr crlfout +#endif + tya + and #2 + cmp #2 + rts + +error cli + log(2) + pla + pla + sec + rts + +wait30us + ldy #$5d + .byt $2c +wait75us + ldy #$ea + ldx #0 +w75a dex + bne w75a + dey + bne w75a + rts + +/************************************************************************* + * Read a block from the device + * task+2/3/4/5 has block number (hi-lo), task+7/8 has number of blocks to rd + * a/y has memory address of buffer where to write block to + */ + +&readblock + sta dp + sty dp+1 + stx actdev + +#ifdef PRINT2 + .( + log(10) + hout(actdev) + log(11) + ldy #0 +rdll lda lba,y + jsr hexout + iny + cpy #4 + bcc rdll + log(12) + hout(nsec) + hout(nsec+1) + log(13) + hout(dp+1) + hout(dp) + log(14) +nopr2 + .) +#endif + lda #0 + sta task+1 + sta task+9 + + jsr selcntr + bcs selerr3 + + lda #$28 ; read extended (32 bit LBA) + jsr taskAout + + ldy #0 +rdloop jsr reqwait + bmi rddone + lda DATA + sta (dp),y + iny + bne rdloop + inc dp+1 + jmp rdloop +rddone + jmp getstat + +selerr3 jmp selerr + +/************************************************************************* + * Read a block from the device + * task+2/3/4/5 has block number (hi-lo), task+7/8 has number of blocks to rd + * a/y has memory address of buffer where to write block to + */ + +&writeblock + sta dp + sty dp+1 + stx actdev + +#ifdef PRINT2 + .( + log(15) + hout(actdev) + log(11) + ldy #0 +rdll lda lba,y + jsr hexout + iny + cpy #4 + bcc rdll + log(12) + hout(nsec) + hout(nsec+1) + log(13) + hout(dp+1) + hout(dp) + log(14) +nopr2 + .) +#endif + lda #0 + sta task+1 + sta task+9 + + jsr selcntr + bcs selerr3 + + lda #$2A ; write extended (32 bit LBA) + jsr taskAout + + ldy #0 +wrloop jsr reqwait + bmi wrdone + lda (dp),y + sta DATA + iny + bne wrloop + inc dp+1 + jmp wrloop +wrdone jmp getstat + +/************************************************************************* + * Initialization (a/y = buffer) + */ + +&initscsi + sta dp + sty dp+1 + + log(0) + + sei + + lda #C_RST ; send reset pulse + sta CTRL + jsr wait30us ; approx. 30us + lda #0 + sta CTRL ; clear RST + + lda #12 ; wait approx. ? ms +rd jsr wait75us + sec + sbc #1 + bne rd + +; scan SCSI bus for devices + + jsr clrtask + lda #0 + sta actdev ; start with first device +iniloop + lda actdev + cmp #MYID + beq nodev + + jsr selcntr + bcs iselerr + lda #0 ; drive ready command + jsr taskout + jsr getstat + bcc iniok + + log(1) + hout(actdev) + crlf() + jmp next + +iselerr cli + log(4) + hout(actdev) + crlf() + jmp nodev + +iniok log(3) + hout(actdev) + crlf() + + lda dp + ldy dp+1 + ldx actdev + jsr inquire +#ifdef PRINT + pha + jsr loginquire + pla +#endif + .byt $2c +nodev lda #$ff + cli + ldx actdev + sta devtype,x + +#ifdef PRINT + cmp #5 + beq print + cmp #0 + bne next +print + lda dp + ldy dp+1 + ldx actdev + jsr getsize + jsr printsize +#endif +next + inc actdev + lda actdev + cmp #8 + bcc iniloop + + lda #devtype + ldx #8 + clc + rts + +selerr cli + log(4) + hout(actdev) + crlf() + sec + rts + +/************************************************************************* + * Inquire device status/info into buffer (addr=a/y) + */ + +&inquire + sta dp + sty dp+1 + stx actdev + lc("i") + jsr clrtask + jsr selcntr +selerr2 bcs selerr + lda #<-1 + sta task+4 + lda #$12 + jsr taskout + + ldy #0 +inl jsr reqwait + bmi indone + lda DATA + sta (dp),y + iny + bne inl +indone +#ifdef DEBUG + lc("d") + tya + jsr hexout +#endif + jsr getstat + bcc inrts + jmp error +inrts ldy #0 + lda (dp),y ; 0 = disk, 1 = Tape, 5 = CDROM + rts + + +/************************************************************************* + * Get Medium capacity, a/y = buffer + * returns 4 byte # of blocks (hi-low format) + 4 byte byte/block in + * buffer + */ + +&getsize + sta dp + sty dp+1 + stx actdev + jsr clrtask + jsr selcntr + bcs selerr2 + lda #$25 + jsr taskAout + ldy #0 +gsl jsr reqwait + bmi gsdone + lda DATA + sta (dp),y + iny + bne gsl +gsdone jsr getstat + bcc gsrts + jmp error +gsrts rts + +/************************************************************************* + * Print data subroutines + *************************************************************************/ + +#ifdef PRINT + +/************************************************************************* + * Print inquiry data + */ + +loginquire + ldy #8 +li1 lda (dp),y + jsr cout + iny + cpy #32 + bcc li1 + log(5) + ldy #0 + lda (dp),y + and #%00011111 + jsr hexout + log(6) + ldy #2 + lda (dp),y + and #%00000111 + jsr hexout +liret log(7) + rts + +/************************************************************************* + * Print media size + */ + +printsize + log(8) + + ldy #0 +pl1 lda (dp),y + jsr hexout + iny + cpy #4 + bcc pl1 + + log(9) + + ldy #4 +pl2 lda (dp),y + jsr hexout + iny + cpy #8 + bcc pl2 + + jmp liret + + +/************************************************************************* + * Generic Subroutines + */ + +logout txa + asl + tax + lda laddr+1,x + tay + lda laddr,x + jmp txtout + +laddr .word logt0, logt1, logt2, logt3, logt4, int0, int1, int2, ps1, ps2 +#ifdef PRINT2 + .word rd1, rd2, rd3, rd4, rd5, rd6 +#endif + +logt0 .asc 13,10,"CS/A65 SCSI driver",13,10 + .asc 13,10,"Resetting SCSI bus",13,10,0 +logt1 .asc "Device not ready ",0 +logt2 .asc "Device error bit set",13,10,0 +logt3 .asc "Device found ",0 +logt4 .asc "Device select timeout ",0 + +int0 .asc "[Type ",0 +int1 .asc ", SCSI Rev. ",0 +int2 .asc "]",13,10,0 + +ps1 .asc " [Blocks: ",0 +ps2 .asc ", Byte/Block: ",0 + +#ifdef PRINT2 + +rd1 .asc "Read Block Dev: ",0 +rd2 .asc ", Sect: ",0 +rd3 .asc ", nsec: ",0 +rd4 .asc " To: ",0 +rd5 .asc 13,10,0 +rd6 .asc "Write Block Dev: ",0 + +#endif + +#endif /* PRINT */ + +/************************************************************************* + * Data structures (no extended read/writes) + */ + + .bss + +; active device number (0-7) + +actdev .byt 0 + +; contains the device type for each SCSI ID + +&devtype .dsb 8 + +; this structure is sent as it is for one command + +task .byt 0 ; command code + .byt 0 ; LUN +&lba .byt 0 ; + .byt 0 ; + .byt 0 ; + .byt 0 ; + .byt 0 +&nsec .byt 0 + .byt 0 + .byt 0 + + .) + +#ifdef STANDALONE + +buffer =* + +#endif + .text + + + diff --git a/dump/oa-2.0.9/devices/scsi/csascsi1.fig b/dump/oa-2.0.9/devices/scsi/csascsi1.fig new file mode 100644 index 0000000..d67b4ec --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/csascsi1.fig @@ -0,0 +1,1405 @@ +#FIG 3.2 +Portrait +Center +Metric +A4 +70.00 +Single +2 +1200 2 +5 1 1 1 0 7 0 0 -1 4.000 0 1 0 0 14422.500 5512.500 14400 5400 14310 5490 14400 5625 +6 1575 8325 3825 9000 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 3600 8550 45 45 3600 8550 3645 8550 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 2250 8550 1800 8550 1800 8775 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 8550 3600 8550 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1710 8775 1890 8775 +4 0 0 0 0 16 12 0.0000 4 135 405 2250 8550 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 8550 20\001 +4 0 0 0 0 16 12 0.0000 4 135 210 2025 8550 10\001 +4 0 0 0 0 16 12 0.0000 4 135 345 2790 8550 Vcc\001 +-6 +6 5625 4950 7875 5625 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 7650 5175 45 45 7650 5175 7695 5175 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 6300 5175 5850 5175 5850 5400 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 5175 7650 5175 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 5760 5400 5940 5400 +4 0 0 0 0 16 12 0.0000 4 135 405 6300 5175 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 5175 20\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 5175 10\001 +4 0 0 0 0 16 12 0.0000 4 135 345 6840 5175 Vcc\001 +-6 +6 7515 1800 8010 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 7762.500 2475.000 7560 2295 7740 2205 7965 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 7762.500 2385.000 7560 2205 7740 2115 7965 2205 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 7801.875 2171.250 7560 2205 7650 1980 7740 1935 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 7738.269 2165.192 7965 2205 7875 1980 7740 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 7740 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7740 1935 7740 1800 +-6 +6 7965 1800 8460 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8212.500 2475.000 8010 2295 8190 2205 8415 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8212.500 2385.000 8010 2205 8190 2115 8415 2205 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8251.875 2171.250 8010 2205 8100 1980 8190 1935 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 8188.269 2165.192 8415 2205 8325 1980 8190 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 8190 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8190 1935 8190 1800 +-6 +6 8415 1800 8910 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8662.500 2475.000 8460 2295 8640 2205 8865 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8662.500 2385.000 8460 2205 8640 2115 8865 2205 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8701.875 2171.250 8460 2205 8550 1980 8640 1935 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 8638.270 2165.192 8865 2205 8775 1980 8640 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 8640 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8640 1935 8640 1800 +-6 +6 8865 1800 9360 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 9112.500 2475.000 8910 2295 9090 2205 9315 2295 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 9112.500 2385.000 8910 2205 9090 2115 9315 2205 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 9151.875 2171.250 8910 2205 9000 1980 9090 1935 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 9088.270 2165.192 9315 2205 9225 1980 9090 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 9090 1935 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9090 1935 9090 1800 +-6 +6 7740 1260 8235 1755 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 7987.500 1935.000 7785 1755 7965 1665 8190 1755 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 7987.500 1845.000 7785 1665 7965 1575 8190 1665 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8026.875 1631.250 7785 1665 7875 1440 7965 1395 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 7963.269 1625.192 8190 1665 8100 1440 7965 1395 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 7965 1395 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7965 1395 7965 1260 +-6 +6 8640 1260 9135 1755 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8887.500 1935.000 8685 1755 8865 1665 9090 1755 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8887.500 1845.000 8685 1665 8865 1575 9090 1665 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8926.875 1631.250 8685 1665 8775 1440 8865 1395 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 8863.270 1625.192 9090 1665 9000 1440 8865 1395 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 8865 1395 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8865 1395 8865 1260 +-6 +6 8190 675 8685 1170 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8437.500 1350.000 8235 1170 8415 1080 8640 1170 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8437.500 1260.000 8235 1080 8415 990 8640 1080 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 8476.875 1046.250 8235 1080 8325 855 8415 810 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 8413.270 1040.192 8640 1080 8550 855 8415 810 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 8415 810 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8415 810 8415 675 +-6 +6 9450 450 9675 900 +1 4 0 1 0 7 0 0 -1 0.000 1 0.0000 9562 787 33 33 9540 765 9585 810 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 9450 540 9450 810 9675 675 9450 540 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9585 810 9585 900 +-6 +6 11925 1350 14175 2025 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 12015 1350 14085 1350 14085 2025 12015 2025 12015 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12240 1350 12240 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12465 1350 12465 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12690 1350 12690 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12915 1350 12915 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13140 1350 13140 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13365 1350 13365 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13590 1350 13590 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13815 1350 13815 2025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 12150 1350 +-6 +6 11925 9000 14175 9675 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 12015 9000 14085 9000 14085 9675 12015 9675 12015 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12240 9000 12240 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12465 9000 12465 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12690 9000 12690 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12915 9000 12915 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13140 9000 13140 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13365 9000 13365 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13590 9000 13590 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13815 9000 13815 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 1 + 12150 9000 +-6 +6 12150 900 14175 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 12150 1350 12150 900 14175 900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12375 900 12375 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12600 900 12600 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12825 900 12825 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13050 900 13050 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13275 900 13275 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13500 900 13500 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13725 900 13725 1350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13950 900 13950 1350 +-6 +6 12375 14985 12600 15165 +1 4 0 1 0 7 0 0 -1 0.000 1 0.0000 12555 15075 45 45 12510 15075 12600 15075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 12375 14985 12375 15165 12510 15075 12375 14985 +-6 +6 12375 15210 12600 15390 +1 4 0 1 0 7 0 0 -1 0.000 1 0.0000 12555 15300 45 45 12510 15300 12600 15300 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 12375 15210 12375 15390 12510 15300 12375 15210 +-6 +6 8775 13950 9225 14175 +1 4 0 1 0 7 0 0 -1 0.000 0 4.7124 8888 14063 33 33 8910 14085 8865 14040 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 9135 14175 8865 14175 9000 13950 9135 14175 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8865 14040 8775 14040 +-6 +6 10350 9225 11925 13950 +6 10440 9900 11610 10575 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 10440 9900 11610 9900 11610 10575 10440 10575 10440 9900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10665 9900 10665 10575 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10890 9900 10890 10575 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11115 9900 11115 10575 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11340 9900 11340 10575 +-6 +6 10440 12375 11610 13050 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 10440 12375 11610 12375 11610 13050 10440 13050 10440 12375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10665 12375 10665 13050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10890 12375 10890 13050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11115 12375 11115 13050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11340 12375 11340 13050 +-6 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 11700 9450 45 45 11700 9450 11745 9450 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11475 9450 45 45 11475 9450 11520 9450 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11250 9450 45 45 11250 9450 11295 9450 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11025 9450 45 45 11025 9450 11070 9450 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 10800 9450 45 45 10800 9450 10845 9450 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 10575 13500 45 45 10575 13500 10620 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 10800 13500 45 45 10800 13500 10845 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11025 13500 45 45 11025 13500 11070 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11250 13500 45 45 11250 13500 11295 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 10575 11025 45 45 10575 11025 10620 11025 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 10800 11250 45 45 10800 11250 10845 11250 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11025 11475 45 45 11025 11475 11070 11475 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11250 11700 45 45 11250 11700 11295 11700 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11475 11925 45 45 11475 11925 11520 11925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10575 10575 10575 12375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10800 10575 10800 12375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 10575 11025 12375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11250 10575 11250 12375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11475 10575 11475 12375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 10575 9900 10575 9450 11700 9450 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10800 9900 10800 9450 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 9450 11025 9900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11250 9450 11250 9900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11475 9450 11475 9900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10575 13050 10575 13725 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10800 13050 10800 13500 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 13050 11025 13500 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11250 13050 11250 13500 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 11475 13050 11475 13500 10575 13500 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 10485 13725 10665 13725 +-6 +6 9315 9900 10035 10350 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 9675.000 10398.214 9315 10350 9675 10035 10035 10350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9315 10350 10035 10350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9675 10035 9675 9900 +-6 +6 9540 9135 9810 9450 +1 4 0 1 0 7 0 0 -1 0.000 1 0.0000 9675 9180 45 45 9675 9225 9675 9135 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 9540 9450 9810 9450 9675 9225 9540 9450 +-6 +6 6300 17550 7200 18450 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 6300 17550 7200 17550 7200 18450 6300 18450 6300 17550 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 6300 17910 6525 18000 6300 18090 +4 0 0 0 0 16 12 0.0000 4 135 135 6345 17865 D\001 +4 0 0 0 0 16 12 0.0000 4 135 180 6345 18315 /S\001 +4 0 0 0 0 16 12 0.0000 4 135 180 6930 18315 /R\001 +4 0 0 0 0 16 12 0.0000 4 135 150 6975 17865 Q\001 +-6 +6 6300 19125 7200 20025 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 6300 19125 7200 19125 7200 20025 6300 20025 6300 19125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 6300 19485 6525 19575 6300 19665 +4 0 0 0 0 16 12 0.0000 4 135 135 6345 19440 D\001 +4 0 0 0 0 16 12 0.0000 4 135 180 6345 19890 /S\001 +4 0 0 0 0 16 12 0.0000 4 135 180 6930 19890 /R\001 +4 0 0 0 0 16 12 0.0000 4 135 150 6975 19440 Q\001 +-6 +6 12375 15660 12600 15840 +1 4 0 1 0 7 0 0 -1 0.000 1 0.0000 12555 15750 45 45 12510 15750 12600 15750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 12375 15660 12375 15840 12510 15750 12375 15660 +-6 +6 12375 16110 12600 16290 +1 4 0 1 0 7 0 0 -1 0.000 1 0.0000 12555 16200 45 45 12510 16200 12600 16200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 12375 16110 12375 16290 12510 16200 12375 16110 +-6 +6 10125 15975 10575 16425 +1 4 0 1 0 7 0 0 -1 0.000 1 4.7124 10350 16155 45 45 10350 16110 10350 16200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 10440 15975 10260 15975 10350 16110 10440 15975 +-6 +6 13140 13950 14085 14625 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 13140 13950 14085 13950 14085 14625 13140 14625 13140 13950 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13365 13950 13365 14625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13590 13950 13590 14625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13815 13950 13815 14625 +-6 +6 13140 16650 14085 17325 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 13140 16650 14085 16650 14085 17325 13140 17325 13140 16650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13365 16650 13365 17325 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13590 16650 13590 17325 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13815 16650 13815 17325 +-6 +6 4050 8775 4500 9225 +1 4 0 1 0 7 0 0 -1 0.000 0 1.5708 4275 9045 45 45 4275 9090 4275 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 4365 9225 4185 9225 4275 9090 4365 9225 +-6 +6 4500 15750 4950 16200 +1 4 0 1 0 7 0 0 -1 0.000 1 0.0000 4680 15975 45 45 4635 15975 4725 15975 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 4500 15885 4500 16065 4635 15975 4500 15885 +-6 +6 3015 14625 3735 15075 +5 1 0 1 0 7 0 0 -1 0.000 0 1 0 0 3375.000 14576.786 3015 14625 3375 14940 3735 14625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3015 14625 3735 14625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3375 14940 3375 15075 +-6 +6 9675 13950 10125 14175 +1 4 0 1 0 7 0 0 -1 0.000 0 4.7124 9788 14063 33 33 9810 14085 9765 14040 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 10035 14175 9765 14175 9900 13950 10035 14175 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9765 14040 9675 14040 +-6 +6 13185 18585 15660 19935 +4 0 -1 0 0 18 20 0.0000 4 270 1740 13185 19155 (c) A. Fachat\001 +4 0 -1 0 0 18 20 0.0000 4 270 2475 13185 19500 All rights reserved\001 +4 0 -1 0 0 18 20 0.0000 4 270 1755 13185 19845 No Warranty!\001 +4 0 -1 0 0 18 20 0.0000 4 210 1440 13185 18810 CS/A SCSI\001 +-6 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 3600 6075 45 45 3600 6075 3645 6075 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 3600 7200 45 45 3600 7200 3645 7200 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 3600 7425 45 45 3600 7425 3645 7425 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 3825 6975 45 45 3825 6975 3870 6975 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 3825 6750 45 45 3825 6750 3870 6750 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 3825 6525 45 45 3825 6525 3870 6525 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 4050 6075 45 45 4050 6075 4095 6075 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 3600 11700 45 45 3600 11700 3645 11700 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 1800 12600 45 45 1800 12600 1845 12600 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 9225 4275 45 45 9225 4275 9270 4275 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 9000 4050 45 45 9000 4050 9045 4050 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 8775 3825 45 45 8775 3825 8820 3825 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 8550 3600 45 45 8550 3600 8595 3600 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 8325 3375 45 45 8325 3375 8370 3375 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 8100 3150 45 45 8100 3150 8145 3150 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 7875 2925 45 45 7875 2925 7920 2925 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 7650 2700 45 45 7650 2700 7695 2700 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 9450 4725 45 45 9450 4725 9495 4725 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12150 2475 45 45 12150 2475 12195 2475 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12375 2700 45 45 12375 2700 12420 2700 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12600 2925 45 45 12600 2925 12645 2925 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12825 3150 45 45 12825 3150 12870 3150 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13050 3375 45 45 13050 3375 13095 3375 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13275 3600 45 45 13275 3600 13320 3600 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13500 3825 45 45 13500 3825 13545 3825 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 4050 45 45 13725 4050 13770 4050 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13950 4275 45 45 13950 4275 13995 4275 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 14175 900 45 45 14175 900 14220 900 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12375 6750 45 45 12375 6750 12420 6750 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12600 6975 45 45 12600 6975 12645 6975 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12825 7200 45 45 12825 7200 12870 7200 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13050 7425 45 45 13050 7425 13095 7425 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13275 7650 45 45 13275 7650 13320 7650 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13500 7875 45 45 13500 7875 13545 7875 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 8100 45 45 13725 8100 13770 8100 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13950 8325 45 45 13950 8325 13995 8325 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12375 10125 45 45 12375 10125 12420 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12150 10125 45 45 12150 10125 12195 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12600 10125 45 45 12600 10125 12645 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12825 10125 45 45 12825 10125 12870 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13050 10125 45 45 13050 10125 13095 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13275 10125 45 45 13275 10125 13320 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13500 10125 45 45 13500 10125 13545 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 10125 45 45 13725 10125 13770 10125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12375 900 45 45 12375 900 12420 900 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12600 900 45 45 12600 900 12645 900 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 12825 900 45 45 12825 900 12870 900 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13050 900 45 45 13050 900 13095 900 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13275 900 45 45 13275 900 13320 900 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13500 900 45 45 13500 900 13545 900 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 900 45 45 13725 900 13770 900 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 11475 5175 45 45 11475 5175 11520 5175 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 7650 13500 45 45 7650 13500 7695 13500 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 7650 9225 45 45 7650 9225 7695 9225 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 7650 16650 45 45 7650 16650 7695 16650 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 9000 8325 45 45 9000 8325 9045 8325 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 8775 15750 45 45 8775 15750 8820 15750 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 9900 11025 45 45 9900 11025 9945 11025 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 7650 18225 45 45 7650 18225 7695 18225 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 5850 18225 45 45 5850 18225 5895 18225 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 5850 19800 45 45 5850 19800 5895 19800 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 5850 19350 45 45 5850 19350 5895 19350 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 8325 17775 45 45 8325 17775 8370 17775 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 8100 19350 45 45 8100 19350 8145 19350 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 11925 11250 45 45 11925 11250 11970 11250 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13275 17775 45 45 13275 17775 13320 17775 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13500 17775 45 45 13500 17775 13545 17775 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 17775 45 45 13725 17775 13770 17775 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13275 15075 45 45 13275 15075 13320 15075 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13500 15300 45 45 13500 15300 13545 15300 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 15750 45 45 13725 15750 13770 15750 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13950 16200 45 45 13950 16200 13995 16200 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13500 13500 45 45 13500 13500 13545 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 13500 45 45 13725 13500 13770 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13725 13500 45 45 13725 13500 13770 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 13950 13500 45 45 13950 13500 13995 13500 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 5850 15975 45 45 5850 15975 5895 15975 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 4050 15975 45 45 4050 15975 4095 15975 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 4500 10575 45 45 4500 10575 4545 10575 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 4275 10350 45 45 4275 10350 4320 10350 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 14175 13500 45 45 14175 13500 14220 13500 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 14400 5625 45 45 14400 5625 14445 5625 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 14400 5400 45 45 14400 5400 14445 5400 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 14400 4725 45 45 14400 4725 14445 4725 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 2025 19125 45 45 2025 19125 2070 19125 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 2025 18675 45 45 2025 18675 2070 18675 +1 3 0 1 0 0 0 0 20 0.000 1 0.0000 9900 11925 45 45 9900 11925 9945 11925 +1 3 0 1 0 7 0 0 -1 0.000 1 0.0000 2025 16650 45 45 2025 16650 2070 16650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 675 1125 1350 1125 1350 13500 675 13500 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 2925 1800 2925 2025 2700 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 3150 1800 3150 2025 2925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 3375 1800 3375 2025 3150 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 3600 1800 3600 2025 3375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 3825 1800 3825 2025 3600 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 4050 1800 4050 2025 3825 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 4275 1800 4275 2025 4050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 4500 1800 4500 2025 4275 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 2250 5625 3150 5625 3150 8775 2250 8775 2250 5625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 6075 2250 6075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 6300 2250 6300 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 6525 2250 6525 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 6750 2250 6750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 6975 2250 6975 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 7200 2250 7200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 7425 2250 7425 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 7650 2250 7650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 8100 2250 8100 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 6075 4050 6075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 3150 7650 3600 7650 3600 6075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 7425 3600 7425 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 7200 3600 7200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 3150 6300 3825 6300 3825 7200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 6525 3825 6525 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 6750 3825 6750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 6975 3825 6975 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3735 7200 3915 7200 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 2250 9675 3150 9675 3150 11925 2250 11925 2250 9675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 10575 2250 10575 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 10800 2250 10800 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 11025 2250 11025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 6 + 3150 8100 3825 8100 3825 9225 1800 9225 1800 9900 2250 9900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 11250 2250 11250 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 2250 10125 1800 10125 1800 10350 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1710 10350 1890 10350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 2250 11700 1800 11700 1800 11925 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1710 11925 1890 11925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3150 11700 3600 11700 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1350 12600 1800 12600 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1350 12825 1800 12825 1800 13050 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1710 13050 1890 13050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 6 + 2025 4275 2025 2250 2250 2025 5175 2025 5400 2250 5400 17550 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 2475 5625 2700 6300 2700 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 2700 5625 2925 6300 2925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 2925 5625 3150 6300 3150 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 3150 5625 3375 6300 3375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 3375 5625 3600 6300 3600 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 3600 5625 3825 6300 3825 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 3825 5625 4050 6300 4050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 4050 5625 4275 6300 4275 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 6300 2250 7200 2250 7200 5400 6300 5400 6300 2250 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 2925 10125 2925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 3150 10125 3150 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 3375 10125 3375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 3600 10125 3600 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 3825 10125 3825 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 4050 10125 4050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 4275 10125 4275 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7650 2250 7650 2700 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7875 2250 7875 2925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8100 2250 8100 3150 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8325 2250 8325 3375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8550 2250 8550 3600 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8775 2250 8775 3825 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9000 2250 9000 4050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9225 2250 9225 4275 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7740 1800 7875 1800 7875 1710 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 8190 1800 8100 1800 8100 1710 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 8640 1800 8775 1800 8775 1710 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 9090 1800 9000 1800 9000 1710 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7965 1260 8325 1260 8325 1125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 8550 1125 8550 1260 8865 1260 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8415 675 8550 675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8550 675 9450 675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 9585 900 9585 1125 9450 1125 9450 6075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9450 4725 10125 4725 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7200 4725 7650 4725 7650 4950 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7560 4950 7740 4950 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 2700 15075 2700 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 2925 15075 2925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 3150 15075 3150 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 3375 15075 3375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 3600 15075 3600 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 3825 15075 3825 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 4050 15075 4050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 4275 15075 4275 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 9675 675 11475 675 11475 2475 15075 2475 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12150 2025 12150 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12375 2025 12375 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12600 2025 12600 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12825 2025 12825 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13050 2025 13050 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13275 2025 13275 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13500 2025 13500 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13725 2025 13725 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13950 2025 13950 9000 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9585 5400 9765 5400 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 6750 12375 6750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 6975 12600 6975 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 7200 12825 7200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 7425 13050 7425 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 7650 13275 7650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 7875 13500 7875 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 8100 13725 8100 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 8325 13950 8325 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 6525 5625 6750 6300 6750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 6975 5625 7200 6300 7200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 7200 5625 7425 6300 7425 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 7425 5625 7650 6300 7650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 7650 5625 7875 6300 7875 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 7875 5625 8100 6300 8100 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 8100 5625 8325 6300 8325 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12375 9675 12375 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12600 9675 12600 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12825 9675 12825 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13050 9675 13050 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13275 9675 13275 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13500 9675 13500 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13725 9675 13725 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13950 9675 13950 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12150 9675 12150 10350 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12060 10350 12240 10350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12150 10125 13950 10125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 2700 10125 2700 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 10125 2250 11025 2250 11025 5400 10125 5400 10125 2250 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 11025 4725 11475 4725 11475 4950 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11385 4950 11565 4950 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 10125 5175 9675 5175 9675 5400 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 11025 5175 11475 5175 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 6750 5625 6975 6300 6975 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 6300 10575 7200 10575 7200 13725 6300 13725 6300 10575 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7200 13050 7650 13050 7650 13275 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7560 13275 7740 13275 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 6300 13500 5850 13500 5850 13725 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 13500 7650 13500 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 5760 13725 5940 13725 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 6300 6300 7200 6300 7200 9450 6300 9450 6300 6300 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7200 8775 7650 8775 7650 9000 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7560 9000 7740 9000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 6300 9225 5850 9225 5850 9450 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 9225 7650 9225 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 5760 9450 5940 9450 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 10800 5625 11025 6300 11025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 11025 5625 11250 6300 11250 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 11250 5625 11475 6300 11475 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 11475 5625 11700 6300 11700 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 11700 5625 11925 6300 11925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 11925 5625 12150 6300 12150 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 12150 5625 12375 6300 12375 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 11025 15075 11025 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 11250 15075 11250 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 11475 15075 11475 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 11925 15075 11925 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 6300 14625 7200 14625 7200 16875 6300 16875 6300 14625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 14850 5625 15075 6300 15075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 15075 5625 15300 6300 15300 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 15300 5625 15525 6300 15525 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 15525 5625 15750 6300 15750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 6300 16650 5850 16650 5850 16875 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 16650 7650 16650 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 5760 16875 5940 16875 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 15075 12375 15075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12600 15075 15075 15075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12600 15300 15075 15300 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9000 14175 9000 14400 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 8910 14400 9090 14400 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7200 15750 8775 15750 8775 14040 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9000 13950 9000 8325 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9900 11025 9900 10350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 9675 9000 9675 6075 9450 6075 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9675 9450 9675 9900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9675 9000 9675 9135 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5400 17550 5625 17775 6300 17775 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 6300 18225 5850 18225 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 18225 7650 18225 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 6300 19800 5850 19800 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 6300 19350 5850 19350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 11700 15075 11700 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 9675 14040 9675 15525 7200 15525 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7200 12150 8325 12150 8325 17775 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 7200 12375 8100 12375 8100 19350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7200 15300 12375 15300 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 7200 17775 10800 17775 10800 15750 12375 15750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12600 15750 15075 15750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 12600 16200 15075 16200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 11925 11250 11925 14625 10350 14625 10350 15975 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 7200 19350 11250 19350 11250 16200 12375 16200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 10350 16200 10350 19800 7200 19800 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 15750 1800 15075 1800 15075 17550 15750 17550 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 14625 7650 14625 7425 15075 7425 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 14535 7650 14715 7650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 14535 8325 15075 8325 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13275 14625 13275 16650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13500 14625 13500 16650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13725 14625 13725 16650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13950 14625 13950 16650 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 13275 13950 13275 13500 14175 13500 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13500 13500 13500 13950 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13725 13500 13725 13950 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13950 13500 13950 13950 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13275 17325 13275 18000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13500 17325 13500 17775 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13725 17325 13725 17775 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 13950 17325 13950 17775 13275 17775 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 13185 18000 13365 18000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 3150 10350 4275 10350 4275 9225 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 4275 9000 4275 4725 6300 4725 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 3150 10575 4500 10575 4500 8775 6300 8775 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 3150 10800 4050 10800 4050 15975 4500 15975 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 4725 15975 6300 15975 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 5850 15975 5850 16200 6300 16200 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 4050 15975 4050 18000 6300 18000 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 3150 11025 3825 11025 3825 13050 6300 13050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 4275 10350 4275 13950 3150 13950 3150 14625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 4 + 4500 10575 4500 14175 3600 14175 3600 14625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 8775 15750 9450 15750 9450 10350 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 3375 15075 3375 19575 6300 19575 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1935 19800 2115 19800 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1575 19575 2025 19575 2025 19800 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 675 18225 1575 18225 1575 20025 675 20025 675 18225 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 225 225 16650 225 16650 21375 225 21375 225 225 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 15075 5850 14400 5850 14400 5625 +2 1 0 1 0 7 0 0 -1 4.000 0 0 -1 0 0 2 + 14265 5175 14535 5175 +2 1 0 1 0 7 0 0 -1 4.000 0 0 -1 0 0 4 + 14400 5175 14265 4950 14535 4950 14400 5175 +2 1 0 1 0 7 0 0 -1 4.000 0 0 -1 0 0 2 + 14400 5175 14400 5400 +2 1 0 1 0 7 0 0 -1 4.000 0 0 -1 0 0 2 + 14400 4950 14400 4725 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 14625 6750 14625 6525 15075 6525 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 14535 6750 14715 6750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1575 19125 2025 19125 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1575 18450 2025 18450 2025 18900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1575 18675 2025 18675 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1935 18900 2115 18900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9900 14175 9900 14400 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9810 14400 9990 14400 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 9900 13950 9900 11925 +2 1 0 2 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1935 17550 2115 17550 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3 + 1575 17325 2025 17325 2025 17550 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 1575 16650 2025 16650 +2 2 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 5 + 675 15975 1575 15975 1575 17775 675 17775 675 15975 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 6075 c12\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 6300 c13\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 6525 c14\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 6750 c15\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 6975 c16\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 7200 c17\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 7425 c18\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 7650 c19\001 +4 0 0 0 0 16 12 0.0000 4 135 210 1350 8100 a7\001 +4 0 0 0 0 16 12 0.0000 4 135 345 900 6075 A11\001 +4 0 0 0 0 16 12 0.0000 4 135 345 900 6300 A10\001 +4 0 0 0 0 16 12 0.0000 4 135 600 675 8100 /IOSEL\001 +4 0 0 0 0 16 12 0.0000 4 135 195 2250 8100 /G\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 8100 19\001 +4 0 0 0 0 16 12 0.0000 4 135 420 2700 8100 /A=B\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 8100 1\001 +4 0 0 0 0 16 12 0.0000 4 135 360 2475 5850 '688\001 +4 0 0 0 0 16 12 0.0000 4 135 210 2025 6075 12\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 6300 9\001 +4 0 0 0 0 16 12 0.0000 4 135 210 2025 6525 14\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 6750 7\001 +4 0 0 0 0 16 12 0.0000 4 135 210 2025 6975 16\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 7200 5\001 +4 0 0 0 0 16 12 0.0000 4 135 210 2025 7425 18\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 7650 3\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 6075 11\001 +4 0 0 0 0 16 12 0.0000 4 135 105 3150 6300 8\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 6525 13\001 +4 0 0 0 0 16 12 0.0000 4 135 105 3150 6750 6\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 6975 15\001 +4 0 0 0 0 16 12 0.0000 4 135 105 3150 7200 4\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 7425 17\001 +4 0 0 0 0 16 12 0.0000 4 135 105 3150 7650 2\001 +4 0 0 0 0 16 12 0.0000 4 135 285 2475 5625 IC1\001 +4 0 0 0 0 16 12 0.0000 4 135 285 2475 9675 IC2\001 +4 0 0 0 0 16 12 0.0000 4 135 360 2700 9900 '138\001 +4 0 0 0 0 16 12 0.0000 4 135 285 2250 9900 /E1\001 +4 0 0 0 0 16 12 0.0000 4 135 285 2250 10125 /E2\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2250 10575 E3\001 +4 0 0 0 0 16 12 0.0000 4 135 135 2250 10800 C\001 +4 0 0 0 0 16 12 0.0000 4 135 120 2250 11025 B\001 +4 0 0 0 0 16 12 0.0000 4 135 135 2250 11250 A\001 +4 0 0 0 0 16 12 0.0000 4 135 405 2250 11700 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 345 2790 11700 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 9900 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 10125 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 10575 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 10800 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 11025 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 11250 1\001 +4 0 0 0 0 16 12 0.0000 4 135 105 2025 11700 8\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 11700 16\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 10575 c26\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 10800 c22\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 11025 c23\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 11250 c25\001 +4 0 0 0 0 16 12 0.0000 4 135 375 900 10575 Phi2\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 10800 A1\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 11025 A0\001 +4 0 0 0 0 16 12 0.0000 4 135 465 900 11250 R/-W\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 10350 15\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 10575 14\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 10800 13\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 11025 12\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 2925 a22\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 3150 a21\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 3375 a20\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 3600 a19\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 3825 a18\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 4050 a17\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 4500 a15\001 +4 0 0 0 0 16 12 0.0000 4 135 315 1350 4275 a16\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 2925 D0\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 3150 D1\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 3375 D2\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 3600 D3\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 3825 D4\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 4050 D5\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 4275 D6\001 +4 0 0 0 0 16 12 0.0000 4 135 240 900 4500 D7\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 2700 D0\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 4275 D7\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 2700 19\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 2925 18\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 3150 17\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 3375 16\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 3600 15\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 3825 14\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 4275 12\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 4050 13\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 4725 1\001 +4 0 0 0 0 16 12 0.0000 4 135 330 6840 4725 /OE\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 4275 Q7\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 4050 Q6\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 3825 Q5\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 3600 Q4\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 3375 Q3\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 3150 Q2\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 2925 Q1\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 2700 Q0\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 2700 D0\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 2925 D1\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 3150 D2\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 3375 D3\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 3600 D4\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 3825 D5\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 4050 D6\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 4275 D7\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6300 4725 LE\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 2700 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 2925 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 3150 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 3375 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 3600 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 3825 7\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 4050 8\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 4275 9\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 4725 11\001 +4 0 0 0 0 16 12 0.0000 4 135 285 6525 2250 IC6\001 +4 0 0 0 0 16 12 0.0000 4 135 360 6525 2475 '573\001 +4 0 0 0 0 16 12 0.0000 4 135 390 10350 2250 IC10\001 +4 0 0 0 0 16 12 0.0000 4 135 360 10350 2475 '540\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 2700 18\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 2925 17\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 3150 16\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 3375 15\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 3600 14\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 3825 13\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 4050 12\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 4275 11\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 4725 19\001 +4 0 0 0 0 16 12 0.0000 4 135 435 10575 4725 /OE2\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 2700 E0\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 2925 E1\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 3150 E2\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 3375 E3\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 3600 E4\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 3825 E5\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 4050 E6\001 +4 0 0 0 0 16 12 0.0000 4 135 225 10125 4275 E7\001 +4 0 0 0 0 16 12 0.0000 4 135 435 10125 4725 /OE1\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 2700 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 2925 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 3150 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 3375 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 3600 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 3825 7\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 4050 8\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 4275 9\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9900 4725 1\001 +4 0 0 0 0 16 12 0.0000 4 135 405 10125 5175 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 210 11025 5175 20\001 +4 0 0 0 0 16 12 0.0000 4 135 210 9900 5175 10\001 +4 0 0 0 0 16 12 0.0000 4 135 345 10665 5175 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 360 6525 10800 '540\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 13050 19\001 +4 0 0 0 0 16 12 0.0000 4 135 435 6750 13050 /OE2\001 +4 0 0 0 0 16 12 0.0000 4 135 435 6300 13050 /OE1\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 13050 1\001 +4 0 0 0 0 16 12 0.0000 4 135 405 6300 13500 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 13500 20\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 13500 10\001 +4 0 0 0 0 16 12 0.0000 4 135 345 6840 13500 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 11025 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 11250 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 11475 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 11700 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 11925 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 12150 7\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 12375 8\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 12600 9\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 11025 /Q0\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 11250 /Q1\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 11475 /Q2\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 11700 /Q3\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 11925 /Q4\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 12150 /Q5\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 12375 /Q6\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 12600 /Q7\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 11025 18\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 11250 17\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 11475 16\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 11700 15\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 11925 14\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 12150 13\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 12375 12\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 12600 11\001 +4 0 0 0 0 16 12 0.0000 4 135 285 6525 6300 IC7\001 +4 0 0 0 0 16 12 0.0000 4 135 360 6525 6525 '540\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 8775 19\001 +4 0 0 0 0 16 12 0.0000 4 135 435 6750 8775 /OE2\001 +4 0 0 0 0 16 12 0.0000 4 135 435 6300 8775 /OE1\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 8775 1\001 +4 0 0 0 0 16 12 0.0000 4 135 405 6300 9225 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 9225 20\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 9225 10\001 +4 0 0 0 0 16 12 0.0000 4 135 345 6840 9225 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 6750 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 6975 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 7200 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 7425 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 7650 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 7875 7\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 8100 8\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 8325 9\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 6750 /Q0\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 6975 /Q1\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 7200 /Q2\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 7425 /Q3\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 7650 /Q4\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 7875 /Q5\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 8100 /Q6\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6300 8325 /Q7\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 6750 18\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 6975 17\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 7200 16\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 7425 15\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 7650 14\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 7875 13\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 8100 12\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 8325 11\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 11025 D0\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 11250 D6\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 11475 D7\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 11700 D4\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 11925 D3\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 12150 D2\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 12375 D1\001 +4 0 0 0 0 16 12 0.0000 4 135 405 6300 16650 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 345 6840 16650 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 16650 12\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 16650 5\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 15075 D0\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 15300 D3\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 15525 D2\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 15750 D1\001 +4 0 0 0 0 16 12 0.0000 4 135 105 12150 15075 4\001 +4 0 0 0 0 16 12 0.0000 4 135 210 12600 15075 16\001 +4 0 0 0 0 16 12 0.0000 4 135 105 12150 15300 3\001 +4 0 0 0 0 16 12 0.0000 4 135 210 12600 15300 17\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6525 14850 '75\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 15075 16\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 15300 15\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 15525 11\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 15750 8\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 15075 1D\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 15300 2D\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 15525 3D\001 +4 0 0 0 0 16 12 0.0000 4 135 240 6300 15750 4D\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 15075 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 15300 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 15525 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 15750 7\001 +4 0 0 0 0 16 12 0.0000 4 135 390 9675 450 IC13\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9675 675 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9225 675 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9675 900 1\001 +4 0 0 0 0 16 12 0.0000 4 135 495 14175 1575 9*220\001 +4 0 0 0 0 16 12 0.0000 4 135 495 14175 9225 9*330\001 +4 0 0 0 0 16 12 0.0000 4 135 345 14175 9450 RP2\001 +4 0 0 0 0 16 12 0.0000 4 135 345 14175 1800 RP1\001 +4 0 0 0 0 16 12 0.0000 4 135 210 9450 9225 12\001 +4 0 0 0 0 16 12 0.0000 4 135 285 9225 9450 IC4\001 +4 0 0 0 0 16 12 0.0000 4 135 285 9900 10125 IC3\001 +4 0 0 0 0 16 12 0.0000 4 135 240 4950 17775 D7\001 +4 0 0 0 0 16 12 0.0000 4 135 390 10125 14175 IC13\001 +4 0 0 0 0 16 12 0.0000 4 135 390 8550 13725 IC13\001 +4 0 0 0 0 16 12 0.0000 4 135 105 12150 15750 6\001 +4 0 0 0 0 16 12 0.0000 4 135 210 12600 15750 14\001 +4 0 0 0 0 16 12 0.0000 4 135 105 12150 16200 5\001 +4 0 0 0 0 16 12 0.0000 4 135 210 12600 16200 15\001 +4 0 0 0 0 16 12 0.0000 4 135 105 10125 15975 7\001 +4 0 0 0 0 16 12 0.0000 4 135 210 10125 16425 13\001 +4 0 0 0 0 16 12 0.0000 4 135 285 9900 16200 IC4\001 +4 0 0 0 0 16 12 0.0000 4 135 465 12150 16650 4*IC4\001 +4 0 0 0 0 16 12 0.0000 4 135 315 15075 2475 /DP\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 2700 /D0\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 2925 /D1\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 3150 /D2\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 3375 /D3\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 3600 /D4\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 3825 /D5\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 4050 /D6\001 +4 0 0 0 0 16 12 0.0000 4 135 300 15075 4275 /D7\001 +4 0 0 0 0 16 12 0.0000 4 135 255 15075 11025 I/O\001 +4 0 0 0 0 16 12 0.0000 4 135 450 15075 11250 /REQ\001 +4 0 0 0 0 16 12 0.0000 4 135 330 15075 11475 C/D\001 +4 0 0 0 0 16 12 0.0000 4 135 480 15075 11700 /MSG\001 +4 0 0 0 0 16 12 0.0000 4 135 435 15075 11925 /BSY\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 2475 18\001 +4 0 0 0 0 16 12 0.0000 4 135 105 14850 2700 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 14850 2925 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 14850 3150 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 14850 3375 8\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 3600 10\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 3825 12\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 4050 14\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 4275 16\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 11025 50\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 11250 48\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 11475 46\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 11700 42\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 11925 36\001 +4 0 0 0 0 16 12 0.0000 4 135 405 15075 15075 /SEL\001 +4 0 0 0 0 16 12 0.0000 4 135 435 15075 15300 /ATN\001 +4 0 0 0 0 16 12 0.0000 4 135 405 15075 15750 /RST\001 +4 0 0 0 0 16 12 0.0000 4 135 450 15075 16200 /ACK\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 15075 44\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 15300 32\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 15750 40\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 16200 38\001 +4 0 0 0 0 16 12 0.0000 4 135 420 15525 9450 SCSI\001 +4 0 0 0 0 16 12 0.0000 4 135 405 15075 7425 GND\001 +4 0 0 0 0 16 12 0.0000 4 165 735 14310 7425 1,3,...,49\001 +4 0 0 0 0 16 12 0.0000 4 135 345 11700 10350 RP3\001 +4 0 0 0 0 16 12 0.0000 4 135 495 11700 10575 5*220\001 +4 0 0 0 0 16 12 0.0000 4 135 345 10125 12600 RP4\001 +4 0 0 0 0 16 12 0.0000 4 135 495 9945 12825 5*330\001 +4 0 0 0 0 16 12 0.0000 4 135 345 14175 14175 RP3\001 +4 0 0 0 0 16 12 0.0000 4 135 495 14175 14400 4*220\001 +4 0 0 0 0 16 12 0.0000 4 135 345 14175 16875 RP4\001 +4 0 0 0 0 16 12 0.0000 4 135 495 14175 17100 4*330\001 +4 0 0 0 0 16 12 0.0000 4 135 615 6525 17550 1/2 IC9\001 +4 0 0 0 0 16 12 0.0000 4 135 615 6525 19125 1/2 IC9\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 17775 2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 18000 3\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 18225 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 17775 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 18225 1\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 19350 12\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 19575 11\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 19800 10\001 +4 0 0 0 0 16 12 0.0000 4 135 105 7200 19350 9\001 +4 0 0 0 0 16 12 0.0000 4 135 210 7200 19800 13\001 +4 0 0 0 0 16 12 0.0000 4 135 285 6300 15975 /E1\001 +4 0 0 0 0 16 12 0.0000 4 135 285 6300 16200 /E2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 6075 15975 4\001 +4 0 0 0 0 16 12 0.0000 4 135 210 6075 16200 13\001 +4 0 0 0 0 16 12 0.0000 4 135 210 4725 16200 11\001 +4 0 0 0 0 16 12 0.0000 4 135 105 4275 16200 9\001 +4 0 0 0 0 16 12 0.0000 4 135 225 15300 1800 P2\001 +4 0 0 0 0 16 12 0.0000 4 135 225 900 1125 P1\001 +4 0 0 0 0 16 12 0.0000 4 135 345 900 12600 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 405 900 12825 GND\001 +4 0 0 0 0 16 12 0.0000 4 165 375 1350 12600 c2,3\001 +4 0 0 0 0 16 12 0.0000 4 165 1350 1350 12825 a1,28-32,c1,32\001 +4 0 0 0 0 16 12 0.0000 4 135 285 2700 14850 IC3\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3375 14625 13\001 +4 0 0 0 0 16 12 0.0000 4 135 285 6525 14625 IC5\001 +4 0 0 0 0 16 12 0.0000 4 135 240 990 6525 A9\001 +4 0 0 0 0 16 12 0.0000 4 135 240 990 6750 A8\001 +4 0 0 0 0 16 12 0.0000 4 135 240 990 6975 A7\001 +4 0 0 0 0 16 12 0.0000 4 135 240 990 7200 A6\001 +4 0 0 0 0 16 12 0.0000 4 135 240 990 7425 A5\001 +4 0 0 0 0 16 12 0.0000 4 135 240 990 7650 A4\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2295 6075 B4\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2295 6300 B3\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2295 6525 B5\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2295 6750 B2\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2340 6975 B6\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2340 7200 B1\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2295 7425 B7\001 +4 0 0 0 0 16 12 0.0000 4 135 225 2295 7650 B0\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 6075 A4\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 6300 A3\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 6525 A5\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 6750 A2\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 6975 A6\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 7200 A1\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 7425 A7\001 +4 0 0 0 0 16 12 0.0000 4 135 240 2880 7650 A0\001 +4 0 0 0 0 16 12 0.0000 4 135 315 2790 10350 /Q0\001 +4 0 0 0 0 16 12 0.0000 4 135 315 2790 10575 /Q1\001 +4 0 0 0 0 16 12 0.0000 4 135 315 2790 10800 /Q2\001 +4 0 0 0 0 16 12 0.0000 4 135 315 2790 11025 /Q3\001 +4 0 0 0 0 16 12 0.0000 4 135 210 1575 19575 10\001 +4 0 0 0 0 16 12 0.0000 4 135 405 1125 19575 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 285 990 18225 IC4\001 +4 0 0 0 0 16 12 0.0000 4 135 450 450 9450 CS/A\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9765 10575 4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9315 10575 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9495 9990 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9540 9675 8\001 +4 0 0 0 0 16 12 0.0000 4 135 285 6525 10575 IC8\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 6750 E0\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 6975 E1\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 7200 E2\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 7425 E3\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 7650 E4\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 7875 E5\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 8100 E6\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 8325 E7\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 11025 E0\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 11250 E1\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 11475 E2\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 11700 E3\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 11925 E4\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 12150 E5\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 12375 E6\001 +4 0 0 0 0 16 12 0.0000 4 135 225 6930 12600 E7\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 15075 Q1\001 +4 0 0 0 0 16 12 0.0000 4 135 255 6930 15300 Q2\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6885 15525 /Q3\001 +4 0 0 0 0 16 12 0.0000 4 135 315 6885 15750 /Q4\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 2700 /Q0\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 2925 /Q1\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 3375 /Q3\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 3150 /Q2\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 3600 /Q4\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 3825 /Q5\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 4050 /Q6\001 +4 0 0 0 0 16 12 0.0000 4 135 315 10710 4275 /Q7\001 +4 0 0 0 0 16 12 0.0000 4 135 285 4275 15795 IC4\001 +4 0 0 0 0 18 14 0.0000 4 210 7350 5580 20655 - One Controller on SCSI-bus only (SCSI Data/Ctrl bus always driven)\001 +4 0 0 0 0 18 14 0.0000 4 210 2295 5580 20910 - Controller ID 7 only \001 +4 0 0 0 0 18 14 0.0000 4 210 1380 4050 20655 Known Bugs:\001 +4 0 0 0 0 18 14 0.0000 4 210 4230 5580 21165 - Controller only (not useable as device)\001 +4 0 0 0 0 16 12 0.0000 4 135 915 15075 5850 TERMPWR\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14175 5850 J1\001 +4 0 0 0 0 16 12 0.0000 4 135 240 14625 5175 D1\001 +4 0 0 0 0 18 14 0.0000 4 165 1185 4050 20385 Comments:\001 +4 0 0 0 0 18 14 0.0000 4 210 4410 5580 20385 - RP1-4 only if SCSI termination on board\001 +4 0 0 0 0 16 9 0.0000 4 90 75 7650 1935 3\001 +4 0 0 0 0 16 9 0.0000 4 90 75 7560 2430 1\001 +4 0 0 0 0 16 9 0.0000 4 90 75 7785 2430 2\001 +4 0 0 0 0 16 9 0.0000 4 90 150 8235 1935 11\001 +4 0 0 0 0 16 9 0.0000 4 90 150 7920 2430 13\001 +4 0 0 0 0 16 9 0.0000 4 90 150 8145 2430 12\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8460 2430 1\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8685 2430 2\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8550 1935 3\001 +4 0 0 0 0 16 9 0.0000 4 90 150 9135 1935 11\001 +4 0 0 0 0 16 9 0.0000 4 90 150 8820 2430 13\001 +4 0 0 0 0 16 9 0.0000 4 90 150 9045 2430 12\001 +4 0 0 0 0 16 9 0.0000 4 90 75 7695 1800 4\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8235 1800 5\001 +4 0 0 0 0 16 9 0.0000 4 90 75 7875 1395 6\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8595 1800 4\001 +4 0 0 0 0 16 9 0.0000 4 90 75 9135 1800 5\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8910 1395 6\001 +4 0 0 0 0 16 12 0.0000 4 135 570 6885 1755 3*IC12\001 +4 0 0 0 0 16 12 0.0000 4 135 570 8865 1125 4*IC11\001 +4 0 0 0 0 16 9 0.0000 4 90 150 8100 1260 10\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8685 1260 9\001 +4 0 0 0 0 16 9 0.0000 4 90 75 8325 810 8\001 +4 0 0 0 0 16 12 0.0000 4 135 210 2925 14625 12\001 +4 0 0 0 0 16 12 0.0000 4 135 210 3150 15120 11\001 +4 0 0 0 0 16 12 0.0000 4 135 210 14850 5850 26\001 +4 0 0 0 0 16 12 0.0000 4 135 405 15075 6525 GND\001 +4 0 0 0 0 16 12 0.0000 4 135 795 15075 8325 Reserved\001 +4 0 0 0 0 16 12 0.0000 4 135 360 14175 8415 N.C.\001 +4 0 0 0 0 16 12 0.0000 4 135 210 4050 9000 18\001 +4 0 0 0 0 16 12 0.0000 4 135 285 3870 9225 IC4\001 +4 0 0 0 0 16 12 0.0000 4 135 105 4140 9450 2\001 +4 0 0 0 0 16 12 0.0000 4 135 345 1125 19125 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 210 1575 19125 20\001 +4 0 0 0 0 16 12 0.0000 4 135 105 1575 18450 1\001 +4 0 0 0 0 16 12 0.0000 4 135 210 1575 18675 19\001 +4 0 0 0 0 16 12 0.0000 4 135 435 1125 18450 /OE1\001 +4 0 0 0 0 16 12 0.0000 4 135 435 1125 18675 /OE2\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9045 14355 9\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9945 14355 5\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9945 13950 6\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9045 13950 8\001 +4 0 0 0 0 16 12 0.0000 4 135 210 8550 14085 10\001 +4 0 0 0 0 16 12 0.0000 4 135 105 9540 14085 4\001 +4 0 0 0 0 16 12 0.0000 4 165 480 14580 8325 24,28\001 +4 0 0 0 0 16 12 0.0000 4 165 1020 14085 6525 20,22,30,34\001 +4 0 0 0 0 16 12 0.0000 4 135 210 1575 16650 14\001 +4 0 0 0 0 16 12 0.0000 4 135 105 1575 17325 7\001 +4 0 0 0 0 16 12 0.0000 4 135 345 1125 16650 Vcc\001 +4 0 0 0 0 16 12 0.0000 4 135 405 1125 17325 GND\001 +4 0 0 0 0 16 12 0.0000 4 165 1260 585 15975 IC3,9,11,12,13\001 +4 0 -1 0 0 18 16 0.0000 4 240 3045 12960 20475 CS/A-SCSI-1.0A-05jun98\001 diff --git a/dump/oa-2.0.9/devices/scsi/csascsi1.gif b/dump/oa-2.0.9/devices/scsi/csascsi1.gif new file mode 100644 index 0000000..f852c03 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/csascsi1.gif Binary files differ diff --git a/dump/oa-2.0.9/devices/scsi/csascsi1.ps b/dump/oa-2.0.9/devices/scsi/csascsi1.ps new file mode 100644 index 0000000..c3a5451 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/csascsi1.ps @@ -0,0 +1,2849 @@ +%!PS-Adobe-2.0 +%%Title: csascsi1.ps +%%Creator: fig2dev Version 3.2 Patchlevel 0-beta2 +%%CreationDate: Sat Jun 6 17:53:48 1998 +%%For: fachat@newton (Andre Fachat) +%%Orientation: Portrait +%%BoundingBox: 26 71 569 770 +%%Pages: 1 +%%BeginSetup +%%IncludeFeature: *PageSize A4 +%%EndSetup +%%Magnification: 0.55 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end +save +19.0 777.5 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def +%%EndProlog + +$F2psBegin +10 setmiterlimit +n 0 21427 m 0 0 l 16702 0 l 16702 21427 l cp clip + 0.03300 0.03300 sc +%%Page: 1 1 +7.500 slw +% Ellipse +n 3600 8550 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 2250 8550 m 1800 8550 l 1800 8775 l gs col0 s gr +% Polyline +n 3150 8550 m 3600 8550 l gs col0 s gr +% Polyline +15.000 slw +n 1710 8775 m 1890 8775 l gs col0 s gr +/Helvetica ff 180.00 scf sf +2250 8550 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 8550 m +gs 1 -1 sc (20) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 8550 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +2790 8550 m +gs 1 -1 sc (Vcc) col0 sh gr +7.500 slw +% Ellipse +n 7650 5175 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 6300 5175 m 5850 5175 l 5850 5400 l gs col0 s gr +% Polyline +n 7200 5175 m 7650 5175 l gs col0 s gr +% Polyline +15.000 slw +n 5760 5400 m 5940 5400 l gs col0 s gr +/Helvetica ff 180.00 scf sf +6300 5175 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 5175 m +gs 1 -1 sc (20) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 5175 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +6840 5175 m +gs 1 -1 sc (Vcc) col0 sh gr +% Arc +7.500 slw +gs n 7762.5 2475.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 7762.5 2385.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 7801.9 2171.2 244.2 172.1 -104.7 arc +gs col0 s gr + gr + +% Arc +gs n 7738.3 2165.2 230.2 10.0 -89.6 arcn +gs col0 s gr + gr + +% Polyline +n 7736 1935 m 7744 1935 l gs col0 s gr +% Polyline +n 7740 1935 m 7740 1800 l gs col0 s gr +% Arc +gs n 8212.5 2475.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8212.5 2385.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8251.9 2171.2 244.2 172.1 -104.7 arc +gs col0 s gr + gr + +% Arc +gs n 8188.3 2165.2 230.2 10.0 -89.6 arcn +gs col0 s gr + gr + +% Polyline +n 8186 1935 m 8194 1935 l gs col0 s gr +% Polyline +n 8190 1935 m 8190 1800 l gs col0 s gr +% Arc +gs n 8662.5 2475.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8662.5 2385.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8701.9 2171.2 244.2 172.1 -104.7 arc +gs col0 s gr + gr + +% Arc +gs n 8638.3 2165.2 230.2 10.0 -89.6 arcn +gs col0 s gr + gr + +% Polyline +n 8636 1935 m 8644 1935 l gs col0 s gr +% Polyline +n 8640 1935 m 8640 1800 l gs col0 s gr +% Arc +gs n 9112.5 2475.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 9112.5 2385.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 9151.9 2171.2 244.2 172.1 -104.7 arc +gs col0 s gr + gr + +% Arc +gs n 9088.3 2165.2 230.2 10.0 -89.6 arcn +gs col0 s gr + gr + +% Polyline +n 9086 1935 m 9094 1935 l gs col0 s gr +% Polyline +n 9090 1935 m 9090 1800 l gs col0 s gr +% Arc +gs n 7987.5 1935.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 7987.5 1845.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8026.9 1631.2 244.2 172.1 -104.7 arc +gs col0 s gr + gr + +% Arc +gs n 7963.3 1625.2 230.2 10.0 -89.6 arcn +gs col0 s gr + gr + +% Polyline +n 7961 1395 m 7969 1395 l gs col0 s gr +% Polyline +n 7965 1395 m 7965 1260 l gs col0 s gr +% Arc +gs n 8887.5 1935.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8887.5 1845.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8926.9 1631.2 244.2 172.1 -104.7 arc +gs col0 s gr + gr + +% Arc +gs n 8863.3 1625.2 230.2 10.0 -89.6 arcn +gs col0 s gr + gr + +% Polyline +n 8861 1395 m 8869 1395 l gs col0 s gr +% Polyline +n 8865 1395 m 8865 1260 l gs col0 s gr +% Arc +gs n 8437.5 1350.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8437.5 1260.0 270.9 -138.4 -41.6 arc +gs col0 s gr + gr + +% Arc +gs n 8476.9 1046.2 244.2 172.1 -104.7 arc +gs col0 s gr + gr + +% Arc +gs n 8413.3 1040.2 230.2 10.0 -89.6 arcn +gs col0 s gr + gr + +% Polyline +n 8411 810 m 8419 810 l gs col0 s gr +% Polyline +n 8415 810 m 8415 675 l gs col0 s gr +% Ellipse +n 9562 787 33 33 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 9450 540 m 9450 810 l 9675 675 l 9450 540 l cp gs col0 s gr +% Polyline +n 9585 810 m 9585 900 l gs col0 s gr +% Polyline +n 12015 1350 m 14085 1350 l 14085 2025 l 12015 2025 l cp gs col0 s gr +% Polyline +n 12240 1350 m 12240 2025 l gs col0 s gr +% Polyline +n 12465 1350 m 12465 2025 l gs col0 s gr +% Polyline +n 12690 1350 m 12690 2025 l gs col0 s gr +% Polyline +n 12915 1350 m 12915 2025 l gs col0 s gr +% Polyline +n 13140 1350 m 13140 2025 l gs col0 s gr +% Polyline +n 13365 1350 m 13365 2025 l gs col0 s gr +% Polyline +n 13590 1350 m 13590 2025 l gs col0 s gr +% Polyline +n 13815 1350 m 13815 2025 l gs col0 s gr +% Polyline +n 12146 1350 m 12154 1350 l gs col0 s gr +% Polyline +n 12015 9000 m 14085 9000 l 14085 9675 l 12015 9675 l cp gs col0 s gr +% Polyline +n 12240 9000 m 12240 9675 l gs col0 s gr +% Polyline +n 12465 9000 m 12465 9675 l gs col0 s gr +% Polyline +n 12690 9000 m 12690 9675 l gs col0 s gr +% Polyline +n 12915 9000 m 12915 9675 l gs col0 s gr +% Polyline +n 13140 9000 m 13140 9675 l gs col0 s gr +% Polyline +n 13365 9000 m 13365 9675 l gs col0 s gr +% Polyline +n 13590 9000 m 13590 9675 l gs col0 s gr +% Polyline +n 13815 9000 m 13815 9675 l gs col0 s gr +% Polyline +n 12146 9000 m 12154 9000 l gs col0 s gr +% Polyline +n 12150 1350 m 12150 900 l 14175 900 l gs col0 s gr +% Polyline +n 12375 900 m 12375 1350 l gs col0 s gr +% Polyline +n 12600 900 m 12600 1350 l gs col0 s gr +% Polyline +n 12825 900 m 12825 1350 l gs col0 s gr +% Polyline +n 13050 900 m 13050 1350 l gs col0 s gr +% Polyline +n 13275 900 m 13275 1350 l gs col0 s gr +% Polyline +n 13500 900 m 13500 1350 l gs col0 s gr +% Polyline +n 13725 900 m 13725 1350 l gs col0 s gr +% Polyline +n 13950 900 m 13950 1350 l gs col0 s gr +% Ellipse +n 12555 15075 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 12375 14985 m 12375 15165 l 12510 15075 l 12375 14985 l cp gs col0 s gr +% Ellipse +n 12555 15300 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 12375 15210 m 12375 15390 l 12510 15300 l 12375 15210 l cp gs col0 s gr +% Rotated Ellipse +gs +8888 14063 tr +-270.001 rot +n 0 0 33 33 0 360 DrawEllipse gs col0 s gr +gr + +% Polyline +n 9135 14175 m 8865 14175 l 9000 13950 l 9135 14175 l cp gs col0 s gr +% Polyline +n 8865 14040 m 8775 14040 l gs col0 s gr +% Polyline +n 10440 9900 m 11610 9900 l 11610 10575 l 10440 10575 l cp gs col0 s gr +% Polyline +n 10665 9900 m 10665 10575 l gs col0 s gr +% Polyline +n 10890 9900 m 10890 10575 l gs col0 s gr +% Polyline +n 11115 9900 m 11115 10575 l gs col0 s gr +% Polyline +n 11340 9900 m 11340 10575 l gs col0 s gr +% Polyline +n 10440 12375 m 11610 12375 l 11610 13050 l 10440 13050 l cp gs col0 s gr +% Polyline +n 10665 12375 m 10665 13050 l gs col0 s gr +% Polyline +n 10890 12375 m 10890 13050 l gs col0 s gr +% Polyline +n 11115 12375 m 11115 13050 l gs col0 s gr +% Polyline +n 11340 12375 m 11340 13050 l gs col0 s gr +% Ellipse +n 11700 9450 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 11475 9450 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11250 9450 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11025 9450 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 10800 9450 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 10575 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 10800 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11025 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11250 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 10575 11025 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 10800 11250 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11025 11475 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11250 11700 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11475 11925 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Polyline +n 10575 10575 m 10575 12375 l gs col0 s gr +% Polyline +n 10800 10575 m 10800 12375 l gs col0 s gr +% Polyline +n 11025 10575 m 11025 12375 l gs col0 s gr +% Polyline +n 11250 10575 m 11250 12375 l gs col0 s gr +% Polyline +n 11475 10575 m 11475 12375 l gs col0 s gr +% Polyline +n 10575 9900 m 10575 9450 l 11700 9450 l gs col0 s gr +% Polyline +n 10800 9900 m 10800 9450 l gs col0 s gr +% Polyline +n 11025 9450 m 11025 9900 l gs col0 s gr +% Polyline +n 11250 9450 m 11250 9900 l gs col0 s gr +% Polyline +n 11475 9450 m 11475 9900 l gs col0 s gr +% Polyline +n 10575 13050 m 10575 13725 l gs col0 s gr +% Polyline +n 10800 13050 m 10800 13500 l gs col0 s gr +% Polyline +n 11025 13050 m 11025 13500 l gs col0 s gr +% Polyline +n 11250 13050 m 11250 13500 l gs col0 s gr +% Polyline +n 11475 13050 m 11475 13500 l 10575 13500 l gs col0 s gr +% Polyline +15.000 slw +n 10485 13725 m 10665 13725 l gs col0 s gr +% Arc +7.500 slw +gs n 9675.0 10398.2 363.2 -172.4 -7.6 arc +gs col0 s gr + gr + +% Polyline +n 9315 10350 m 10035 10350 l gs col0 s gr +% Polyline +n 9675 10035 m 9675 9900 l gs col0 s gr +% Ellipse +n 9675 9180 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 9540 9450 m 9810 9450 l 9675 9225 l 9540 9450 l cp gs col0 s gr +% Polyline +n 6300 17550 m 7200 17550 l 7200 18450 l 6300 18450 l cp gs col0 s gr +% Polyline +n 6300 17910 m 6525 18000 l 6300 18090 l gs col0 s gr +/Helvetica ff 180.00 scf sf +6345 17865 m +gs 1 -1 sc (D) col0 sh gr +/Helvetica ff 180.00 scf sf +6345 18315 m +gs 1 -1 sc (/S) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 18315 m +gs 1 -1 sc (/R) col0 sh gr +/Helvetica ff 180.00 scf sf +6975 17865 m +gs 1 -1 sc (Q) col0 sh gr +% Polyline +n 6300 19125 m 7200 19125 l 7200 20025 l 6300 20025 l cp gs col0 s gr +% Polyline +n 6300 19485 m 6525 19575 l 6300 19665 l gs col0 s gr +/Helvetica ff 180.00 scf sf +6345 19440 m +gs 1 -1 sc (D) col0 sh gr +/Helvetica ff 180.00 scf sf +6345 19890 m +gs 1 -1 sc (/S) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 19890 m +gs 1 -1 sc (/R) col0 sh gr +/Helvetica ff 180.00 scf sf +6975 19440 m +gs 1 -1 sc (Q) col0 sh gr +% Ellipse +n 12555 15750 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 12375 15660 m 12375 15840 l 12510 15750 l 12375 15660 l cp gs col0 s gr +% Ellipse +n 12555 16200 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 12375 16110 m 12375 16290 l 12510 16200 l 12375 16110 l cp gs col0 s gr +% Rotated Ellipse +gs +10350 16155 tr +-270.001 rot +n 0 0 45 45 0 360 DrawEllipse gs col0 s gr +gr + +% Polyline +n 10440 15975 m 10260 15975 l 10350 16110 l 10440 15975 l cp gs col0 s gr +% Polyline +n 13140 13950 m 14085 13950 l 14085 14625 l 13140 14625 l cp gs col0 s gr +% Polyline +n 13365 13950 m 13365 14625 l gs col0 s gr +% Polyline +n 13590 13950 m 13590 14625 l gs col0 s gr +% Polyline +n 13815 13950 m 13815 14625 l gs col0 s gr +% Polyline +n 13140 16650 m 14085 16650 l 14085 17325 l 13140 17325 l cp gs col0 s gr +% Polyline +n 13365 16650 m 13365 17325 l gs col0 s gr +% Polyline +n 13590 16650 m 13590 17325 l gs col0 s gr +% Polyline +n 13815 16650 m 13815 17325 l gs col0 s gr +% Rotated Ellipse +gs +4275 9045 tr +-90.000 rot +n 0 0 45 45 0 360 DrawEllipse gs col0 s gr +gr + +% Polyline +n 4365 9225 m 4185 9225 l 4275 9090 l 4365 9225 l cp gs col0 s gr +% Ellipse +n 4680 15975 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 4500 15885 m 4500 16065 l 4635 15975 l 4500 15885 l cp gs col0 s gr +% Arc +gs n 3375.0 14576.8 363.2 172.4 7.6 arcn +gs col0 s gr + gr + +% Polyline +n 3015 14625 m 3735 14625 l gs col0 s gr +% Polyline +n 3375 14940 m 3375 15075 l gs col0 s gr +% Rotated Ellipse +gs +9788 14063 tr +-270.001 rot +n 0 0 33 33 0 360 DrawEllipse gs col0 s gr +gr + +% Polyline +n 10035 14175 m 9765 14175 l 9900 13950 l 10035 14175 l cp gs col0 s gr +% Polyline +n 9765 14040 m 9675 14040 l gs col0 s gr +/Helvetica-Bold ff 300.00 scf sf +13185 19155 m +gs 1 -1 sc (\(c\) A. Fachat) col-1 sh gr +/Helvetica-Bold ff 300.00 scf sf +13185 19500 m +gs 1 -1 sc (All rights reserved) col-1 sh gr +/Helvetica-Bold ff 300.00 scf sf +13185 19845 m +gs 1 -1 sc (No Warranty!) col-1 sh gr +/Helvetica-Bold ff 300.00 scf sf +13185 18810 m +gs 1 -1 sc (CS/A SCSI) col-1 sh gr +% Arc +gs [60] 0 sd +n 14422.5 5512.5 114.7 -101.3 101.3 arcn +gs col0 s gr + gr + [] 0 sd +% Ellipse +n 3600 6075 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 3600 7200 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 3600 7425 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 3825 6975 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 3825 6750 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 3825 6525 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 4050 6075 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 3600 11700 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 1800 12600 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 9225 4275 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 9000 4050 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 8775 3825 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 8550 3600 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 8325 3375 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 8100 3150 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 7875 2925 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 7650 2700 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 9450 4725 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12150 2475 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12375 2700 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12600 2925 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12825 3150 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13050 3375 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13275 3600 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13500 3825 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 4050 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13950 4275 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 14175 900 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 12375 6750 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12600 6975 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12825 7200 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13050 7425 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13275 7650 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13500 7875 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 8100 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13950 8325 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12375 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12150 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12600 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12825 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13050 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13275 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13500 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 10125 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12375 900 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12600 900 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 12825 900 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13050 900 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13275 900 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13500 900 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 900 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11475 5175 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 7650 13500 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 7650 9225 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 7650 16650 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 9000 8325 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 8775 15750 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 9900 11025 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 7650 18225 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 5850 18225 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 5850 19800 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 5850 19350 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 8325 17775 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 8100 19350 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 11925 11250 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13275 17775 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13500 17775 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 17775 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13275 15075 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13500 15300 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 15750 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13950 16200 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13500 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13725 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 13950 13500 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 5850 15975 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 4050 15975 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 4500 10575 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 4275 10350 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 14175 13500 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 14400 5625 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 14400 5400 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 14400 4725 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 2025 19125 45 45 0 360 DrawEllipse gs col0 s gr + +% Ellipse +n 2025 18675 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 9900 11925 45 45 0 360 DrawEllipse gs 0.00 setgray ef gr gs col0 s gr + +% Ellipse +n 2025 16650 45 45 0 360 DrawEllipse gs col0 s gr + +% Polyline +n 675 1125 m 1350 1125 l 1350 13500 l 675 13500 l gs col0 s gr +% Polyline +n 1350 2925 m 1800 2925 l 2025 2700 l gs col0 s gr +% Polyline +n 1350 3150 m 1800 3150 l 2025 2925 l gs col0 s gr +% Polyline +n 1350 3375 m 1800 3375 l 2025 3150 l gs col0 s gr +% Polyline +n 1350 3600 m 1800 3600 l 2025 3375 l gs col0 s gr +% Polyline +n 1350 3825 m 1800 3825 l 2025 3600 l gs col0 s gr +% Polyline +n 1350 4050 m 1800 4050 l 2025 3825 l gs col0 s gr +% Polyline +n 1350 4275 m 1800 4275 l 2025 4050 l gs col0 s gr +% Polyline +n 1350 4500 m 1800 4500 l 2025 4275 l gs col0 s gr +% Polyline +n 2250 5625 m 3150 5625 l 3150 8775 l 2250 8775 l cp gs col0 s gr +% Polyline +n 1350 6075 m 2250 6075 l gs col0 s gr +% Polyline +n 1350 6300 m 2250 6300 l gs col0 s gr +% Polyline +n 1350 6525 m 2250 6525 l gs col0 s gr +% Polyline +n 1350 6750 m 2250 6750 l gs col0 s gr +% Polyline +n 1350 6975 m 2250 6975 l gs col0 s gr +% Polyline +n 1350 7200 m 2250 7200 l gs col0 s gr +% Polyline +n 1350 7425 m 2250 7425 l gs col0 s gr +% Polyline +n 1350 7650 m 2250 7650 l gs col0 s gr +% Polyline +n 1350 8100 m 2250 8100 l gs col0 s gr +% Polyline +n 3150 6075 m 4050 6075 l gs col0 s gr +% Polyline +n 3150 7650 m 3600 7650 l 3600 6075 l gs col0 s gr +% Polyline +n 3150 7425 m 3600 7425 l gs col0 s gr +% Polyline +n 3150 7200 m 3600 7200 l gs col0 s gr +% Polyline +n 3150 6300 m 3825 6300 l 3825 7200 l gs col0 s gr +% Polyline +n 3150 6525 m 3825 6525 l gs col0 s gr +% Polyline +n 3150 6750 m 3825 6750 l gs col0 s gr +% Polyline +n 3150 6975 m 3825 6975 l gs col0 s gr +% Polyline +15.000 slw +n 3735 7200 m 3915 7200 l gs col0 s gr +% Polyline +7.500 slw +n 2250 9675 m 3150 9675 l 3150 11925 l 2250 11925 l cp gs col0 s gr +% Polyline +n 1350 10575 m 2250 10575 l gs col0 s gr +% Polyline +n 1350 10800 m 2250 10800 l gs col0 s gr +% Polyline +n 1350 11025 m 2250 11025 l gs col0 s gr +% Polyline +n 3150 8100 m 3825 8100 l 3825 9225 l 1800 9225 l 1800 9900 l 2250 9900 l gs col0 s gr +% Polyline +n 1350 11250 m 2250 11250 l gs col0 s gr +% Polyline +n 2250 10125 m 1800 10125 l 1800 10350 l gs col0 s gr +% Polyline +15.000 slw +n 1710 10350 m 1890 10350 l gs col0 s gr +% Polyline +7.500 slw +n 2250 11700 m 1800 11700 l 1800 11925 l gs col0 s gr +% Polyline +15.000 slw +n 1710 11925 m 1890 11925 l gs col0 s gr +% Polyline +7.500 slw +n 3150 11700 m 3600 11700 l gs col0 s gr +% Polyline +n 1350 12600 m 1800 12600 l gs col0 s gr +% Polyline +n 1350 12825 m 1800 12825 l 1800 13050 l gs col0 s gr +% Polyline +15.000 slw +n 1710 13050 m 1890 13050 l gs col0 s gr +% Polyline +7.500 slw +n 2025 4275 m 2025 2250 l 2250 2025 l 5175 2025 l 5400 2250 l 5400 17550 l gs col0 s gr +% Polyline +n 5400 2475 m 5625 2700 l 6300 2700 l gs col0 s gr +% Polyline +n 5400 2700 m 5625 2925 l 6300 2925 l gs col0 s gr +% Polyline +n 5400 2925 m 5625 3150 l 6300 3150 l gs col0 s gr +% Polyline +n 5400 3150 m 5625 3375 l 6300 3375 l gs col0 s gr +% Polyline +n 5400 3375 m 5625 3600 l 6300 3600 l gs col0 s gr +% Polyline +n 5400 3600 m 5625 3825 l 6300 3825 l gs col0 s gr +% Polyline +n 5400 3825 m 5625 4050 l 6300 4050 l gs col0 s gr +% Polyline +n 5400 4050 m 5625 4275 l 6300 4275 l gs col0 s gr +% Polyline +n 6300 2250 m 7200 2250 l 7200 5400 l 6300 5400 l cp gs col0 s gr +% Polyline +n 7200 2925 m 10125 2925 l gs col0 s gr +% Polyline +n 7200 3150 m 10125 3150 l gs col0 s gr +% Polyline +n 7200 3375 m 10125 3375 l gs col0 s gr +% Polyline +n 7200 3600 m 10125 3600 l gs col0 s gr +% Polyline +n 7200 3825 m 10125 3825 l gs col0 s gr +% Polyline +n 7200 4050 m 10125 4050 l gs col0 s gr +% Polyline +n 7200 4275 m 10125 4275 l gs col0 s gr +% Polyline +n 7650 2250 m 7650 2700 l gs col0 s gr +% Polyline +n 7875 2250 m 7875 2925 l gs col0 s gr +% Polyline +n 8100 2250 m 8100 3150 l gs col0 s gr +% Polyline +n 8325 2250 m 8325 3375 l gs col0 s gr +% Polyline +n 8550 2250 m 8550 3600 l gs col0 s gr +% Polyline +n 8775 2250 m 8775 3825 l gs col0 s gr +% Polyline +n 9000 2250 m 9000 4050 l gs col0 s gr +% Polyline +n 9225 2250 m 9225 4275 l gs col0 s gr +% Polyline +n 7740 1800 m 7875 1800 l 7875 1710 l gs col0 s gr +% Polyline +n 8190 1800 m 8100 1800 l 8100 1710 l gs col0 s gr +% Polyline +n 8640 1800 m 8775 1800 l 8775 1710 l gs col0 s gr +% Polyline +n 9090 1800 m 9000 1800 l 9000 1710 l gs col0 s gr +% Polyline +n 7965 1260 m 8325 1260 l 8325 1125 l gs col0 s gr +% Polyline +n 8550 1125 m 8550 1260 l 8865 1260 l gs col0 s gr +% Polyline +n 8415 675 m 8550 675 l gs col0 s gr +% Polyline +n 8550 675 m 9450 675 l gs col0 s gr +% Polyline +n 9585 900 m 9585 1125 l 9450 1125 l 9450 6075 l gs col0 s gr +% Polyline +n 9450 4725 m 10125 4725 l gs col0 s gr +% Polyline +n 7200 4725 m 7650 4725 l 7650 4950 l gs col0 s gr +% Polyline +15.000 slw +n 7560 4950 m 7740 4950 l gs col0 s gr +% Polyline +7.500 slw +n 11025 2700 m 15075 2700 l gs col0 s gr +% Polyline +n 11025 2925 m 15075 2925 l gs col0 s gr +% Polyline +n 11025 3150 m 15075 3150 l gs col0 s gr +% Polyline +n 11025 3375 m 15075 3375 l gs col0 s gr +% Polyline +n 11025 3600 m 15075 3600 l gs col0 s gr +% Polyline +n 11025 3825 m 15075 3825 l gs col0 s gr +% Polyline +n 11025 4050 m 15075 4050 l gs col0 s gr +% Polyline +n 11025 4275 m 15075 4275 l gs col0 s gr +% Polyline +n 9675 675 m 11475 675 l 11475 2475 l 15075 2475 l gs col0 s gr +% Polyline +n 12150 2025 m 12150 9000 l gs col0 s gr +% Polyline +n 12375 2025 m 12375 9000 l gs col0 s gr +% Polyline +n 12600 2025 m 12600 9000 l gs col0 s gr +% Polyline +n 12825 2025 m 12825 9000 l gs col0 s gr +% Polyline +n 13050 2025 m 13050 9000 l gs col0 s gr +% Polyline +n 13275 2025 m 13275 9000 l gs col0 s gr +% Polyline +n 13500 2025 m 13500 9000 l gs col0 s gr +% Polyline +n 13725 2025 m 13725 9000 l gs col0 s gr +% Polyline +n 13950 2025 m 13950 9000 l gs col0 s gr +% Polyline +15.000 slw +n 9585 5400 m 9765 5400 l gs col0 s gr +% Polyline +7.500 slw +n 7200 6750 m 12375 6750 l gs col0 s gr +% Polyline +n 7200 6975 m 12600 6975 l gs col0 s gr +% Polyline +n 7200 7200 m 12825 7200 l gs col0 s gr +% Polyline +n 7200 7425 m 13050 7425 l gs col0 s gr +% Polyline +n 7200 7650 m 13275 7650 l gs col0 s gr +% Polyline +n 7200 7875 m 13500 7875 l gs col0 s gr +% Polyline +n 7200 8100 m 13725 8100 l gs col0 s gr +% Polyline +n 7200 8325 m 13950 8325 l gs col0 s gr +% Polyline +n 5400 6525 m 5625 6750 l 6300 6750 l gs col0 s gr +% Polyline +n 5400 6975 m 5625 7200 l 6300 7200 l gs col0 s gr +% Polyline +n 5400 7200 m 5625 7425 l 6300 7425 l gs col0 s gr +% Polyline +n 5400 7425 m 5625 7650 l 6300 7650 l gs col0 s gr +% Polyline +n 5400 7650 m 5625 7875 l 6300 7875 l gs col0 s gr +% Polyline +n 5400 7875 m 5625 8100 l 6300 8100 l gs col0 s gr +% Polyline +n 5400 8100 m 5625 8325 l 6300 8325 l gs col0 s gr +% Polyline +n 12375 9675 m 12375 10125 l gs col0 s gr +% Polyline +n 12600 9675 m 12600 10125 l gs col0 s gr +% Polyline +n 12825 9675 m 12825 10125 l gs col0 s gr +% Polyline +n 13050 9675 m 13050 10125 l gs col0 s gr +% Polyline +n 13275 9675 m 13275 10125 l gs col0 s gr +% Polyline +n 13500 9675 m 13500 10125 l gs col0 s gr +% Polyline +n 13725 9675 m 13725 10125 l gs col0 s gr +% Polyline +n 13950 9675 m 13950 10125 l gs col0 s gr +% Polyline +n 12150 9675 m 12150 10350 l gs col0 s gr +% Polyline +15.000 slw +n 12060 10350 m 12240 10350 l gs col0 s gr +% Polyline +7.500 slw +n 12150 10125 m 13950 10125 l gs col0 s gr +% Polyline +n 7200 2700 m 10125 2700 l gs col0 s gr +% Polyline +n 10125 2250 m 11025 2250 l 11025 5400 l 10125 5400 l cp gs col0 s gr +% Polyline +n 11025 4725 m 11475 4725 l 11475 4950 l gs col0 s gr +% Polyline +15.000 slw +n 11385 4950 m 11565 4950 l gs col0 s gr +% Polyline +7.500 slw +n 10125 5175 m 9675 5175 l 9675 5400 l gs col0 s gr +% Polyline +n 11025 5175 m 11475 5175 l gs col0 s gr +% Polyline +n 5400 6750 m 5625 6975 l 6300 6975 l gs col0 s gr +% Polyline +n 6300 10575 m 7200 10575 l 7200 13725 l 6300 13725 l cp gs col0 s gr +% Polyline +n 7200 13050 m 7650 13050 l 7650 13275 l gs col0 s gr +% Polyline +15.000 slw +n 7560 13275 m 7740 13275 l gs col0 s gr +% Polyline +7.500 slw +n 6300 13500 m 5850 13500 l 5850 13725 l gs col0 s gr +% Polyline +n 7200 13500 m 7650 13500 l gs col0 s gr +% Polyline +15.000 slw +n 5760 13725 m 5940 13725 l gs col0 s gr +% Polyline +7.500 slw +n 6300 6300 m 7200 6300 l 7200 9450 l 6300 9450 l cp gs col0 s gr +% Polyline +n 7200 8775 m 7650 8775 l 7650 9000 l gs col0 s gr +% Polyline +15.000 slw +n 7560 9000 m 7740 9000 l gs col0 s gr +% Polyline +7.500 slw +n 6300 9225 m 5850 9225 l 5850 9450 l gs col0 s gr +% Polyline +n 7200 9225 m 7650 9225 l gs col0 s gr +% Polyline +15.000 slw +n 5760 9450 m 5940 9450 l gs col0 s gr +% Polyline +7.500 slw +n 5400 10800 m 5625 11025 l 6300 11025 l gs col0 s gr +% Polyline +n 5400 11025 m 5625 11250 l 6300 11250 l gs col0 s gr +% Polyline +n 5400 11250 m 5625 11475 l 6300 11475 l gs col0 s gr +% Polyline +n 5400 11475 m 5625 11700 l 6300 11700 l gs col0 s gr +% Polyline +n 5400 11700 m 5625 11925 l 6300 11925 l gs col0 s gr +% Polyline +n 5400 11925 m 5625 12150 l 6300 12150 l gs col0 s gr +% Polyline +n 5400 12150 m 5625 12375 l 6300 12375 l gs col0 s gr +% Polyline +n 7200 11025 m 15075 11025 l gs col0 s gr +% Polyline +n 7200 11250 m 15075 11250 l gs col0 s gr +% Polyline +n 7200 11475 m 15075 11475 l gs col0 s gr +% Polyline +n 7200 11925 m 15075 11925 l gs col0 s gr +% Polyline +n 6300 14625 m 7200 14625 l 7200 16875 l 6300 16875 l cp gs col0 s gr +% Polyline +n 5400 14850 m 5625 15075 l 6300 15075 l gs col0 s gr +% Polyline +n 5400 15075 m 5625 15300 l 6300 15300 l gs col0 s gr +% Polyline +n 5400 15300 m 5625 15525 l 6300 15525 l gs col0 s gr +% Polyline +n 5400 15525 m 5625 15750 l 6300 15750 l gs col0 s gr +% Polyline +n 6300 16650 m 5850 16650 l 5850 16875 l gs col0 s gr +% Polyline +n 7200 16650 m 7650 16650 l gs col0 s gr +% Polyline +15.000 slw +n 5760 16875 m 5940 16875 l gs col0 s gr +% Polyline +7.500 slw +n 7200 15075 m 12375 15075 l gs col0 s gr +% Polyline +n 12600 15075 m 15075 15075 l gs col0 s gr +% Polyline +n 12600 15300 m 15075 15300 l gs col0 s gr +% Polyline +n 9000 14175 m 9000 14400 l gs col0 s gr +% Polyline +15.000 slw +n 8910 14400 m 9090 14400 l gs col0 s gr +% Polyline +7.500 slw +n 7200 15750 m 8775 15750 l 8775 14040 l gs col0 s gr +% Polyline +n 9000 13950 m 9000 8325 l gs col0 s gr +% Polyline +n 9900 11025 m 9900 10350 l gs col0 s gr +% Polyline +n 9675 9000 m 9675 6075 l 9450 6075 l gs col0 s gr +% Polyline +n 9675 9450 m 9675 9900 l gs col0 s gr +% Polyline +n 9675 9000 m 9675 9135 l gs col0 s gr +% Polyline +n 5400 17550 m 5625 17775 l 6300 17775 l gs col0 s gr +% Polyline +n 6300 18225 m 5850 18225 l gs col0 s gr +% Polyline +n 7200 18225 m 7650 18225 l gs col0 s gr +% Polyline +n 6300 19800 m 5850 19800 l gs col0 s gr +% Polyline +n 6300 19350 m 5850 19350 l gs col0 s gr +% Polyline +n 7200 11700 m 15075 11700 l gs col0 s gr +% Polyline +n 9675 14040 m 9675 15525 l 7200 15525 l gs col0 s gr +% Polyline +n 7200 12150 m 8325 12150 l 8325 17775 l gs col0 s gr +% Polyline +n 7200 12375 m 8100 12375 l 8100 19350 l gs col0 s gr +% Polyline +n 7200 15300 m 12375 15300 l gs col0 s gr +% Polyline +n 7200 17775 m 10800 17775 l 10800 15750 l 12375 15750 l gs col0 s gr +% Polyline +n 12600 15750 m 15075 15750 l gs col0 s gr +% Polyline +n 12600 16200 m 15075 16200 l gs col0 s gr +% Polyline +n 11925 11250 m 11925 14625 l 10350 14625 l 10350 15975 l gs col0 s gr +% Polyline +n 7200 19350 m 11250 19350 l 11250 16200 l 12375 16200 l gs col0 s gr +% Polyline +n 10350 16200 m 10350 19800 l 7200 19800 l gs col0 s gr +% Polyline +n 15750 1800 m 15075 1800 l 15075 17550 l 15750 17550 l gs col0 s gr +% Polyline +n 14625 7650 m 14625 7425 l 15075 7425 l gs col0 s gr +% Polyline +15.000 slw +n 14535 7650 m 14715 7650 l gs col0 s gr +% Polyline +7.500 slw +n 14535 8325 m 15075 8325 l gs col0 s gr +% Polyline +n 13275 14625 m 13275 16650 l gs col0 s gr +% Polyline +n 13500 14625 m 13500 16650 l gs col0 s gr +% Polyline +n 13725 14625 m 13725 16650 l gs col0 s gr +% Polyline +n 13950 14625 m 13950 16650 l gs col0 s gr +% Polyline +n 13275 13950 m 13275 13500 l 14175 13500 l gs col0 s gr +% Polyline +n 13500 13500 m 13500 13950 l gs col0 s gr +% Polyline +n 13725 13500 m 13725 13950 l gs col0 s gr +% Polyline +n 13950 13500 m 13950 13950 l gs col0 s gr +% Polyline +n 13275 17325 m 13275 18000 l gs col0 s gr +% Polyline +n 13500 17325 m 13500 17775 l gs col0 s gr +% Polyline +n 13725 17325 m 13725 17775 l gs col0 s gr +% Polyline +n 13950 17325 m 13950 17775 l 13275 17775 l gs col0 s gr +% Polyline +15.000 slw +n 13185 18000 m 13365 18000 l gs col0 s gr +% Polyline +7.500 slw +n 3150 10350 m 4275 10350 l 4275 9225 l gs col0 s gr +% Polyline +n 4275 9000 m 4275 4725 l 6300 4725 l gs col0 s gr +% Polyline +n 3150 10575 m 4500 10575 l 4500 8775 l 6300 8775 l gs col0 s gr +% Polyline +n 3150 10800 m 4050 10800 l 4050 15975 l 4500 15975 l gs col0 s gr +% Polyline +n 4725 15975 m 6300 15975 l gs col0 s gr +% Polyline +n 5850 15975 m 5850 16200 l 6300 16200 l gs col0 s gr +% Polyline +n 4050 15975 m 4050 18000 l 6300 18000 l gs col0 s gr +% Polyline +n 3150 11025 m 3825 11025 l 3825 13050 l 6300 13050 l gs col0 s gr +% Polyline +n 4275 10350 m 4275 13950 l 3150 13950 l 3150 14625 l gs col0 s gr +% Polyline +n 4500 10575 m 4500 14175 l 3600 14175 l 3600 14625 l gs col0 s gr +% Polyline +n 8775 15750 m 9450 15750 l 9450 10350 l gs col0 s gr +% Polyline +n 3375 15075 m 3375 19575 l 6300 19575 l gs col0 s gr +% Polyline +15.000 slw +n 1935 19800 m 2115 19800 l gs col0 s gr +% Polyline +7.500 slw +n 1575 19575 m 2025 19575 l 2025 19800 l gs col0 s gr +% Polyline +n 675 18225 m 1575 18225 l 1575 20025 l 675 20025 l cp gs col0 s gr +% Polyline +n 225 225 m 16650 225 l 16650 21375 l 225 21375 l cp gs col0 s gr +% Polyline +n 15075 5850 m 14400 5850 l 14400 5625 l gs col0 s gr +% Polyline +n 14265 5175 m 14535 5175 l gs col0 s gr +% Polyline +n 14400 5175 m 14265 4950 l 14535 4950 l 14400 5175 l cp gs col0 s gr +% Polyline +n 14400 5175 m 14400 5400 l gs col0 s gr +% Polyline +n 14400 4950 m 14400 4725 l gs col0 s gr +% Polyline +n 14625 6750 m 14625 6525 l 15075 6525 l gs col0 s gr +% Polyline +15.000 slw +n 14535 6750 m 14715 6750 l gs col0 s gr +% Polyline +7.500 slw +n 1575 19125 m 2025 19125 l gs col0 s gr +% Polyline +n 1575 18450 m 2025 18450 l 2025 18900 l gs col0 s gr +% Polyline +n 1575 18675 m 2025 18675 l gs col0 s gr +% Polyline +15.000 slw +n 1935 18900 m 2115 18900 l gs col0 s gr +% Polyline +7.500 slw +n 9900 14175 m 9900 14400 l gs col0 s gr +% Polyline +15.000 slw +n 9810 14400 m 9990 14400 l gs col0 s gr +% Polyline +7.500 slw +n 9900 13950 m 9900 11925 l gs col0 s gr +% Polyline +15.000 slw +n 1935 17550 m 2115 17550 l gs col0 s gr +% Polyline +7.500 slw +n 1575 17325 m 2025 17325 l 2025 17550 l gs col0 s gr +% Polyline +n 1575 16650 m 2025 16650 l gs col0 s gr +% Polyline +n 675 15975 m 1575 15975 l 1575 17775 l 675 17775 l cp gs col0 s gr +/Helvetica ff 180.00 scf sf +1350 6075 m +gs 1 -1 sc (c12) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 6300 m +gs 1 -1 sc (c13) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 6525 m +gs 1 -1 sc (c14) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 6750 m +gs 1 -1 sc (c15) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 6975 m +gs 1 -1 sc (c16) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 7200 m +gs 1 -1 sc (c17) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 7425 m +gs 1 -1 sc (c18) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 7650 m +gs 1 -1 sc (c19) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 8100 m +gs 1 -1 sc (a7) col0 sh gr +/Helvetica ff 180.00 scf sf +900 6075 m +gs 1 -1 sc (A11) col0 sh gr +/Helvetica ff 180.00 scf sf +900 6300 m +gs 1 -1 sc (A10) col0 sh gr +/Helvetica ff 180.00 scf sf +675 8100 m +gs 1 -1 sc (/IOSEL) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 8100 m +gs 1 -1 sc (/G) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 8100 m +gs 1 -1 sc (19) col0 sh gr +/Helvetica ff 180.00 scf sf +2700 8100 m +gs 1 -1 sc (/A=B) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 8100 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +2475 5850 m +gs 1 -1 sc ('688) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 6075 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 6300 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 6525 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 6750 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 6975 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 7200 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 7425 m +gs 1 -1 sc (18) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 7650 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 6075 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 6300 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 6525 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 6750 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 6975 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 7200 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 7425 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 7650 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +2475 5625 m +gs 1 -1 sc (IC1) col0 sh gr +/Helvetica ff 180.00 scf sf +2475 9675 m +gs 1 -1 sc (IC2) col0 sh gr +/Helvetica ff 180.00 scf sf +2700 9900 m +gs 1 -1 sc ('138) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 9900 m +gs 1 -1 sc (/E1) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 10125 m +gs 1 -1 sc (/E2) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 10575 m +gs 1 -1 sc (E3) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 10800 m +gs 1 -1 sc (C) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 11025 m +gs 1 -1 sc (B) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 11250 m +gs 1 -1 sc (A) col0 sh gr +/Helvetica ff 180.00 scf sf +2250 11700 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +2790 11700 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 9900 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 10125 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 10575 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 10800 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 11025 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 11250 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +2025 11700 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 11700 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 10575 m +gs 1 -1 sc (c26) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 10800 m +gs 1 -1 sc (c22) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 11025 m +gs 1 -1 sc (c23) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 11250 m +gs 1 -1 sc (c25) col0 sh gr +/Helvetica ff 180.00 scf sf +900 10575 m +gs 1 -1 sc (Phi2) col0 sh gr +/Helvetica ff 180.00 scf sf +900 10800 m +gs 1 -1 sc (A1) col0 sh gr +/Helvetica ff 180.00 scf sf +900 11025 m +gs 1 -1 sc (A0) col0 sh gr +/Helvetica ff 180.00 scf sf +900 11250 m +gs 1 -1 sc (R/-W) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 10350 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 10575 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 10800 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 11025 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 2925 m +gs 1 -1 sc (a22) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 3150 m +gs 1 -1 sc (a21) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 3375 m +gs 1 -1 sc (a20) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 3600 m +gs 1 -1 sc (a19) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 3825 m +gs 1 -1 sc (a18) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 4050 m +gs 1 -1 sc (a17) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 4500 m +gs 1 -1 sc (a15) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 4275 m +gs 1 -1 sc (a16) col0 sh gr +/Helvetica ff 180.00 scf sf +900 2925 m +gs 1 -1 sc (D0) col0 sh gr +/Helvetica ff 180.00 scf sf +900 3150 m +gs 1 -1 sc (D1) col0 sh gr +/Helvetica ff 180.00 scf sf +900 3375 m +gs 1 -1 sc (D2) col0 sh gr +/Helvetica ff 180.00 scf sf +900 3600 m +gs 1 -1 sc (D3) col0 sh gr +/Helvetica ff 180.00 scf sf +900 3825 m +gs 1 -1 sc (D4) col0 sh gr +/Helvetica ff 180.00 scf sf +900 4050 m +gs 1 -1 sc (D5) col0 sh gr +/Helvetica ff 180.00 scf sf +900 4275 m +gs 1 -1 sc (D6) col0 sh gr +/Helvetica ff 180.00 scf sf +900 4500 m +gs 1 -1 sc (D7) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 2700 m +gs 1 -1 sc (D0) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 4275 m +gs 1 -1 sc (D7) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 2700 m +gs 1 -1 sc (19) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 2925 m +gs 1 -1 sc (18) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 3150 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 3375 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 3600 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 3825 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 4275 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 4050 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 4725 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +6840 4725 m +gs 1 -1 sc (/OE) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 4275 m +gs 1 -1 sc (Q7) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 4050 m +gs 1 -1 sc (Q6) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 3825 m +gs 1 -1 sc (Q5) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 3600 m +gs 1 -1 sc (Q4) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 3375 m +gs 1 -1 sc (Q3) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 3150 m +gs 1 -1 sc (Q2) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 2925 m +gs 1 -1 sc (Q1) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 2700 m +gs 1 -1 sc (Q0) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 2700 m +gs 1 -1 sc (D0) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 2925 m +gs 1 -1 sc (D1) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 3150 m +gs 1 -1 sc (D2) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 3375 m +gs 1 -1 sc (D3) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 3600 m +gs 1 -1 sc (D4) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 3825 m +gs 1 -1 sc (D5) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 4050 m +gs 1 -1 sc (D6) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 4275 m +gs 1 -1 sc (D7) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 4725 m +gs 1 -1 sc (LE) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 2700 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 2925 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 3150 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 3375 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 3600 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 3825 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 4050 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 4275 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 4725 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 2250 m +gs 1 -1 sc (IC6) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 2475 m +gs 1 -1 sc ('573) col0 sh gr +/Helvetica ff 180.00 scf sf +10350 2250 m +gs 1 -1 sc (IC10) col0 sh gr +/Helvetica ff 180.00 scf sf +10350 2475 m +gs 1 -1 sc ('540) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 2700 m +gs 1 -1 sc (18) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 2925 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 3150 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 3375 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 3600 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 3825 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 4050 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 4275 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 4725 m +gs 1 -1 sc (19) col0 sh gr +/Helvetica ff 180.00 scf sf +10575 4725 m +gs 1 -1 sc (/OE2) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 2700 m +gs 1 -1 sc (E0) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 2925 m +gs 1 -1 sc (E1) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 3150 m +gs 1 -1 sc (E2) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 3375 m +gs 1 -1 sc (E3) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 3600 m +gs 1 -1 sc (E4) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 3825 m +gs 1 -1 sc (E5) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 4050 m +gs 1 -1 sc (E6) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 4275 m +gs 1 -1 sc (E7) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 4725 m +gs 1 -1 sc (/OE1) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 2700 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 2925 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 3150 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 3375 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 3600 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 3825 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 4050 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 4275 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 4725 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 5175 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +11025 5175 m +gs 1 -1 sc (20) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 5175 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +10665 5175 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 10800 m +gs 1 -1 sc ('540) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 13050 m +gs 1 -1 sc (19) col0 sh gr +/Helvetica ff 180.00 scf sf +6750 13050 m +gs 1 -1 sc (/OE2) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 13050 m +gs 1 -1 sc (/OE1) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 13050 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 13500 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 13500 m +gs 1 -1 sc (20) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 13500 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +6840 13500 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 11025 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 11250 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 11475 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 11700 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 11925 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 12150 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 12375 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 12600 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 11025 m +gs 1 -1 sc (/Q0) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 11250 m +gs 1 -1 sc (/Q1) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 11475 m +gs 1 -1 sc (/Q2) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 11700 m +gs 1 -1 sc (/Q3) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 11925 m +gs 1 -1 sc (/Q4) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 12150 m +gs 1 -1 sc (/Q5) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 12375 m +gs 1 -1 sc (/Q6) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 12600 m +gs 1 -1 sc (/Q7) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 11025 m +gs 1 -1 sc (18) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 11250 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 11475 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 11700 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 11925 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 12150 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 12375 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 12600 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 6300 m +gs 1 -1 sc (IC7) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 6525 m +gs 1 -1 sc ('540) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 8775 m +gs 1 -1 sc (19) col0 sh gr +/Helvetica ff 180.00 scf sf +6750 8775 m +gs 1 -1 sc (/OE2) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 8775 m +gs 1 -1 sc (/OE1) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 8775 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 9225 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 9225 m +gs 1 -1 sc (20) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 9225 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +6840 9225 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 6750 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 6975 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 7200 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 7425 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 7650 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 7875 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 8100 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 8325 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 6750 m +gs 1 -1 sc (/Q0) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 6975 m +gs 1 -1 sc (/Q1) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 7200 m +gs 1 -1 sc (/Q2) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 7425 m +gs 1 -1 sc (/Q3) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 7650 m +gs 1 -1 sc (/Q4) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 7875 m +gs 1 -1 sc (/Q5) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 8100 m +gs 1 -1 sc (/Q6) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 8325 m +gs 1 -1 sc (/Q7) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 6750 m +gs 1 -1 sc (18) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 6975 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 7200 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 7425 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 7650 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 7875 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 8100 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 8325 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 11025 m +gs 1 -1 sc (D0) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 11250 m +gs 1 -1 sc (D6) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 11475 m +gs 1 -1 sc (D7) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 11700 m +gs 1 -1 sc (D4) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 11925 m +gs 1 -1 sc (D3) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 12150 m +gs 1 -1 sc (D2) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 12375 m +gs 1 -1 sc (D1) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 16650 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +6840 16650 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 16650 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 16650 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 15075 m +gs 1 -1 sc (D0) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 15300 m +gs 1 -1 sc (D3) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 15525 m +gs 1 -1 sc (D2) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 15750 m +gs 1 -1 sc (D1) col0 sh gr +/Helvetica ff 180.00 scf sf +12150 15075 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +12600 15075 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +12150 15300 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +12600 15300 m +gs 1 -1 sc (17) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 14850 m +gs 1 -1 sc ('75) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 15075 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 15300 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 15525 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 15750 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 15075 m +gs 1 -1 sc (1D) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 15300 m +gs 1 -1 sc (2D) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 15525 m +gs 1 -1 sc (3D) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 15750 m +gs 1 -1 sc (4D) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 15075 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 15300 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 15525 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 15750 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +9675 450 m +gs 1 -1 sc (IC13) col0 sh gr +/Helvetica ff 180.00 scf sf +9675 675 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +9225 675 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +9675 900 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 1575 m +gs 1 -1 sc (9*220) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 9225 m +gs 1 -1 sc (9*330) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 9450 m +gs 1 -1 sc (RP2) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 1800 m +gs 1 -1 sc (RP1) col0 sh gr +/Helvetica ff 180.00 scf sf +9450 9225 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +9225 9450 m +gs 1 -1 sc (IC4) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 10125 m +gs 1 -1 sc (IC3) col0 sh gr +/Helvetica ff 180.00 scf sf +4950 17775 m +gs 1 -1 sc (D7) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 14175 m +gs 1 -1 sc (IC13) col0 sh gr +/Helvetica ff 180.00 scf sf +8550 13725 m +gs 1 -1 sc (IC13) col0 sh gr +/Helvetica ff 180.00 scf sf +12150 15750 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +12600 15750 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +12150 16200 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +12600 16200 m +gs 1 -1 sc (15) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 15975 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 16425 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +9900 16200 m +gs 1 -1 sc (IC4) col0 sh gr +/Helvetica ff 180.00 scf sf +12150 16650 m +gs 1 -1 sc (4*IC4) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 2475 m +gs 1 -1 sc (/DP) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 2700 m +gs 1 -1 sc (/D0) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 2925 m +gs 1 -1 sc (/D1) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 3150 m +gs 1 -1 sc (/D2) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 3375 m +gs 1 -1 sc (/D3) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 3600 m +gs 1 -1 sc (/D4) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 3825 m +gs 1 -1 sc (/D5) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 4050 m +gs 1 -1 sc (/D6) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 4275 m +gs 1 -1 sc (/D7) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 11025 m +gs 1 -1 sc (I/O) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 11250 m +gs 1 -1 sc (/REQ) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 11475 m +gs 1 -1 sc (C/D) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 11700 m +gs 1 -1 sc (/MSG) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 11925 m +gs 1 -1 sc (/BSY) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 2475 m +gs 1 -1 sc (18) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 2700 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 2925 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 3150 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 3375 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 3600 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 3825 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 4050 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 4275 m +gs 1 -1 sc (16) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 11025 m +gs 1 -1 sc (50) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 11250 m +gs 1 -1 sc (48) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 11475 m +gs 1 -1 sc (46) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 11700 m +gs 1 -1 sc (42) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 11925 m +gs 1 -1 sc (36) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 15075 m +gs 1 -1 sc (/SEL) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 15300 m +gs 1 -1 sc (/ATN) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 15750 m +gs 1 -1 sc (/RST) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 16200 m +gs 1 -1 sc (/ACK) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 15075 m +gs 1 -1 sc (44) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 15300 m +gs 1 -1 sc (32) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 15750 m +gs 1 -1 sc (40) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 16200 m +gs 1 -1 sc (38) col0 sh gr +/Helvetica ff 180.00 scf sf +15525 9450 m +gs 1 -1 sc (SCSI) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 7425 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +14310 7425 m +gs 1 -1 sc (1,3,...,49) col0 sh gr +/Helvetica ff 180.00 scf sf +11700 10350 m +gs 1 -1 sc (RP3) col0 sh gr +/Helvetica ff 180.00 scf sf +11700 10575 m +gs 1 -1 sc (5*220) col0 sh gr +/Helvetica ff 180.00 scf sf +10125 12600 m +gs 1 -1 sc (RP4) col0 sh gr +/Helvetica ff 180.00 scf sf +9945 12825 m +gs 1 -1 sc (5*330) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 14175 m +gs 1 -1 sc (RP3) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 14400 m +gs 1 -1 sc (4*220) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 16875 m +gs 1 -1 sc (RP4) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 17100 m +gs 1 -1 sc (4*330) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 17550 m +gs 1 -1 sc (1/2 IC9) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 19125 m +gs 1 -1 sc (1/2 IC9) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 17775 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 18000 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 18225 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 17775 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 18225 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 19350 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 19575 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 19800 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 19350 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +7200 19800 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 15975 m +gs 1 -1 sc (/E1) col0 sh gr +/Helvetica ff 180.00 scf sf +6300 16200 m +gs 1 -1 sc (/E2) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 15975 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +6075 16200 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +4725 16200 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +4275 16200 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +15300 1800 m +gs 1 -1 sc (P2) col0 sh gr +/Helvetica ff 180.00 scf sf +900 1125 m +gs 1 -1 sc (P1) col0 sh gr +/Helvetica ff 180.00 scf sf +900 12600 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +900 12825 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 12600 m +gs 1 -1 sc (c2,3) col0 sh gr +/Helvetica ff 180.00 scf sf +1350 12825 m +gs 1 -1 sc (a1,28-32,c1,32) col0 sh gr +/Helvetica ff 180.00 scf sf +2700 14850 m +gs 1 -1 sc (IC3) col0 sh gr +/Helvetica ff 180.00 scf sf +3375 14625 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 14625 m +gs 1 -1 sc (IC5) col0 sh gr +/Helvetica ff 180.00 scf sf +990 6525 m +gs 1 -1 sc (A9) col0 sh gr +/Helvetica ff 180.00 scf sf +990 6750 m +gs 1 -1 sc (A8) col0 sh gr +/Helvetica ff 180.00 scf sf +990 6975 m +gs 1 -1 sc (A7) col0 sh gr +/Helvetica ff 180.00 scf sf +990 7200 m +gs 1 -1 sc (A6) col0 sh gr +/Helvetica ff 180.00 scf sf +990 7425 m +gs 1 -1 sc (A5) col0 sh gr +/Helvetica ff 180.00 scf sf +990 7650 m +gs 1 -1 sc (A4) col0 sh gr +/Helvetica ff 180.00 scf sf +2295 6075 m +gs 1 -1 sc (B4) col0 sh gr +/Helvetica ff 180.00 scf sf +2295 6300 m +gs 1 -1 sc (B3) col0 sh gr +/Helvetica ff 180.00 scf sf +2295 6525 m +gs 1 -1 sc (B5) col0 sh gr +/Helvetica ff 180.00 scf sf +2295 6750 m +gs 1 -1 sc (B2) col0 sh gr +/Helvetica ff 180.00 scf sf +2340 6975 m +gs 1 -1 sc (B6) col0 sh gr +/Helvetica ff 180.00 scf sf +2340 7200 m +gs 1 -1 sc (B1) col0 sh gr +/Helvetica ff 180.00 scf sf +2295 7425 m +gs 1 -1 sc (B7) col0 sh gr +/Helvetica ff 180.00 scf sf +2295 7650 m +gs 1 -1 sc (B0) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 6075 m +gs 1 -1 sc (A4) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 6300 m +gs 1 -1 sc (A3) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 6525 m +gs 1 -1 sc (A5) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 6750 m +gs 1 -1 sc (A2) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 6975 m +gs 1 -1 sc (A6) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 7200 m +gs 1 -1 sc (A1) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 7425 m +gs 1 -1 sc (A7) col0 sh gr +/Helvetica ff 180.00 scf sf +2880 7650 m +gs 1 -1 sc (A0) col0 sh gr +/Helvetica ff 180.00 scf sf +2790 10350 m +gs 1 -1 sc (/Q0) col0 sh gr +/Helvetica ff 180.00 scf sf +2790 10575 m +gs 1 -1 sc (/Q1) col0 sh gr +/Helvetica ff 180.00 scf sf +2790 10800 m +gs 1 -1 sc (/Q2) col0 sh gr +/Helvetica ff 180.00 scf sf +2790 11025 m +gs 1 -1 sc (/Q3) col0 sh gr +/Helvetica ff 180.00 scf sf +1575 19575 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +1125 19575 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +990 18225 m +gs 1 -1 sc (IC4) col0 sh gr +/Helvetica ff 180.00 scf sf +450 9450 m +gs 1 -1 sc (CS/A) col0 sh gr +/Helvetica ff 180.00 scf sf +9765 10575 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +9315 10575 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +9495 9990 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +9540 9675 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +6525 10575 m +gs 1 -1 sc (IC8) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 6750 m +gs 1 -1 sc (E0) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 6975 m +gs 1 -1 sc (E1) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 7200 m +gs 1 -1 sc (E2) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 7425 m +gs 1 -1 sc (E3) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 7650 m +gs 1 -1 sc (E4) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 7875 m +gs 1 -1 sc (E5) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 8100 m +gs 1 -1 sc (E6) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 8325 m +gs 1 -1 sc (E7) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 11025 m +gs 1 -1 sc (E0) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 11250 m +gs 1 -1 sc (E1) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 11475 m +gs 1 -1 sc (E2) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 11700 m +gs 1 -1 sc (E3) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 11925 m +gs 1 -1 sc (E4) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 12150 m +gs 1 -1 sc (E5) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 12375 m +gs 1 -1 sc (E6) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 12600 m +gs 1 -1 sc (E7) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 15075 m +gs 1 -1 sc (Q1) col0 sh gr +/Helvetica ff 180.00 scf sf +6930 15300 m +gs 1 -1 sc (Q2) col0 sh gr +/Helvetica ff 180.00 scf sf +6885 15525 m +gs 1 -1 sc (/Q3) col0 sh gr +/Helvetica ff 180.00 scf sf +6885 15750 m +gs 1 -1 sc (/Q4) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 2700 m +gs 1 -1 sc (/Q0) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 2925 m +gs 1 -1 sc (/Q1) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 3375 m +gs 1 -1 sc (/Q3) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 3150 m +gs 1 -1 sc (/Q2) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 3600 m +gs 1 -1 sc (/Q4) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 3825 m +gs 1 -1 sc (/Q5) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 4050 m +gs 1 -1 sc (/Q6) col0 sh gr +/Helvetica ff 180.00 scf sf +10710 4275 m +gs 1 -1 sc (/Q7) col0 sh gr +/Helvetica ff 180.00 scf sf +4275 15795 m +gs 1 -1 sc (IC4) col0 sh gr +/Helvetica-Bold ff 210.00 scf sf +5580 20655 m +gs 1 -1 sc (- One Controller on SCSI-bus only \(SCSI Data/Ctrl bus always driven\)) col0 sh gr +/Helvetica-Bold ff 210.00 scf sf +5580 20910 m +gs 1 -1 sc (- Controller ID 7 only ) col0 sh gr +/Helvetica-Bold ff 210.00 scf sf +4050 20655 m +gs 1 -1 sc (Known Bugs:) col0 sh gr +/Helvetica-Bold ff 210.00 scf sf +5580 21165 m +gs 1 -1 sc (- Controller only \(not useable as device\)) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 5850 m +gs 1 -1 sc (TERMPWR) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 5850 m +gs 1 -1 sc (J1) col0 sh gr +/Helvetica ff 180.00 scf sf +14625 5175 m +gs 1 -1 sc (D1) col0 sh gr +/Helvetica-Bold ff 210.00 scf sf +4050 20385 m +gs 1 -1 sc (Comments:) col0 sh gr +/Helvetica-Bold ff 210.00 scf sf +5580 20385 m +gs 1 -1 sc (- RP1-4 only if SCSI termination on board) col0 sh gr +/Helvetica ff 135.00 scf sf +7650 1935 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 135.00 scf sf +7560 2430 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 135.00 scf sf +7785 2430 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 135.00 scf sf +8235 1935 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 135.00 scf sf +7920 2430 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 135.00 scf sf +8145 2430 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 135.00 scf sf +8460 2430 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 135.00 scf sf +8685 2430 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 135.00 scf sf +8550 1935 m +gs 1 -1 sc (3) col0 sh gr +/Helvetica ff 135.00 scf sf +9135 1935 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 135.00 scf sf +8820 2430 m +gs 1 -1 sc (13) col0 sh gr +/Helvetica ff 135.00 scf sf +9045 2430 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 135.00 scf sf +7695 1800 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 135.00 scf sf +8235 1800 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 135.00 scf sf +7875 1395 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 135.00 scf sf +8595 1800 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 135.00 scf sf +9135 1800 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 135.00 scf sf +8910 1395 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +6885 1755 m +gs 1 -1 sc (3*IC12) col0 sh gr +/Helvetica ff 180.00 scf sf +8865 1125 m +gs 1 -1 sc (4*IC11) col0 sh gr +/Helvetica ff 135.00 scf sf +8100 1260 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 135.00 scf sf +8685 1260 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 135.00 scf sf +8325 810 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +2925 14625 m +gs 1 -1 sc (12) col0 sh gr +/Helvetica ff 180.00 scf sf +3150 15120 m +gs 1 -1 sc (11) col0 sh gr +/Helvetica ff 180.00 scf sf +14850 5850 m +gs 1 -1 sc (26) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 6525 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +15075 8325 m +gs 1 -1 sc (Reserved) col0 sh gr +/Helvetica ff 180.00 scf sf +14175 8415 m +gs 1 -1 sc (N.C.) col0 sh gr +/Helvetica ff 180.00 scf sf +4050 9000 m +gs 1 -1 sc (18) col0 sh gr +/Helvetica ff 180.00 scf sf +3870 9225 m +gs 1 -1 sc (IC4) col0 sh gr +/Helvetica ff 180.00 scf sf +4140 9450 m +gs 1 -1 sc (2) col0 sh gr +/Helvetica ff 180.00 scf sf +1125 19125 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +1575 19125 m +gs 1 -1 sc (20) col0 sh gr +/Helvetica ff 180.00 scf sf +1575 18450 m +gs 1 -1 sc (1) col0 sh gr +/Helvetica ff 180.00 scf sf +1575 18675 m +gs 1 -1 sc (19) col0 sh gr +/Helvetica ff 180.00 scf sf +1125 18450 m +gs 1 -1 sc (/OE1) col0 sh gr +/Helvetica ff 180.00 scf sf +1125 18675 m +gs 1 -1 sc (/OE2) col0 sh gr +/Helvetica ff 180.00 scf sf +9045 14355 m +gs 1 -1 sc (9) col0 sh gr +/Helvetica ff 180.00 scf sf +9945 14355 m +gs 1 -1 sc (5) col0 sh gr +/Helvetica ff 180.00 scf sf +9945 13950 m +gs 1 -1 sc (6) col0 sh gr +/Helvetica ff 180.00 scf sf +9045 13950 m +gs 1 -1 sc (8) col0 sh gr +/Helvetica ff 180.00 scf sf +8550 14085 m +gs 1 -1 sc (10) col0 sh gr +/Helvetica ff 180.00 scf sf +9540 14085 m +gs 1 -1 sc (4) col0 sh gr +/Helvetica ff 180.00 scf sf +14580 8325 m +gs 1 -1 sc (24,28) col0 sh gr +/Helvetica ff 180.00 scf sf +14085 6525 m +gs 1 -1 sc (20,22,30,34) col0 sh gr +/Helvetica ff 180.00 scf sf +1575 16650 m +gs 1 -1 sc (14) col0 sh gr +/Helvetica ff 180.00 scf sf +1575 17325 m +gs 1 -1 sc (7) col0 sh gr +/Helvetica ff 180.00 scf sf +1125 16650 m +gs 1 -1 sc (Vcc) col0 sh gr +/Helvetica ff 180.00 scf sf +1125 17325 m +gs 1 -1 sc (GND) col0 sh gr +/Helvetica ff 180.00 scf sf +585 15975 m +gs 1 -1 sc (IC3,9,11,12,13) col0 sh gr +/Helvetica-Bold ff 240.00 scf sf +12960 20475 m +gs 1 -1 sc (CS/A-SCSI-1.0A-05jun98) col-1 sh gr +$F2psEnd +rs +showpage diff --git a/dump/oa-2.0.9/devices/scsi/csascsi1desc.txt b/dump/oa-2.0.9/devices/scsi/csascsi1desc.txt new file mode 100644 index 0000000..603bcd0 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/csascsi1desc.txt @@ -0,0 +1,35 @@ + +Description for CS/A SCSI, version 1.0 +-------------------------------------- + +whatsit : SCSI interface for CS/A bus +I/O : ports at $870-$e87f +Mem : -- + +IC1 selects the I/O range $87*, and IC2 selects the right registers. +IC6, 7 and 10 make up the SCSI data port at $870. IC11 and 12 compute the +parity. IC8 reads the status lines of the SCSI bus. +IC5 outputs SCSI control lines. The two parts of IC13 controlled +by IC5 are used as pseudo Open Collector for arbitration purposes. +The lower half of IC9 implements a hardware handshake to simplify +data transfer: a simple read or write acknowledges a /REQ request +from the bus. + +During arbitration the data bus outputs are decoupled from the +data bus (D1 through IC5) and also lowers data bus 7 to indicate +SCSI ID 7 (highest priority - the ID is hardcoded). + +For operation with another controller this controller must not drive +the SCSI data bus. But this is not implemented. So only one controller +is possible. + +Also I/O can not be driven by the controller so deselect/reselect +can not be supported. + +The SCSI protocol can be seen from the SCSI(-II) standard. + +The usual rules for SCSI cable termination etc. apply. + +See also several SCSI FAQs on the internet. + + diff --git a/dump/oa-2.0.9/devices/scsi/csascsi1parts.txt b/dump/oa-2.0.9/devices/scsi/csascsi1parts.txt new file mode 100644 index 0000000..78042d5 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/csascsi1parts.txt @@ -0,0 +1,23 @@ + +Parts list for CS/A SCSI board, version 1.0 +------------------------------------------- + +IC 1 74HCT688 + 2 74LS138 + 3 74LS08 + 4,7,8,10 74LS540 + 5 74LS75 + 6 74LS573 + 9 74LS74 + 11,12 74LS86 + 13 74LS125 + +P 1 CS/A bus connector + 2 50 pin flat cable boxed male connector, standard pitch + +RP 1,3 9*220 Ohm 1) + 2,4 9*330 Ohm 1) + + +1) only if SCSI termination on board + diff --git a/dump/oa-2.0.9/devices/scsi/main.a65 b/dump/oa-2.0.9/devices/scsi/main.a65 new file mode 100644 index 0000000..987bef7 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/main.a65 @@ -0,0 +1,109 @@ + + +#define PRINT +#undef PRINT2 +#undef DEBUG + +/* + * Sample SCSI + PC-style partition manager program + */ + +;-------------------------------------------------------------- +; C64 specific code + +#ifdef C64 + +#define CSADAPTER $de00 + +#define SCSIBASE (CSADAPTER+$70) + + .word $801 + *=$801 + .word link + .word 10 + .byt $9e, "2061",0 +link .word 0 + + ; set up C64 - CS/A adapter + lda #$00 + sta CSADAPTER+$80 + lda #$10 + sta CSADAPTER+$81 + lda #$ff + sta CSADAPTER+$82 + sta CSADAPTER+$83 + + jmp main + +#include "printc64.a65" + +#endif /* C64 */ + +;-------------------------------------------------------------- +; CS/A65 specific code + +#ifdef CSA + +#define SCSIBASE $e870 + + jmp main + +#include "printcsa.a65" + +#endif /* CSA */ + +;-------------------------------------------------------------- + +#include "part.i65" + +main .( + lda #buffer + ldx #2 + jsr scanpart + + rts + + lda #0 + sta rwpar+PRW_PART + lda #1 + sta rwpar+PRW_NSEC + + ldy #PRW_SECTOR + lda #0 +ml1 sta rwpar,y + iny + cpy #PRW_SECTOR+4 + bcc ml1 + + lda #buffer + sta rwpar+PRW_BUF+1 + + lda #rwpar + jsr pread + + inc rwpar+PRW_PART + lda #rwpar + jsr pread + + rts + + .) + + .bss + +buffer .dsb 512 + +rwpar .dsb PRW_SLEN + + .text + +#include "pcpart.a65" +#include "paccess.a65" +#include "csascsi1.a65" /* needs SCSIBASE */ + + diff --git a/dump/oa-2.0.9/devices/scsi/paccess.a65 b/dump/oa-2.0.9/devices/scsi/paccess.a65 new file mode 100644 index 0000000..6aa7be4 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/paccess.a65 @@ -0,0 +1,80 @@ + +/* + * read/write block on partitions partition + * + * pread <- a/y address of PRW struct + * pwrite <- a/y address of PRW struct + * + * $Log$ + * + */ + +#include "devices/scsi/part.i65" + + .( + +/*************************************************************************** + * read/write sector on partitions + */ + +&pwrite jsr ptrans + jmp writeblock + +&pread jsr ptrans + jmp readblock + +ptrans sta pp + sty pp+1 + ldy #PRW_PART + lda (pp),y + asl + asl + asl + asl + sta apart + + tax + lda parts+PT_ID,x + bne ptrok + sec + rts +ptrok + ldx #3 + ldy #PRW_SECTOR + clc +ptr1 lda (pp),y + sta lba,x + iny + dex + bpl ptr1 + + ldy apart + ldx #3 + clc +ptr2 lda lba,x + adc parts+PT_START,y + sta lba,x + iny + dex + bpl ptr2 + + ldy #PRW_NSEC + lda (pp),y + sta nsec+1 + lda #0 + sta nsec + + ldx apart + lda parts+PT_DEV,x + tax + ldy #PRW_BUF + lda (pp),y + pha + iny + lda (pp),y + tay + pla + rts + + .) + diff --git a/dump/oa-2.0.9/devices/scsi/part.i65 b/dump/oa-2.0.9/devices/scsi/part.i65 new file mode 100644 index 0000000..7983f3c --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/part.i65 @@ -0,0 +1,36 @@ + +/* + * Definitions for using the partition interface + */ + +#ifndef _PART_I65_ +#define _PART_I65_ + +/* parameter for pread/pwrite */ + +#define PRW_PART 0 /* 1 byte partition number */ +#define PRW_NSEC 1 /* 1 byte number of sectors to rd/wr */ +#define PRW_SECTOR 2 /* 4 byte 1st sector to rd/wr (Lo-hi) */ +#define PRW_BUF 6 /* 2 byte address of buffer */ +#define PRW_SLEN 8 + +/* definition of the partition table entries */ + +#define PT_ID 0 +#define PT_FLAG 1 +#define PT_DEV 2 +#define PT_RESERVED 3 +#define PT_BSIZE 4 +#define PT_START 8 +#define PT_LEN 12 +#define PT_SLEN 16 + +/* partition type (ID) definitions */ + +#define PI_NONE 0 +#define PI_FAT16 4 /* 16 bit FAT < 32M */ +#define PI_FAT16L 6 /* 16 bit FAT >= 32M */ +#define PI_EXTENDED 5 + +#endif + diff --git a/dump/oa-2.0.9/devices/scsi/pcpart.a65 b/dump/oa-2.0.9/devices/scsi/pcpart.a65 new file mode 100644 index 0000000..d125e76 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/pcpart.a65 @@ -0,0 +1,372 @@ + +/* + * PC-style partition scanner for Generic SCSI interface + * + * + * scanpart <- a/y address of buffer + * x = length of buffer in 256-byte blocks, >=2 + * -> a/y address of partition table + * also available in "parts" + * x = max. number of entries in partition table + * + * scandev calls initscsi + * + * $Log$ + * + */ + + +#define PE_ID 4 +#define PE_START 8 +#define PE_LEN 12 + +#define NPART 12 /* maximum number of useable partitions */ + +#define LASTPART (NPART*PT_SLEN) + +#ifdef DEBUG +#define PRINT +#endif + +#ifdef PRINT +#define log(a) ldx #a:jsr slogout +#define hout(a) lda a:jsr hexout +#else +#define log(a) +#define hout(a) +#endif + +#ifdef DEBUG +#define lc(a) php:pha:lda #a:jsr cout:pla:plp +#else +#define lc(a) +#endif + + .( + +/*************************************************************************** + * Scan SCSI bus for partitions + */ + +&scanpart + sta pp + sty pp+1 + stx blen + + ; clear partition table (all ID becomes 0) + lda #0 + sta apart +cp tax + lda #0 + sta parts,x + txa + clc + adc #PT_SLEN + sec + cmp #LASTPART + bne cp + + lda pp + ldy pp+1 + jsr initscsi + stx ndev + + log(0) + + ldx #0 + stx adev + +sl1 ldx adev + cpx ndev + bne scandev + clc +sle ldx ndev + lda #parts + rts + +next2 jmp next + +scandev lda devtype,x + cmp #<-1 + beq next2 + + cmp #0 ; direct access + bne next2 + + log(1) + hout(adev) + log(2) + + lda #devpar + ldx adev + jsr getsize + bcs next2 + + lda devpar+4 + ora devpar+5 + bne next2 ; byte/block >= 64k + lda devpar+6 + cmp blen + bcc lenok + bne next2 + lda devpar+7 + bne next2 +lenok + ldy #3 + lda #0 +sl2 sta offset,y + dey + bpl sl2 + +slread ldy #0 + sty mbrfl + ldx #3 +slr1 lda offset,y + sta lba,x + ora mbrfl + sta mbrfl + iny + dex + bpl slr1 + + ldy #0 + sty nsec + iny + sty nsec+1 + + lda pp + ldy pp+1 + ldx adev + jsr readblock + bcs next + + lda pp + clc + adc #$be + sta dp + lda pp+1 + adc #1 + sta dp+1 +eloop + jsr getentry + beq nextx + + cmp #PI_EXTENDED + beq extended + + pha + jsr compnext + pla + + cmp #PI_FAT16 + beq getit + cmp #PI_FAT16L + beq getit +nextx + lda #0 + sta parts+PT_ID,x + jmp nexte + +extended +/* This has been used but the first block entry is not relieable! + ldy #PE_START + clc + php +ex1 plp + lda (dp),y + adc offset-PE_START,y + sta offset-PE_START,y + php + iny + cpy #PE_START+4 + bcc ex1 + plp +*/ + ldy #0 +ex1 lda nextlba,y + sta offset,y + iny + cpy #4 + bcc ex1 + jmp slread + +nexte lda dp + clc + adc #16 + sta dp + bcs next + adc #16 + bcc eloop + +next inc adev + jmp sl1 + +getit + lda apart + clc + adc #PT_SLEN + sta apart + cmp #LASTPART + beq pmemerr + jmp nexte +pmemerr log(7) + sec + jmp sle + +getentry + ldy #PE_ID + lda (dp),y + ldx apart + sta parts+PT_ID,x + lda adev + sta parts+PT_DEV,x + lda #0 + sta parts+PT_FLAG,x + ldy #PE_START + clc + php +gi1 plp + lda (dp),y + adc offset-PE_START,y + sta parts+PT_START,x + php + iny + inx + cpy #PE_START+4 + bcc gi1 + plp +gi2 lda (dp),y + sta parts+PT_START,x + inx + iny + cpy #PE_LEN+4 + bcc gi2 + + ldy #7 + ldx apart +gi3 lda devpar,y + sta parts+PT_BSIZE,x + inx + dey + cpy #4 + bcs gi3 + + ldx apart + lda parts+PT_ID,x + +#ifdef PRINT + beq noprint + pha + jsr printpt + pla +noprint +#endif + rts + +compnext ; compute lba of next partition block + ldy #$fc + ldx apart + clc +cn1 lda parts+PT_START,x + adc parts+PT_LEN,x + sta nextlba-$fc,y + inx + iny + bne cn1 + rts + +/*************************************************************************** + * print stuff + */ + +#ifdef PRINT + +printpt + log(3) + ldx apart + lda parts+PT_ID,x + jsr hexout + log(4) + ldx apart + lda parts+PT_DEV,x + jsr hexout + ldx apart + lda parts+PT_ID,x + cmp #PI_EXTENDED + beq endpr + log(5) + ldy #4 + lda apart + clc + adc #PT_START+3 + tax +pt1 lda parts,x + jsr hexout + dex + dey + bne pt1 + log(6) + ldy #4 + lda apart + clc + adc #PT_LEN+3 + tax +pt2 lda parts,x + jsr hexout + dex + dey + bne pt2 + log(2) + rts +endpr log(8) + rts + +slogout txa + asl + tax + lda tadr+1,x + tay + lda tadr,x + jmp txtout + +tadr .word slog0, slog1, slog2, slog3, slog4, slog5, slog6, slog7, slog8 + +slog0 .asc 13,10,"Scanning for PC-type partitions",13,10,0 +slog1 .asc 13,10,"Found Direct Access Device ",0 +slog2 .asc 13,10,0 +slog3 .asc "Partition Type ",0 +slog4 .asc ", Device ",0 +slog5 .asc ", First ",0 +slog6 .asc ", Len ",0 +slog7 .asc "No more partition table entries!",13,10,0 +slog8 .asc " (extended)",13,10,0 + +#endif + +/*************************************************************************** + * data + */ + + .zero +&pp .word 0 + + .bss + +blen .byt 0 +&apart .byt 0 +ndev .byt 0 +adev .byt 0 +mbrfl .byt 0 + +offset .dsb 4 +nextlba .dsb 4 + +devpar .dsb 8 /* 8 bytes for GET_CPACITY */ + +&parts .dsb NPART * PT_SLEN /* partition table */ + + .text + .) + diff --git a/dump/oa-2.0.9/devices/scsi/printc64.a65 b/dump/oa-2.0.9/devices/scsi/printc64.a65 new file mode 100644 index 0000000..476588d --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/printc64.a65 @@ -0,0 +1,68 @@ + +/* + * Print routines for Generic SCSI driver + * + * cout + * crlfout + * txtout + * hexout + * + * $Log$ + */ + +#ifdef PRINT + + .( + +/************************************************************************* + * Generic Subroutines + */ + + .zero +p .word 0 + .text + + +&crlfout + lda #13 + jsr cout + lda #10 + +&cout jmp $ffd2 + +&txtout sta p + sty p+1 + ldy #<-1 +to1 iny + clc + lda (p),y + beq toend + jsr cout + bcc to1 +toend rts + +&hexout pha + lsr + lsr + lsr + lsr + jsr nibout + pla + and #$0f +nibout clc + adc #"0" + cmp #"9"+1 + bcc ho + adc #"A"-"9"-1-1 +ho jmp cout + + .bss + + .text + .) + +#endif /* PRINT */ + + + + diff --git a/dump/oa-2.0.9/devices/scsi/printcsa.a65 b/dump/oa-2.0.9/devices/scsi/printcsa.a65 new file mode 100644 index 0000000..c1299b7 --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/printcsa.a65 @@ -0,0 +1,90 @@ + +/* + * Print routines for Generic SCSI driver + * + * cout + * crlfout + * txtout + * hexout + * + * $Log$ + */ + +#ifdef PRINT + +#include "kdefs.i65" /* error codes */ +#include "kernel.i65" /* test system is OS/A 1.3... */ +/* +#define PUTC $f01b +#define YIELD $f03c +*/ + .( + +/************************************************************************* + * Generic Subroutines + */ + + .zero +p .word 0 + .text + + +&crlfout + lda #13 + jsr cout + lda #10 + +&cout + stx xr + ldx #STDERR +cout1 + pha + jsr PUTC + bcc ce + jsr YIELD ; give other tasks chance to run + cmp #E_NUL + beq ce + pla + jmp cout1 +ce pla + ldx xr + rts + +&txtout sta p + sty p+1 + ldy #<-1 +to1 iny + clc + lda (p),y + beq toend + jsr cout + bcc to1 +toend rts + +&hexout pha + lsr + lsr + lsr + lsr + jsr nibout + pla + and #$0f +nibout clc + adc #"0" + cmp #"9"+1 + bcc ho + adc #"A"-"9"-1-1 +ho jmp cout + + .bss + +xr .byt 0 + + .text + .) + +#endif /* PRINT */ + + + + diff --git a/dump/oa-2.0.9/devices/scsi/ramdscsi.a65 b/dump/oa-2.0.9/devices/scsi/ramdscsi.a65 new file mode 100644 index 0000000..7bf811f --- /dev/null +++ b/dump/oa-2.0.9/devices/scsi/ramdscsi.a65 @@ -0,0 +1,582 @@ + +/* + * Generic SCSI driver for CS/A SCSI card + * + * emulating a SCSI interface by using a disk image on the ramdisk + * emulation of the xcsa emulator + * + * Hardware: + * + * 2 addresses, $e870-$e871 + * + * $e870 : read SCSI data bus; write data for SCSI data bus + * + * $e871 : read status + * bit 0: I/O (SCSI in) + * 1: -ACK (SCSI out, from latch) + * 2: -RST (SCSI out, from latch) + * 3: BSY (SCSI in) + * 4: MSG (SCSI in) + * 5: + * 6: REQ (SCSI in) + * 7: C/D (SCSI in) + * write control + * bit 0: 1 = -SEL active + * 1: 1 = activate ID bit for arbitration + * 2: 1 = -BSY active + * 3: 1 = -ATN active + * 4: + * 5: + * 6: + * 7: 1 = /RST active + * + * $e872 : write any value -> pulse on /SEL (SCSI out) + * + * Software: + * + * This is a stateless SCSI driver with the following routines: + * + * initscsi <- a/y address of buffer (>=256 byte) + * -> a/y address of (static) table with device type + * of each device in it (0=disk, ff=none) + * also available as "devtype" + * x = number of table entries + * + * inquiry <- a/y address of buffer (>=256 byte) + * x = device SCSI ID + * -> buffer contains SCSI return + * + * getsize <- a/y address of buffer (>=8 byte) + * x = device SCSI ID + * -> buffer contains 4 byte # of blocks (hi-low format) + * and 4 byte byte/blocks (hi-lo) + * + * readblock <- a/y address of buffer (>= N * byte/block) + * x = SCSI device address + * lba (4 byte) LBA of first block to read (hi-lo) + * nsec (2 byte) # of blocks to read (consecutively) + * -> buffer contains data + * writeblock <- see readblock, buffer contains data + * + * + * $Log$ + * + */ + +#define DEBUG +/* #undef PRINT */ +/* #undef STANDALONE */ + +#define RAMD_DRV $e870 +#define RAMD_SECTOR $e871 + +#define RAMD_DATA $ec00 + +#ifdef DEBUG +#define PRINT +#endif + +#ifdef PRINT2 +#define PRINT +#endif + +/********************************************************************** + * system defines + */ +/* +#define DATA $e870 +#define CTRL $e871 +#define STATUS $e871 + +#define DATA $de70 +#define CTRL $de71 +#define STATUS $de71 +*/ + +#define DATA 0+SCSIBASE +#define CTRL 1+SCSIBASE +#define STATUS 1+SCSIBASE + +#define S_IO %00000001 +#define S_ACK %00000010 +#define S_RST %00000100 +#define S_BSY %00001000 +#define S_MSG %00010000 +#define S_REQ %01000000 /* check BVC/BVS */ +#define S_CD %10000000 /* check BMI/BPL */ + +#define S_PHASEMASK S_IO+S_CD+S_MSG +#define S_DATAIN S_IO +#define S_MSGIN S_IO+S_CD+S_MSG +#define S_STATUS S_IO+S_CD +#define S_COMMAND S_CD + +#define C_RST %10000000 +#define C_SEL %00001000 +#define C_BSY %00000100 +#define C_IDENT %00000010 +#define C_ATN %00000001 + +#define MYID 7 /* hardcoded in controller */ + +#ifdef PRINT +#define log(a) ldx #a:jsr logout +#define hout(a) lda a:jsr hexout +#define crlf() jsr crlfout +#else +#define log(a) +#define hout(a) +#define crlf(a) +#endif + +#ifdef DEBUG +#define lc(a) php:pha:lda #a:jsr cout:pla:plp +#else +#define lc(a) +#endif + +/************************************************************************* + * load addr and Jump table + */ + +#ifdef STANDALONE + + lda #buffer + jsr initscsi + + lda #0 + sta task+2 + sta task+3 + sta task+4 + sta task+5 + + sta task+7 + lda #1 + sta task+8 + + lda #buffer + ldx #0 + jsr readblock + rts + +#endif + + .( + +/************************************************************************* + * globals + */ + + ; powers of 2 + +pow2 .byt 1, 2, 4, 8, 16, 32, 64, 128 + + + .zero +&dp .word 0 + .text + + +/************************************************************************* + * Read a block from the device + * task+2/3/4/5 has block number (hi-lo), task+7/8 has number of blocks to rd + * a/y has memory address of buffer where to write block to + */ + +&readblock + sta dp + sty dp+1 + stx actdev + +#ifdef PRINT2 + .( + log(10) + hout(actdev) + log(11) + ldy #0 +rdll lda lba,y + jsr hexout + iny + cpy #4 + bcc rdll + log(12) + hout(nsec) + hout(nsec+1) + log(13) + hout(dp+1) + hout(dp) + log(14) +nopr2 + .) +#endif + lda #0 + sta task+1 + sta task+9 + + lda #0 + sta RAMD_DRV + lda lba+3 + sta RAMD_SECTOR + lda lba+2 + sta RAMD_SECTOR+1 + lda lba+1 + sta RAMD_SECTOR+2 + lda lba + bne rderr + ; sta RAMD_SECTOR+3 + + ldy #0 +rdloop lda RAMD_DATA,y + sta (dp),y + iny + bne rdloop + inc dp+1 +rdl2 lda RAMD_DATA+$100,y + sta (dp),y + iny + bne rdl2 + clc + rts + +rderr sec + rts + +/************************************************************************* + * Read a block from the device + * task+2/3/4/5 has block number (hi-lo), task+7/8 has number of blocks to rd + * a/y has memory address of buffer where to write block to + */ + +&writeblock + sta dp + sty dp+1 + stx actdev + +#ifdef PRINT2 + .( + log(15) + hout(actdev) + log(11) + ldy #0 +rdll lda lba,y + jsr hexout + iny + cpy #4 + bcc rdll + log(12) + hout(nsec) + hout(nsec+1) + log(13) + hout(dp+1) + hout(dp) + log(14) +nopr2 + .) +#endif + lda #0 + sta task+1 + sta task+9 + + lda #0 + sta RAMD_DRV + lda lba+3 + sta RAMD_SECTOR + lda lba+2 + sta RAMD_SECTOR+1 + lda lba+1 + sta RAMD_SECTOR+2 + lda lba + bne wrerr + ; sta RAMD_SECTOR+3 + + ldy #0 +wrloop + lda (dp),y + sta RAMD_DATA,y + iny + bne wrloop + inc dp+1 +wrl2 + lda (dp),y + sta RAMD_DATA+$100,y + iny + bne wrl2 + clc + rts + +wrerr sec + rts + +/************************************************************************* + * Initialization (a/y = buffer) + */ + +&initscsi + sta dp + sty dp+1 + + log(0) + +; scan SCSI bus for devices + + lda #0 + sta actdev ; start with first device +iniloop + lda actdev + cmp #MYID + beq nodev + + cmp #0 + beq iniok + + log(1) + hout(actdev) + crlf() + jmp next + +iselerr cli + log(4) + hout(actdev) + crlf() + jmp nodev + +iniok log(3) + hout(actdev) + crlf() + + lda dp + ldy dp+1 + ldx actdev + jsr inquire +#ifdef PRINT + pha + jsr loginquire + pla +#endif + .byt $2c +nodev lda #$ff + ldx actdev + sta devtype,x + +#ifdef PRINT + cmp #5 + beq print + cmp #0 + bne next +print + lda dp + ldy dp+1 + ldx actdev + jsr getsize + jsr printsize +#endif +next + inc actdev + lda actdev + cmp #8 + bcc iniloop + + lda #devtype + ldx #8 + clc + rts + +selerr cli + log(4) + hout(actdev) + crlf() + sec + rts + +/************************************************************************* + * Inquire device status/info into buffer (addr=a/y) + */ + +inqdata .byt 0, 0, 1, 0, 0, 0, 0, 0 + .byt "VICE XCSA EMU " + +&inquire + sta dp + sty dp+1 + stx actdev + + ldy #0 +inl lda inqdata,y + sta (dp),y + iny + cpy #32 + bne inl +indone +#ifdef DEBUG + lc("d") + tya + jsr hexout +#endif +inrts ldy #0 + lda (dp),y ; 0 = disk, 1 = Tape, 5 = CDROM + rts + + +/************************************************************************* + * Get Medium capacity, a/y = buffer + * returns 4 byte # of blocks (hi-low format) + 4 byte byte/block in + * buffer + */ + +getsdata .byt $00, $01, $38, $80 + .byt $00, $00, $02, $00 + +&getsize + sta dp + sty dp+1 + stx actdev + ldy #0 +gsl lda getsdata,y + sta (dp),y + iny + cpy #8 + bne gsl + clc + rts + +/************************************************************************* + * Print data subroutines + *************************************************************************/ + +#ifdef PRINT + +/************************************************************************* + * Print inquiry data + */ + +loginquire + ldy #8 +li1 lda (dp),y + jsr cout + iny + cpy #32 + bcc li1 + log(5) + ldy #0 + lda (dp),y + and #%00011111 + jsr hexout + log(6) + ldy #2 + lda (dp),y + and #%00000111 + jsr hexout +liret log(7) + rts + +/************************************************************************* + * Print media size + */ + +printsize + log(8) + + ldy #0 +pl1 lda (dp),y + jsr hexout + iny + cpy #4 + bcc pl1 + + log(9) + + ldy #4 +pl2 lda (dp),y + jsr hexout + iny + cpy #8 + bcc pl2 + + jmp liret + + +/************************************************************************* + * Generic Subroutines + */ + +logout txa + asl + tax + lda laddr+1,x + tay + lda laddr,x + jmp txtout + +laddr .word logt0, logt1, logt2, logt3, logt4, int0, int1, int2, ps1, ps2 +#ifdef PRINT2 + .word rd1, rd2, rd3, rd4, rd5, rd6 +#endif + +logt0 .asc 13,10,"CS/A65 SCSI driver",13,10 + .asc 13,10,"Resetting SCSI bus",13,10,0 +logt1 .asc "Device not ready ",0 +logt2 .asc "Device error bit set",13,10,0 +logt3 .asc "Device found ",0 +logt4 .asc "Device select timeout ",0 + +int0 .asc "[Type ",0 +int1 .asc ", SCSI Rev. ",0 +int2 .asc "]",13,10,0 + +ps1 .asc " [Blocks: ",0 +ps2 .asc ", Byte/Block: ",0 + +#ifdef PRINT2 + +rd1 .asc "Read Block Dev: ",0 +rd2 .asc ", Sect: ",0 +rd3 .asc ", nsec: ",0 +rd4 .asc " To: ",0 +rd5 .asc 13,10,0 +rd6 .asc "Write Block Dev: ",0 + +#endif + +#endif /* PRINT */ + +/************************************************************************* + * Data structures (no extended read/writes) + */ + + .bss + +; active device number (0-7) + +actdev .byt 0 + +; contains the device type for each SCSI ID + +&devtype .dsb 8 + +; this structure is sent as it is for one command + +task .byt 0 ; command code + .byt 0 ; LUN +&lba .byt 0 ; + .byt 0 ; + .byt 0 ; + .byt 0 ; + .byt 0 +&nsec .byt 0 + .byt 0 + .byt 0 + + .) + +#ifdef STANDALONE + +buffer =* + +#endif + .text + + + diff --git a/dump/oa-2.0.9/devices/ser_acia.a65 b/dump/oa-2.0.9/devices/ser_acia.a65 new file mode 100644 index 0000000..8f20660 --- /dev/null +++ b/dump/oa-2.0.9/devices/ser_acia.a65 @@ -0,0 +1,325 @@ +/**************************************************************************** + + OS/A65 Version 1.3.3 + Multitasking Operating System for 6502 Computers + ACIA 6551 device + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + * + * This device lacks the BRKKEY feature of the 1.4 kernel + * + * It also doesn't handle the broken handshaking of the 6551 + */ + +/* + * This is a ACIA 6551 serial line driver for CS/A65. It uses the + * hardware installed in my personal C64. The 6551 is at address $d600. + * + * The ACIA 6551 has a real bad 'feature'. The RTS/CTS lines are not + * independent from the transmitter and receiver. Instead, making + * RTS high automatically disables receiver _and_ transmitter! + * Also an incoming CTS high immediately disables the transmitter. + * That's why I use the DSR input for the CTS modem line. This line + * can be checked independently. + */ + +#include "chips/acia6551.i65" + +#ifdef ACIABASE +#define ACIA ACIABASE +#else +#define ACIA $d600 +#endif + +#define Anzdev 1 + + .( + .word devend2 + jmp prg1 + .asc "ser", sernr ,0 +-sernr += 1 + +/* + * status: Bit 0 = 1= handshake enabled + * 1 : 1= no ACIA found + * 5 : 1= set RTS hi + * 6 : 1= we are transmitting + * 7 : 1= we are receiving + * + */ + + .bss +dev .byt 0 +div .byt 0 +status .dsb Anzdev +instr .dsb Anzdev +outstr .dsb Anzdev + .text + +prg1 ldx #0 + + stx dev + cmp #DC_RES + beq devini + pha + lda status,x + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts +prgok pla + cmp #DC_IRQ + beq devirq + jmp others + +devini + lda #0 + sta status,x + sta instr,x + sta outstr,x + + STA ACIA+ACIA_SR ; programmed reset + LDA #%00011000 ; 1200 BAUD, 1 stop bit, 8 data bits + STA ACIA+ACIA_CTRL + cmp ACIA+ACIA_CTRL + bne devx + LDA #%00000101 ; no parity, normal receiver mode, + ; RTS low, Tx interrupt enabled + STA ACIA+ACIA_CMD + cmp ACIA+ACIA_CMD + bne devx + LDA ACIA+ACIA_SR ; clear interrupt + + clc + rts + +devx lda status,x + ora #2 + sta status,x + lda #E_NOTIMP + sec + rts + +devirq + .( + lda ACIA+ACIA_SR + bpl irqend ; not this ACIA + tay + bit status ; check if receiving + bpl tx ; no -> tx + and #%00001000 ; Rx data register full? + beq nobyt ; no -> nobyt + ldx outstr + lda ACIA + jsr PUTC + bcs test + +nobyt ldx outstr + lda #SC_STAT + jsr STRCMD +test bcc tx + cmp #E_NUL + bne tstwater + jsr rxoff + jmp tx +tstwater cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SFULL + beq wh + cmp #E_SHWM + bne twl +wh ldx #0 + jsr rtshi + jmp tx ; unbedingt +twl cmp #E_SLWM + bne tx +wl ldx #0 + jsr rtslo + +tx bit status + bvc irqhs + tya + and #%00010000 ; transmit data register empty? + beq irqhs ; no then -> irqhs + + lda #32 + bit status + bne endsend ; do not send any more to make RTS high. + + tya + and #%01000000 ; DSR high? + bne irqhs ; -> irqhs + + ldx instr ; send new data byte + jsr GETC + bcs test2 + sta ACIA + bcc irqhs +test2 cmp #E_EOF + bne irqhs + jsr txoff + +irqhs lda ACIA+ACIA_SR + lda #E_OK ; irq source removed + rts +irqend lda #E_NOIRQ ; no irq source found + rts + +endsend + lda ACIA+ACIA_CMD + and #%11110011 + sta ACIA+ACIA_CMD + jmp irqhs + + .) + +rtshi + lda status,x + ora #%00100000 + sta status,x + rts + +rtslo + lda ACIA+ACIA_CMD + ora #%00000100 + sta ACIA+ACIA_CMD + lda status,x + and #%11011111 + sta status,x + rts + +others cmp #DC_GS + bne o1 + lda status,x + and #DC_SW_TX + bne devonx + tya + sta instr,x + jmp ok +devonx jmp devon +o1 cmp #DC_PS + bne o2 + lda status,x + and #DC_SW_RX + bne devonx + tya + sta outstr,x +okx jmp ok +o2 cmp #DC_RX_ON + bne o3 + jsr rtslo + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON + bne o4 + lda #DC_SW_TX +o2a ora status,x + sta status,x + bne okx +o4 cmp #DC_RX_OFF + bne o5 +rxoff ldx dev + lda status,x + and #DC_SW_RX + beq devoffx + lda outstr,x + tax + lda #SC_EOF + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_RX + sta status,x + +rx1off ;jsr rts1hi + ;bcc okx + jmp okx +devoffx jmp devoff +o5 cmp #DC_TX_OFF + bne o6 +txoff ldx dev + lda status,x + and #DC_SW_TX + beq devoffx + lda instr,x + tax + lda #SC_NUL + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_TX + sta status,x + jmp ok +o6 cmp #DC_HS + bne o6a + lda status,x + and #255-1 + sta status,x + tya + and #1 + ora status,x + sta status,x + jmp ok +o6a cmp #DC_SPD + bne o7 + tya + and #%00001111 + sta div + + lda ACIA+ACIA_CTRL + and #%11110000 + ora div + sta ACIA+ACIA_CTRL + jmp ok + +o7 cmp #DC_ST + beq ok + cmp #DC_EXIT + bne onotimp + jsr rxoff + jsr txoff + ldx dev + lda status,x + ora #2 + sta status,x + sta ACIA+ACIA_SR ; programmed reset + bne ok + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +devend2 .) + diff --git a/dump/oa-2.0.9/devices/ser_uart.a65 b/dump/oa-2.0.9/devices/ser_uart.a65 new file mode 100644 index 0000000..ec21b5f --- /dev/null +++ b/dump/oa-2.0.9/devices/ser_uart.a65 @@ -0,0 +1,506 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + Generic UART 16550 serial line device + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This is an UART 16550A serial line driver for CS/A65. + * It uses the hardware installed in my personal C64. The + * 16550A is mapped at $d600, above the SID. + * + * The 16550 is not really an easy chip, but it has 16 byte + * input and output FIFO buffers, which allows much higher + * interrupt latencies. + */ + +#ifdef UARTBASE +#define UART UARTBASE +#else +#define UART $d600 +#endif + +#ifdef UARTXTAL +#define XTALMULT UARTXTAL +#else +#define XTALMULT 1 +#endif + +#include "chips/uart16550.i65" + +#define Anzdev 1 + + .( + .word devend2 + jmp prg1 + .asc "ser",sernr, 0 + +-sernr += 1 + +/* + * status: Bit 0 = 1= handshake enabled + * 1 : 1= no ACIA found + * 5 : 1= set RTS hi + * 6 : 1= we are transmitting + * 7 : 1= we are receiving + * + */ + +/* + * 16550 divisor values for BAUD rates ?, 50, 75, 110, 134.5, 150, + * 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 19200 + */ +divisor .word -1, 2304 * XTALMULT, 1536 * XTALMULT, 1047 * XTALMULT + .word 857 * XTALMULT, 768 * XTALMULT, 384 * XTALMULT + .word 192 * XTALMULT, 96 * XTALMULT + .word 64 * XTALMULT, 48 * XTALMULT, 32 * XTALMULT + .word 24 * XTALMULT, 16 * XTALMULT, 12 * XTALMULT + .word 6 * XTALMULT + + .data +dev .byt 0 +div .byt 0 +status .dsb Anzdev +instr .dsb Anzdev +outstr .dsb Anzdev +brkkey .dsb Anzdev + .text + +prg1 ldx #0 + + stx dev + cmp #DC_RES + beq devini + pha + lda status,x + and #2 + beq prgok + pla + lda #E_NOTIMP + sec + rts +prgok pla + cmp #DC_IRQ + beq devirq2 + jmp others +devirq2 jmp devirq + +/*****************************************************************/ + +devini lda #0 + sta status,x + sta instr,x + sta outstr,x + + lda #3 + sta brkkey,x + + ldy UART+UART_MCR + lda #$10 + sta UART+UART_MCR + lda UART+UART_MSR + and #$f0 + bne nodev + lda #$1f + sta UART+UART_MCR + lda UART+UART_MSR + and #$f0 + cmp #$f0 + bne nodev + sty UART+UART_MCR + + ldy UART+UART_SCR + lda #%10101010 + sta UART+UART_SCR + cmp UART+UART_SCR + bne dev8250 + lsr + sta UART+UART_SCR + cmp UART+UART_SCR + bne dev8250 + sty UART+UART_SCR + + lda #1 + sta UART+UART_FCR + lda UART+UART_IIR + ldy #0 + sty UART+UART_FCR + asl + bcc dev16450 + asl + bcc dev16550 + ; else dev16550A; currently only this one is supported + + lda #%10000000 + sta UART+UART_LCR + ldx #14*2 ; 9600 BAUD + lda divisor,x + sta UART+UART_DLL + lda divisor+1,x + sta UART+UART_DLH + lda #%00000011 ; 8N1 + sta UART+UART_LCR + + lda #7 ; no FIFO enable and clear FIFOs, + sta UART+UART_FCR ; trigger at 1 byte + lda #0 + sta UART+UART_IER ; polled mode (so far) + lda UART+UART_MCR + and #%00001100 ; keep OUT1, OUT2 values + sta UART+UART_MCR ; reset DTR, RTS + + clc + rts + +nodev ; no UART at all +dev8250 ; no Scratchpad, no FIFO +dev16450 ; scratchpad, no FIFO +dev16550 ; FIFO bug + lda status,x + ora #2 + sta status,x + lda #E_NOTIMP + sec + rts + +/*****************************************************************/ + +devirq + .( + lda UART+UART_IIR + lsr + bcc intr +irqend lda #E_NOIRQ ; no irq source found + ;rts ; not this one + jmp irqe + + ;----------------------------------------------- + +intr + and #%00000011 ; interrupt mask - makes four possible IRQs + tay + bne int_tx + + lda UART+UART_MSR + jmp checkint + +int_tx + dey + bne int_rx +tx_loop + jsr tx2 + jmp checkint + +int_rx + dey + bne int_status +rx_loop + jsr rx2 ; get one char + lda UART+UART_LSR + lsr + bcs rx_loop +; and #$20 ; THRE ($40/2) +; bne tx_loop + jmp checkint + +int_status + lda UART+UART_LSR + +checkint + lda UART+UART_IIR + lsr + bcc intr ; irq still pending + +; lda UART+UART_LSR +; and #$40 +; beq nbyt +; jsr tx2 +;nbyt + jsr nobyt + +irqok lda #E_OK ; irq source removed +irqe pha + + lda UART+UART_LSR + and #$40 + beq nbyt + jsr tx2 + jsr nobyt +nbyt + pla + rts + + ;----------------------------------------------- + +rx2 .( + lda UART+UART_RXTX + bit status + bpl rx2end + ldx outstr + + cmp brkkey + bne nobrk + lda #SC_SSTAT + ldy #SCE_BRK + jsr STRCMD + lda brkkey +nobrk + jsr PUTC + bcc rx2end + cmp #E_SLWM ; this happens most and is caught by nobyt + bne test +rx2end rts + +&nobyt ldx outstr + bit status + bpl rx2end + lda #SC_STAT + jsr STRCMD + bcc rx2end +test + cmp #E_NUL + bne tstwater + jmp rxoff +tstwater + cmp #E_SEMPTY + beq wl + tax + lda status + and #1 + bne wh + txa + cmp #E_SHWM + beq wh + cmp #E_SFULL + bne twl +;inc $d020 +wh ldx #0 + jmp rtshi +twl cmp #E_SLWM + bne rx2end +wl ldx #0 + jmp rtslo + .) + + ;----------------------------------------------- + +tx2 .( + bit status + bvc txrt ; reading IIR should clear this line + + lda UART+UART_MSR + and #%00110000 + cmp #%00110000 ; cts or dsr inactive + bne txrt + + ldy #15 +txloop + ldx instr ; send new data byte + jsr GETC + bcs test2 + sta UART+UART_RXTX + dey + bne txloop ; fill up FIFO + bcc txrt + +test2 cmp #E_EOF + bne txrt + jmp txoff +txrt rts + .) + + .) + +/*****************************************************************/ + +dtrhi + lda UART+UART_MCR + and #%11111110 + sta UART+UART_MCR + lda #0 + sta UART+UART_IER + rts + +dtrlo + lda UART+UART_MCR + ora #%00000001 + sta UART+UART_MCR + lda #3 + sta UART+UART_IER + rts + +rtshi + lda UART+UART_MCR + and #%11111101 + sta UART+UART_MCR + lda status,x + ora #%0010000 + sta status,x + rts + +rtslo + lda UART+UART_MCR + ora #%00000010 + sta UART+UART_MCR + lda status,x + and #%11011111 + sta status,x + rts + +/*****************************************************************/ + +others cmp #DC_GS ; set stream to get data from + bne o1 + lda status,x + and #DC_SW_TX + bne devonx + tya + sta instr,x + jmp ok +devonx jmp devon +o1 cmp #DC_PS ; set stream to put data to + bne o2 + lda status,x + and #DC_SW_RX + bne devonx + tya + sta outstr,x +okx jmp ok +o2 cmp #DC_RX_ON ; switch receiver on + bne o3 + ; lda #3 + ; sta brkkey + jsr rtslo + jsr dtrlo + lda #DC_SW_RX + bne o2a +o3 cmp #DC_TX_ON ; switch sender on + bne o4 + jsr dtrlo + lda #DC_SW_TX +o2a ora status,x + sta status,x + bne okx +o4 cmp #DC_RX_OFF ; switch receiver off, send eof to stream + bne o5 +rxoff ldx dev + lda status,x + and #DC_SW_RX + beq devoffx + jsr rtshi + lda outstr,x + tax + lda #SC_EOF + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_RX + sta status,x + jmp checkdtr + +devoffx jmp devoff + +o5 cmp #DC_TX_OFF ; switch sender off, send nul to stream + bne o6 +txoff ldx dev + lda status,x + and #DC_SW_TX + beq devoffx + lda instr,x + tax + lda #SC_NUL + jsr STRCMD + ldx dev + lda status,x + and #255-DC_SW_TX + sta status,x +checkdtr + and #DC_SW_TX+DC_SW_RX + bne active + jsr dtrhi +active jmp ok + +o6 cmp #DC_HS ; set handshake -- currently ignored (TODO) + bne o6a + lda status,x + and #255-1 + sta status,x + tya + and #1 + ora status,x + sta status,x + jmp ok + +o6a cmp #DC_SPD ; set speed + bne o7 + tya + and #%00001111 + asl + tax + beq ok + + lda UART+UART_LCR + ora #$80 + sta UART+UART_LCR + lda divisor,x + sta UART+UART_DLL + lda divisor+1,x + sta UART+UART_DLH + lda UART+UART_LCR + and #$7f + sta UART+UART_LCR + + jmp ok + +o7 cmp #DC_ST ; get status... + beq ok + cmp #DC_EXIT ; disable everything + bne o8 ; onotimp + jsr rxoff + jsr txoff + ldx dev + lda status,x + ora #2 + sta status,x + bne ok +o8 + cmp #DC_BRKKEY + bne onotimp + lda brkkey + sty brkkey + tay + ; jmp ok + +ok lda #E_OK + .byt $2c +devon lda #E_DON + .byt $2c +devoff lda #E_DOFF + .byt $2c +onotimp lda #E_NOTIMP + cmp #1 + rts + +#undef UART +#undef XTALMULT + +devend2 .) + diff --git a/dump/oa-2.0.9/devices/spooler.a65 b/dump/oa-2.0.9/devices/spooler.a65 new file mode 100644 index 0000000..11b655f --- /dev/null +++ b/dump/oa-2.0.9/devices/spooler.a65 @@ -0,0 +1,169 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + Generic spooler device + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#define ANZINSTR 16 + + .( + .word spoolend + jmp spoolprg + .asc "spooler",0 + + .data +anzinstr .byt 0 +outstr .byt 0 +status .byt 0 +byte .byt 0 +instr .dsb ANZINSTR + .text + +spoolprg cmp #DC_RES + bne sp1 + + lda #0 + sta anzinstr + sta status + clc + rts + +sp1 cmp #DC_IRQ + bne sp2 + + lda status + and #DC_SW_RX + beq spi1 + lda status + and #DC_SW_TX + beq spi4 +spil lda status + and #1 + bne spi2 + ldx instr + jsr GETC + bcc spi2b + cmp #E_EOF + bne spi4 + + ldx instr + lda #SC_NUL + jsr STRCMD + + dec anzinstr + beq rxoff + ldx #0 +spi3 lda instr+1,x + sta instr,x + cpx anzinstr + bcs sp4 + inx + bne spi3 + +spi2b sta byte + lda #1 + ora status + sta status +spi2 lda byte + ldx outstr + jsr PUTC + bcs spi5 + lda status + and #%11111110 + sta status + jmp spil + +spi4 ldx outstr + lda #SC_STAT + jsr STRCMD + +spi5 cmp #E_NUL + beq rxoff +spi1 clc + lda #E_NOIRQ + rts + +sp2 cmp #DC_RX_OFF + beq rxoff + cmp #DC_TX_OFF + bne sp3 +rxoff lda status + and #DC_SW_RX + beq spe4 + ldx outstr + lda #SC_EOF + jsr STRCMD +spe4 lda status + and #DC_SW_TX + beq spe1 + ldx #0 +spe2 cpx anzinstr + bcs spe1 + lda #SC_NUL + jsr STRCMD + inx + bne spe2 +spe1 lda #0 + sta anzinstr + sta status + beq ok + +sp3 cmp #DC_RX_ON + bne sp4 + lda #DC_SW_RX + bne setst +sp4 cmp #DC_TX_ON + bne sp5 + lda #DC_SW_TX +setst ora status + sta status +ok lda #0 + .byt $2c +spdevon lda #E_DON + .byt $2c +sp7 lda #E_NOTIMP + cmp #1 + rts + +sp5 cmp #DC_GS + bne sp6 + lda status + ldx anzinstr + cpx #ANZINSTR + bcs spdevon + tya + sta instr,x + inc anzinstr + jmp ok + +sp6 cmp #DC_PS + bne sp7 + lda status + and #DC_SW_RX + bne spdevon + sty outstr + jmp ok + +#undef ANZINSTR + +spoolend .) + diff --git a/dump/oa-2.0.9/doc/BUGS b/dump/oa-2.0.9/doc/BUGS new file mode 100644 index 0000000..d104c1f --- /dev/null +++ b/dump/oa-2.0.9/doc/BUGS @@ -0,0 +1,92 @@ + +Here is a list of known bugs of version 2.0.0-pre1 +-------------------------------------------------- + +- starting ROM program is only possible in the old-style shell + and it doesn't fill in the command line. Starting o65 files is ok. + +- lib6502 does not use SBRK when memory is exhausted. + +- slipd libip routines seem to be buggy still - very weird effects! + I have no idea where they come from. When I start hunting one, it + disappears and another pops up. Amongs them were: + - closing telnet seems to set nthreads in kernel tables to $ff!!!! + - also opening a telnet connection prints some weird characters on the + wrong screen (stream gets "$ff $ff $c6 $07 $07 $07..." bytes sent, + I have no idea where from...) + - telnet works on telnet port somehow - bug hangs if streams are closed... + should comply to rfc1143 + - httpd doesn't work although using almost all the same routines as + rsh which work + - SC_ESTAT does not seem to recognize E_EOF the same way as SC_STAT? + (slipd, in rsh.a65, label newpkt) + I have found and fixed a bug in the lib6502 fread/fwrite that could + probably have caused this bug, but have not (yet) checked this. + +- using inet apps without registering an inet task blocks those programs + (kernel problem as not-registered task is not recognized) + +- listen does not check if port already in use + also there is no way to free listenports in use by crashed/killed + programs - probably when reuse, overwrite old listenport such + that table does not fill up? + +- telnet doesn't really implement local echo mode. + +- slipd uses accesses to $dc** (C64 CIA timers) to generate initial + pseudo-random sequence numbers. + +- when getting tcp signal, set error flag in associated streams + +- SLIPD: wwwroot path given to chdir, but not used when opening a file; + only the first letter is used as drive. + +- FSIEC does not recognize chdir paths when reading directories + from the bus (i.e. C64 reads from IEEE488 bus and CSA drive is the + fsibm drive), files are ok. + +- more diagnostics ("why the beep...", i.e. why the "?") in lsh + +- keyboard layout into docs + +- when fsiec on C64 is parallel but doesn't find the interface, it + dies too ungracefully... + +- when path overflows, behaviour is undefined + +- C64 sbrk always returns ROMSTART instead of RAMSIZE? + +- a semaphore can be released when a process is waiting for it + +- console: control-character printed? + +- (multiple) errors on non-existant IEC drives are not handled correctly: + gecko may break, C64 sometimes reads empty stream... + +- FSIEC hangs on disk full with C64 parallel IEC bus interface (and probably + others too) + +- FSIEC (on CS/A65) seems not to release the interface semaphore after + init every time? + +- serial line drivers ignore handshake value (i.e. rts/cts vs. xon/xoff) + +- serial IEC bus for CS/A65 architecture only works with 1MHz (is this a bug?) + +- The CS/A65 console doesn't work when interrupting the device is enabled. + (could be kernel or device problem...) + +- C64 fsiec filesystem (serial/parallel?) reads one byte from file even + when it's not found (in VICE) + +- C64 console doesn't generate the F1 key with shift and shift/ctrl? + +- CS/A65: non-ROM-started devices don't work. + +- spooler device doesn't forward BRK and PUSH flags + +- fsiec, fsibm and fsdev ignore stream brk/push/pull flags, and don't set + stream error flags (only fsiec sets SCE_[RW]ERRM flags). + +- PET don't do shifted characters on keyboard + diff --git a/dump/oa-2.0.9/doc/COPYING b/dump/oa-2.0.9/doc/COPYING new file mode 120000 index 0000000..012065c --- /dev/null +++ b/dump/oa-2.0.9/doc/COPYING @@ -0,0 +1 @@ +../COPYING \ No newline at end of file diff --git a/dump/oa-2.0.9/doc/IDEAS b/dump/oa-2.0.9/doc/IDEAS new file mode 100644 index 0000000..47137d5 --- /dev/null +++ b/dump/oa-2.0.9/doc/IDEAS @@ -0,0 +1,33 @@ + +- vt100 control codes for the console + +- native C128 port + +- use STDIN stream as 'controlling terminal', i.e. when break flag on + STDIN stream is set, send SIG_BRK to task (to be done in scheduler?). + +- slipd/rsh should interpret telnet commands and options transparently + when telnet port is used. Set the stream break flag for example. + This would make slipd the controlling terminal for the remotely started + process. + +- map $e8** to some other place when entering the kernel to gain + two more kB for CS/A65 architecture + +- stream receiver sets special bit to indicate it can receive block + commands -> sender can send parameter for a BLKCPY call where the + receiver directly copies data from sender memory. + When this bit is not set, sender does not send block but only byte data. + Problem: serialization of block command byte sequence read/write, + i.e. multiple readers/writers have to content for the stream + +- move the WD1772 stuff from fsibm to some other file and abstract it + to a kind of block device interface. Then have some SCSI disk + block device, RAMdisk block device, VC1571 MFM mode block device... + +- clean up out-of-band data path, i.e. CTRL-C in terminal, SIGINT, + lib6502 kill -> SIG_KILL, ... + +- lib6502 call "loader" to load overlays and remove overlays again, + including binding etc. Probably in different steps? + diff --git a/dump/oa-2.0.9/doc/LOG-1.3 b/dump/oa-2.0.9/doc/LOG-1.3 new file mode 100644 index 0000000..a492db8 --- /dev/null +++ b/dump/oa-2.0.9/doc/LOG-1.3 @@ -0,0 +1,332 @@ + +******** OS/A 1.00 ******** 23sep90, Andre Fachat + +Multitasking Operating system for the 6502 CPU. +The system has a memory manager, stream handler and device handler. +Also there is an environment handler with a scheduler. +The whole stuff works like a kind of virtual machine, with the only +difference that hardware accesses are done via the kernel. +But each task and each device has its dedicated memory area. +Each task can think of having its own CPU concerning memory environment +and esp. stack and zeropage. +This only works with the CS/A builtin MMU, where the upper 4 bit are +expanded to 8 bit, thus allowing 1 MByte of virtual memory. +The memory block size is 4kByte. The possible 1 MByte is divided into +256 blocks, which can be mapped at any of the 16 possible positions +in the 64k size 6502 address space. +Each task can have up to 58 kByte of linear address space, which is +64k minus 4 kByte kernel ($f***) and 2 kByte I/O ($e800-$efff). +The communication between the tasks work via streams, i.e. asynchronous +first-in-first-out buffer. For example, a device can write into the +stream that is being used as STDIN stream, while tasks puts its data +to the STDOUT stream that might be written to file on a filesystem. +Devices are a set of subroutines that can have up to 4 kBytes, i.e. +one memory block. They are mostly called during an interrupt, which they +have to serve. +Tasks can also have their own interrupt routine. Semaphores to +synchronize different tasks are also available. As long as a +semaphore has a Pass (P) operation done on it and no Free (V), +another task trying to Pass it will be set asleep. +With SEND and RECEIVE messages up to 256 byte can be passed from one +to another task. When receiving, the sending task can also be specified. +READ and WRITE allow a task to manipulate another tasks memory. + +Currently available are the NULL, SPOOLER, CENTRONICS, SER(1-2) and VIDEO(1-4) +devices. The NULL device empties all streams, until there is no further +data available (EOF). The spooler copies all input streams one after +the other to its output stream (serialization). +File handling is done with the filesystems. Currently available are +the FSDEV and the FSIEC filesystems. Filesystems are called with +SEND on task $fe. FSDEV allows the handling of devices as files. +FSIEC handles Commodore disk drives with device address 8 and 9. + +******** OS/A 1.01 ******** 1oct90, Andre Fachat + +Video device and shell/monitor overhauled, mainly because of better +cooperation on full screen editor. + +******** OS/A 1.30 ******** 14apr91, Andre Fachat + +Complete reworking: +Several negative task numbers can be assigned an +specific 'real' tasks. For each negative number only one task can +be assigned. +The operating system now even works in a computer without MMU. All tasks +work in the same environment, so that identical programs cannot be +invoked twice. +For speed reasons the task interrupts can be disabled at assemble time. +Also the availability of a system port can be flaged at assmble time. +The IEC bus filesystem can also work as a drive for the IEEE bus. +That means that e.g. a C64 can use the internal filesystems of the +CS/A computer as a disk drive. +With a new hardware board, the computer can now handle IBM PC style +disks with FSIBM. Disks from 360k up to 1.44 MByte can be handled, +with block sizes up to 1 kByte (what you get from a WD1770). +A Basic interpreter has been ported from the C64, thus making it possible +to run BASIC programs in parallel... + +******** OS/A 1.31 ******** 25jun91, Andre Fachat + +A special MCOPY program to copy multiple files one after each other +is available in the ROM. (Starting the copies in the shell in the +background would eat up resources). Also filename jokers (*, ?) are +available with this program. + +******** OS/A 1.31 ******** (19jan92) 21feb92, Andre Fachat + +Introduced some kind of STDIO library below $e800, i.e. below the I/O +area. These library routines run in the tasks own memory and handle some +things happening in most tasks. +The centronics device finally works, and FSIEC now accepts an additional +drive number for dir and and the disk commands, for the handling of +dual disk drives for example. + +******** OS/A 1.31 ******** 10may92 Andre Fachat + +Two new options when compiling: BATMEM allows some battery buffered +memory ($0000-$8000) to not be erased on boot. NOMIRRORMEM saves a few +byte in the kernel if it's sure that we have no mirrored memory +(no open address lines). + +******** OS/A 1.31 ******** 12jul92 Andre Fachat + +When using PSEM, the Carry flag now says, if the task should block +(C=0) or if the task should return immediately with an error if it +could not get the semaphore (C=1). +Negative semaphores can be used as system semaphores. + +********* OS/A 1.31 ******** 15oct92 A.Fachat + +Another bug in the STDIO library is fixed: The drive is set correctly +with Usedir. In the monitor, when setting registers or parameters, the +"." to ignore an entry (leave byte untouched) has been replaced by +a dash ("-"). Now it is possible to enter decimal numbers (with leading +"."). +A bug in the shell DEVCMD introduced with the STDIO lib has been fixed. +The programs got too big, so now MCOPY is not in the ROM anymore. +Exchanged FSIEC and FSIBM in the ROM, so that drive C: is IEC drive 8, +which normally is the harddisk of my Atari. + +******** OS/A 1.32 ******** 16oct92 A.Fachat + +In the shell and in the monitor now RAM extensions are accepted not only +till $8000 but till program start. Also, if no more memory available, +the block is not set to $20 anymore. +Without an MMU, the NMI interrupt can now also be used. +If NOSINPORT is set when assembling, the system port is only used +for output, so that plugging a debug card into the bus enables debug +output (if any). + +******** OS/A 1.33 ******** 17oct92 A.Fachat + +In this version the previous kernel task tables (task data and the +task name) are put into two tables with the same offset for a task. +(previously the task number had to be multiplied by 24 and 8, now +by 16 for both tables). Thus now with MMU, 16 instead of 10 tasks can +be running. +The 'SYSBUF' has been eliminated. Instead of copying data from PCBUF to +SYSBUF and vice versa for (system) SENDs, REGDEV,... the MMU is now used. +Now the PCBUF is used by the kernel ony during startup and can later +be used by the programs. + +******** OS/A 1.3.3 ******** apr1996 A.Fachat + +Put the source code into a Unix tar archive, html-ized the docs and +put it on the World Wide Web. + +******** OS/A 1.3.5 ******** apr1996 A.Fachat + +Introduced a version for the C64 (on public demand... ;-) +The FSIEC has been changed to handle the original Commodore C64 IEEE488 +bus interface. The terminal device handles the C64 screen and keyboard. +The kernel uses the CIA1 timer B for interrupts. +Many things have now only been ported to a system without MMU, because +that's a lot of work. Everything has to be check if using global +variables, esp. when called from different tasks, like the STDIO lib... +Development took place on the vice C64 emulator. + +******** OS/A 1.3.6e ******** 09jun1996 A.Fachat + +The C64 is now real 'breadbox C64' tested and debugged. The parallel +port (IEEE488) stuff had bugs that are now fixed. The serial bus is now +working as well. Some more bugs in the NOMMU port have been fixed. A +semaphore for the use of the global PCBUF send buffer has been +introduced. All filesystems and tasks now try to get the SENDBUF +semaphore first before trying to write to the send buffer. +Also system semaphores for some hardware (IEEE488 interface, WD1770 PC +disk controller) have been introduced. + +******** OS/A 1.3.6f ******** 09jun1996 A.Fachat + +Changed the maximum number of tasks for systems without MMU from 6 to 5. +This gives 40 instead of 32 bytes of stack space for each task. +Hopefully now occasional BRKs are gone. +FSIEC does now recognize the "/" DIRSIGN at the beginning of a directory +search mask and removes it - all filenames are global. + +******** OS/A 1.3.7 ******** 30jun1996 A.Fachat + +Introduced return code for device interrupt routines. It is returned +if an interrupt source has been cleared (E_OK) or not (E_NOIRQ). +This is checked, and if a source has been removed, the interrupt +routine is left - if we cannot check the irq line directly with SYSINPORT. +The C64 got a ACIA 6551 device, if it is built into the C64. + +******** OS/A 1.3.8 ******** 13oct1996 A.Fachat + +Added two routines (PUTB, GETB) to handle block transfers to Stream +buffers. SBLK transfers a block of data (length in a) to (c=1) or from +(c=0) a stream (xr) buffer to memory (address in zeropage address +pointed to by yr). The routine returns the number of actually +transfered data in a (?). The data must not cross page (4k) boundaries +on MMU systems. +This procedure (hopefully) avoids a lot of context switches. + +******** OS/A 1.3.8d ******** 16oct1996 A.Fachat + +a log says more than thousand words :-))) +---------------------------------------------------------------- +root:/root>ping -c 1 192.168.0.13 +PING 192.168.0.13 (192.168.0.13): 56 data bytes +64 bytes from 192.168.0.13: icmp_seq=0 ttl=64 time=4673.4 ms + +--- 192.168.0.13 ping statistics --- +1 packets transmitted, 1 packets received, 0% packet loss +round-trip min/avg/max = 4673.4/4673.4/4673.4 ms +root:/root>date +Wed Oct 16 18:07:58 MET 1996 +root:/root> +---------------------------------------------------------------- +Well, there still is a lot to do: +- problems with lost characters +- memory management buggy +- removing DEBUG output (gets down to 1.6s for a ping reply) + +******** OS/A 1.3.8e ******** 16oct1996 A.Fachat + +Ironed out some bugs in SLIP memory handling, which seems stable now. +SLIP behaves strange when packet buffer is _not_ empty (i.e. filled +with zero) + +******** OS/A 1.3.8f ******** 18oct1996 A.Fachat + +SLIP IP layer is stable now. Added serial device driver for UART 16550A. +with FIFO. But still lost chars above 2400 baud :-( +Fixed another bug in GETB, but GETB version of SLIP is way _slower_ +than GETC version!? GETC version gives PING replies in 860ms (@ 2400 baud), +GETB version in around 1750ms. +Serial line interrupts still increase cursor speed. + +******** OS/A 1.3.9 ******** 19oct1996 A.Fachat + +A new compile option STACKCOPY for systems without MMU allows the stack +to be copied into a save area on context switch (i.e. $80-$ff is system, +$00-$7f for task, the stack is copied only when a real task change takes +place). This now allows more than 5 tasks in systems without MMU. + +******** OS/A 1.3.9a ******** 19oct1996 A.Fachat + +Optimized UART 16550A driver. Now works for 9600 baud (if not much other +work to do). Then we still loose characters. Running SLIP with 19200 +crashes the system :-( + +******** OS/A 1.3.9b ******** 20oct1996 A.Fachat + +I managed to get my selfbuilt hardware running again! So the current +stdrom is checked with MMU. OLDROM will from the next version on +refer to 1.3.9b + +******** OS/A 1.3.9d ******** 21oct1996 A.Fachat + +Serial device driver for the fast (i.e. 9600 baud) RS232 interface by +Daniel Dallmann started. Transmitting works. + +******** OS/A 1.3.9e ******** 22oct1996 A.Fachat + +Now receiving at slow byterate (though 9600 baud) works. Too many bytes +(i.e. NMIs) in a short time kill the machine... + +******** OS/A 1.3.9f ******** 22oct1996 A.Fachat + +Made NMI driver a bit faster, receiving at fast RS232 works better now +for low byterates, although still crashes at high byterates. +SETNMI now returns the old NMI vector, and the NMI routine has not to +RTS, but to JMP(old_vector). + +******** OS/A 1.3.9g ******** 23oct1996 A.Fachat + +Fixed the bug in the serial driver IRQ (not NMI!) routine, which messed +up the stack when getting above the stream low water mark... +SETNMI now sets the NMI routine directly, i.e. ($fffa) jumps to +jmp (vector), where vector can be set with SETNMI; so registers have to +be saved in the NMI routine. +TODO now: a means to disable NMI during disk or whatever access. +Maybe redefine $f003 jmp, because NMI vector is known anyway: jmp ($fffa). +PING now gives around 10 seconds reply time, dropping every second packet +due to full tx queue: tx byterate is slow due to 16 used bits per byte +(i.e. 6 additional stop bits) and interrupt latency. But usually receiving +should have higher byterate than receiving. With PING, the SLIP task +tries to send as fast as it receives, which doesn't work... + +The same bug as in the fast serial driver was in the UART driver, which +now works at 19200 baud, only very occasionally loosing characters. +Also some more handshake bugs in these drivers have been fixed. + +******** OS/A 1.3.10a ******** 25oct1996 A.Fachat + +Added CTRLNMI system call, together with the NMI chain. There is still +a way missing to remove a driver from the chain. +The C64 fast serial driver uses this method now. Although flooding the +computer with bytes slows it down to near unusability. + +******** OS/A 1.3.11 ******** jan1997 A.Fachat + +Been working on TCP implementation. discard & echo ports work. +Also connection closing ceremonies. Packet Retransmission works. +Retransmission timeouts, timewait timeouts work. +chargen port works. program registers itself as filesystem. + +TODO: 32-bit-modulo, some timeouts... + +******** OS/A 1.3.12 ******** 2mar1997 A.Fachat + +Implemented the Gecko OS ROM. It features a shell (with monitor), +the irtx program to send commands to IR devices (like CD players or +TV sets), a serial IEC filesystem. The shell runs over the serial +line (with 16550). + +******** OS/A 1.3.13 ******** 09mar1997 A.Fachat + +The fstcp filesystem works for reading files and directories. +Directories without directory mask, though. +The fstcp server accepts connections only from a given address now, +and (hopefully) doesn't allow accesses outside the given directory. +TODO: 32-bit modulo, fstcp writes, bugfixes + +******** OS/A 1.3.13a ******** 10mar1997 A.Fachat + +Writing to the fstcp filesystem seems to work now. +FSTCP can now be disabled in main.a65. + +******** OS/A 1.3.13b ******** 11mar1997 A.Fachat + +hacked a small (and dirty) WWW server... + +******** OS/A 1.3.13d ******** 14mar1997 A.Fachat + +Bug fixes...: +- It is now possible to run the WWW server together with the + FSTCP filesystem at the same time - it is _not_ allowed to let the + WWW server access a file on the FSTCP filesystem - it hangs the SLIP + process! +- The problem with the aborts is gone: I forgot to release the STREAMS + in the WWW server +- the transition from LASTACK to CLOSED wasn't detected, because ackxmit + overwrote the "tmp" variable that holds the checkack return value... +- LASTACK now also has a timeout to close the TCB after a while +- FINW2 was not resolved to TIMEW because there was no check... + so the available number of TCBs decreased... +- FINW2 now also has a timeout to closed, as when the FIN is ack'd, we + cannot resend it (removed from queue...). This is probably not as it should + be, but it works anyway. + diff --git a/dump/oa-2.0.9/doc/LOG-2.0 b/dump/oa-2.0.9/doc/LOG-2.0 new file mode 100644 index 0000000..27a43e4 --- /dev/null +++ b/dump/oa-2.0.9/doc/LOG-2.0 @@ -0,0 +1,56 @@ + +2.0.9 - 06oct2013 - A. Fachat + +- fixed an uninitialized variable bug in the console driver that only showed + on the real machine + +- fixed build problems for the c64 ("notimp" code in lib6502 jump table) + +- lsh got cmdline option where to CHDIR on start, ROMs set it to boot drive + Also got a new "reset" command + +- adapt new c1541 command syntax for formatting an x64 file + + +2.0.8 - 20dec1998 - A. Fachat + +- console device now implements TC_CPOS multibyte control code + to place cursor directly on screen. + +- init features MMU mode to scan second bank for the ROM link + chain to execute. It uses the "magic" non-sysapp to determine + if it found one. + +- break fsibm into parts, especially separate the hardware (WD1770) + driver from the rest. Implement a RAMdisk driver for fsibm. + +- moved computation of DPB and translation of linear address -> C/H/S + into hardware driver. Implemented "linear" ramdisk driver. + +- made fsibm loadable as o65 file. + increase memory size for CS/A65 lib6502 files from 4 to 12k. + loading sometimes doesn't work... + +- fix kernel/init to make booting TESTROM image work + +- init now handles second ROM image in INIT_MMU_BANK + Started work on SCSI driver for FSIBM + +- continued working on SCSI driver for FSIBM. + + Now formating hangs at the + _end_ of the sequence, probably disk name error? (test with emulator?) + + formating only sets to small disk size... + +- formating works for ramdisk device - leaving the old boot sector. + +- continued working on SCSI driver. Had to use div32 instead of div at + several places because cluster/sector >= 0x8000 bugged out! + Now computes right number of sectors when formating SCSI harddisk. + TODO: - copying a file to FSIEC stops after 128 byte - Stream problem? + - bytes free decrease by approx. double the used amount + +- FSIBM can now use FAT16 partitions above 32M, but boot sector is + not standard and FSIBM_SECTOR24BIT has to be defined. + +- The scsi/hd driver can now us the xcsa ramdisk + diff --git a/dump/oa-2.0.9/doc/LOG-pre-2.0 b/dump/oa-2.0.9/doc/LOG-pre-2.0 new file mode 100644 index 0000000..e945ff0 --- /dev/null +++ b/dump/oa-2.0.9/doc/LOG-pre-2.0 @@ -0,0 +1,312 @@ + +Now the transition from 1.3.x to 1.4.0 takes place + +1) 1.3.90: make new directory structure, and use segments: + + - include directory overhauled. 20mar1997 + + - kernel now assembles standalone (with xa >= 2.1.3) + + - fsdev now assembles standalone (with xa >= 2.1.3) + + - C64 is working now (w/o fsiec) + + - removed many global variables (mostly from kernel) + + - made fsiec assemble, checked C64 serial and parallel (fixed a bug + in the serial code) + + - now all architectures (c64, csa65, gecko) are converted, + although only c64 is tested now. + + - all apps are converted, although not tested + +2) 1.3.91: cleanup more archtecture dependend stuff + + - moved hardware stuff from oa1si.a65 to arch/*/devices/kinit.a65 + C64 works again + + - put Gecko fsiec back to mainstream fsiec. added getif and freif + to fsiec device interface + + - divided console code into hardware independent (devices/console.a65) + and hardware dependent (arch/*/devices/con_*.a65) code. + C64 should work (does on VICE), csa also, but this is not tested. + C64 cannot give the F1 switch key with shift+ctrl (bug!) + + - CS/A architecture (with ROMTEST) works, except for the console + + - CS/A console works, when not interruptable. + +3) 1.3.92: dynamic memory management / relocatable loader + + - added memory management from slip to stdlib. It is initialized + from the kernel on startup. New GETPID system call added to allow + owner identification for memory blocks + + - new zeropage memory management in stdlib. Added o65 loader from xa + to stdlib + + - made loader work. loads o65 files now, but no undefined symbols + (like KERNEL and STDIOADDR) are relocated. + +4) 1.3.93: started kernel rewrite... + + - removed: memory management, signals + + - added error state byte for streams (untested) + + - rewrote env handling to allow threads etc. Use different tables + removed send/(x)receive, setirq, getenv, freenv, setblk, wterm, getinfo, + treset, read/write and signal from kernel in this process. + + - reimplemented send/receive/xreceive. + + - implemented signals + + - reimplemented STACKCOPY option. + + - started working on CS/A65 MMU architecture + + - implemented SLOCK and RENICE kernel calls + + - cleaned up kernel init routines, added zerotest.a65 and ramtest.a65 + + - worked on SEND/RECEIVE for MMU. + + - real memory handling for MMU + + - cleanup device handling code (with and w/o MMU) + but: in CS/A65, non-ROM-started devices don't work! + + - fixed a bug in setnam (device handling kernel code). + + - moved [load|save][thread|task] all to setthread, which is + now completely in kenv + + - runs on the Gecko now. + + - made all calls to memtask from JSR to JMP (for NOMMU, keep a + dummy for CS/A). return from interrupt needs special care, though. + + - The debugging speed when running on the xcsa emulator is impressing, + compared to the time to find an error on the real machine..... + CSA debugging done (multitasking works, video device too, so works + send/receive) + +5) 1.3.94: support code and glue fixes + + - console and serial devices support SCE_PUSH (console only) and + SCE_BRK bits. fsdev and fsiec support the error code bits SCE_?ERRM. + + - shortened CS/A65 part a bit to get more kernel space + + - sbrk for CS/A65, GETINFO (short version...) + + - SHORTRAMTEST - only check one value besides MEMINIVAL, probably + MEMINIVAL ^ $ff, to still allow mirrorcheck in CS/A + + - fixed nasty bug in CS/A65 setthread. + + - removes stream read/write counter handling from FORK and from + ROM init. Introduced new ROM file format. + Introduced "init" process to start ROM processes with command line + FORK now copies the PCBUF to the started process, which has to releas + the SENDBUF semaphore after reading the command line + + - removed stdlib calls from most sysapps (fs*, mon) + Also put "sh" from "apps" to "sysapps" and renamed it to "mon". + So far there is still a link from "apps/sh" to "sysapps/mon", + as long as there is no new shell. + + - included fileformat.html (for o65 files) and lib6502.html for the + new stdlib in the doc directory. + moved the "stdlib" directory to "oldlib" + + - moved libsave to THREADSAVE, TASKSAVE and ENVSAVE + all are now cleared on respective allocation + + - removed bogus kernel calls. updated kernel docs (kernel.html). + improved GETINFO call and adapted the Shell code for it. + + - fixed small bugs in fork and kill. (revealed by GETINFO...) + + - SLOCK (scheduler lock) is optional now. + + - reordered error codes + + - made some more stuff for the proto directory + + - when a process terminates and the parent waits for sigchld, + TT_NTHREADS is set to -1 and sigchld is sent. If parent is killed + or checkchld is called from parent, then task is freed. + checkchld returns the process ID of the terminated child + + - init process now has restart ability - a ROM task can be restarted + when the task has terminated. + + - fixed a bug in the console code that didn't check for E_NUL + in any case... + + - also fixed a little bug in asetxy... + + - kernel seems to work on real CS/A65 too now... + (fixed a little bug in BRK handling of csa65/devices/oa1sd.a65) + +6) 1.3.95: stdlib handling + + - SUSPEND kernel call renamed to YIELD + + - realloc added to lib6502 + + - implemented file handling, signal handling, semaphores + according to lib6502 specs + + - changed command line parameter format for ROM + + - fixed a bug in arch/c64/kernal/kenv.a65 for stack address overflow + with more than 4 threads. + + - stdlib handling + When task is killed (from other task, or BRK), how to clear all + lib resources? Call signal exit handler on _any_ exit, and lib + clears then? + + - implemented almost all (except network and environment) feasible + lib6502 calls. + + - moved the lib6502 to version 0.5 + + - init now boots (i.e. loads and starts) o65 file from lib6502 :-)) + + - exec now passes command line parameter to program + + - dup works with stdio + + - added cwd to lib6502 definition + + - changed names from "oa1*" to more descriptive names + + - lsh parses command line and redirects stdio + + - lsh now executes builtin commands as well as external commands :-)) + + - streams are now 64 instead of 128 byte long (gives double the number + of streams on a C64) + + - FSIEC opens files now without ",P" + + - lsh can now combine stdout and stderr with ">!" or "!>! redirectors. + replacing ">" with ">>" does an append. + + - giving the shell a filename should make it read from the file and + put it into quiet mode (untested) + + - shell now receives sigchld from started tasks + + - added sigchld to signal definition in lib6502 + + - added yield to lib6502 definition + + - shell understands "&" and ";" + + - added some simple file utilities (rmdir, mkdir, rm, format, chkdsk) + but more info has to be put here. + + - added simple "ls" command + + - added "cat" command + + - changed return values for fread/fwrite + + - added "mv" command (only to same device) + + - forkto now copies the cwd to the child process, which makes it + run programs from relative path. + +6) 1.3.96: inet handling + + - mon and slipd can now also be run from lsh + + - slipd now works as before. It now takes its IP address from the first + packet received. + + - implemented traceroute protocol: ICMP port unreachable for udp + + - some TCP bugfixes: does not eat up tcbs anymore when errorneous packets + arrive while listening. Detected some weird end of connection bug + triggered by high traffic... + + - seem to have fixed the all end-of-connection problems. + + - added one more virtual terminal to C64 console device + + - slipd seems to be fixed...? + slipd can now redirect its stderr (away from stdout and to a file given + on the command line) -> rom startable. + + - wwwsrv prefixes a file with the content-type header, depending on file + extension. + + - fixed a nasty old bug in ackxmit (slipd) + + - added flib2osa_[rw] calls to stdlib to map from lib6502 fileno to + OS/A65 stream. + + - rsh working + + - simple tlogin + + - fixed bugs in lib6502 exec and bcleanpida code + + - tlogin now sends the telnet WILL ECHO and WON'T ECHO options to + hide password + +6) 1.3.97: lib6502 inet handling + + - fixed a bug in lib6502 fopendir + + - made fstcp working again + + - console is in no-echo mode by default. mon now switches console to + fullscreen mode with TC_ECHO + + - telnet works + + - getenv/putenv work + + - shell now has "echo" and "set" builtins, including variable substitution + + - added "getos" lib6502 call and "uname" shell builtin. + + - listen works + + - rewrote fcntl to use checkfd_* - makes it shorter and works with STDIO + + - fixed a really nasty bug that decreased system stack when receiving + a message that is already prepared. + + - implemented lib6502 httpd, and lib6502 accept/listen works + + - fixed a bug in slipd that killed it when no memory available. Now a + random connection is closed to get more memory. + + - mon now recognizes STDOUT E_NUL as break condition, which makes + it stop much faster when it is in an endless loop... :-) + + - loader does now align, and relocates LIB6502 and OSA2KERNEL, and calls + "main" to start + + - overhauled docs + +6) 2.0.0-pre*: ports and bugfixes + + - added CBM8x96 support + + - added support for PET with 32k RAM + + +TODO: + + - tons of bugfixes + diff --git a/dump/oa-2.0.9/doc/README b/dump/oa-2.0.9/doc/README new file mode 100644 index 0000000..e20310e --- /dev/null +++ b/dump/oa-2.0.9/doc/README @@ -0,0 +1,21 @@ + +This is the source code for the OS/A65 multitasking operating system for +6502 computer. It is designed to work with a CS/A65 computer system or +a Commodore 64. But then the kernel is almost completely hardware +independent, so that it should be quite easy to port it to other 6502 +computer. See oa1.html for more details. + +The source is copyrighted by Andre Fachat and is released under the +GNU public license. See the file COPYING for more details. + +To build the binaries, a 6502 cross compiler has to be used. The source +is written to work with my 'xa' (version >= 2.1.4e), see my WWW page for the +source (it's under GNU public license). + +The doc directory contains the english html documentation. + +Andre Fachat +a.fachat@physik.tu-chemnitz.de +http://www.tu-chemnitz.de/~fachat + + diff --git a/dump/oa-2.0.9/doc/README.c64 b/dump/oa-2.0.9/doc/README.c64 new file mode 100644 index 0000000..7daaf05 --- /dev/null +++ b/dump/oa-2.0.9/doc/README.c64 @@ -0,0 +1,139 @@ + + OS/A65 v2.0.0 + --- C64 version --- + + +These are the instructions how to load and run OS/A65 on a C64. + + +At the moment the main development takes place on the C64 emulator +VICE. I did not have the time to test everything on the real machine. +So beware (but VICE has become quite accurate in the meantime!) + +I have an original C64 parallel IEEE488 expansion board, so that +I use this for better performance. I also implemented the hardware +emulation for the CBM IEEE488 interface for the C64 in the VICE +Commodore emulator (from version 0.11 on). So if you have this interface, +use it for better file transfer performance on the real C64 or +for file access in VICE. Change the line in c64rom/c64rom.a65 from +'#undef PARALLEL' to '#define PARALLEL'. For the C64, the +devices 9 to 11 are mapped to the drives c: to f: + +As the C64 doesn't have an MMU, there are other restrictions. +If you don't want to have the application stack being copied +to a save area at every thread switch the stack can be parted +amongst the threads, allowing a maximum of 5 threads running +concurrently. But then if you allow copying, you can have up +to 16 threads running. The main configuration file (arch/c64/config.a65) +has the definitions for that. + +If you change something there and reassemble, check from the file65 +output that the data and bss segments don't overlap. Also the +memory that is dynamically allocated starts at $1600 (see +arch/c64/c64rom.a65). Only if nothing overlaps there is no danger. + +I don't think I can get the BASIC to work - it wants +too much stack space to run without MMU. + +The programs have to use the PCBUF to send and receive messages. +If two or more programms access this 'shared' memory without +protection, bad things can happen. Imagine one task preparing a +FORK call and then getting interrupted. Another task is then +scheduled and using the buffer for something else, causing the +FORK of the first task to go bad... +Because of this, a system semaphore is defined that has to be +allocated (PSEM) before accessing the send buffer and released +(VSEM) after using it. More on this issue in doc/nommu.html. + +There still are some glitches, but the system itself is stable. Some +things might happen, because there's no MMU. I have tried to +fix all this, but remnants are there... +(When you have a 'virtual machine' for a program, you get some kind +of lazy about where to put the variables sometimes...) + +How to get started +------------------ + +To build the program, you have to have my 6502 cross assembler 'xa-2.1.4e' +Current testing takes place on 'VICE' (x64), the versatile Commodore emulator. +Better get the newest version because the IEEE488 interface is not +yet in vice-0.10.0. + +In the file c64rom/c64rom.a65, a few options can be set by setting +the defines appropriately. See doc/build.html. + +Go to the arch/c64/boot directory and type "make" this will build +all necessary files in this directory, including links to all +important applications. Typing "make osa.d64" will produce a +d64 disk image with all necessary files. This disk image can be +transfered to a C64 and used. + +In VICE (i.e. x64) or on the C64 load the (BASIC) program 'loader', which +is in the boot directory and the osa.d64 disk image. When run, this +program loads the charom, the program ROM and +a small machine language program (boot.obj, which is made from +boot.a65). It then starts the boot routine that copies the ROMs to +their places and jumps to the kernel RESET routine. + +When using osa.d64 in VICE, you have to enable the true1541 emulation. + +The current ROM contains the video device, the device filesystem, an +IEC filesystem and a 'small' monitor. +The video device is able to handle up to four screen output windows. +The F1 key switches between the different windows (You can change the +switch key in arch/c64/devices/con_c64.a65, but when you're using +the "C=" key, don't try to use the Ctrl-Alt-Fx keys in XFree when the +mouse cursor is in the vice window. OS/A will detect a Ctrl-Switchkey +and therefore send an EOF to the program....) +On the first window, a lib6502 "lsh" is started. On the second one, the +small monitor is started. As the C64 has no MMU, these two programs +have to use different memory locations. The monitor is assembled into the +ROM and can be started only once from the ROM. The lsh is a lib6502 +program and is loaded by the init process. The ROM only contains a +command to the init process to start the lib6502 program. It uses +a relocatable fileformat and can thus started more than once. + +In the shell you can use "c:ls" on drives a: (registered devides) and +b: (rom inventory). If the iec bus works, then drive c: is disk unit 8 +and drive d: is disk unit 9, till drive f: is device 11. + +For the shell/monitor commands see the docs. +The memory map is described below. When writing and using lib6502 +programs they are relocated automagically. + +Internals: +---------- + +The arch/c64/devices and arch/c64/kernel directories contain the only +C64 specific stuff. + +fsiec uses CIA2 timer b as serial bus timer. + +Due to the deficiencies of the C64 hardware, the C64 cannot serve as +a disk drive on the bus, giving access to its devices to other +computers (as my selfbuilt one does). + +Memory Map. +----------- + +The area below $70 is used by the ROM. The same holds true between +$300 and $1600. The exact values can be seen in the assembler screen +output (file65 - comes with xa) + +$1600-$8000 free memory - i.e. lib6502 malloc-able +$8000-$d000 ROM (well, the RAM contains what should be in the ROM of + a CS/A computer...) +$d000-$e000 I/O area and the RAM under it contains the charrom +$e000-$e400 screen buffer 1 +$e400-$e800 screen buffer 2 +$e800-$ec00 screen buffer 3 +$ec00-$f000 screen buffer 4 +$f000-$10000 OS/A65 kernel. + +The kernel and lib6502 addresses are automatically relocated +when loading a lib6502 program. + +-------------- +Any suggestions and comments welcome +Andre Fachat (a.fachat@physik.tu-chemnitz.de) + diff --git a/dump/oa-2.0.9/doc/README.lsh b/dump/oa-2.0.9/doc/README.lsh new file mode 120000 index 0000000..d380c0e --- /dev/null +++ b/dump/oa-2.0.9/doc/README.lsh @@ -0,0 +1 @@ +../apps/lsh/README \ No newline at end of file diff --git a/dump/oa-2.0.9/doc/README.slip b/dump/oa-2.0.9/doc/README.slip new file mode 100644 index 0000000..c709bd0 --- /dev/null +++ b/dump/oa-2.0.9/doc/README.slip @@ -0,0 +1,281 @@ + + TCP/SLIP implementation for the OS/A65 + -------------------------------------- + (c) 1997-1998 A. Fachat + + +0) Warning: This code is experimental and in a late Beta now! + It has bugs, and may damage files on your computer! + The programs are provided "as is", there is no warranty at all, + and the usual disclaimers apply. + + I you are a beginner, forget it. This is (still) advanced stuff. + +1) Never, never ever run the "fstcp" server on a computer connected + to the Internet! + It has no other security protection than checking the IP address of + an incoming connection request! + + Never, never ever run the WWW server on the OS/A computer (C64), if + it is connected to more than your home PC. It reads all files from + the specified (C64 or OS/A) drive! + +2) Now that you're warned: What's it for? + + The TCP/SLIP implementation can be used for telneting to and + from an OS/A65 computer. Now it's used to transfer files between an + OS/A65 computer and a (Unix) computer. It can also be used as a simple + WWW server now. + + I use it on a C64, to transfer files between a PC and a VC1541 disk. + + The lowest level you can see is the icmp (internet control message + protocol) level. If you "ping" the OS/A65 computer, it replies. + See "man ping" on a Unix machine. It also replies to "traceroute" + packets appropriately. + + Then there are the simple test TCP ports "echo" (7), "discard" (9) and + "chargen" (19). You can telnet to these ports on the OS/A65 computer. + See "man telnet" on how to telnet to a different port. + + Another special port is the http port (80). This port is used to + transfer html pages for the World Wide Web (WWW). A special server + is listening on this port and serves requests from a given directory. + + The next level is a client-server-application. The server "fstcp" + runs on a connected (unix) system. The client "slipd" runs on the + OS/A65 machine. It tries to connect to a remote server (the fstcp + program on the unix machine) and establishes a TCP connection to the + server. This connection is then used to transfer file data. + + The "slipd" internet daemon exports internet capabilities to the + lib6502 library. This is actually the only part that still seems + to be buggy. The www server built into slipd is quite stable, as + is the rest of the OS (has been running for several days without + problems) + + The default configuration for slipd (see sysapps/slipd/main.a65) + is to run the builtin WWW server, the telnet server (starts + the apps/inet/tlogin program for login) and the lib6502 stuff. + You have to change login/password/shell in tlogin.a65 to your + preferences. + + With the lib6502 inet stuff the apps/inet/telnet program opens + a telnet connection to the host given at the command line + (in doted quad notation). + + The procedures described here are for a Linux machine and a C64 + with OS/A65 running. For the serial line setup you need root + (superuser) access to the unix machine. It should run without + any changes on any OS/A65 machine with a serial line. + +3) IP concepts + + a) addresses + + In an IP (internet protocol) network, each computer has an IP number. + Normally you have to formally apply at the network information center + for an IP number or net. But there are numbers assigned to be used + in private, non-connected networks. + + IP addresses are usually noted in the "doted quad" notation, i.e. + four decimal values from 0-255 each, separated by dots. + + The private network I use is are the numbers + + 192.168.0.* + + i.e. the numbers 192.168.0.1 - 192.168.0.254. There are two numbers + missing, they are used as network address (0) and normally as broadcast + address (255). + + My unix (i.e. Linux) computer at home has the IP 192.168.0.10. This is + the IP the fstcp server is running on. + My C64 (with the OS/A65 operating system) has the IP 192.168.0.64. + So if the C64 has the slipd program running, I can do a + "ping 192.168.0.64" on my unix machine and get a reply! + + b) routing + + The internet protocol is a packet oriented network. A packet is + sent from one host to another, which is normally not the final + destination. Each host decides where to send a packet next, to get + the packet to its destination. This process is called routing. + Normally the program "route" is used to tell the computer which packets + to put where. + + c) preparing a serial port + + If you connect a serial line from the C64 to the unix machine, the + unix machine has to know that it has to send and which IP packets to + send there. There are some ways to achieve this. + + The first way is with the command "slattach", which puts the + serial line from "terminal mode" to "SLIP" mode. Then "ifconfig" + configures the "sl0" interface with the IP address. The last command + is "route", which tells the unix OS that is has to send packets to the + C64's IP address to the interface sl0, which goes to the serial line. + The small script "csaip", provided in the oaslip directory, does + everything. + Warning: this script assumes you have network device "sl0" for the + OS/A65 link. If you have a SLIP connection somewhere else already. + this might not be true! The script then mangles your routing tables! + + Another way is the program "diplogin" or "sliplogin" which does everything, + see the appropriate man pages. + + I have added a program "term9600" which is a little C64 BASIC terminal + program to run the serial line at 9600 - if the kernel ROM allows that. + It can be used to login to the remote host if necessary. + + +4) TCP concepts + + a) addresses + + TCP addresses not only contain the IP address of the host, but also + the "port". The Port is like the number of the flat in a house, when the + IP number is the address of this house. Certain port numbers are + registered for a special use. Port 7 (echo) for example will send + all data you send to it back. + When you open a connection to a port on a remote computer, your own + computer also assigns a local port number to the connection, to have + a full TCP address at the sender side. + + b) connections + + In contrary to the IP protocol, the TCP is a connection based protocol. + A connection always takes place between two TCP "ports" or + two "pairs of IP and TCP port numbers". This connection is defined + with the properties: + - no data "overtakes" data sent before + - no data is lost + - no data is doubled + (which are all effects that can occur on IP) + With retransmissions, sequence numbers and lots of other things the + TCP ensures that the data is received in order and nothing is missing. + + c) establishing a connection + + Normally one side creates a "socket" and "binds" it to a specific + local TCP/IP address. It can then either "connect" to a remote + socket, or "listen" for remote connect requests. If the socket + listens on a port, the "accept" call will bind the local and remote + socket to a valid connection. + + Normally a server program listens on a socket while the client tries + to connect to it. + + d) used ports + + I chose to use port "8090" as the port where the fstcp server is + listening at. + The WWW server built into slipd listens at the standard port 80, + and the telnet connection is listening at the standard telnet port (23). + + +5) Building the programs + + a) the "fstcp" server + + The fstcp server is a C program, in sysapps/slipd/fstcp.c. Going to the + slipd directory and typing "make fstcp" should work on unix (linux) + machines. In the first lines the port is defined where the server is + listening at. + + b) the "slipd" client. + + Most other files in the oaslip directory are to build the slip client. + In the first lines of "main.a65" the OS/A65 IP address (MY_IP) is defined. + (note the comma instead of the dots!). But the slipd server listens + for incoming packets and sets its own IP address if necessary. + Also the fstcp server TCP address (IP and port) are defined there. + The WWW server defines its drive and directory it will read the files + from. Do _never_ specify a drive on the fstcp filesystem. The slipd prg + will hang on the first access! + + To assemble the files, you have to have my 6502 crossassembler "xa" + in you path, with version above 2.1.4d. + + The slipd program is built when running "make" in the sysapps/slipd + subdirectory. + + +6) running the program + + To run the program, do the following steps: + + - connect the C64 (either with Daniel Dallmans 9600 baud interface, + or any other RS232 interface supported by OS/A65) and a serial + port of the (Linux-) PC with a Nullmodem cable. + The standard C64 configuration allows an UART16550 at address + $d600. To change that have a look at arch/c64/c64rom.a65, which + holds the configuration for the C64. + + - enable SLIP on the serial line by running something similar to + the script oaslip/csaip (does slattach, ifconfig, route). + + - If you want fstcp services, start the fstcp server on the unix + host. As arguments it needs the directory (relative from the + starting directory) to export and the IP address to which to export + the directory. + As fstcp might very well be buggy, try to be as cautions as + possible. Never ever run it on a computer connected to the internet. + Never ever run it as root (superuser). + + - Transfer the slipd file to a disk accessible to the C64 when running + OS/A65 (using an x1541 cable, for example) + + - start OS/A65 on the C64 (see other files, like README.c64) + + - You should have a shell prompt (">") with a binking cursor. + Now start the slip.obj program by typing + + c:slip.obj a:video4 c: c:tlogin a:ser1 & + + This starts the slip client from drive c: (usually Commodore serial + IEC device #8, the floppy disk), piping the STDIO + to the C64 serial line ser1 (in standard C64 OS/A65 it's Daniel + Dallmanns 9600 baud interface). STDERR is sent to the 4th virtual + console (first command line parameter). The second parameter + is the drive to use as WWW server file source. The third parameter + is the program to start at a remote login on the telnet port. + The ampersand makes the slip program running in the background. + The slip program receives and sends its SLIP data via STDIO. + STDERR prints (currently a horrible lot of) debugging output. + + You can also start the slipd program directly from the C64 + ROM, see c64rom.a65 + + - If enabled, the slip client registers a filesystem with one drive. + On a standard C64 OS/A65 system, it will be drive g:. + If a connection to the server cannot be found, or breaks + later, the fstcp tries to reconnect in periodic intervals. + + - You should now be able to ping the C64, and do telnets to the + echo, discard and chargen ports. + + - when telneting to the http port (80) + (When the WWW server is enabled in oaslip/main.a65), you can issue + the "GET" command, followed by an URL on the OS/A65 computer. + You then get the specified file. + You can also point your Web browser (netscape) to the C64 + with the URL "http://192.168.0.64/index.html". Replace the IP + number with the one you have chosen for your system. + + - If fstcp is enabled, it should now also be possible to show the + directory of drive g:, and to read files from or write files to + drive g: This drive will be the contents of the directory given to + the fstcp server, i.e. on your Unix machine! + + +7) (Known) Bugs + + - The WWW server only understands "GET filename" requests. No "http://" + or host prefixes are allowed. At least with Netscape it seems to work. + + - The implementation is bloated, and horribly slow. + + - Tons of others, I'm sure + + - lib6502 binding seems to bug. diff --git a/dump/oa-2.0.9/doc/TODO b/dump/oa-2.0.9/doc/TODO new file mode 100644 index 0000000..5e37618 --- /dev/null +++ b/dump/oa-2.0.9/doc/TODO @@ -0,0 +1,33 @@ + +TODO-List for 2.1.0 +------------------- + +- FSIBM: + + + ignore VFAT long filenames (or handle them... :-) + + I had problems copying file from HD to IEC? Stream error feature? + + implement OSA2 stream error feature + + check filesystem structure (esp. on FAT16) + (bytes free count differs from what is expected) + +- ramtest: + + + make a small program to be able to test RAM on non-standard + places and make it available to the kernel. + +- lib6502: + + + memory handling should use SBRK call to incerease memory size + if necessary + +- FSDEV: + + + fix _AS_INIT handling (release SEM_SENDBUF etc appropriately) + + use alternate ROM pages as file source (like in init) + + allow reading of binary files from ROM + +- FSIEC: + + + fix _AS_INIT handling (release SEM_SENDBUF etc appropriately) + + fix protocol bugs when talking to a PET on IEEE488 + diff --git a/dump/oa-2.0.9/doc/announce-2.0.0-pre1 b/dump/oa-2.0.9/doc/announce-2.0.0-pre1 new file mode 100644 index 0000000..d63ab4f --- /dev/null +++ b/dump/oa-2.0.9/doc/announce-2.0.0-pre1 @@ -0,0 +1,58 @@ + +This is the release note for the GeckOS/A65 operating system for +6502 computers, version 2.0.0. This is a new major release +as the kernel has been partly rewritten, a complete new lib6502 +implementation has been done and the o65 relocatable fileformat +is now supported, as well as multithreading. + +Also a sophisticated "slipd" daemon supports internet connectivity +by using a SLIP connection, with a telnetd, a WWW server and related +programs. The lib6502 network connectivity is supported, although +this seems to be the only buggy part left... + +What's new: + + - major kernel rewrite: + improved speed, now supports threads and task priorites. + Signals are now unix-like (they even can interrupt blocking + system calls :-) + + - much improved porting ability: + _all_ system dependend stuff has been moved to a directory + in an "arch" subdirectory. Currently there are + "arch/csa65", "arch/gecko" and "arch/c64" subdirectories + (waiting for more contributions, hint, hint!) + + - better kernel doc in "doc/kernel.html" + + - lib6502 implementation + + - dynamic memory management with lib6502 + + - relocatable fileformat + + - telnet in and out from OS/A65 + + - stable WWW server (built into slipd daemon) + +What's still to do: + + - Tons of bugfixes - but in general quite stable already. + +What do I want from you: + + - Comments: How do you like it? + + - new lib6502 applications! + + - new ports! + If you want to port the kernel to a new system without + real memory management, it's almost only copying two files, + editing one of them and then writing the device drivers. + Taking the existing C64 stuff, that shouldn't be difficult. + +Any comments welcome! + +Thanks! +Andre + diff --git a/dump/oa-2.0.9/doc/basic.html b/dump/oa-2.0.9/doc/basic.html new file mode 100644 index 0000000..a2e1392 --- /dev/null +++ b/dump/oa-2.0.9/doc/basic.html @@ -0,0 +1,82 @@ + + + OS/A65 BASIC interpreter + + +

Warning!

+ +The BASIC interpreter is derived from copyrighted code! +So the basic interpreter is only an +educational example of how to port other programs from the C64 +or other PET computers to the OS/A65 operating system.

+Do not try to assemble it or run it! + +


+The basic interpreter is taken from the C64. I de-assembled it into +normal source code and patched it to work with OS/A65 and multitasking. +Several commands are changed and others, most notably the BASIC V4 +commands, are added. +

changed commands

+
    +
  • OPEN fnr, drv, mode, name
    +'drv' has changed from the commodore specific device id to the OS/A +drive number. 'mode' then is the command to open a file, i.e. +FS_xxx. +
  • LOAD name, drv +
  • SAVE name, drv
    +'drv' has changed to the OS/A drive number +
  • LIST name, drv [,a-b]
    +You can now list a program directly to a file. a and b are filenumbers +and optional (as usual with list) +
  • SYS adr
    +'adr' is checked for some C64 specific addresses and changes them +to the routines where they are now. Detected addresses are +$ff90, $ff99, $ff9c, $ffb7-$ffe7, $fff0, $fff3. +
+

new commands

+Some parameter can be left off, I was just to lazy to write all the brackets... +
    +
  • DIR [mask,] drv
    +print directory of a drive +
  • MKDIR name, drv
    +creates new subdirectory +
  • RMDIR name, drv
    +remove (empty) subdirectory +
  • SCRATCH name, drv
    +remove file +
  • RENAME name1 TO name2, drv
    +rename a file 'name1' to 'name2'. +
  • DELETE a-b
    +remove BASIC lines a-b; syntax is the same as with list +
  • RENUMBER start, step, a-b
    +change basic line numbers of the lines a-b (syntax as with list) to +start, start+step, start+2*step,... All GOSUB and GOTO statements are +changed appropriately in the whole program. +
  • RENEW
    +Gets a BASIC program back that has been deleted with NEW. It only works if +the program has not been overwritten by e.g. setting a new variable in +memory. +
  • DUMP
    +prints all variables +
  • FIND text
    +list the lines where 'text' occurs. +
  • HIMEM adr
    +sets a new end of basic ram address and executes a CLR. +
  • LOMEM adr
    +sets a new basic program start address and executes a NEW. +
  • QUIT
    +In contrast to the original C64 Basic interpreter this one can be left... +
  • ENTER name, drv
    +redirects STDIN to the given file, so that e.g. a complete basic program +can be read in from an ASCII (not tokenized) file. +
  • CALL adr, a, x, y, c, ra, rx, ry, rc
    +Calls a machine language routine at adr, with a,x,y,c in accumulator, +x- and y-register and in the status register. Return values are put into +ra, rx, ry, rc. +
  • SPUT adr, string
    +Write a string directly into memory at adr, end with nullbyte. +
  • SGET adr, len, stringvar
    +reads len bytes from memory at adr and saves it in string variable. +
+ + diff --git a/dump/oa-2.0.9/doc/build.html b/dump/oa-2.0.9/doc/build.html new file mode 100644 index 0000000..5f4f29f --- /dev/null +++ b/dump/oa-2.0.9/doc/build.html @@ -0,0 +1,101 @@ + + OS/A65 Building Procedure + +

OS/A65 Building Procedure

+

(c) 1989-98 Andre Fachat

+

+ +Building the object files for use on an OS/A65 machine should really +be only a 'make', as long as my cross assembler +xa +is in the path. +If there weren't these many options one can change. +

+The options below can be set in the appropriate files. But if the +programs are assembled as part of a ROM, then "ROM" is defined and +the 'local' options are ignored and overwritten by the ones defined +in stdrom/rom.a65 or c64rom/c64rom.a65. These two files are +the files to build a rom for a CS/A computer with MMU or the C64 +respectively. +


+global options, to be set in stdrom/rom.a65 or c64rom/c64rom.a65:
+
+ROM		mandatory for a rom build. All local options are ignored.
+
+ROMSTART	Where in CPU memory (with MMU with the upper 4 bits set
+		to zero, i.e. $00000-$0ffff) starts the ROM.
+
+

+
+C64 specific options, to be set in arch/c64//c64rom.a65:
+
+CLEARMEM	if defined, the memory is set to the value CLEARMEM is defined
+		to when booting.
+C64NEEDCIA1	if defined, disables reading the CIA1 icr in the kernel.
+		Therefore it has to be assured that a device reads this 
+		register to clear the interrupt line again.
+		Undefine this for use with the fast RS232 driver.
+
+C64_BGND_COL
+C64_TEXT_COL
+C64_BORDER_COL	colors to use
+
+C64SWITCH	The terminal switch key, 61= C= key, 4= F1
+
+C64NMIRESET	makes the Restore key a RESET key. Doesn't work with fast
+		serial driver!
+STACKCOPY	If defined in non-MMU systems, save stack area somewhere else
+		when doing a task switch. If a task switch is done, the stack
+		is copied back. If not defined, divide the 6502 stack
+		from $100 to $1ff into pieces, one for each task and one
+		for the system. It's faster without, but with this option
+		there is much more stack space per task and more tasks 
+		are available.
+
+

+
+kernel options in kernel/kernel.a65:
+
+ROM		with ROM all options are set globally or somewhere else
+ROMTEST		with ROMTEST the MMU is not loaded, but the contents of
+		the MMU registers secured with GETBLK. Also memory is
+		not tested (to test a new system ROM)
+CMOSCPU		for (Rockwell) CMOS CPU
+NOMMU		system for a computer without MMU 
+NOSYSPORT	system has no SYSPORT (at $efe0)
+NOSINPORT	system has no SYSPORT, but LED is driven, if a board is
+		plugged in
+NOENVIRQ	to build system where tasks cannot have an own irq routine
+BATMEM		main memory is not erased at memory test (for battery buffered
+		RAM)
+NOMIRRORMEM	if the memory chip is definitely not mirrored (i.e. no 
+		unconnected CPU address lines), one can 
+		disable the test for this.
+CLK2MHZ		if NOSYSPORT or NOSINPORT, the CPU clock has to be set here
+NMIDEV		enables NMI routine (without MMU only)
+

+
+shell options in oash/sh.a65:
+
+SHORTMON	no assembler/disassembler in monitor
+NOSYSFKT	no file/system calls in monitor
+NOMON		no monitor
+NOSH		no shell
+NOPRG		without PRG header
+SHORTLINE	use 40 columns instead of 80
+

+
+fsiec options in oafs/fsiec.a65
+
+INVERT		parallel IEEE488 port output lines are inverted
+PARALLEL	do it for IEEE488 interface, not serial interface
+		(works for CS/A computer and C64). NOLOOP has then 
+		to be defined also.
+NOCMD		do not interpret other fs commands than FS_OPEN_*
+NOFS		do not register as fs - listen on bus only
+NOLOOP		do not listen on bus - register as fs only
+STDTST		include STDIO lib if needed.
+NOPRG		without PRG header
+
+ + diff --git a/dump/oa-2.0.9/doc/cbm8x96.html b/dump/oa-2.0.9/doc/cbm8x96.html new file mode 100644 index 0000000..cec1b9e --- /dev/null +++ b/dump/oa-2.0.9/doc/cbm8x96.html @@ -0,0 +1,103 @@ + + OS/A65 CBM 8x96 Notes + +

OS/A65 CBM PET Notes

+

(c) 1998 Andre Fachat

+
+

OS/A65 CBM PET Version 2.0

+

CBM 8x96

+

+The Commodore PET 8096 and 8296 (also known as CBM 8096 and CBM 9296) computers +have at least 96 kByte of RAM and can remap the ROM area with RAM. This +makes them a nice base for OS/A65. Although they don't have many I/O devices +at least they provide an 80 columns screen. +

+

Memory Map

+

In the CBM 8x96 one can remap the upper 32k of CPU address space by +writing certain values to $fff0. The blocks $8000-$bfff and +$c000-$ffff can be remapped to two different banks of RAM +each. The screen memory ($8000-$9000) and I/O +($e800-$efff) can be set to `peek-through' separately. +In the OS/A65 memory configuration the lower 32k and one bank of the upper +32k of RAM are used for the OS image (the `ROM') and the lib6502 managed +application memory. The screen memory and I/O area are not accessible for +lib6502 applications. The second upper 32k RAM bank is used (with screen +and I/O mapped through) as system memory area, together with some RAM +from $300-$b00. Also there are the mirrors of the other +virtual console screen areas - when switching screens they are copied around. +

+Addr     RAM 0        RAM 1
+$ffff  ----------------------
+$fff0	configuration register
+$ff00   -------      -------
+                     system
+           |         memory
+$f000                -------
+           |         I/O
+$e800                -------
+        lib6502
+        application
+        memory
+$b000                -------
+           |         virtual 
+                     screens
+$9000      |         -------
+                     screen
+$8000      |         -------
+
+$6800   -------
+        OS/A65          |
+        `ROM'
+        image           |
+$0b00   ------
+        system        no 
+        RAM           memory!
+$0200   ------
+        Stack           |
+$0100   ------
+        Zerop.
+$0000  ----------------------
+
+

ROM image build

+

Building the 8x96 ROM image is simple. Just go to the arch/cbm8x96/boot +directory and type "make". This should build all files. +"make osa.d64" should make a d64 VC1541 disk image with all necessary files. +You have to have my new XA version in the path, though. +

+To customize the ROM, change edit rom.a65 in arch/cbm8x96. You can gain some +memory when you remove the shell/monitor from the ROM image. +(You could replace it with the lib6502 monitor "mon" to be loaded like +"lsh".) +When running "make" then the command "file65" should print the addresses +used for the different segments. They must not overlap. In addition the +data segment must be below $8000, as it is needed by lib6502 that can +be called from both RAM banks. +To move the lib6502 RAM area, edit the values for Memstart, Memend +and Zerostart at the end of rom.a65. +To move the segments, edit the Makefile and change the addresses for the +segments in the XA calls. The text segment address must be two below +the actual start as it also counts the two byte starting address used +for loading. In addition you have to edit the value for the definition +of ROMSTART in rom.a65. +

+

Boot

+

Put the files "loader", "lsh" and "rom" on a disk accessible by the +PET 8x96. load "loader" into BASIC memory and start it (probably edit +it for the right load device number). This boots OS/A65. +

+

Any 80 columns PET with 32k

+

Build a version for this computer is a bit more difficult because of +the restricted memory. I have now tried to build such a version. +The device does not (yet) check for 40 columns but can now use only 80 cols. +

+

Memory Map

+

The memory map is straightforward. First zeropage, stack, then +system memory (all of it), then OS image, then lib6502 memory. At the end +($7800) a second virtual screen, and at $8000 the normal screen area. +At $90-$93 in the zeropage the PET ROM IRQ and BRK vectors are located +and have to be used. +

+

Build 'n Boot

+

Basically the same applies as for the 8x96.

+ + diff --git a/dump/oa-2.0.9/doc/devices.html b/dump/oa-2.0.9/doc/devices.html new file mode 100644 index 0000000..7afb58b --- /dev/null +++ b/dump/oa-2.0.9/doc/devices.html @@ -0,0 +1,81 @@ + + OS/A65 Device Drivers + +

OS/A65 Device Drivers

+

(c) 1989-96 Andre Fachat

+

+ +This file gives a description of the so far implemented device drivers +for OS/A65. + +

video Device

+The video device incorporates not only one but four devices, video1-video4 +(with 2MHz, only 2 devices are working). +As hardware it needs the video card and the keyboard card with a CBM 3032 +keyboard attached to it. If available, +the piezo beeper on the IEEE488 card is used to generate bell signals. +
The video card has one video port only, so the video is shared +between the four possible video devices. The "@" key is used to switch between +the different terminals. As there is no way to send some kind of ioctl +message along a stream, this key has some more functions: +with Control (RVS/OFF key on CBM 3032 keyboard), the key closes the stream +from the sender side, thus signaling an EOF. With control and shift, +the the device is switched between the two modes. +
    +
  1. indirect mode: keyboard events are printed on the +screen only, not sent to the stream. If a Return occurs, the actual +line is sent to the stream. This is default. +
  2. direct mode: all keyboard events are directly +passed to the stream. +
+Supported terminal control codes are Bell, Backspace, Carriage Return, +Line Feed and Form Feed. +

par Device

+This device handles the (simple) centronics port on the shugart bus +board. +

nuldev Device

+This device reads a given stream until end, i.e. EOF and then closes +the stream. Like /dev/null for writing. You cannot read from it. Only +a certain number of streams can be handled before an error is returned +on open. +

spooler Device

+This is a kind of serializer. You can copy one file after the other +to this device, even if the first files are not yet through. When copying +the output of the spooler to another file, e.g. the spooler +device, they appear in the same order as copied into and intact, i.e. +the files are not mixed. +

ser Device

+Ser stands for serial device and that's what it's doing. It handles the +two serial device ACIAs on the BIOS and on the keyboard board of the CS/A65 +computer. There are +some watch outs, though. From the serial device, only RTS/CTS are handled. +A low on an incoming /RTS stops sending. If the stream to write the data +to is above the high water mark (3/4 fifo size), then /CTS is set low. +After the stream going below the low water mark (1/4 fifo size), /CTS +is set high again.
+With DC_SPEED, the baud rate of the device can be set: +
+parameter (y)      speed (baud)
+-------------------------------
+ 1                   50
+ 2                   75
+ 3                  109.92
+ 4                  134.58
+ 5                  150
+ 6                  300
+ 7                  600
+ 8                 1200
+ 9                 1800
+ 10                2400
+ 11                3600
+ 12                4800
+ 13                7200
+ 14                9600
+ 15               19200
+
+With version 1.3.10 we now also have driver for an UART 16550A, with 16 +byte builtin FIFO (oa1ds3.a65). There also is a RS232 driver for the +fast RS232 interface for the C64 by Daniel Dallmann, as +described on his homepage or in the comp.sys.cbm FAQ. + + diff --git a/dump/oa-2.0.9/doc/embedded.html b/dump/oa-2.0.9/doc/embedded.html new file mode 100644 index 0000000..0bc364e --- /dev/null +++ b/dump/oa-2.0.9/doc/embedded.html @@ -0,0 +1,42 @@ + + OS/A65 Embedded Application Notes + +

OS/A65 Embedded Application Notes

+

(c) 1989-98 Andre Fachat

+
+

OS/A65 Embedded Version 2.0

+

Introduction

+

+Embedded applications normally don't have the amount of RAM and ROM +that a "normal" (whatever this means) system has. Therefore I have tried +to make some parts of the kernel removable, allowing for a much smaller +kernel to fit into embedded applications. +

+This way the more interesting features are still available, like +multithreading, signals and the device code. Some of the more sophisticated +kernel features can be removed however. For how to do this see +the config section of the kernel +description. The application can be tested on a full-featured +system while the embedded kernel provides compatibility where necessary. +

+Parts of the kernel that can be removed are +

    +
  • streams +
  • memory management +
  • file manager +
  • send/receive +
  • semaphores +
+

+This shortens the kernel to almost 2k in size. +Also the used amount of RAM is $bc = 188 byte normal RAM, +plus $e = 14 byte zeropage (not counting the environment, task and +thread-save 6 bytes from addresses 2-8), also not counting +the possible use of PCBUF by fork and devcmd. +1k RAM total should now be sufficient for simple applications. +

+Using the PCBUF without locking with a semaphore should be handled with +care, however. +

+ + diff --git a/dump/oa-2.0.9/doc/fileformat.html b/dump/oa-2.0.9/doc/fileformat.html new file mode 100644 index 0000000..eaccfb2 --- /dev/null +++ b/dump/oa-2.0.9/doc/fileformat.html @@ -0,0 +1,584 @@ + + 6502 binary relocation format + + +

6502 binary relocation format

+

V1.2 as of 26jan1998

+

(c) Andr� Fachat (a.fachat@physik.tu-chemnitz.de)

+
+

Changes from V1.1

+

+The order for saving the undefined reference and the low byte of a +high byte relocation entry has changed. This makes the OS/A65 lib6502 +implementation easier. How many other people use this format anyway...? +

+
+

+

0) Preface

+

+With some new 6502/C64/C128 operating systems comes the need for a new +binary format. In multitasking operating systems like Lunix, SMOS, or +OS/A65, a binary file cannot be loaded to a fixed location that might +already be used by another program. Therefore it must be possible to +relocate the program to an arbitrary address at least at load time. +In addition to that, more specific information might be stored in a +binary executable file, like interrupt vectors for example. +

+This text gives a good solution to this problem for the 6502 CPU and an +assembler source format to use this format in a general manner. The file +format can even be used as an object file format, i.e. a format a linker +can use as an input file. It is also usable as a 65816 file format. +Instead of zeropage addressing modes, the 65816 has direct addressing +modes, that add the contents of the direct register to the zeropage +address in the opcode. +

+ +

1) 6502/65816 specifics

+

+The 6502 has the special feature of a 'zeropage', i.e. a very limited +memory address range used for special addressing modes. So the format +should not only provide a means to relocate absolute addresses but also +zeropage addresses. The 65816 replaces zeropage addressing with direct +addressing modes. +

+The stack space is also very limited. A binary format has to provide a +measure of how much stack space is needed for the application. +

+Such limits should be defined as 2 byte values, even if the 6502 only has +a range of 8 address bits for zeropage and stack. But the 65816 behaves +differently, it has a 16 bit stack pointer for example. For further +expandability, a 32 bit format should be provided, although the 16 bit +format suffices for the 65816 already. +

+Another problem is, that an address can be 'split', i.e. you can just use +the high byte or the low byte separately in an opcode. This gives need +to a special relocation table format, that can cope with half-address +references. The 65816 can even have three byte addresses, i.e. address +in a segment and segment number. +

+ +

2) binary format

+ +

2.1) General

+

+The file differs from the known Commodore file formats, in that a lot +more information is stored in the file. First the data is structured +in separate segments to allow different handling of text (program code), +data (like tables) and bss (uninitialized data). +

+Also tables are included to allow late binding, i.e. linking the +file with other files at load time, and relocation, i.e. executing +the file at different addresses in 6502 address space. +

+

2.2) Segments

+

+As already used in other formats, the assembler uses three different +segment types, i.e. text (the actual program code), data (initialized +variables), and bss (uninitialized variables). +To have these different segments seems to be 'overdesigned', but they +actually make memory handling easier in more complex operating systems +on systems with virtual addresses (OS/A65, for example). +

+The text segment is defined to be read-only memory. This doesn't allow +self-modifying code in this segment, but allows memory sharing in virtual +memory architectures. The data segment actually is like the text segment, +only it is allocated writable. This segment might not be shared between +different processes. The contents of these two segments are loaded from +the file. The bss segment is uninitialized data, i.e. upon program start, +it is not defined - and not loaded from the file. This area is read-write +and can be used during program execution. It is also not shared between +processes. In addition to these segments, the 6502 format also includes a +zeropage segment type, to allow zeropage variables to be relocated. This +zeropage segment is like a bss segment, in that only the length, but +not the data is saved. For the 65816 the zeropage segment changes its +meaning to a bank zero segment. +

+The different segments hold different type of data and can be located +anywhere in memory (except zero segment, which has to be in the zeropage +resp. bank zero). The program must therefore not assume anything about +the relative addresses between different segments. +

+

2.3) Relocation

+

+In general, there are three ways to handle the relocation problem so far: +

+- Tables: have a relocation table for a text segment
+  if the relocation table is put in front of code
+  you have to save the table in a side-storage
+  if table is behind, you still cannot relocate 'on the fly'.
+
+- Deassembling: go through the code, deassemble it and change all absolute
+  addresses. Problem: needs to know or have hints about where some
+  data is in the code.
+
+- Relocation info in the code: here each address is preceeded with an
+  'escape' code and is relocated when loading. But this disallows block
+  oriented transfer from storage media to memory.
+
+This binary format uses the first method, with the table after the +code/data. This way block oriented transfer for the text/data segment can +be used. And while reading the relocation tables bytewise, the relocation +can be done without the need to save the table somewhere. +

+

2.4) External References & Exported Globals

+

+As this file format should not only be used as an executable format, but +also as object file format, it must provide a way to define references +- references exported from this object and labels referenced in this +object. The external references list (also called 'undefined list') lists +the addresses where labels not defined in this object are referenced. +The exported globals list lists the addresses that are available for +other objects. The labels are named by null-terminated ASCII strings. +

+Even an executable file can have non-empty globals and externals lists, +but only if the operating system allows this. In this case, so called +'late binding' is used to link the object with some global libraries +at link time. +

+

2.5) File extension

+

+The proposed standard extension for the described format is ".o65" when +used as an object file. +

+

2.6) Format description

+

+The binary format is the following: +

+   (
+	header
+
+	text segment
+
+	data segment
+
+	external references list
+
+	relocation table for text segment
+
+	relocation table for data segment
+
+	exported globals list
+   )
+
+The description of the parts follows: +

+

2.6.1) Header
+

+The header contains the minimum needed data in a fixed struct. +The rest of the necessary information is put into the header options. +[Note: .word is a 16 bit value, low byte first, .byt is a simple byte. +.long is a 32 bit value, low byte first. .size is a 16 or 32 bit +value according to .word and .long, depending on the size bit in the +mode field ] +

+This is the fixed struct: +

+   (
+	.byt $01,$00		; non-C64 marker
+
+	.asc "o65"		; o65 MAGIC!
+	.byt 0			; version
+
+	.word mode		; mode word
+
+	.size tbase		; address to which text is assembled to 
+				; originally
+	.size tlen		; length of text segment
+	.size dbase		; originating address for data segment
+	.size dlen		; length of data segment
+	.size bbase		; originating address for bss segment
+	.size blen		; length of bss segment
+	.size zbase		; originating address for zero segment
+	.size zlen		; length of zero segment
+	.size stack		; minimum needed stack size, 0= not known.
+				; the OS should add reasonable values for
+				; interrupt handling before allocating
+				; stack space
+   )
+
+The mode word currently has these defined bits: +
+	mode.15 :	CPU	0= 6502 	1= 65816 
+	mode.14	:	reloc	0= bytewise... 	1= page(256byte)wise relocation
+						   allowed
+	mode.13	:	size	0= size=16 bit,	1= size=32 bit
+	mode.12 :	obj	0= executable	1= object file
+
+	mode.0-1:	align	0= byte align,	
+				1= word (i.e. 2 byte) align
+				2= long (4 byte) align
+				3= block (256 byte) align
+
+The CPU bit tells the loader for which CPU the file was made. This has +implications on the zero segment, for example. Also a system can check +if the program will run at all (on a 6502 that is). +The reloc bit defines if an object file can be relocated bytewise, +or if it must be page-aligned. A page has 256 bytes. The restriction to +pagewise relocation simplifies the relocation table and also allows +simpler compilers/assemblers. +The size bit determines the size of the segment base address and length +entries. Currently the 16 bit size (size bit = 0) works for 6502 and +65816 CPUs. +

+The obj bit distinguishes between object files and executables. +An object file is used as assembler output that can be linked with +other object files to build an executable or an object library. +The two align bits give the address boundary the segments can be +placed. Even the 6502 needs this, as, for example, "jmp ($xxFF)" is +broken. The align bits are valid for all of the segments. +[Note: if reloc=1, then align should be 3. But if align=3, reloc need +not be 1, because reloc switches to a simpler version of the relocation +table. The reloc bit might be obsoleted in newer versions of this +format. Though it should be set, if necessary.] +

+All unused bits in the mode field must be zero. +

+Note that the header size is 26 if the size bit is zero and 44 if the +size bit is one. +

+The fixed sized struct is immediately followed by a list of header options. +Each header option consists of a single byte total length, a type byte +and some data bytes if needed. A single length byte of $00 ends the +header option list. +

+   (
+  	{			; optional options, more than one allowed
+	   .byt olen		; overall length (including length and type
+				; byte
+	   .byt otype		; option type
+	   [ .byt option_bytes ]
+	}
+	.byt $00		; end of options marker (i.e. option len=0)
+   )
+
+The header options currently defined/proposed are: +
+- Filename:
+  type=0; len=strlen(filename_in_ascii)+3; content="filename_in_ascii",0
+  The string contains the name of the object.
+
+- Operating System Header
+  type=1; len=?
+  the first data byte is the OS type:
+    	1 	OSA/65 header supplement
+	2	Lunix header supplement
+	[others to follow?]
+  the following data contains OS specific information.
+  A suggested data byte is the OS version as second byte.
+
+- Assemblerprogram:
+  type=2; len=strlen(ass)+3; content="ass",0
+  The string contains the name of the assembler resp. linker that produced 
+  this file/object.
+  For example (syntax see below)
+     .fopt 2, "xa 2.1.1g",0
+  becomes
+     0c 02 78 61 20 32 2e 31 2e 31 67 00
+  in the file.
+
+- Author:
+  type=3; len=strlen(author)+3; content="author",0
+  The string contains the author of the file. 
+
+- Creation data:
+  type=4; len=strlen(date)+3; content="date_string",0
+  The string contains the creation date in format like:
+  "Sat Dec 21 14:00:23 MET 1996", where we have the day, Month, date,
+  time, timezone and year. See output of `date`...
+
+
2.6.2) text and data segments
+

+The text and data segments are just the assembled code. +The only difference between text and data segments is the read/write mode +of the two segments. Therefore, to be compliant to this file format, +self-modifying code goes into the data segment. +

+

2.6.3) Undefined references list
+

+The next list is an ASCII list of labels that are referenced in this file +but not defined. The lists is preceeded with the number of undefined labels +(16 or 32 bits, according to the mode.size bit). +

+undef_list:	number_of_undefined_labels.s
+		"undefined_label1",0
+		"undefined_label2",0
+		...
+
+ +
2.6.4) Relocation tables
+

+The relocation tables are the same format for the two segments, text and +data. In general a relocation entry consists of the offset from the +previous relocation address to the next one, the type of the relocation +and additional info. Relocation not only defines the relocation when +moving object code to a different address, but also filling in the +undefined references. +

+Each table starts at relocation address = segment base address -1. +I.e. if the segment base address is $1000 for example, the first entry +has an offset computed from base address-1 = $0fff. +The offset to the next relocation address is the first byte of each +entry. If the offset is larger than 254 (i.e. 255 or above), than a +255 is set as offset byte, the offset is decremented by 254 (note the +difference) and the entry is started again. +

+{ [255,...,255,] offset of next relocation (b), typebyte|segmentID [, low_byte] }+
+
+where typebyte has the bits 5, 6 and 7 and is one of +
+WORD	$80	2 byte address
+HIGH	$40	high byte of an address
+LOW	$20	low byte of an address
+SEGADR	$c0	3 byte address (65816)
+SEG	$a0	segment byte of 3 byte address
+
+The segmentID stands for the segment the reference points to: +
+0		undefined
+1		absolute value
+2		text segment
+3		data segment
+4		bss segment
+5		zero segment
+
+(Of course the absolute value will never appear in a relocation table, +but this value is necessary for the exported list) +

+If the type is HIGH, the low byte of the value is stored behind the +relocation table entry, if bytewise relocation is allowed (header mode +field bit 14). If only pagewise relocation is allowed, then only HIGH +relocation entries can occur, and the low byte is implicitely set zero +(i.e. it is _not_ saved in the relocation table). +

+If the type is SEG, then the two lower bytes of the three byte segment +address are stored behind the entry in the relocation table, lower byte +first. +

+ + +If the segment is "undefined", the typebyte is immediately followed +by the two (mode size=0) or four (mode size=1) byte value index +in the undefined references list. If it is a high byte relocation, +the low byte is saved behind the index value. The index value +determines the undefined reference, which must be looked up by the +loader. +

+The value taken from the relocation address in the segment, together with +the low byte from the relocation table (if HIGH entry) form the address +used if the segment would be used unrelocated. To relocate the segment, +the difference between the relocated segment base address and the segment +base address from the file is then added to the above address. The result +is again saved in the segment. +

+A zero offset byte ends the relocation table. The first offset is computed +from the segment base address-1, to avoid a 0 value in the first entry. +

+Note that direct addressing modes do not generate entries in the +relocation table. instead it is assumed that the 65816 direct register +holds the correct value (i.e. zero segment base address) when running +this program. +

+Example: +

+Segment Base address in file (header.tbase) is $1000. +The start address of the text segment after relocation is real.tbase = $1234. +

+Now the first (unrelocated) address at which a relocation should take +place is here: +

+$1222	A9 23 		lda #>vector
+
+This generates the offset: $1222-($1000-1) = $223. This is larger than +254 ($fe), so the first byte is 255 ($ff). The offset is decremented +by $fe, and gives $125. This again is larger than $fe, so the next byte +is $ff again. After substracting $fe again, we have $27. But this is +the address of the opcode. To get the address of the address byte, we +have to add 1 to get $28, which becomes the third byte. +The next offset is then computed from $1223, because this is the +last relocation address. +

+Now we reference the high byte of an address, lets say vector=$23d0 (not +relocated), in the text segment. Therefore the relocation type becomes +'HIGH | text_segmentID = $42', which is the next byte. Because we are +referencing a high byte of an address, the low byte of the unrelocated +address is saved behind the typebyte in the relocation entry. This byte +is missing when referencing a low byte or address. +

+The relocation table entry is now: +

+$ff, $ff, $28, $42, $d0.
+
+When actually doing the relocation, the relocation pointer is initialized +to real.tbase-1 = $1233. Then we compute the offset to $224, which brings +us to $1457, where the address byte of the above opcode is after loading +the file to $1234. We now have to compute the new address, where vector +is after relocation. So we take the unrelocated low byte from the +relocation table ($d0) and the high byte from $1457 ($23). +
+vector_file = ($23 << 8) + $c0
+
+To this value we add +the difference between the address the program is assembled to and the +real load address: +
+vector_relocated = vector_file + (real.tbase - header.tbase)
+		 = $23d0 + ($1234 - $1000)
+		 = $23d0 + $234
+		 = $2604
+
+From this value the high byte is then written back to the address $1457. +Had we not saved the low byte in the relocation table, and only added +the high bytes, we would have missed the carry bit that increments +the high byte in this case! +

+Had "vector" now been an undefined reference, and "vector" would be +the second label in the undefined references list, we would get the +following relocation table entry (assuming mode.size=0): +

+$ff, $ff, $28, $40, $00, $02, $00
+
+The value computed with the above formula for vector_file is now added +to the address the label "vector" now really has (This must of course +be looked up into an external table or list). +Had the opcode been "LDA #>vector+$567", then the low byte in the relocation +table would be $67, while the high byte in the opcode would be $05. +This value would result in vector_file and the real address of "vector" +would be added before wrting back the high byte to the opcode. +

+ +

2.6.5) exported globals list
+

+The global list is a list of names, together with the target segment +and the offset in the segment for each name. It is preceeded with the +number of exported labels. This allows the loader to allocate a table +large enough, if needed. The number of labels and the offset value +are 16 bit or 32 bit values according to the size bit in the header mode +field. The segmentID is a byte value and the same as in the relocation +table entry (see section 2.6.3). +

+	number_of_exported_labels.s
+        "global_label_name_in_asc1",0, segmentID.b, value.s
+	...
+
+ +

3) assembler source format

+

+The assembler source format is a suggestion only. It will be implemented +in xa65, a cross assembler for 6502 CPUs running on Unix/Atari ST/Amiga +as a reference platform. +

+The assembler provides a way to embed absolute address code in relocatable +code. This is needed when code should be copied to a specific location +known at assemble time. +There also is a way to make a file 'romable'. You can give the start +address of the _file_ in ROM, and the assembler automatically sets +the text segment start address to where the code will be in the ROM. +Of course, the other segments must be taken care of with -b? command +line parameter, that set the segment start address. +

+

3.1) embed absolute code in relocatable files

+

+When the assembler is started in relocatable mode, everything is put into +a .o65 relocatable file. All address references generate relocation table +entries. If a "*= value" pseudo opcode is encountered, +then the assembler switches to absolute mode. The following opcodes don't +generate relocation table entries. If a "*=" without a value is read, +then the assembler switches back to relocatable mode. The relocation +program counter is increased with the length of the absolute part and +the absolute code is embedded between the relocatable parts. +

+

3.2) embed relocatable code in absolute files

+

+This is dropped - too complicated. Should better be done with some +objdump or linker programs or so. +

+

3.2) Header options

+

+Before any opcode (after starting in relocatable mode, or after a .reloc +opcode), a header option can be set by: +

+	.fopt byte1, byte2, ...
+
+The header option length is automatically set by the assembler. +An example for an file author entry: +
+	.fopt 3, "Andre Fachat",0
+
+The 3 is the type byte for the author header option. The last zero ends +the name. The assembler can be configured to automatically include an +assembler header option into a file header. +

+

3.3) allocation of data segment/zeropage segment address space

+

+The assembler switches between the different segments by the means of +".text", ".data", ".bss" and ".zero" pseudo opcodes. After starting in +relocatable mode, the assembler is in the text segment. +

+The text segment contains the program code. Data holds the initialized data, +while bss and zero segments contain uninitialized data for normal/zeropage +address space. +Everything that is between one of these segment opcodes and the next segment +opcode gets into the corresponding segment, i.e. labels, assembled code etc. +The text and data segments are saved in the file, while for the bss and +zero segments only the length is saved in the file. +

+The assembler should issue a warning when a direct addressing mode +is used without a zero segment address and vice versa for 65816 CPUs. +

+

3.4) referencing data/bss/zeropage addresses

+

+One problem with the 6502 is, that it cannot load an address within one +step or assembler opcode. So an address is loaded with standard byte +opcodes, like "lda # +The assembler is now intelligent enough to evaluate such expressions +and check for: +

+- no address label			: ok, absolute
+- one address label, only add to label	: ok, relocate
+- difference between two addresses 	: If addresses in same segment, compute
+					  diff and set absolute, otherwise bail
+- everything else			: warning
+
+This way there is no change in syntax. Address labels are distinguished +by using the "label:" syntax, as opposed to "label = value". +Also, if the assembler is capable of doing so, an address label may be +defined by "label opcode", i.e. without a colon. +

+

3.5) aligning code

+

+The 6502 has the problem that some opcodes (e.g. "JMP ($xxFF)" are +broken, if the address given is at some (odd) address. But when loading +a relocatable file, one cannot know if an address will be odd or even. +Therefore there is a new opcode, +

+	.align 2
+
+that aligns the next address at the given address boundary. Valid +values are 2, 4, and 256. +

+

4) Clearance

+

+This file is surely not the optimum and could be improved. Also the +header option "assigned numbers" should be added here. +

+For this reason the author, Andr� Fachat, will function as a +clearing point, where problems can be discussed and number can be assigned. +

+ +Dec. 22, 1996,
+André Fachat
+(fachat@physik.tu-chemnitz.de)
+

+

Appendix

+ +

A) File examples

+

+(to be done with reference assembler) + diff --git a/dump/oa-2.0.9/doc/files.txt b/dump/oa-2.0.9/doc/files.txt new file mode 100644 index 0000000..c9d9f40 --- /dev/null +++ b/dump/oa-2.0.9/doc/files.txt @@ -0,0 +1,187 @@ + + +/***************** c64 rom build - arch/c64/* *****************************/ + +c64rom.a65 includes/wraparound to build 'ROM' image for C64 +c64def.i65 additional C64 defines +config.i65 standard OS/A65 config defines +devices/c64dev.a65 device wraparound +devices/ser_acia1.a65 ACIA 6551 RS232 device driver +devices/ser_9600.a65 Fast RS232 driver for interface by D. Dallmann +devices/con_c64.a65 include for standard console driver +devices/piec_c64.a65 include for standard IEEE488 driver - parallel IEEE +devices/siec_c64.a65 include for standard IEEE488 driver - serial IEC +kernel/kinit.a65 C64 reset functions +kernel/kenv.a65 plain memory config task switching stuff + +boot/loader BASIC loader to start everything +boot/loader11 BASIC loader to start everything on VICE with piec +boot/boot small Machine Language boot program +boot/boot.a65 source for boot +boot/charom charom to use (needs ASCII, not PETSCII) +boot/term9600 small terminal program (BASIC) + +/***************** CS/A65 rom build - arch/csa/* **************************/ + +csarom.a65 includes/wraparound to build a complete rom image +config.i65 standard OS/A65 config defines +csa65.i65 additional CS/A65 defines +devices/oadev.a65 mainly includes, to build devices into the kernel +devices/par.a65 parallelport device +devices/piec_csa.a65 include for standard IEEE488 driver - parallel IEEE +devices/siec_csa.a65 include for standard IEEE488 driver - serial IEC +devices/oa1ds.a65 ACIA6551 serial device +devices/con_csa.a65 include for standard console driver. +boot/inirom.a65 inirom sets the memory configuration for testing a + new rom and starts it +boot/charom charom to use (ASCII) +kernel/kinit.a65 CS/A65 reset functions +kernel/kenv.a65 CS/A MMU memory config task switching stuff + + +/***************** gecko rom build - arch/gecko/* *************************/ + +devices/fsiec.a65 modified FSIEC filesystem for Gecko +config.i65 standard OS/A65 config defines +gecko.a65 main ROM (includes, wraparound) +gecko.i65 additional Gecko defines +boot/inig2.a65 Program to start Gecko emulation on CS/A MMU +boot/inig3.a65 - " - +boot/inigecko.a65 A small program to make test environment for Gecko +devices/keydev.a65 device for keyboard +devices/oadev.a65 device wraparounds (also uses oadev/oa1ds2.a65) +devices/siec_gecko.a65 include for standard IEEE488 driver - serial IEC +kernel/kinit.a65 Gecko reset functions +kernel/kenv.a65 plain memory config task switching stuff + +/***************** defines - include/* ************************************/ + +chips/* hardware (chips) definitions +fdefs.i65 kernel file interface definitions +kdefs.i65 kernel interface definitions +kernel.i65 kernel jump table +file_o65.i65 o65 fileformat definitions +inet.i65 kernel network interface definitions +lib6502.i65 lib6502 definitions + +/***************** kernel - kernel/* **************************************/ + +kernel.a65 kernel: wraparound/includes +jmptbl.a65 jumptable / address defines (for include) +init.a65 bootup: memory test, start rom processes, frequency + detect; irq/nmi wraparounds (vectors) +tasks.a65 kernel entry/exit gates (memsys/memtask), scheduler, + environment stuff, kill, term, send/receive, fork, + read, write, setblk, dup,... +devices.a65 kernel device routines, registering, device irq +files.a65 fs manager - dispatch fs messages to registered fs +streams.a65 stream manager + +ramtest.a65 RAM test routines for inclusion in arch specific stuff +zerotest.a65 zeropage test routines for inclusion in arch stuff + +/***************** oldlib - oldlib/* **************************************/ + +- old stuff - not documented any more + +/***************** devices - devices/* ************************************/ + +nulldev.a65 kind of /dev/null +ser_acia.a65 two serial devices for ACIA 6551 +ser_uart.a65 a serial device for UART 16550A (16 byte FIFO) +spooler.a65 spooler - serialize output requests +console.a65 terminal device - video, keyboard, bell + +arch/proto/devices/oa1std.a65 standard device routines - for new devices +arch/proto/devices/oa1stds.a65 standard device routines for multiple devices + +/***************** system applications ************************************/ + +/***************** filesystems sysapps/fs/* *******************************/ + +fsdev.a65 filesystem for accessing devices +fsibm.a65 IBM PC fs for drives on csa shugart bus +fsiec.a65 fs for CBM drives on IEEE 488 interface + +/***************** command shell and monitor sysapps/mon/* ****************/ + +mon.a65 shell with i/o redirection, pipes, and more +shdir.a65 file stuff for shell +shmon.a65 machine language monitor for shell + +/***************** ibm disk monitor - sysapps/ibmon/* *********************/ + +ibmon.a65 disk monitor for IBM PC disks. doesn't work with +ibmon.doc fsibm due to lack of mutex/semaphore + +/***************** simulate keyboard for a C64 - ? ************************/ + +keyrom/ky.a65 device to send stream data to a c64, of that the +keyrom/kyc64_1.a65 keyboard is emulated by dual ported (time sharing) + ram + +/***************** send infrared commands to the stereo - sysapps/irtx ****/ + +irtx.a65 program to send infrared commands + +/***************** multicopy - sysapps/mcopy/* ****************************/ + +mcopy.a65 multicopy programm - serialize copy commands + (that are executed by setting up a stream and + leaving it alone in the shell, thus causing + performance/resource problems when copying many + files) + +/***************** basic interpreter - sysapps/basic/* ********************/ + +basic4.a65 extended basic interpreter, running in multitasking + ported from C64, (c) commodore. + Not (yet?) running on the C64 under this OS. + +/***************** slip client - sysapps/slipd/* **************************/ + +fstcp.c fstcp server +main.a65 main client wraparound +fstcp.a65 fstcp client code +fstcp.h fstcp defines +icmp.a65 ICMP (ping echo) code +mem.a65a memory handling for packets +slipi.a65 SLIP input loop +slipo.a65 SLIP output loop +sltcp.def IP & TCP defines +tcp.a65 basic TCP code (when packet arrives) +tcpuser.a65 basic TCP code (user calls) +tcpsrv.a65 echo, discard, and chargen code +putil.a65 protocl utility functions +tutil.a65 TCP utility functions +util.a65 utility functions +csaip small example script to prepare serial line +mon.a65 some general debug output +rsh.a65 telnetd server +libip.a65 lib6502 binding + +/***************** lib6502 applications ***********************************/ + +/***************** file apps - apps/file/* ********************************/ + +cat.a65 cat +chkdsk.a65 chkdsk +format.a65 format +ls.a65 ls +mkdir.a65 mkdir +mv.a65 mv +rm.a65 rm +rmdir rmdir + +/***************** shell - apps/lsh/* *************************************/ + +lsh.a65 lib6502 shell + +/***************** inet apps - apps/inet/* ********************************/ + +tlogin.a65 login program called by slipd when incoming telnet + connection is opened. +telnet.a65 telnet program +httpd.a65 lib6502 WWW server - not yet working. + + diff --git a/dump/oa-2.0.9/doc/filesystems.html b/dump/oa-2.0.9/doc/filesystems.html new file mode 100644 index 0000000..4f3eaa5 --- /dev/null +++ b/dump/oa-2.0.9/doc/filesystems.html @@ -0,0 +1,161 @@ + + OS/A65 Kernel Filesystem Interface + +

OS/A65 Kernel Filesystem Interface

+

(c) 1989-98 Andre Fachat

+
+The kernel filesystem interface should not be used by normal applications +anymore. Instead the lib6502 calls should be used. +
+
+The interface to the filesystems is handled by the standard send/receive
+and stream routines. To access a file, a message has to be sent to the
+filesystem manager, i.e. to task id SEND_FM.
+To 'mount' a filesystem to a drive, the task has to register itself with
+the filesystem manager. To do this, it sends a message of type FM_REG
+to the filesystem manager. In PCBUF ($0200), the message contains
+the number of drives to register (FM_REG_DRVS) and the task id of
+the filesystem task (FM_REG_ENV).
+
+/*        FileManager              */
+
+#define   SEND_FM        $fe
+
+#define   FM_REG         0
+
+#define   FM_REG_DRVS    0
+#define   FM_REG_ENV     1
+
+
+All other messages to the filesystem manager have to have the drive in
+PCBUF+FM_OPEND_DRV to allow easy redirection. '/' is used to separate 
+dirs from each other in a filename.
+
+#define   FM_OPEN_DRV    0
+
+#define   DIRSIGN        "/"       /* Trennzeichen zwischen Verzeichnissen */
+
+
+The following message types are defined, although not all have been 
+implemented. 
+
+#define   FS_OPEN_RD     1         /* Open file for reading only */
+#define   FS_OPEN_WR     2         /* Open file for writing only (with error
+				      if file exists) */
+#define   FS_OPEN_RW     3         /* Open file for read and write */
+#define   FS_OPEN_OW     4         /* Open file for overwriting */
+#define   FS_OPEN_AP     5         /* Open file for append */
+#define   FS_OPEN_DR     6         /* Open directory for reading */
+#define   FS_RENAME      7         /* rename file */
+#define   FS_DELETE      8         /* remove file */
+#define   FS_FORMAT      9         /* format disk */
+#define   FS_CHKDSK      10        /* check disk */
+#define   FS_CLOSE       11        /* close file (only for FS_OPEN_RW) */
+#define   FS_RMDIR       12        /* remove subdirectory */
+#define   FS_MKDIR       13        /* create subdirectory */
+#define   FS_CHDIR       14        /* ----                                 */
+#define   FS_ASSIGN      15        /* ----                                 */
+
+/* struct, that has to be sent in PCBUF for any FS_OPEN_* message */
+/* after a successful open with FS_OPEN_RD/WR/OW/AP, the filesystem
+tries to read data from stream or write to it. It ends when it
+gets an E_EOF on reading streams or E_NUL on writing streams.
+If a file is read to the end, the filesystem decrements the write
+task counter (thus signaling the end of file) and closes the file
+internally */
+ 
+#define   FS_OPEN_DRV    0         /* drive = FM_OPEN_DRV */
+#define   FS_OPEN_STR    1         /* stream over which the data is 
+				      transfered */
+#define   FS_OPEN_PFAD   2         /* ----                                 */
+#define   FS_OPEN_NAME   3         /* name of the file to be opened */
+
+/* struct to be sent for any message except FS_OPEN_* */
+
+#define   FS_CMD_DRV     0    /* target drive */
+#define   FS_CMD_PFAD    1    /* ---  */
+#define   FS_CMD_FIL     2    /* ---  */
+#define   FS_CMD_NAME    3    /* for rename, the original filename has to
+				 be sent as usual, but after the nullbyte 
+				 at the end of the first name follows the 
+				 name the file has to be renamed to, 
+				 ended with a nullbyte */
+
+/* struct that is sent back by the filesystem task */
+
+#define   FS_X_ERR       0         /* error code, that is also returned 
+				      in the accumulator */
+#define   FS_X_ENV       1         /* task id of filesystem task */
+#define   FS_X_FIL       2         /* file handle (for FS_OPEN_RW only) */
+#define   FS_X_SLEN      3         /* length of this struct (not sent) */
+
+
+A directory is being read as a normal file, but the file has a structrure,
+that is being described here.
+
+/* struct of a directory entry in a directory file */
+
+#define   FS_DIR_LEN     0    /* length of file, 4 byte, lo byte first */
+#define   FS_DIR_YEAR    4    /* year -1900, */
+#define   FS_DIR_MONTH   5    /* month, */
+#define   FS_DIR_DAY     6    /* day, */
+#define   FS_DIR_HOUR    7    /* hour, */
+#define   FS_DIR_MIN     8    /* minute, */
+#define   FS_DIR_SEC     9    /* and second of last change */
+#define   FS_DIR_MODE    10   /* type of file */
+#define   FS_DIR_NAME    11   /* name, ended with a nullbyte */
+
+/* file types */
+
+#define   FS_DIR_MOD_FIL 0    /* normal file */
+#define   FS_DIR_MOD_NAM 1    /* disk name */
+#define   FS_DIR_MOD_FRE 2    /* number of free bytes in FS_DIR_LEN */
+#define   FS_DIR_MOD_DIR 3    /* subdirectory */
+
+
+Now comes the definition of an executable file, as interpreted by the ROM
+startup and by the shell.
+
+/*	Prg-Header		*/
+
+#define	P_KIND		0	/* type of program */
+#define	P_MEM		1	/* memory size in kByte */
+#define	P_RES		2	/* --- */
+#define	P_ADR		4	/* start address of program */
+#define	P_TAB		6	/* memory relocation table: a series of two 
+				   bytes, the first describing the position 
+				   in the MMU map, the second the memory block
+				   to map in this position. This is used
+				   to map the ROM in the memory for 
+				   autostart executables. The table is ended
+				   with a single $ff. */
+
+/*	Prg-types 		*/
+
+#define	PK_PRG		0	/* program executable */
+#define	PK_DEV		1	/* device block - memory size is ignored and
+				   exactly one position in the relocation table
+			    	   has to be set. These values are given to
+				   REGDEV.
+#define	PK_FS		2	/* filesystem - STD* streams are set to 
+				   STDNUL */
+
+
+Appendix
+--------
+
+For the FAT filesystem, several disk sizes have been defined for the 
+format command. The disk size is stored in the FS_CMD_PFAD byte in PCBUF.
+
+dsize   kByte  pages tracks sectors blocksize dd/hd  comment
+------------------------------------------------------------
+  0     360     1     80      9       512      dd	Atari ST single sided
+  1     720     2     80      9       512      dd	3.5"
+  2     1440    2     80     18       512      hd	3.5"
+  3     1200    2     80     15       512      hd       5.25"
+  4     1280    2     80      8      1024      hd       5.25"
+  5     360     2     40      9       512      dd       5.25"
+
+
+ + diff --git a/dump/oa-2.0.9/doc/header b/dump/oa-2.0.9/doc/header new file mode 100644 index 0000000..be0b3c7 --- /dev/null +++ b/dump/oa-2.0.9/doc/header @@ -0,0 +1,4 @@ +

OS/A65

+

(c) 1989-1996 +André Fachat

+
diff --git a/dump/oa-2.0.9/doc/index.html b/dump/oa-2.0.9/doc/index.html new file mode 100644 index 0000000..9604156 --- /dev/null +++ b/dump/oa-2.0.9/doc/index.html @@ -0,0 +1,186 @@ + + OS/A65 Operating System + +

OS/A65 Operating System

+

Version 2.0.1

+

(c) 1989-1998 +André Fachat +[Homepage]

+

+This is a completely new version of my 6502 operating system GeckOS/A65. +From version 2.0.0 on it has a lot of new features: +

    +
  • multithreading +
  • dynamic memory management +
  • relocatable fileformat +
  • lib6502 standard library +
  • internet support +
+ +

Description

+

+OS/A65 is a full-featured Multitasking/Multithreading operating system +for the 6502. It is preemptive and implements some Unix-like features, +like signals, semaphores, +relocatable fileformat, +standard library, internet support via +a kind of simplified sockets and last but not least virtual consoles. +

+It is extremly scalable. Stripped down to the scheduler and interrupt +handling the kernel is only slightly above 2k. In normal +embedded systems +the kernel has around 4k, with only application programs running. +Full featured systems have a 4k kernel, and several support tasks +provided system services like TCP/SLIP and (different) filesystems. +

+The kernel is almost completely hardware independent. All the +architecture-specific stuff is in a separate subdirectory +for each architecture. +

+The lib6502 as standard library allows easy +access to the system services. Parts of this library are already +implemented in another 6502 operating system, Lunix by Daniel Dallmann. +This way source code compatibility is achieved. +

+Version 2.0.0 features a "slipd" server process that brings easy internet +access to all lib6502 programs, that can now access TCP connections +like files. A stable WWW server running on the OS is built into the +slipd daemon. Also a remote login can be done. This way the OS can run +programs to for example read sensors and write the stuff to files, which +are exported by the WWW server. +

+The relocatable o65 fileformat used by the lib6502 standard library +in version 2.0.0 allows more than one instance of a program being run +at the same time without interference, even without virtual memory. +Also the very same binaries runs on all supported platforms (if they do not +use architecture specific stuff, but lib6502 calls only). +

+

Architectures

+

+Architectures supported are the C64, as well as my +CS/A65 +MMU selfbuilt computer and my +CS/A65 Gecko board. +Also supported are the Commodore CBM8096 and CBM8296 computers, as well as +any 32k RAM PET (the 3032, 4032 and 8032) +

+
    +

  • CBM PET documentation. Supported are 40 and +80 column models 3032, 4032, 8032, 8096 and 8296. +

  • Embedded systems need not all features. Here is some doc to strip the OS down to the basics (with around 2.5k in the end...) +
+

Development

+

+For the development of OS/A65 programs there are two possibilities: +

    +
  • lib6502 with the +o65 +file format. This allows source compatibility (to some degree) with Lunix, as +well as that the program runs on all supported platforms.

    +lib6502 programs are simply assembled with my xa65 crossassembler with the +including the file "lib6502.i65" and the assembler option "-LLIB6502" set. +This tells the compiler to put "LIB6502" into the +file as undefined reference that is resolved when loading. The lib6502 +jump table is relative to this address. + +

  • A system application not only uses lib6502 calls (if it uses them) +but also kernel calls. The kernel can be at +different addresses for different +architecture as well. Therefore you have to add "-LOSA2KERNEL" to the assembler +line. This address is also resolved when loading. If the file should also +be used as a ROM file, then it has to have a ROM boot header, see the +kernel description. +
+

More Docs

+
    + +

  • Here is the cross assembler +xa +you need to assemble the whole stuff +

  • What's new in this version since 2.0.0 +

  • How to build the binaries +

  • A description of the files in the archive +

  • kernel interface +

  • lib6502 description +

  • Operation without an MMU +

  • introduction to the devices +

  • filesystem interface +

  • The README that comes with the binary. +

  • The README.c64 with instructions how to run it on the C64 +

  • The README.slip with instructions how to run the TCP/SLIP software +

  • There also is a list of Known Bugs +

  • There also is a list of Ideas what to do next... +

  • An instruction to the lib6502 lsh +
+

Old stuff:

+
    +

  • Overview over the Computer System and its Software +

  • The old standard library has been +replace with the lib6502 and is not longer supported. + +

  • The old summary of shell has been replaced +by the lib6502 lsh and will no longer be developed. +

  • The old monitor is still supported, but not actively developed any more. +

  • summary of features and extensions of the +BASIC interpreter (c) Commodore +

  • The ChangeLog for version 1.3.* and for +the development of 2.0.0. +
+

History

+

+I didn't dream of this becoming such a nice project when I started +building this computer in 1989. +

+After someone asked me to release it to the public, I decided +to put it under the GNU public license. +(Which, of course, doesn't hold true for the ported BASIC interpreter, which +is taken from the C64. +See this file for more.) Also the +character ROMs are taken from the C64. However, Commodore in its old +form doesn't exist anymore and attempts to contact the new right holders +have not brought any success, so I put them here. +

+Well, when I did this project, it was just for fun. But now I find it +quite nice. Well, if you know some magazin that would like to publish +some of it, I will be glad writing an article or so (if anybody really +wants it ;-)
+But on the other hand my interests have moved. +Occasionally I still work on the project - when I have the time (or take +the time ;-)
+But after all, I don't really have time for it. +

+

Ideas for later versions

+
    +

  • vt100 control codes for the console. +

  • native C128 port +

  • in this process abstract a kind of block device from fsibm and use +it for the VC1571 as well +
+


+Last modified 14 march 1997 by A. Fachat
+This Page has been read approx. +[Can't display counter!] +times since march 14, 1996. + + diff --git a/dump/oa-2.0.9/doc/kernel.html b/dump/oa-2.0.9/doc/kernel.html new file mode 100644 index 0000000..504a7fc --- /dev/null +++ b/dump/oa-2.0.9/doc/kernel.html @@ -0,0 +1,1000 @@ + + OS/A65 Kernel Interface Description + +

OS/A65 Kernel Interface Description

+

(c) 1989-98 Andre Fachat

+
+

OS/A65 Version 2.0

+

Introduction

+ +The change from kernel 1.3 to kernel 2.0 is radical in some things, but +conservative in others. The complete environment handling has been +rewritten to make it easier to port to different platforms. Also threads +have been introduced. Therefore all the memory management and +interprocess communication calls have changed as well. +The scheduler is now a lot faster, as no more checks are done for threads +in the waiting list. +

+Although most routines have been rewritten, many of these calls still +have the same parameters and behave the same way. +Also the PCBUF is still used (unfortunately). This is the general +communications buffer needed for filesystem operation and some kernel +calls. It is a global buffer, and as such it is protected by the +SEM_SENDBUF system semaphore. Each task that wants to use +has to allocate this semaphore with PSEM before using the +buffer. +

+Also there still is no block oriented communication, although the +stream based communication has been improved by the out-of-band +error, brk and push/pull flags. +

+I try to keep this documentation as correct and up-to-date as possible, +but if in doubt, read the source... :-) +

+There are now some comments like "this need not be available in all +OS implementations". These comments mostly refer to the embedded +versions of the OS where the kernel can be shortened to (almost) +2k in size by leaving out some stuff not necessary for the particular +application. +

+

Contents

+ + +

Kernel Interface Description

+ +Most kernel routines return an error code in the accumlator (a), if the +carry flag is reset upon return. Otherwise the ac might contain data.

+ +


+ +
+
+$f000  	RESET   System reset
+
+

+
+$f003	ENMEM	Enable 4k memory block, no in xr, for memory management - 
+		MMU version only
+$f006	SETBLK	set memory block ac at MMU entry yr - returns old entry
+		in ac. MMU version only
+
+

+

+The Stream functions have not changed much. The only addition compared to +kernel 1.x is the error code byte, that allows passing of error conditions +and push/pull signals as "out-of-band" data. +

+In the embedded versions the stream functions +are not necessarily implemented. +

+
+
+$f009	GETSTR	Get a free stream. increase read and write task counter,
+		returns stream number in x
+
+$f00c	FRESTR	decreases read and write task counter, thus freeing the
+		stream, if both result in zero. parameter: stream number in x
+
+$f00f	PUTC	puts a byte on the stream. parameter: stream number in x,
+		data byte in a. returns errorcode in a
+
+$f012	GETC	Get a byte from the stream. parameter: stream number in x,
+		returns data byte in a (with carry=0) or error code 
+		(carry=1)
+
+$f015	UNGETC	Gives byte from stream back. parameter: stream number in x,
+		data byte in a, returns error code in a
+
+$f018	STRCMD	executes a stream command. parameter: stream number in x,
+		stream command in a, returns error code in a.
+
+		possible stream commands are:
+
+		SC_GET		0	same as GETSTR
+		SC_REG_RD	1	increase read task counter by one
+		SC_REG_WR	2	increase write task counter by one
+		SC_CLR		3	empty the stream
+		SC_EOF		4	closing the stream from the sender 
+					side, i.e. decrease write task 
+					counter by one
+		SC_NUL		5	closing the stream from the receiver
+					side, i.e. decrease read task 
+					counter.
+		SC_FRE		6	same as FRESTR
+		SC_STAT		7	read stream status into ac
+		SC_GANZ		8	returns number of bytes in stream in a
+		SC_RWANZ	9	returns the stream write pointer in
+					a and the stream read pointer in y
+
+		SC_ESTAT	10	Get the error code byte in yr,
+					and the normal (i.e. what you get
+					with SC_STAT) stream state in ac.
+		SC_SSTAT	11	Set bits in the error code byte
+					each bit set in yr is set in error byte
+		SC_CSTAT	12	Clear bits in the error code byte
+					each bit set in yr is cleared in error 
+					byte
+					
+
+		Possible stream status are:
+
+		E_NUL		Noone reading from stream
+				(i.e. read task counter is zero)
+		E_EOF		stream is empty and noone is writing anymore
+				(i.e. write task counter is zero)
+		E_SEMPTY	stream buffer is empty
+		E_SFULL		stream buffer is full
+		E_SLWM		number of bytes below Low Water Mark 
+				(1/4 buffer size)
+		E_SHWM		number of bytes above Hogh Water Mark
+				(3/4 buffer size)
+
+		The error code byte has the following bits:
+
+		SCE_PULL	%10000000  reader pulls data from sender
+		SCE_PUSH	%01000000  writer pushes data to receiver
+		SCE_BRK		%00100000  writer sends 'break' signal
+		SCE_RERRM	%00001100  reader error condition mask
+		SCE_WERRM	%00000011  writer error condition mask
+
+
+The error condition byte can be set and read from both ends. This byte is +cleared when the stream is allocated. If the reader "pulls" data, this is +a sign for the writer to flush all its internal buffers into the stream. +When this is done, the writer clears the pull flag. +

+If the writer wants to push his data (like after an CR on a terminal, +for example) the reader should get the number of bytes in the stream to +have an inidcation of how many bytes to read as "pushed" (or urgent in +Internet speak). Then it removes the push flag and gets the bytes from the +stream +

+If an error occurs, e.g. a read error when reading a file, the writer +sets all the bits in the error code byte masked by SCE_WERRM to 1 +(which is general error code - other codes still have to be defined). +The reader of the stream then reads this and can handle the error. +

+If an error on the reading side occurs (like disk full when writing +a file), The reader sets all the error bits masked by SCE_RERRM to 1 +(which is general error code - other codes still have to be defined). +The writer can then close the file on his side. +

+If the writer wants to send a Break (i.e. a ^C equivalent) +code to the reader, it sets +the SCE_BRK bit. The reader must clear it itself. +

+


+
+$f01b	DEVCMD	executes device commands. parameter: device number in x,
+		device command in a, optional parameter in y.
+		returns error code in a.
+
+		possible stream commands are:
+
+		DC_IRQ		0	execute IRQ routine
+					the interrupt routine has to return
+					E_OK if an interrupt source is cleared
+					or E_NOIRQ if not.
+		DC_RES		1	initialize device
+		DC_GS		2	sets the stream (in y) the device 
+					reads from
+		DC_PS		3	sets the stream (in y) the device 
+					writes to
+		DC_RX_ON	4	switch on receive
+		DC_TX_ON	5	switch off receive
+		DC_RX_OFF	6	switch on send
+		DC_TX_OFF	7	switch off send
+	
+		DC_SPD		8	set speed (in y), device dependend
+		DC_HS		9	set handshake (in y), device dependend
+		DC_ST		10	get device status, device dependend
+		DC_EXIT		11	disable device, including IRQ sources
+
+		DC_GNAM		16	get the name of a device, parameter:
+					device number in x, returns 
+					name PCBUF ($0200)
+		DC_GNUM		17	get number of a device from name,
+					parameter: name in PCBUF, length
+					of name in x, returns device number 
+					in x
+		DC_REGDEV	18	register new device(s)
+
+
+ With the registration of the device the system has to know + what to do with it and where to put it in memory. + Therefore you have to put the address of the following + struct into x/y registers. +
		
+		
+		x/y ->          2 byte pointer to label1
+				JMP Start_of_1st_device
+				Name_of_device,0
+				...
+		label1		2 byte pointer to label2
+				JMP Start_of_2nd_device
+				Name_of_2nd_device,0
+				...
+		labeln		$ffff
+ 
+
+ With this method it is possible to register several devices, + as long as they are in one memory block, with one call. + + The devices are started with DC_RESET. In y they get a + system feature byte. Currently only bit 7 is defined, + where $00 is 1 MHz system clock and $80 is 2 MHz system clock. +


+
+$f01e	FORK	start a new task. parameter: yr = length of the following
+		struct in PCBUF
+
+		FORK_SIZE	0	The size of the needed memory
+					in 256 byte blocks, from botton up
+		FORK_SHARED	1	number of 256 byte blocks that 
+					share the mapping with the current
+					task, from top down. 
+		FORK_PRIORITY	2	priority of new task (0=inherit
+					from parent)
+		FORK_STDIN	3	stdin stream
+		FORK_STDOUT	4	stdout stream
+		FORK_STDERR	5	stderr stream
+		FORK_ADDR	6	start address of task
+		FORK_NAME	8	name of the program, ended by a 
+					nullbyte. After that follows the 
+					command line that started the program.
+
+		FORK returns the PID of the new task in xr.
+
+ The commandline is put into the PCBUF of the starting + task. The new task gets its own task id in x + The stream read/write task counter are not changed. + I.e. a thread that wants to use the end given to fork too + has to increase the read/write counters itself. +

+ The priority is a hack to allow to run tasks with different + execution priorities. The priority + counts the number of interruptions before a thread + switch occurs. Default value is 3. A value of 0 lets + the new task inherit the priority of the current task. +

+ It is now somewhat difficult to really start a new task, as + the READ/WRITE routines to access another tasks memory + have been removed.
+ One standard procedure could be to write a boot routine + into the current PCBUF, after the command line, and + jump to this boot routine when the FORK parameters are + copied to the target PCBUF. The length parameter + to FORK must of course include this routine.
+ You could also use a routine in the ROM, which then + should be shared between the calling and the called + task. The boot routine can then load the executable.
+ For a stdlib with null-separated command line parameters, + they may also be included after the name, as long as the + length byte includes them too.
+

+ In fact, the FORK_NAME entry is somewhat arbitrary at this + time, as it is not used within the kernel. In fact, + one could write anything there. But to keep compatible, + the name and command line must have the same format + as for the ROM startup, i.e. a nullbyte separated list + of program name and parameter, with a zero-length parameter + at the end. +

+ The newly created task must release + the SEM_SENDBUF semaphore for the PCBUF. + +

+
+$f021	TERM	<- a = return code
+		ends the current thread. If still threads in the tasks are
+		running, the return code is ignored. Otherwise the return 
+		code is sent to the parent with SIGCHLD.
+
+$f024	KILL	<- a = return code, x = task id
+		ends a complete task, with all threads in them. 
+		ac is return code, xr is task ID to kill.
+		The return code is sent to the parent with SIGCHLD.
+
+$f027	YIELD	just give control back to the scheduler, as there is nothing
+		to do at the moment - but keep running (not needed for
+		preemtive multitasking, an interrupt interrupts any task!)
+
+$f02a	FORKT	forks a new thread in the current task. Execution start
+		address must be in a/y.
+		returns c=0 for ok and new thread no in xr;
+		or c=1 for error (errno in AC).
+
+$f02d	SBRK	(carry=1): sets the freely available RAM area in the
+			   active environment to ac blocks with 256 byte 
+			   each, by adding memory to or removing memory 
+			   from the end of the already available memory 
+			   area. Returns in ac the length
+			   of the available memory in 256 byte blocks,
+			   if c=0 on return. Otherwise returns error.
+		(carry=0): returns in ac the length of the available 
+			   memory in 256 byte blocks. 
+
+$f030	GETINFO	getinfo returns process information about all (up to 16) 
+		running processes in the PCBUF (which must be allocated
+		by the process before)
+		
+		May not be available in all OS implementations.
+
+		There are ANZ_ENV valid entries in the table, a 
+		0 in the TN_NTHREADS field indicates an empty slot.
+
+		The fields are as follows:
+
+		TN_PID		0	PID of process in this entry
+		TN_NTHREADS	1	Number of threads for process
+		TN_ENV		2	Environment number for process
+		TN_PARENT	3	Parent process
+		TN_MEM		4	amount of allocated RAM
+		TN_SIGNAL	5	signal address
+		TN_STDIN	7	STDIN stream
+		TN_STDOUT	8	STDOUT stream
+		TN_STDERR	9	STDERR stream
+		TN_SIGMASK	10	signal mask value
+		TN_NAME		11	start of prog name (if available)
+
+		each field is TN_SLEN bytes long and the
+		length of the name field is TNAMLEN. If the name is longer
+		than TNAMLEN-1, the the last characters are cut off, and in
+		the table the ending nullbyte is missing.
+
+
+
+$f033	DUP	(carry=1): set new STD* stream. parameter: STD* number in x,
+		new stream in a, returns old stream in ac;
+		read/write task counters are not touched!
+		(carry=0): get redirected STD* stream number. parameter:
+		STD* number in x, returns stream in a
+
+

+

+The semaphore calls need not be available in all OS implementations. +

+
+
+$f036	GETSEM	gets a free semaphore. returns semaphore number in x
+
+$f039	FRESEM	frees a semaphore. parameter: semaphore number in x
+		negative (system) semaphores cannot be freed (nor are they 
+		returned by GETSEM)
+
+$f03c	PSEM	'PSEM' operation on a given semaphore. task waits till
+		semaphore is freed. parameter: semaphore number in x
+		carry=0: block till semaphore is free
+		carry=1: do a test&set operation and return with 
+		E_OK if semaphore gotten, or E_SEMSET if semaphore is in use.
+
+$f03f	VSEM	'VSEM' operation on semaphore, allows other tasks
+		to grab the semaphore.
+		parameter: semaphore number in x
+
+
+
+
+$f042	SEND	send a message to another task
+		parameter: optional message type in a, target task in x,
+		length of data in PCBUF in y; y=0 means 256 byte in PCBUF
+		The data is in PCBUF ($0200-$02ff). returns a and y as 
+                given and the 'redirected' target (e.g. from filesystem 
+                manager) in x
+
+$f045	RECEIVE	receives a message.
+		(carry=1): waits for any message
+		(carry=0): returns immediately, with an error if no message
+		received. Otherwise if a message is received, 
+		return sender task id in x, length of
+		data in PCBUF in y (0 means 256) and the optional message
+		type as given with SEND in a.
+
+

+
+$f048	SETSIG	sets the signal address and the signal mask
+		(carry=1): sets signal address in a/y
+		(carry=0): sets signal mask
+		returns the old mask resp. the old signal address
+		in the same registers.
+
+$f04b	SENDSIG	c=1: ac contains the signal mask to be sent to the task ID 
+		given in xr
+		c=0: set thread to sleep until it receives a signal
+
+
+Signal handling works as follows: With SETSIG the signal address and the +signal mask can be set. There is only one signal address, that is the +address of a subroutine that is called on a signal. When the routine is +called, it has the current pending signal mask in AC. +The routine must return with a code sniplet +
+	pla
+	rti
+
+which jumps directly to the code executed before the signal occured. +Note that the x and y register must not be changed or must be preserved +during the signal routine. The current thread execution is changed +to run the signal handler and to immediately return with the code like above. +

+SENDSIG can be called from other tasks or from devices, not from a thread +in the same task. When SENDSIG is called, first the signal mask is checked +to see if the signal is allowed. If it is not, SENDSIG just returns. +If the signal is allowed, threads in the receiving task can be +in different states: Ready, Interrupted, or Waiting. If ready or +interrupted, the thread is directly set up to execute the signal +routine. If the thread is waiting, it depends on the INT bit in the +signal mask what happens. +

+If the INT bit is set, then any system call that lets the thread block +(i.e. wait for Semaphore, wait for Receive, wait for Send) +will be interrupted. They then return E_INT in ac - after the signal routine +has been called. The other registers are bogus after an interrupted +system call. +

+If the INT bit is not set, then the signal is pending, and the +signal routine is called when a thread of the task is set to running +again. +

+Signal mask values are +

+	SIG_INT		%10000000	/* allow interruptable kernel calls */
+	SIG_CHLD	%01000000	/* Child process has terminated */
+	SIG_TERM	%00100000	/* Child process has terminated */
+
+	SIG_USR4	%00001000	/* user signal 4 - used for STDLIB */
+	SIG_USR3	%00000100	/* user signal 3 */
+	SIG_USR2	%00000010	/* user signal 2 */
+	SIG_USR1	%00000001	/* user signal 1 */
+
+When a SIG_CHLD is executed, the receiving task is notified that a child +has died. This means it should call CHECKCHLD to see which child has +died with what error code. +

+The SIG_TERM code should be used by "standard" libraries. Currently there +is no way to inform a task about its death and let it clean up all +resources - that are not bookkept by the kernel! - before it dies. +So other libraries should, instead of calling "KILL", send a SIG_TERM signal +when they want to kill a process. The signal routine of the receiving +process should catch this signal and clean up and then call +TERM itself. +

+SENDSIG with carry clear (wait for signal) must be called by threads only, +not by devices. Also the SIG_INT bit must be set before this call is done. +If there is only one thread in the task, then the thread is sleeping until +a signal is received. When a signal is received, the signal handler is +called, then the thread is awakened and returns with E_INT. +The other registers are not preserved. +

+


+
+$f04e	TDUP	register a task for a (negative) system task number.
+		parameter: (negative) task number to replace in x,
+		new task number to be used instead in a
+
+$f051	XRECEIVE receives a message from a specified task only. parameter as
+		with RECEIVE, plus sender task id in x
+
+$f054	SETNMI	in systems without MMU, set the system NMI routine address.
+		(carry=1): set the new NMI routine address (in a/y)
+			   returns the old NMI address in a/y.
+			   The old address is saved in the place pointed
+			   to by (newadress-4) (see below) by this routine.
+		(carry=0): clear NMI routine.
+		The NMI routine has to save all registers by itself!
+
+		At NMI address -2 there must be the address of a ctrl routine
+		that can be called via CTRLNMI. Expect that the 
+		ctrlnmi routine is called during this SETNMI  with either
+		NMI_ON of NMI_OFF in AC, to set the initial state.
+		The ctrlnmi routines is called with JSR, i.e. return with RTS.
+
+		At NMI address -4 is a pointer to a memory location
+		where the address of the next NMI routine can be found.
+		If the address found there is $ffff, then the list is at
+		its end.
+
+		A possible scenario then is:
+
+		Task calls SETNMI with NEWNMI in a/y. We then have the 
+		structure:
+
+		(NEWNMI-4)	address of oldvec -->   address of OLDNMI
+		(NEWNMI-2)	address of nmictrl			
+		NEWNMI -->  	NMI routine code
+
+		This way the structure can be held in ROM, and still allow
+		flexible NMI chaining. If CTRLNMI is called, each of the 
+		nmictrl routines is called with the given value in AC.
+
+$f057	CTRLNMI	Send command in AC to all currently chained NMI ctrl 
+		routines as described with SETNMI. Possible values are:
+
+		NMI_ON  = allow NMIs 
+		NMI_OFF = disallow NMIs
+
+		This routine is called when initiating and ending an
+		IEC serial bus transfer, for example.
+
+

+
+$f05a	GETPID	returns the current task ID in x and the current thread ID
+		in y
+
+$f05d	SLOCK	c=1: locks scheduler to actual task. 
+		c=0: unlocks scheduler
+		returns c=0 when ok, c=1 with E_NOTIMP if error.
+
+		May not be available in all OS implementations.
+
+$f060	RENICE	changes the priority of the current task.
+		ac = value to add to the priority.
+		returns ac = old priority.
+
+		May not be available in all OS implementations.
+
+$f063	CHECKCHLD
+                returns:
+		c=0: returns a child process ID in x and child return code
+		in a of a child process that has died. Only works
+		if the SIGCHLD signal mask has been set when the 
+		child died.
+		c=1: no child that has died found.
+
+

+


+

Error Codes

+ +On bootup the system is tested and possible errors are detected. +On systems with a system port, the hardware error is shown by the number +of flashes the LED makes before the system reboots + +
+/*        Hardware-Errors          */
+
+#define   HE_ZP     <-1	/* zeropage mem test */
+#define   HE_RAM    <-2	/* RAM test  (to few RAM) */
+#define   HE_ROM    <-3	/* Couldn't start a program */
+#define   HE_DEV    <-4	/* device returns error upon init */
+#define   HE_TASK   <-5	/* all programs have terminated - reboot */
+
+
+possible error codes are (from oadef/oa1str.def, where most things, +except filesystem stuff are defined) +(These codes must be reordered): +
+
+/*        Software-Errors          */
+
+#define   E_OK          0       /* no error                             */
+#define   E_NOTIMP      <-1     /* feature/function not implemented     */
+#define   E_CONFIG      <-2     /* in this configuration not available  */
+#define   E_ILLPAR      <-3     /* illegal parameter                    */
+#define   E_NOMEM       <-4     /* no more memory                       */
+
+/* stream handling errors */
+#define   E_NOSTR       <-5     /* no more streams available            */
+#define   E_SFULL       <-6     /* stream is full                       */
+#define   E_SEMPTY      <-7     /* stream is empty                      */
+#define   E_SLWM        <-8     /* stream below low-water-mark (1/4)    */
+#define   E_SHWM        <-9     /* stream above high-water-mark (3/4)   */
+#define   E_EOF         <-10    /* last byte read, other side has closed */
+#define   E_NUL         <-11    /* noone listening on stream            */
+
+/* device handling errors */
+#define   E_NODEV       <-12    /* illegal device number                */
+#define   E_DON         <-13    /* device already in use                */
+#define   E_DOFF        <-14    /* device not in use                    */
+#define   E_NOTX        <-15    /* device doesn't send                  */
+
+/* misc errors */
+
+#define   E_NOENV       <-16    /* no more free environment/task ID     */
+#define   E_NOSEM       <-17    /* no more free semaphore               */
+#define   E_SEMSET      <-18    /* semaphore is already set (with PSEM) */
+
+#define   E_NOIRQ       <-19    /* irq routine has not removed irq source */
+#define   E_VERSION     <-20    /* wrong (executable file) version      */
+
+#define   E_NOTASK      <-21    /* no more free task */
+#define   E_INT         <-22    /* interrupted (by signal) system call */
+
+#define   E_ILLSIG      <-23    /* illegal signal number                */
+
+#define   E_TRYAGAIN    <-24    /* try again                            */
+
+/* file handling errors */
+
+#define   E_FNODRV      <-32    /* illegal drive number                 */
+#define   E_FNOPATH     <-33    /* wrong path                           */
+#define   E_FILLNAM     <-34    /* illegal name (joker "*","?","\"")    */
+#define   E_FNAMLEN     <-35    /* name too long                        */
+#define   E_FNOFIL      <-36    /* file not found                       */
+#define   E_FWPROT      <-37    /* file write protected                 */
+#define   E_FILEXIST    <-38    /* file exists                          */
+#define   E_FDISKFULL   <-39    /* disk full                            */
+#define   E_FDNEMPTY    <-40    /* subdirectory not empty when rmdir    */
+#define   E_FLOCKED     <-41    /* file locked                          */
+#define   E_FMEDIA      <-42    /* media error                          */
+#define   E_FLOGICAL    <-43    /* bad logical structure on media       */
+#define   E_FINTERNAL   <-44    /* internal error - should not happen!  */
+
+/* lib6502 errors */
+
+#define   E_ILLADDR     <-64    /* illegal address for lib6502 mfree    */
+#define   E_NOFILE      <-65    /* illegal file number for lib6502      */
+#define   E_NOSEEK      <-66    /* file not seekable                    */
+#define   E_NOREAD      <-67    /* read on file would block             */
+#define   E_NOWRITE     <-68    /* write on file would block            */
+#define   E_FVERSION    <-69    /* file version number not supported    */
+
+
+#define   E_LASTERR     <-96    /* for customized error numbers         */
+
+
+

+


+

ROM bootup

+

+During bootup, the kernel initializes the memory and sets up the standard +system memory configuration. This includes mapping the system ROM from +the top of memory down, and the system RAM is mapped from the lower end up. +

+When the system initialization is done, the ROM is searched for executable +files. The first two bytes of the ROM are taken as an address. +If this address is not $ffff, then directly after the first two +bytes follows the program ROM structure described below. +After starting the first file, the address at the beginning is taken +as a pointer to the next file and so forth, until the kernel finds +a $ffff. +

+The program ROM structure looks like: +

+	P_KIND		0	/* byte, type of file			*/
+	P_ADDR		1	/* word, start address of execution	*/
+	P_RAM		3	/* byte, amount of RAM needed from 
+				   lower end of memory in 256-byte 
+				   blocks				*/
+	P_SHARED	4	/* byte, size of memory shared with 
+				   parent counted from top of memory, 
+				   in 256-byte blocks			*/
+	P_PRIORITY	5	/* byte, priority of the task to be 
+				   started				*/
+	P_DEV		6	/* 2 byte, the first byte gives the 
+				   device number that is opened for the
+				   stdin stream, the second gives the
+				   device number for stdout/stderr	*/
+	P_NAME		8	/* name of the program, ended by 
+				   nullbyte. After the nullbyte is the
+				   commandline the program is started
+				   with. The parameter are separated
+                                   by nullbytes. After the last parameter
+                                   follow two nullbytes to indicate
+                                   the end of the command line. */
+
+ +There are several program types available: + +
+	PK_PRG		0	/* simple program 			*/
+	PK_DEV		1	/* device block				*/
+	PK_FS		2	/* filesystem				*/
+	PK_INIT		3	/* ROM init process			*/
+
+ +These file types have to be filled into the P_KIND field above. +In addition they can be or'd by the following flags. + +
+	PK_AUTOEXEC	$80	/* autoexecution 			*/
+	PK_RESTART	$40	/* restart when died			*/
+
+ +When the PK_AUTOSTART bit is not set, the file is ignored by +the kernel. +

+The ROM only starts device blocks (PK_DEV) and init processes +(PK_INIT), because they are set up before the scheduler starts +and therefore the PCBUF is (on non-MMU systems) not available. +I.e. init processes do not check their command line, and do not release +the PCBUF. +Also PK_INIT tasks get no stdin, stdout and stderr streams +and have to set them up themselves. +

When starting device blocks, the address given in the +P_ADDR field is given to the DEVCMD command to register +the devices. +

+When using the special init process (init v1.0 from the sysapps directory), +the other entries are started by the init process. +PK_PRG tasks are started with their stdin/out/err opened +to the devices given by the PK_DEV field. +The name and command line are copied from the P_NAME field +to the FORK_NAME field for the fork. +

+PK_FS are started as programs, but with the stdin/out/err +streams set to STDNUL, which is ignored. +

+If the init process is configured for it, and the PK_RESTART +bit is set, it registers the task id of the started process and +restarts it when the task dies. +

+

Variable allocation

+

+ROM tasks are started from the init task and have no way to +determine which RAM locations are used by other tasks. +Therefore the variable allocation must be done when the ROM is +assembled. When using an MMU-based system, where each task has its +own memory environment there need not be much caution. But when +all tasks use the same environment (like in the C64) care has to be +taken not to use a memory location twice. Especially shared libraries +must use an own memory range, and they must be thread-save. +This allows for different threads of one task as well as threads +of different tasks to use the same library in one memory environment. +

+For each environment, task and thread the kernel saves two bytes that +are guaranteed to be unique within the environment, task or thread +respectively. The bytes at addresses 2 and 3 are set to zero when +a memory environment is created and are unique to this environment. +The bytes at addresses 4 and 5 are unique to the task and can be +used for task-specific data, like a pointer to a task structure. +The bytes at addresses 6 and 7 are unique to the thread and +can be used for thread data. +


+

Configuration when building

+

+The kernel is configurable in a wide range. Many options are available +for all versions, but also many options are architecture dependent. +The options are generally set in a global file that builds a +system ROM. Therefore, to not set the options in the kernel file +itself, the macro ROM must be defined. +

+General options: +

+	CMOSCPU		/* have (rockwell) R65C02		*/
+	NMIDEV		/* allows handling of NMI in devices
+			   (only for non-MMU systems, untested)	*/
+	NMIRESET	/* calls RESET when an NMI arrives	*/
+
+	STACKCOPY	/* on non-MMU systems the stack can 
+			   either been split up or, with this
+			   options, copied to a save area	*/
+
+Memory options: +
+	RAMSIZE		/* size of checked RAM during bootup, 
+			   in 256-byte blocks			*/
+	MIN_MEM		/* minimum memory size to boot		*/
+	RAMTEST		/* if set, RAM is tested, if not RAMSIZE
+			   is taken to be the real RAM size	*/
+	BATMEM		/* memory is not cleared but kept during
+			   memory test				*/
+	NOMIRRORMEM	/* can be set if we _know_ that we do
+			   not have mirrored memory		*/
+	MEMINIVAL	/* value with which to set the memory at
+			   boot. If not set, 0			*/
+
+Some Architecture specific options: +
+	NOSYSPORT	/* The CS/A65 computer has a certain 	*/
+			   port where it can read the IRQ line
+			   for example. Not available if set	*/
+	ROMTEST		/* on CS/A65 systems allow booting from	
+			   a running OS/A65 (replacing it)	*/ 
+
+Kernel configuration options for various system calls are the following. +The second half is mostly used to customize for embedded applications. +
+	NEED_CHECKCHLD	/* checkchld available if set 		*/
+	NEED_GETINFO	/* getinfo available if set		*/
+	NEED_RENICE	/* renice available if set		*/
+	NEED_SLOCK	/* slock available if set		*/
+
+	NO_STREAMS	/* streams not available if set		*/
+	NO_FSM		/* filesystem manager not avail. if set	*/
+	NO_SEM		/* semaphores not available if set	*/
+	NO_SEND		/* no send/receive/xreceive if set	*/
+
+	EOK_SEPARATE	/* kernel is not at end of ROM - 	*/
+			/* kernel/end.a65 is included extra.	*/
+	EOK_NOFILL	/* don't fill between kernel and end of */
+			/* it. kinit _must_ copy the stuff from	*/
+			/* eok_addr to $fff*			*/
+
+

+


+

Porting

+

+Porting has been made much easier with this kernel version. +In general, there is a proto architecture subdirectory that holds +some prototype files for a non-MMU system. that can easily be changed to +fit own needs. +

+The kernel needs two files in the arch/*/kernel subdirectory, namely +kenv.a65 and kinit.a65. The kinit.a65 +file is included in the kernel startup code, i.e. after setting +the interrupt flag and clearing the decimal flag this file is +executed, and it is expected that the +CPU gets out of this file at the end of it. +

+

kinit.a65
+

+This file must initialize the stack, the memory management and mapping of the +system ROM and RAM. +Then the system preemption timer must be set up. +When including kernel/zerotest.a65 and kernel/ramtest.a65 here +all the memory options from above are available. +Also the ramtest file returns the size of memory found in 256-byte blocks +in a. This value must be passed to the end of the init routine in this file. +

+In addition to this some Macros have to be defined, that are used +in the kernel later. +

+  	GETFREQ()	returns a=0 for 1Mhz, a=128 for 2MHz
+  	LEDPORT		address of LED port to signal hardware failures
+  	LED_LED		bit of LED bit in LEDPORT address
+  	H_ERROR()	if LEDPORT is not defined, then H_ERROR replaces
+    	                the LED toggle routine if needed.
+  	CLRTIMER()	clear the system preemption timer interrupt
+  	KERNELIRQ()	returns if an interrupt occured in the kernel
+     	                or outside. Is checked by "BNE IRQ_in_Kernel"
+  	SAVEMEM()	save system mem config for interrupt
+  	RESTOREMEM()	restore system mem config after interrupt
+  	STARTMEM()	This is used to alloc/enable memory pages found
+     	                during kernel init. Takes mem size in AC as given
+   	                by the kernel init. It is called _after_ inimem!
+
+For the most systems without MMU, most of these macros can be +taken from the C64 kinit.a65 file. +If you have a more complicated mapping, you can have a look at the +CS/A65 kinit.a65 file. +

+

kenv.a65
+

+The kenv.a65 file is included in another part of the kernel. +It is the part that maps the memory according to the environment +number for each task. +Several routines must be defined here: +

+	inienv		init environment handling
+	setthread	set active thread
+	initsp		init task for thread (no in xr)
+	push		push a byte to active threads stack 
+	pull		pull a byte from active threads stack
+	memtask		jump to active thread
+	memsys		enter kernel
+
+	getenv		get e free environment
+	freenv		free an environmen
+	sbrk		reduce/increase process memory in an environment
+
+	enmem		enable memory blocks for environments
+			(this kernel call is used for MMU systems and
+			heavily system specific)
+	setblk		sets a specific memory block in the memory map	
+			of the active task. Also for MMU systems only
+
+Also some macros must be defined: +
+	MEMTASK2()	This is equivalent to memtask above, but it
+			is used for returns from interrupt
+	MAPSYSBUF	maps the PCBUF of the active task to the
+			address given by SYSBUF in system memory
+	SYSBUF		mapped tasks PCBUF
+	MAPENV()	maps the address given in a/y in env x to somewhere
+			in the kernel map, returns mapped address in a/y
+	MAPAENV()	as MAPENV, but does it for actual env.
+	GETTASKMEM	returns (in AC) how much memory a task has
+			(task id in y)
+	CPPCBUFRX	copies PCBUF from other task (yr) to active one
+	CPPCBUFTX	copies PCBUF from active task to another one (yr)
+	CPFORKBUF()	copies the PCBUF from the FORK call to the task.
+	GETACTENV()	returns active environment in ac
+
+The full descriptions can be found in the C64 kenv file for example. +This may look complicated, but it isn't. If you have a simple 6502 system +without memory management, just copy (or set a link) to the C64 file. +If you have a more complicated system, have a look at the CS/A65 file. +

+


+

System Constants

+ +Terminal devices should understand the following terminal control codes +(But the currently implemented device driver doesn't understand them all, +though...) + +
+/*        Terminal Commands        */
+
+#define   TC_BEL    7		bell	
+#define   TC_BS     8		backspace
+#define   TC_HT     9		horizontal tabulator
+#define   TC_LF     10		line feed
+#define   TC_VT     11		vertical tabulator
+#define   TC_FF     12		form feed
+#define   TC_CR     13		carriage return
+#define   TC_ESC    27		Escape code
+
+#define   TC_CLFT   $80		cursor left
+#define   TC_CRGT   $81		cursor right
+#define   TC_CUP    $82		cursor up
+#define   TC_CDWN   $83		cursor down
+#define   TC_HOME   $84		cursor to the upper left edge
+#define   TC_CLR    $85		clear screen
+#define   TC_DEL    $86		delete char
+#define   TC_INS    $87		insert
+#define   TC_WLO    $88    	set upper left window corner by cursor pos
+#define   TC_WRU    $89  	set lower right window corner by cursor pos
+#define   TC_WCLS   $8a		clear window
+#define   TC_EOL    $8b		put cursor to the end of line
+#define   TC_CLL    $8c		clear rest of line from cursor
+
+#define   TC_ECHO   $8d		switch on local (device) echo mode
+#define   TC_NOECHO $8e		device only sends, application has to echo
+
+#define   TC_CPOS   $8f         next two chars are row and column of new 
+                                cursor position
+
+
+FORK, SETIRQ and TRESET can NO MORE be called via a SEND +system call, when +the receiver address is SEND_SYS and the message type is SP_* !! + +
+/*        SysProcCalls             */
+
+#define   PCBUF     $200
+
+
+ +STD* stream number are replaced by the numbers saved in the environment +struct. + +
+
+/*        StdStream                */
+
+#define   STDNUL         $fc       /* will be ignored (for FS STDIO)*/
+#define   STDIN          $fd
+#define   STDOUT         $fe
+#define   STDERR         $ff
+
+
+ +Reserved system environment numbers: + +
+
+#define   SEND_FM        $fe		/* filesystem manager */
+
+#define	  SEND_ERROR	 $fd		/* critical error handler */
+
+#define   SEND_TIME      $fc		/* set/get actual time */
+
+#define   SEND_NET       $fb            /* open network connections */
+
+
+ + diff --git a/dump/oa-2.0.9/doc/lib6502.html b/dump/oa-2.0.9/doc/lib6502.html new file mode 100644 index 0000000..719e350 --- /dev/null +++ b/dump/oa-2.0.9/doc/lib6502.html @@ -0,0 +1,1161 @@ + + + + lib6502 standard library + + + +

lib6502 standard library

+ +

Version 0.6 (26 january 1997)

+ +

+


(c) A. Fachat

+ +

This document consists of three parts, the Introduction, +the actual library interface definition and the Implementation +Notes. There also is an Index of the used function +names, as well as a section for ideas for the development. +Also acknowledgements are given.

+ +

Introduction

+ +

This file has been written to define a certain compatibility level between +different operating systems for 6502 computer. It defines, on a more abstract +level that can be fitted to different real OSes, an interface for system +services. The goal of this definition is, to be able to fit into various +different environments, like

+ +
    +
  • Computers like the C64 or the Gecko computer, with a single 6502, without +advanced memory management.
  • + +
  • Computers like the C128, with a more enhanced memory management (two +banks with 64kByte each, relocatable zeropage and stack)
  • + +
  • The CS/A65 computer, with a 6502 and a fully virtualized address management. +
  • + +
  • Computers with the 65816 CPU, for programs running in 8 bit emulation +mode.
  • +
+ +

The possible operating systems also differ in style and features:

+ +
    +
  • Single-tasking OSes, like the ones provided with the C64, or other +6502 computers (if interprocess communication and process management calls +are not used, lib6502 programs can even run on such a machine).
  • + +
  • 'Monolithic' multitasking systems, that have all system services in +the kernel
  • + +
  • Microkernel based OSes, that communicate with system servers via kernel +communication paths, providing this functionality to the program via the +lib6502.
  • +
+ +

This interface offers a common level for all these scenarios. Programs +written for this library can run on any of these platforms, a simple recompile +on the proprietary 6502 assembler/compiler will be enough. If people can +agree on a standard file format, not even recompiling might be necessary. +

+ +

In this library there still is a certain degree of freedom in the implementation. +System process IDs can still be 8 bit, as long as the library offers a +16 bit interface to the application. Memory allocation can still be pagewise +(in 256 byte blocks), as long as an application does not rely on that - +in other OSes it can probably allocate smaller chunks. The purpose of this +interface is, to hide the system OS behind. The application, on the other +hand, should never assume any implementation specifics, that are not documented +in this definition.

+ +

Most of the calls are modeled along the standard libc C library, but +there also are some calls from the Unix world.

+ +

This file does not make any assumptions about the implementation of +the calls, although the behaviour is (i.e. should be :-) noted as exactly +as possible. +


+ +

Library Interface definition

+ + + +

File interface

+ +

The file interface uses file numbers. These file numbers are valid in +the local environment, and need not be globally valid. But the lib6502 +always has to accept these numbers, and then tranforms them internally +wo whatever appropriate for the given OS. Of course an implementation where +both are identical should be better in performance.

+ +

file-nrs in lib6502 are treated as uni-directional or bi-directional +channels, i.e. an application can either read or write to a provided uni-directional +file-nr, and both at a time to a bi-directional file-nr. The OS can provide +bi-directional (with read/write operations possible on the same file-descriptor +in one task) or uni-directional (where a write to one end can be read from +the other end even in the same task.) file-descriptors. Only the latter +case is difficult. The stdlib must check the fileno and remap it to different +filenos for reading or writing.

+ +

When an application is started, three uni-directional file-nrs do already +exist and are open: STDIN, STDOUT, and STDERR. STDOUT gives the file-nr +for writing task output, STDERR is for error output, while STDIN is for +reading program input.

+ +

All open files are closed when the process terminates.

+ +
   fopen:       
+                <- a/y = address of null-terminated filename
+		   x   = file mode
+                        mode :  0 = read-only
+                                1 = write-only
+                                2 = read-write
+                                3 = append
+                -> c=0 : x = file-nr 
+                   c=1 : a = error code         E_NOTFOUND
+                                                E_PERMISSION
+                                                E_FNAMLEN
+                                                E_DIRECTORY
+
+ +

Files are named as: "Device:directory/filename", where Device +depends on the OS. There might be OSes where it's a single character (like +A: or 8:), others might have a real name. The lib needs to be able to parse +its own, implementation dependent namespace only. And the application should +not assume anything about the length of the device name. Directory separator +is "/". Escape sequence for the directory separator is "\/". +For the filename interpretation see the beginning of the directory +section. Character set is ASCII (i.e. all codes between 0x20 and 0x7f must +be useable, others are not allowed).

+ +

The filesystem might imply other limitations on filename length, if +there are directories at all, or the allowed characters. Wildcards are +"*" that match any string and "?" that match exacly +one character. The interpretation might depend on the filesystem, i.e. +may not even be the same on the same system, but on different devices. +Escape sequences are "\*" and "\?". Escape sequence +for "\" is "\\".

+ +

The mode byte can be one of the abovementioned, which map to

+ +
                OPEN_RD         0
+                OPEN_WR         1
+                OPEN_RW         2
+                OPEN_AP         3
+
+ +

Append means, that before any write to the file, the file pointer is +positioned at the end of the file. The mode can be or'd with some other +bits, like

+ +
                OPEN_TRUNC      $80     If the file already exists, it will
+                                        be truncated (when writing).
+                OPEN_EXCL       $40     Only one process may have this file
+                                        open at one time.
+                OPEN_NOCREAT    $20     Do not automatically create when 
+                                        writing (OPEN_WR, _RW, _AP).
+
+ +

Default is to automatically create the file when it does not exist and +it is opened for writing.

+ +
   fclose       
+                <- x = file-nr
+                Closes the given file-nr. Pushes all remaining data
+                to the receiver, and waits till it is written.
+                -> c=0 : everything ok
+                   c=1: a = error code          E_NOFILE
+                                                E_WERROR
+                                                E_NUL
+
+   fgetc        
+                <- x = file-nr
+                   c=0 : return immediately, c=1 : block till byte
+                -> c=0 : a = data byte
+                   c=1 : a = error code         E_NOFILE
+                                                E_EMPTY
+                                                E_EOF
+   fputc        
+                <- x = file-nr, a = data byte
+                   c=0 : return immediately, c=1 : block till byte
+                -> c=0 : ??
+                   c=1 : a = error code         E_NOFILE
+                                                E_FULL     (E_TRYAGAIN?)
+                                                E_NUL      (noone reads it)
+
+   fread        
+                <- x = file-nr, a/y = address of struct:
+                        .word address_of_buffer, length_of_buffer
+                   c = 0 : return immediately, even if nothing read or
+                           buffer only partially read.
+                   c = 1 : wait till buffer is full or EOF (or error)
+                -> c = 0 : ok
+                           struct given holds address+a/y, length-a/y,
+                           such that it can directly given to fread again.
+                   c = 1 : error code           E_NOFILE
+                                                E_EMPTY    (E_TRYAGAIN?)
+                                                E_EOF
+
+   fwrite       
+                <- x = file-nr, a/y = address of struct:
+                        .word address_of_buffer, length_of_buffer
+                   c = 0 : return immediately, even if nothing written,
+                           or buffer only partially written.
+                   c = 1 : wait till buffer is empty (or error)
+                -> c = 0 : ok
+                           struct given holds address+a/y, length-a/y,
+                           such that it can directly given to fwrite again.
+                   c = 1 : error code           E_NOFILE
+                                                E_FULL     (E_TRYAGAIN?)
+                                                E_NUL      (noone reads it)
+   fseek
+                <- x = file-nr, a/y = address of struct:
+                        .byt mode ; offset is relative to
+                                        0 = start of file
+                                        1 = end of file
+                                        2 = actual position
+                        .word 0,0 ; 32 bit offset
+                -> c = 0 : ok;
+                   c = 1 : error code           E_NOFILE
+                                                E_NOSEEK
+
+ +

fgetc and fread, and fputc and fwrite can be used interchangeably. fread/fwrite +don't guarantee that the whole buffer is really read/written, even with +carry set. For this, see fcntl below. +If fread returns an E_EOF there can still be bytes that +have been read during this call, so the returned struct has to be checked. +

+

When opening +a file read-write, then when changing between read and write, there always +has to be an fseek operation.

+ +

There are, however, files that cannot be seeked, namely character devices. +If trying to use fseek on such a device, E_NOSEEK is returned. If a seekable +file is given to STDIN and STDOUT/STDERR, the behaviour is not defined. +Only non-seekable files should be given to STDIN and STDOUT/STDERR, when +opened read-write.

+ +
    pipe        
+                -> x = file-nr for reading
+                   y = file-nr for writing
+
+                opens a uni-directional pipe with two file numbers,
+                one for writing, and one for reading. To close the pipe,
+                each end has to be closed separately.
+
+    flock       
+                <- x = file-nr
+                   a = operation: LOCK_SH, LOCK_EX, LOCK_UN
+                   c = 0: don't block
+                   c = 1: block till you get it
+                -> c = 0: ok, got lock
+                   c = 1: a = error code        E_NOTIMP
+                                                E_NOFILE
+                                                E_LOCKED
+
+ +

The flock call locks a file for other tasks access. If locked shared, +then other tasks may also aquire shared locks - for reading, for example. +An exclusive lock can only be aquired by exactly one task at a time - for +writing. An exclusive lock can not be obtained when there are other shared +locks, but a pending exclusive lock blocks all other attempts to lock it, +even for shared locks. The flock implementation should be fair, i.e. lock +attempts are served in the order they arrive, except that exclusive get +served before shared locks. The flock call is optional. If not implemented, +return E_NOTIMP

+ +
    fcntl       
+                <- x = file-nr, a = operation
+                        a = FC_PUSH     0  all buffers are flushed and sent
+                            FC_PULL     1  actively try to get everything 
+                                           that has already been sent
+                            FC_RCHECK   2  checks if there is data to read
+                            FC_WCHECK   3  checks if at least one byte can be
+                                           written.
+                -> c = 0: ok
+                   c = 1: a = error code        E_NOFILE
+                                                E_NOTIMP
+                                                E_NOREAD
+                                                E_NOWRITE
+
+ +

The fcntl return code should be ignored, as it is probably not implemented +in most of the systems, except for RCHECK/WCHECK calls of course.

+ +
    fcmd
+                <- x = operation, a/y = filename,0 [ , filename2, 0 ]
+                        x = FC_RENAME   16   filename -> filename2
+                            FC_DELETE   17
+                            FC_MKDIR    18
+                            FC_RMDIR    19
+                            FC_FORMAT   20   filename only to determine drive
+                            FC_CHKDSK   21    - " -
+
+ +

Other important calls are the stddup and the dup call.

+ +
    stddup
+                <- x = old stdio file-nr (STDIN, STDOUT or STDERR)
+                   y = new file-nr for stdio file.
+                -> c = 0: ok, x = old stdio file
+                   c = 1: a = error code        E_NOFILE
+
+ +

This call replaces a stdio file-nr (the pre-defined STDIN, STDOUT, and +STDERR file-nrs) with a new file-nr. The old file-nr must not be closed, +as it is when the process terminates. Instead the new file-nr returned +must be closed.

+ +
     dup
+                <- x = old file-nr
+                -> c = 0: ok, x = new file-nr
+                   c = 1: a = error code        E_NOFILE
+
+ +

This call 'reopens' a file, i.e. it returns a new file-nr that is used +as the old one. They share the same read/write pointers etc. Both file-nrs +must be closed. This way the same file can be given to STDOUT and STDERR +in a fork call, for example.

+ +

If dup is given a read-write file-nr, both sides are duped and the returned +file-nr is bi-directional again.

+ +

+


+ +

+ +

Directory Interface

+ +

The library maintains a path that is used for each file system operation. +If a filename does not start with a "/" and not with a drive, +the path is put in front of the filename. If the filename starts with a +drive, it is always taken as an absolute filename, even if the "/" +is missing. If only the drive is missing, it is taken from the path.

+ +

A special case is the directory call with a filename as "*:". +It does not use the path, but returns, in each entry, an available device +name. The length attribute should give the available amount of storage +space on the device. A wildcard in the device field is not allowed otherwise. +

+ +
    fopendir    
+                <- a/y = address of filename
+                -> c = 0: ok, x = file-nr
+                   c = 1: a = error code                E_NOFILE
+                                                        E_NOTDIR
+
+    freaddir    
+                <- x = file-nr a/y = address of buffer
+                       blocks until read, otherwise use fcntl(FC_RCHECK)
+
+                reads _one_ directory entry into the buffer, which is
+                of length (FD_NAME + MAX_FILENAME)
+                One entry consists of a directory struct
+
+                .word   0               ; valid bits
+		.word	0		; owner ID
+		.word	0		; group ID
+                .word   0               ; permissions (drwxrwxrwx) (2 byte)
+                .word   0,0             ; file length in byte (4 byte)
+                .byt    0,0,0,0,0,0     ; last modification date
+                                        ; (year-1990, month, day, hr, min, sec)
+
+                The valid bit say, which entry in the struct is valid.
+                bit 0 is for the permissions, bit 1 for the file length, bit 2
+                for the date. The file length, if not zero, is an 
+                approximate value (like the blocks *254 in a vc1541)
+                this struct is followed by the null-terminated filename.
+		The valid bits are:
+
+		FDV_PERM	1
+		FDV_LENGTH	2
+		FDV_MDATE	4
+		FDV_OWNER	8
+		FDV_GROUP	16
+
+		If permissions are valid, but not group/owner, then 
+		the permissions for user and group are invalid, and the 
+		permissions for others should be taken.
+
+		The directory entry struct definitions are:
+
+		FD_VALID	0	/* 1 byte */
+		FD_PERM		1	/* 2 byte */
+		FD_LENGTH	3	/* 4 byte */
+		FD_MDATE	7	/* 6 byte */
+		FD_NAME		13	/* null-terminated */
+
+		The permission bits are actually a copy from the Linux
+		man pages...:
+
+                S_ISUID         $800    /* set user ID on execution */
+                S_ISGID         $400    /* set group ID on execution */
+                S_ISVTX         $200    /* -- (sticky bit) */
+
+                S_IRWXU         $1c0    /* rwx mask for user */
+                S_IRUSR         $100    /* read by owner */
+                S_IWUSR         $080    /* write by owner */
+                S_IXUSR         $040    /* exexute by owner */
+
+                S_IRWXG         $038    /* rwx mask for group */
+                S_IRGRP         $020    /* read by group */
+                S_IWGRP         $010    /* write by group */
+                S_IXGRP         $008    /* execute by group */
+
+                S_IRWXO         $007    /* rwx mask for others */
+                S_IROTH         $004    /* read by others */
+                S_IWOTH         $002    /* write by others */
+                S_IXOTH         $001    /* execute by others */
+
+                S_IFMT          $f000   /* file type mask */
+                S_IFSOCK        $c000   /* socket */
+                S_IFLNK         $a000   /* symbolic link */
+                S_IFREG         $8000   /* regular file */
+                S_IFBLK         $6000   /* block device */
+                S_IFDIR         $4000   /* directory */
+                S_IFCHR         $2000   /* character device */
+                S_IFIFO         $1000   /* fifo */
+
+		S_IFMNAME	$3000	/* media name */
+		S_IFMFREE	$5000	/* free are on media */
+		S_IFMSIZE	$7000	/* media size */
+
+		Most of the file types are probably not implemented
+		on a 6502 system. But before defining new types, one
+		should keep the already defined values save.
+		That's for the last three entries, which are not 
+		Posix standards.
+
+		The length field can be an approximate if it is not zero
+		and the length is not valid (For VC1541 block lengths).
+
+    fgetattr    
+                <- a/y = address of dir struct, incl filename (like in freaddir)
+                -> c = 0: ok,
+                   c = 1: a = error code        E_NOTIMP
+
+                This tries to fill in the bits that are _not_ valid in a
+                dir struct. For example, if freaddir returned
+                the filelength only, but no permissions, then calling
+                fgetattr should get the file permissions.
+                But it is not guaranteed, that all fields are filled,
+                as some are not implemented on a certain filesystem.
+                So even after fgetattr, a check of the valid bits is needed.
+                The filename must be completed with the device and path.
+
+    fsetattr    
+                <- a/y = address of dir struct, incl. filename
+                -> c = 0: ok
+                   c = 1: a = error code        E_NOTIMP
+
+                Tries to write new file attributes (the ones where the
+                valid bits are set). Need not succeed. Clears the valid bits
+                for the attributes it has successfully set.
+                The filename must be completed with the device and path.
+
+    chdir
+                <- a/y = address of new path, relative to the old one
+                -> c = : ok
+                   c = 1: a = error code        E_ILLDRIVE
+                                                E_ILLPATH
+    cwd
+                <- a/y = address of buffer, x = length of buffer
+                -> c = 0: ok, buffer contains the current working directory.
+                   c = 1: a = error code        E_NOTIMP
+                                                E_FNAMLEN
+
+ +

The chdir call changes the saved path in the library. A "." +filename means the same directory, while ".." means the parent +directory.

+

cwd gives the address of the path. However, the path pointed to by +the returned address must not be changed.

+ +

Network Interface

+ +

Network streams are used as well as any other file, so we only need +opening calls. Currently only TCP/IP is defined and thought of, but there +should be no problem allowing other networks.

+ +
    connect     
+                <- a/y address of : byte length of address (incl. length byte), 
+                   plus 4 byte inet addr (+2 byte port for TCP/UDP)
+                   x = protocol (IPV4_TCP, IPV4_UDP,...)
+                -> c = 0: x = (non-seekable, bi-directional) file-nr 
+                          for read/write
+                   c = 1: a = error code        E_NOTIMP
+                                                E_PROT
+                                                E_NOROUTE
+                                                E_NOPERM
+
+    listen
+                <- c = 0: a/y = addr of: 
+                             byte length of port, 2 byte port number 
+                             (for TCP/UDP on IP)
+                          x = protocol
+                -> c = 0: ok, x = listenport
+                   c = 1: a = error code        E_NOTIMP
+                                                E_PROT
+                                                E_PORTINUSE
+                opens a port to listen at
+
+                <- c = 1: x = listenport 
+                -> c = 0: ok
+                   c = 1: a = error code        E_NOTIMP
+                                                E_NOPORT
+                closes the listenport again.
+
+
+    accept      
+                <- a/y = address of buffer for struct:
+                         1 byte length of buffer (incl. length byte),
+                         the rest of the buffer need not be set.
+                         for IPV4 TCP and UDP we need place for:
+                           4 byte IP address + 
+                           2 byte port, 
+                   x = listenport
+                   c = 0: don't block
+                   c = 1: block
+                -> c = 0: x = file-nr for read/write
+                   The buffer contains the address that the remote 
+                   machine uses. The 1st byte contains the length of the 
+                   address (should not differ from the length indicated
+                   by the protocol number in listen.
+                   c = 1: a = error code                E_NOTIMP
+                                                        E_ADDRLEN
+                                                        E_NOMEM
+                                                        E_TRYAGAIN
+
+ +

connect is something like Unix socket() and connect() together. listen +is something like socket(), bind() and listen() together. listen tells +the network layer, that the application is going to accept connections +on a certain port. Therefore, when a connection is requested from remote, +the network layer can accept them already and hold them "on line" +until the task gets the connection with accept. The maxmimum number of +acceptable connections is implementation specific.
+accept gets the first connection waiting for an accept. the other sides +IP and port are stored in the buffer given in a/y If a connection is refused +after checking IP or port, the 'accepted' connection should be closed immediately. +

+ +

Memory Management

+ +

It is possible to have an allocation at byte boundaries, or at page +boundaries - an application does not have to rely on a certain alignment! +

+ +
   malloc       
+                <- a/y length of block needed
+                -> c=0: a/y address of block allocated
+                   c=1: a = error code          E_NOMEM
+
+   mfree        
+                <- a/y address of block released
+                -> c=0: ok
+                   c=1: error code              E_ILLADDR
+
+   realloc
+                <- a/y address of block, x position of new length
+                   in zeropage (2 byte)
+                -> c=0: ok
+                   c=1: error code              E_ILLADDR
+
+
+ +

Allocated memory blocks are automatically freed on process termination. +

+ +

Process Management

+ +

Process management is a bit more complicated. Process ID interface is +16 bit, although they need not all be used, of course.

+ +
   exec         
+                <- a/y = addr of filename,0 [, parameter1, 0 ...] ,0
+                -> if no error, then the new program starts and gets
+                        a/y = address of filename,0 [, parameter1, 0 ...],0
+                        otherwise return:
+                   c=1: a = error code          E_NOTFOUND
+                                                E_NOMEM
+                allocates new environment and removes old environment.
+                starts newly loaded executable file.
+
+   forkto    
+                <- a/y addr of struct: '.byte STDIN, STDOUT, STDERR, exec_struct
+                -> c=0: x/y = child pid
+                   c = 1: a = error code        E_NOMEM
+                                                E_ILLSTR
+                                                E_NOTFOUND
+
+                This is not really a fork like in Unix, but it creates a
+                new process, so it still 'forks'. The new process is 
+                started with executing the file given in the exec_struct
+                - which is the same struct as given to exec.
+                The file-nrs given for STDIN, STDOUT and STDERR share the same
+                read/write pointers as the ones in this process.
+                They are internally 'duped', and the calling task has to 
+                close them after calling forkto. No other file-nos are 
+		inherited.
+
+   forkthread
+		<- a/y addr of execution for new thread
+                -> c = 0: ok, xr = new thread number
+                   c = 1: a = error code        E_NOTIMP
+
+		forkthread sets up a new thread to run in the same
+		memory environment as the calling thread/process.
+		The new thread is started at the given address, with
+		an empty stack. This means the thread has to explicitely
+		call term when terminating.
+
+   term         
+                <- a = return code
+
+   kill         
+                <- a = return code, x/y = pid (or MYTASK = myself -> suicide)
+                -> c=0: ok (except for MYTASK)
+                   c=1: a = error code          E_ILLPID
+
+ +

The term call terminates the current thread only. The memory etc is +only freed when all threads in this environment have terminated. Kill terminates +all threads in the environment indicated by the process ID.

+ +
   getpid       
+                -> x/y = own PID
+
+ +

When forking, the files still share the same seek pointer (address in +the file where they read/write). When one process writes to a file, the +other processes write pointer moves on too, same for the read pointer. +Otherwise file sharing with the 1541 would be impossible, for example. +

+ +

STDIN/STDOUT and STDERR file-nrs appear to be opened before process +start. They can be closed as any other file, though. When calling forkto, +the file-nrs given to it are `duped' internally, such that they have to +be closed in the calling process, as well as in the newly created process. +

+ +

All files opened by this task are closed when it terminates. All memory +blocks allocated by this task are freed when it terminates.

+ +

The newly created process is started by calling the "main" +function, with a/y pointing to a list of arguments:

+ +
        .byt "arg0",0, "arg1",0, ... ,"argn",0,0
+
+ +

The "main" function can either call "term", "kill" +or return with a "rts" opcode.

+ +
   yield       
+
+

yield gives the process control back to the scheduler. It need +not be called at all. But if a process is doing a busy loop (or spin-lock) +waiting for a certain condition, it might call yield to give +other tasks the opportunity to run. It is not necessary to call +yield at all! The scheduler interrupts any thread and +takes control back when the thread has used its timeslice. But if the thread +knows that it waits for something to be done by another task, instead +of waiting for the end of its timeslice it can call yield to give other tasks +the immediate opportunity to run. +

+ +

Interprocess Communication

+ +

Interprocess communication heavily depends on the system underneath +the library, so it's not that easy. So far we handle semaphores, signals, +and send/receive.

+ +
Semaphores
+ +
    semget      
+                <- c = 0: don't block, c = 1: wait till you get one
+                -> c = 0: ok, x = semaphore number
+                   c = 1: a = error code        E_NOTIMP
+                                                E_NOSEM
+                gets a new semaphore 
+
+    semfre      
+                <- x = semaphore number
+                -> c = 0: ok
+                   c = 1: a = error code        E_NOTIMP
+                                                E_NOSEM
+                                                E_INUSE
+                releases a used semaphore. If a process is waiting for
+                the semaphore, returns E_INUSE
+
+    semgetnamed 
+                <- c = 0: a/y = name of semaphore
+                          x = 0 : if not found, return error,
+                          x = 1 : if not found, alloc name and return ok
+                -> c = 0 : ok, x = semaphore number
+                   c = 1 : a = error code       E_NOTIMP
+                                                E_NOTFOUND
+                                                E_NOSEM
+                This calls tries to allocate a 'named' semaphore.
+                If the name already exists, the associated semaphore number
+                is returned. If the name doesn't exist, and x=0, then an
+                error is returned. If a name doesn't exist, and x=1, then
+                the new name is allocated, a semaphore is allocated and
+                associated with the name.
+
+                <- c = 1: a/y = name of semaphore
+                -> c = 0: ok
+                   c = 1: a = error code        E_NOTIMP
+                                                E_NOTFOUND
+                The named semaphore is de-allocated. The named semaphore
+                handler counts the number of allocations and frees a semphore
+                if the name is totally deallocated.
+
+                With this call, one can system-independently allocate
+                system and hardware resources, if they are protected by 
+                semaphores. 
+                predefined semaphore names are:
+
+                        SEM_C64_SERIEC, SEM_C64_PARIEC, SEM_C64_SID,
+                        SEM_C64_VID, SEM_C64_KEYBOARD,
+                        SEM_C64_CIA1TA, SEM_C64_CIA1TB, SEM_C64_CIA1TOD,
+                        SEM_C64_CIA2TA, SEM_C64_CIA2TB, SEM_C64_CIA2TOD,
+
+                        SEM_CSA_SERIEC, SEM_CSA_PARIEC, SEM_CSA_WD1770,
+
+                        SEM_GECKO_SERIEC, SEM_GECKO_IRTX
+                        
+                
+    psem        
+                <- x = semaphore number
+                   c = 0: don't block; c = 1: wait till gotten
+                -> c = 0: got semaphore
+                   c = 1: a = error code        E_NOSEM
+                Pass operation on a semaphore. Locks the semaphore.
+
+    vsem        
+                <- x = semaphore number
+                Free operation on a semaphore. Lets other threads "pass".
+
+
+ +

+ +
Signals
+ +

Signals are some kind of 'remote procedure call' - a signal handler +for a certain signal is called upon another threads' request.

+ +
    signal      
+                <- x = signal-number
+                   a/y = address of signal handler
+                -> c = 0: ok
+                   c = 1: a = error code        E_NOTIMP
+                                                E_ILLSIG
+                installs a signal handler for a signal
+                signal handler address NULL de-installs a handler.
+
+    sendsignal  
+                <- a/y pid of receiving process
+                   x = signal number
+                -> c = 0: ok, sent
+                   c = 1: a = error code        E_ILLPID
+                                                E_ILLSIG
+                sends a signal to another process. A signal is an emulated
+                interrupt to the address specified as the signal handler
+                address.
+
+ +

Allowed signals are

+ +
                SIG_USR1
+                SIG_USR2
+                SIG_USR3
+                SIG_USR4
+		SIG_CHLD
+
+ +

The signal handler gets the signal mask for the signal in ac +(They may or may not be combined if the same signal handler is used for +more than one signal type).
+A SIG_CHLD is used to get information about child processes +that died. If it is received, the +xr/yr registers holds the PID of the dead child and ac holds the return +code of the child. Only child processes are registered that died when the +signal handler mask was set. You can only receive, but not send a +SIG_CHLD. +

+ +
Send/Receive
+ +

This section is very preliminary, as the SEND/RECEIVE interface in OS/A65 +is not really useable without MMU, and Lunix doesn't have SEND/RECEIVE. +

+ +
    send        
+                <- a/y = address of 
+                        .word receiver_pid
+                        .word address_of_data
+                        .word length_of_data
+                   c = 0: don't block
+                   c = 1: wait till accepted
+                -> c = 0: block sent
+                   c = 1: a = error code        E_ILLPID
+                                                E_NOTIMP
+                sends a message to another process. The data sent is not
+                changed, or freed or whatever.
+
+    receive     
+                <- a/y = address of three words, second and third word
+                         give address and length of receiver buffer
+                   x = 0 : accept any sender
+                   x = 1 : first word in (a/y) contains the sender 
+                   c = 0 : don't block
+                   c = 1 : wait till received
+                -> c = 0 : message received, (a/y) has
+                        .word sender_pid
+                        .word address_of_data
+                        .word length_of_data 
+                   c = 1 : a = error code       E_NOTIMP
+                                                E_ILLPID
+                                                E_NOMEM
+                The data is stored in the buffer, and length_of_data is
+                changed to the length actually received. If the buffer
+                is too short, length_of_data is set to the length needed,
+                and E_NOMEM is returned.
+
+
+ +

+


+ +

Environment Handling

+ +The process environment is a table of strings handled by the lib6502 +on a per-task basis. When a task forks a new task, the environment +is inherited by the new task. Strings here are null-terminated ASCII +character arrays. + +
+    getenv: 
+                <- a/y name of env. variable
+                -> a/y = address of value or NULL if not set. 
+
+    putenv: 
+                <- a/y addr of "name=string" 
+		-> c=0: ok
+		   c=1: error			E_NOMEM
+						E_NOTIMP
+		add or change env var. If the variable is empty, it is
+		unset and will return either a NULL pointer with getenv
+		or a pointer to an empty string.
+
+    getenvp: 
+                -> a/y addr of null-terminated list of null-terminated
+                strings with "varname=value" in each string, describing
+                all environment variables. It is NOT allowed
+                to change these variables 'by hand'.
+
+    getos:
+                -> a/y addr of operating system string
+
+

+The operating system string is a string containing the +

    +
  • operating system name (OS/A65) +
  • operating system version (2.0.0) +
  • CPU type (6510) +
  • architecture type (C64) +
  • library type (lib6502) +
  • library version (0.6) +
+separated by spaces and ended by a nullbyte. +
+

Implementation Notes

+ +

Implementation notes are currently available for the o65 +file format only. This file format is rather flexible, and some of the +ideas can be taken for other lib6502 file formats.

+ +

o65 file format

+ +

The o65 file format is defined in another file format specification. +It allows the use of undefined references. In order to simplify the relocation +procedure, lib6502 files have one undefined reference, namely "STDLIB". +This reference defines the base of the lib6502 jump table. At STDLIB+0 +there is a JMP opcode pointing to the code for fopen. At STDLIB+3 is a +JMP opcode pointing to the code for fclose etc. The order is determined +by the order given in the index of this definition.

+ +

A global variable is the "main" address, which is the start +address for any lib6502 executable. If the "main" address is +not given in the object file as a global variable, the start of the text +segment is assumed to be the "main" address.

+ +

The lib6502 file format allows the use of "header options", +where some OS specific options may be saved. The lib6502 files can - but +don't need to - use a lib6502 header option (as defined in the o65 file +format specification). This lib6502 header option contains the following +struct:

+ +
        .byt lib6502_major_version_nr, lib6502_minor_version_number
+        .byt lib6502_needed_level, lib6502_possible_level
+
+ +

The version numbers are hints as to which library version the file is +compiled with. The level is a new number that describes which functions +are used, and which are not. A library may provide a certain amount of +lib calls in the library call table (STDLIB). The maximum number of calls +used is given in the "possible_level" value. The maximum number +that must be functional (and with only few exceptions not just return "E_NOTIMP") +is given by the "needed_level" number.

+ +

The level numbers are defined as:

+ +
    +
  • Level 1: fopen - chdir
  • + +
  • Level 2: connect - accept
  • + +
  • Level 3: malloc - mfree
  • + +
  • Level 4: exec - getpid
  • + +
  • Level 5: semget - receive
  • +
+ +

If the file needs a Possible Level greater than the level provided by +the library, an "E_LIBLEVEL" error code should be returned by +forkto or exec. +


For example, a program that needs the file functions, and can optionally +(i.e. if available) use the exec and fork calls, should have "1" +as a Needed Function, and level 4 as Possible Functions.

+ +

Index

+ + + + + + + + + + + + + + + +

+


+ +

Ideas

+ +
    +
  • service numbers conversion from text to number by generalized getxxxfromname? +
  • + +
  • listen + accept to _one_ call with local space for remote address? +
  • + +
+ +

+


+ +

Acknowledgements

+ +

Acknowledgements go to

+ +
    +
  • Daniel Dallmann, author of Lunix, for discussions and comments on the +library
  • + +
  • Craig Bruce, the author of ACE, for some comments and bugfixes
  • +
+ + + diff --git a/dump/oa-2.0.9/doc/mon.html b/dump/oa-2.0.9/doc/mon.html new file mode 100644 index 0000000..ac23a83 --- /dev/null +++ b/dump/oa-2.0.9/doc/mon.html @@ -0,0 +1,79 @@ + + OS/A65 Machine Language Monitor + +

OS/A65 Machine Language Monitor

+

(c) 1989-98 Andre Fachat

+

+This machine language monitor owns the most standard commands together +with some interesting features taken from my C64 +assembler and some commands to +do system calls easier.
+All addresses and data bytes can be given in hex, decimal (with +preceding "."), octal (with preceding "&") or in binary (with +preceding "%"). The output of the commands M, B, R, D, G and C can +be piped to a file with "> filename", like in the shell. +

+

+X		exits monitor (goes to shell)
+D a b		disassemble from address a to b
+B a b		binary list
+M a b		hex dump
+R		shows register contents
+; a mnem
+A a mnem	assembles 6502 mnemonic to address a
++ pc ac xr yr sp sr
+		sets registers to a new value. a "-" instead of a 
+		value leaves the register unchanged
+E a b		exchanges environment block a (the a'th MMU register) with
+		with memory block b
+S "name" a b	save memory from a (included) to b (not included)
+		in file "name". The first two bytes in the file are the 
+		memory address
+G a		Goto address (executes a JSR)
+L a b		reads b bytes from STDIN and saves them at address a
+L "name" a	Load file "name" to address a or the included load 
+		address if a is left out
+C a b c		Compare memory area from a to b with the area starting at c
+T a b c		Transfer (copy) memory from a to b to the address c
+O a b c		Occupy (fill) memory from a to b with c
+P a b c		sets system parameter: a becomes the standard drive (for
+		load/save), b is the number of bytes printed in a line
+		with hex dump and c becomes the number of available 
+		memory blocks (a 4kByte) for this task. A "-" leaves the
+		value unchanged.
+U a b c d e	change in the memory area from a to b all three byte 
+		assembler opcode addresses pointing to the area between 
+		c and d to the area starting at e
+I a b c ...
+, a b c ...	writes bytes b, c, ... into the memory at address a
+F a b string	tries to Find the string (which is mixed from bytes, 
+		separated by spaces and strings, enclosed in double quotes)
+		in the address area from a to b
+FA a b addressing
+		search all assembler codes in memory from a to b, that have
+		the given addressing mode: "FA a b (**AB)" means to search
+		all absolute indirect addressing modes with low byte
+		equal to $AB
+FR a b		search for relative jumps
+F- a b c	search in memory from a to b for bytes that are not equal to c
+
+YD a b c	DEVCMD with device a, command b and parameter c
+YM		GETMEM
+YF a		FREMEM memory block a
+YS		GETSTR
+YR a		FRESTR stream a
+YE		GETENV
+YP adr env stdin stdout stderr
+		FORK
+YW sem		PSEM
+YV sem		VSEM
+YG a		tries to get memory block a with GETBLK
+YC d:mask	show directory
+
+

Memory Map

+The shell and the monitor both use the zeropage addresses +from 64-128 ($40-$80) and memory addresses from 768-1024 ($300-$400). +In addition to this, of course the stack ($0100-$01ff) and the PCBUF +Send buffer ($0200-$02ff) are being used. + + diff --git a/dump/oa-2.0.9/doc/nommu.html b/dump/oa-2.0.9/doc/nommu.html new file mode 100644 index 0000000..2ff8b60 --- /dev/null +++ b/dump/oa-2.0.9/doc/nommu.html @@ -0,0 +1,78 @@ + + OS/A65 Operation without MMU + +

OS/A65 Operation without MMU

+

(c) 1989-98 Andre Fachat

+

+Using OS/A65 without an MMU used to require some special measures. One of it +was to coordinate all running tasks concerning their memory usage.
+With the new relocatabel o65 fileformat the lib6502 implemetation +takes care of that. +

+This means when building lib6502 programs, you do not have to actively +care about the stuff below, but it is probably good to know anyway. +

+There is one thing that's difficult to handle on a 6502, the stack. +It's only 256 byte large (small that is...). And with a multitasking +OS the stack has to be used by several programs at the same time. +One approach is to copy the stack contents to another place every time +a task switch is done. But that's a big speed penalty. +Instead I split the stack into 6 pieces, 5 of them for a task and the +last one for the system. So on a system without MMU, only five tasks +can be running concurrently. +

+With version 1.3.9 we got a new config option, STACKCOPY. With this option +the stack of a task is saved in some save area when doing a task switch. +This is slower, but allows much more stack space in a task and much more +tasks. +

+There is one other thing that cannot easily be coordinated - the SEND buffer. +This buffer is used for communication with the kernel. As +OS/A65 originated from a system with MMU, there was no real need not to +use an absolute address for the buffer, +thus saving registers for other purposes.
+For all systems now the usage of the SEND buffer +has to be coordinated between the tasks. Therefore +a system semaphore is used. +

+#define	SEM_SENDBUF	<-1
+

+Before accessing the SEND buffer at $02**, the task has to allocate +it with a PSEM operation on the SEM_SENDBUF semaphore. +After the system call, it has to be freed with a VSEM operation. +

+Well, and here we are with the known resource allocation problem. +Imagine two tasks communicating via send/receive. Then, if the order +in which messages are sent is not fixed and therefore predictable, +precautions against a lock have to be taken: task 1 allocating the +send buffer to send a message to task 2. The same time task 2 tries +to allocate the send buffer to send a message to task 1. If it not +tries to receive messages while waiting for the semaphore, it will lock. +
+Therefore the filesystems, for example, do not release the send buffer +while executing a command or open a file. In the meantime another +task could send a message to the filesystem, locking the send buffer. +But the buffer is needed by the filesystem to send the reply message. +The filesystems in their current form are not prepared for this situation, +so that they don't release the send buffer. +

+Be careful when using the send buffer - you are warned! +

+ +The lib6502 library is thread-save. It can be used by any thread at any +time. Internal locks (semaphores) are used to avoid any interference if +necessary. +

+
+Suggested reading: "Operating Systems, design and implementation", Andrew S. +Tanenbaum, Prentice-Hall + + diff --git a/dump/oa-2.0.9/doc/oa1.html b/dump/oa-2.0.9/doc/oa1.html new file mode 100644 index 0000000..8edcb73 --- /dev/null +++ b/dump/oa-2.0.9/doc/oa1.html @@ -0,0 +1,656 @@ + + OS/A65 Multitasking OS for 6502 + +

OS/A65 Multitasking OS for 6502

+

(c) 1989-96 Andre Fachat

+
+

+This is the description of a small operating system for the 6502 CPU. +It is a microkernel design, with preemtive multitasking, without +memory protection and swapping though. With a page mapped MMU the +different tasks are paged out and memory up to 1 MByte is supported. +Available software includes a shell with piping and I/O redirection, +filesystems for (Commodore serial and parallel) IEEE488 interface, +as well as for PC-style disks. Devices can be handled as files as well. +A BASIC interpreter has been ported from the C64. +A version for the C64 is available with version 1.3.5. +

+A description of the kernel interna, the kernel interface and the +standard library is given. +Some of the devices and filesystems are introduced. +

+

+

Overview

+OS/A65 has been written from somewhere in 1989 or 1990 up to the end of 1992 +and is currently in version 1.35. It runs on a selfbuilt 6502 computer +with (or without) a 74ls610 MMU to allow task paging. +

+This system has been written for a special 6502 computer, as described +below. But then the kernel is completly hardware independent, +device drivers doing all the hardware interface stuff. +A special MMU is used to allow task paging, which gives lots +of interesting features. A version for computers without MMU +is available, though. In this version the different tasks +have to be cooperative, in that different zeropage/RAM addresses +have to be used. +

+All tables, like environment tables, or streams etc are static, i.e. +their sizes are fixed at compile time. Otherwise a very sophisticated +memory allocation/free handler for kernel memory would have been necessary. +This would have used much of the CPU power and of the system RAM for +administrative needs only. I didn't want this. +

+If an IRQ occurs, the current process is marked interrupted and +the next runnable task is being started, thus providing preemptive +multitasking. A simlpe round robin scheduler is being used. +No threads are available, as the CPU needs to have its stack +in $01xx in memory. The non-MMU version is a kind of threaded +system, as the memory is the same for all tasks, but the stack +at $01xx being divided into several parts for the different tasks. +

+The MMU maps memory pages of 4k size. The kernel is within the uppermost +4k, to include the 6502 Reset, IRQ and NMI vectors. I/O ports are +mapped to $e800 to $efff. The rest of the memory can be mapped from +the maximum total available memory of 1 MByte in 4k Blocks. +Each task has its own memory environment, i.e. has its own view of the +memory. It communicates with the system only by the means of kernel +calls. Therefore the kernel provides a message-sending interface, as well +as simple signals and semaphores. +

+Data transfer is done via 128 byte sized fifos, called streams. The +stream management as well as the memory manager are within the kernel, +although it wouldn't be necessary. For performance reasons the filesystem +manager is in the kernel as well. It dispatches the messages sent to +the filesystem to registered filesystem tasks. +

+The system structure looks like the following diagram. +

+
+    ---------- --------- --------- ------ -------
+    |  fsdev | | fsiec | | fsibm | | sh | | mon | tasks...
+    ---------- --------- --------- ------ -------
+    ---------------------------- -------------- ----- ---------- --------
+    |          |               | |    fsm     | |   | |        | |      |
+    |          |      env      | -------------- |   | |        | |      |
+    |          |               ------------------   | | stream | | mem  |
+    |          |                                    | |        | |      |
+    |          -------------------------------------- |        | |      |
+    |             devices                           | |        | |      |
+    ------------------------------------------------- ---------- --------
+    --------- ------- ----------- ---------- 
+    | video | | par | | spooler | | serial | devices...
+    --------- ------- ----------- ---------- 
+
+
+

+The CS/A hardware consists of several boards, one for the CPU and MMU, +one for the ROM, 32k RAM and +some basic I/O hardware. A video board with 64k RAM gives PAL +(european video standard, as opposed to NTSC) b/w video output. A high +resolution mode is available. There is a standard PC floppy drive +interface, two serial interfaces (unfortunately without fifo), a +parallel printer output, a keyboard interface, and a parallel IEEE 488 +interface. A serial - Commodore compatible - IEC bus interface is +available as well. +Most interfaces, i.e. chip addresses and I/O connections are compatible +to the old Commodore CBM 3032 computer. Some things have been changed +to avoid connections between different boards, though (A 3032 emulator +is working). +And of course new interfaces have been added, e.g. an infrared LED to +control audio or other equipment by infrared commands. +A special interface card and cable allows to replace a 6502 in an existing +computer and make its 64k memory part of the CS/A memory. +

+ +

Kernel

+The size of the kernel is 4 kByte and it is located at $f000 in +CPU address space. Kernel entry takes place with an IRQ, an NMI +or via kernel call. These calls take place via a jumptable +located at $f000, the beginning of the kernel. +

+

Kernel entry/exit

+It is possible to get into the kernel through an CPU interrupt or a +direct kernel call. After an IRQ the CPU registers are saved on the +stack and the kernel is entered via a special routine 'memsys'. +This transparent (i.e. no registers except stack pointer are changed) +routine switches from Task environment to system memory environment. +Each kernel call has, as one of the first instructions, a call to this +routine to enter kernel address space. A similar routine, 'memtask', +is called at kernel exit to enter task memory space. +

+

Task Handling

+A task can be described by the memory map it is using and the CPU registers. +Interrupting a task and saving this information allows to restart the task +later. Here, in addition to this, a task has some additional properties. +The mapping of the STD* streams is saved in the environment table as well +as an optional task interrupt routine (if enabled at compile time). +The task status shows if a task is blocked, interrupted, runnable +or has executed a BRK opcode (which stops the task). +No resource bookkeeping is done. A task has to release all resources +it has allocated by itself, except for the STD* streams. +

+GETENV allocates a new environment struct in the kernel (which +can be freed with FREENV). With SETBLK the MMU mapping of +bus address space to CPU address space for an environment can be +manipulated. READ and WRITE allow other tasks to manipulate the +contents of another environments memory. +

+With FORK an environment then becomes a task, i.e. +starts to live. TERM and KILL allow the task itself or another task +to remove the task and free the environment struct. WTERM waits until +a task has terminated. TRESET resets the PC of a (running) task to +another address (really dirty trick...). +

+GETINFO gives an overview of how many tasks are in use and what is +their status. At the moment a maximum of 16 tasks (with MMU) is +possible. +

+

Device Management

+Devices are a different kind of object. They have their memory +mapping as well, it just simply consists of one memory page. +Then devices are not really running tasks but they are +waiting for a message, that is passed through the DEVCMD system call. +The DEVCMD call registeres new devices and provides an interface to +the devices. When calling a device, the device memory mapping is +established and the device entry point is called as a subroutine. +After the return the control goes back to the calling task. +The DEVCMD interface is even reentrant: the video device allows +interrupts to occur during device execution so that, for example, +serial devices can be served without loosing characters (Of course +the video device itself has a mutex construct builtin to avoid +confusion). +

+

Memory Management

+The memory management routines are independent from all other +routines. For performance reasons they are in the kernel and not +put into a separate task. At startup no memory is available. +The kernel then tests the memory, gets its size and calls ENMEM +to register usable RAM to the memory handler. The video +driver does the same at startup when adding the video RAM to the +system. GETMEM can then be used to get a free block of RAM. +GETBLK tries to allocate a specific memory block where, for example, +some special hardware like the video buffer is mapped in. +FREMEM releases an allocated memory block. According to the system +hardware a set of 256 memory blocks can be handled, which make up +1 MByte of memory. The memory routines can not be called from within +an interrupt. +

+

Stream Management

+Streams, as this word is used here, are 128 byte FIFO buffers to allow +easy data transfer. The stream routines can be called from within an +interrupt. Each stream counts how many tasks are writing and reading +from it. If both counters are zero, the stream is free. If only one is +empty, special return codes are generated to indicate the situation. +At a fork, for example, the number of writing tasks is incremented for +STDOUT and STDERR, while the number of reading tasks is incremented +for STDIN. After a task has exited, the STD* counters are decremented. +A filesystem listening on the tasks STDOUT stream then +gets the return code E_EOF, because no task is writing on the stream +anymore. +STD* streams are negative stream numbers and are the same +for all tasks. They are mapped to the real stream numbers that are being +kept in the environment table for each task. All other stream numbers are +global and there is only a limited set of stream, as they are +statically allocated. +

+

Messages

+The message interface provides another easy means of interprocess +communication. Messages are exchanged using the rendez-vous technique, +i.e. both involved tasks have to be in the SEND respectively RECEIVE +routine. The SEND routine always blocks until the given message is +taken over by the receiving task. RECEIVE either waits for a +message or returns with E_NOTX if no message has been found. +The message is then copied from the senders message buffer (at $02xx) +to the receivers message buffer (at $02xx). The return values are set +and both tasks are marked runnable. +If a RECEIVE blocks and a SEND takes place, both tasks are marked +waiting at first, but the scheduler detects that and lets them +exchange the messages. +While RECEIVE gets messages from +any task, XRECEIVE allows to receive messages from a certain task +only. +

+Negative task numbers are used for special purposes. Certain system +calls, that need more parameter than fit into the CPU registers +can be called not only via jumptable but also via the SEND interface. +For this, the -1 ($ff) is used for system calls. -2 ($fe) is +used for the file system manager. -3 to -12 ($fd-$f4) can be +mapped to any other task by the TDUP system call. -3 is reserved +for an error exception handler and -4 for a timer task. Messages +to these task numbers are internally redirected to the registered task. +

+

Semaphores

+As the 6502 CPU has no idea about atomic operations, semaphores have to +be provided by the system to allow mutex constructs +(Well, there are atomic instructions, like INC or the shift opcodes. But +then there is - in not-CMOS versions - no test-and-set). Semaphores +can be allocated using GETSEM +and released with FRESEM. Then with a PSEM operation on a certain +semaphore a task can enter a critical region of the program. All other +tasks block when they try to do the same PSEM operation. Only after +a VSEM on the semaphore another task waiting in a PSEM is revived +and can enter the critical region. +Negative semaphore numbers cannot be allocated but can be used as some kind +of system semaphores. What they mean has yet to be defined, though. +

+

Signals

+Signal handling consists of a single system call. With the carry flag +cleared, the calling task is blocked until a specified signal is received. +With the carry flag set, a signal is sent. Only listening tasks receive +the signal. +

+

Filesystem Manager

+Disks are +administered as drives, as a virtual filesystem with mounts etc +would have been to much for this system. +The filesystem manager should actually be another task and is in the +kernel only for performance and resource limitation reasons. +The TDUP interface would provide an easy way to register a filesystem manager, +if it were an extra task. +But then the used filesystem manager just redirects the send message +'on the fly'. An extra task would have to receive the message, +redirect it and send it to the filesystem task - blocking until +the message is taken over! +

+When a filesystem task, e.g. for IBM PC disks, is started, it registers +itself with the filesystem manager by sending an appropriate message +to task -2 ($fe). The filesystem then knows about how many drives are +supported by the filesystem and adds them to its list. A request to, e.g. +open a file is sent to the filesystem manager. From the drive number +the file system manager knows to which task to redirect the message. +It also remaps the drive number to the ones used in the filesystem +task. +

+Once a read-only or write-only file is opened, all communication takes +place via streams. Another interface, using read and write messages +is planned, but has not yet been implemented. Some filesystems (like +fsiec for Commodore floppy drives) wouldn't even support it. +

+

Standard Library

+The standard library of OS/A65 v1 has been replaced by the +lib6502.

+The so called standard library is a set of +subroutines that tasks may +map into their memory or not. The library is below the +I/O area, at $e800. Directly below $e800 the jumptable for the +library is located. All routines run in task space, and have no +connection to the kernel, except for calling normal system calls. +

+

Available Filesystems

+All filesystem tasks use a common Filesystem +Interface to communicate with other tasks. The SEND/RECEIVE +calls are used to open files, while the Streams are used to transfer the +data. The filesystem manager redirects the SENDs to the right +filesystem tasks automatically. +

Device Filesystem 'fsdev'

+The device filesystem provides an easy interface to devices, in allowing +them to be used as files. A request to open the device, for example, +is served by calling the appropriate DEVCMD commands. +

+fsdev also provides an easy interface to the ROM structure. The +programs stored in the system can be started from there. They cannot +be read, as only a header is being provided. This header, when used +to start the program, remaps the ROM into the task memory. This way +one need not move all the program through the stream interface. +

+

IEEE 488 Filesystem 'fsiec'

+This filesystem can be used in two directions. First it provides an +interface for CS/A to access Commodore disk drives on an IEEE 488 +interface. Reading directories as well as renaming and deleting files and +formating and checking disks is supported. +

+The other way around with fsiec the CS/A computer can be used as a disk +drive for Commodore computers. The filesystem drives are mapped to the +drives 0-? of a single drive unit on the IEEE 488 bus. In addition to the +standard IEC floppy commands directory handling is supported. For +programs that only understand one drive, drives can be remapped with +assign. +

+

FAT Filesystem 'fsibm'

+The FAT filesystem is used to control and handle PC-style formatted disks +on standard PC disk drives on the CS/A floppy board. Several +3.5" and 5.25" formats are supported, up to 1.44 MByte 3.5" HD disks. +As hardware a WD1770 floppy controler at address $e8e0 is used. A 6522 VIA +at $e8f0 provides some additional control lines for drive select, motor on, +etc. +

+For those who remember: I wrote the program 'bdos' for the german 64er +magazin, which allowed the C128 to read and write PC disks. fsibm +has not a byte of code from this project, instead it is completely +rewritten. +

+One flaw of this filesystem is that it assumes it has the floppy +controller for itself. So there is no way to share it, e.g. +with a disk monitor. The next revision should define a semaphore +for this. +

+

Available Software

+

The Shell 'sh'

+The shell is a command line interpreter that +provides an easy to use interface to the system. A scripting language is +not available, though. For external commands and some internal commands +like DIR and more I/O redirection is possible. I.e. that the STD* +streams can be redirected to a file or even piped to other programs. +

+

The Monitor 'mon'

+'mon' is a full featured 6502 assembly and +machine language monitor. Among the usual standard commands other +features like, for example, relocating 6502 in a certain area or +searching for opcodes with specified addressing modes is possible. +

+

BASIC interpreter

+The BASIC interpreter is an extended Commodore +Basic V2 interpreter as found in the C64. In fact it is de-assembled +from the C64 and patched to make it work on CS/A. In addition, some +commands have been changed and new commands have been added, amongst +them the Commodore Basic V4 commands. In contrast to the C64 basic +interpreter, it runs in multitasking and you can quit ;-) +

+

CS/A65 Hardware

+

CPU

+The used CPU is a quite old one: the MOS 6502 or one of its clones, +like the Rockwell R65C02, for example. This 8 bit CPU has been designed +in the early 70s (?) but is still in use. The Rockwell modem chipset, +for example, is based on a R65C02 core. The CPU has one general purpose +8 bit register, the accumulator. Two 8 bit index registers, x and y, help with +addressing modes. The PC is 16 bit wide, as is the address bus to the +outside of the chip. The stack pointer is only 8 bit, thus confining +the stack to the area $01xx in memory. The so called zeropage ($00xx) +is used with special addressing modes to allow smaller code and +faster execution times by leaving out the address high byte. +An 8 bit status register completes the register set. +

+The hardware interface is quite simple. In fact it is compatible to the +motorola 6800 series chips. Commodore lost a lawsuit started by Motorola +where commodore +was forbidden to use the number 6500 (or was it 6501) and the same +pinout as the 6800 chip, thus making it a plug in replacement for the +Motorola chip. But then they could use the hardware interface, +though. Which means that one can simply use any 68xx interface chip +with a 6502 and vice versa. +

+Phi2 is the CPU clock output. During Phi2 high all address lines and +the read/write line are valid. Data is given on the data bus for write +somewhere in the middle of Phi2 high and it stays valid until the +Phi2 high-low transition. During read the data lines are latched +at the same transition. The CPU always reads some memory addresses, +even if its really doing something else. +

+/RESET, /NMI and /IRQ are the most important input lines. They are +low active and the I/O chips have open collector outputs so that +they can be wire-or'd together. +

+

Bus system

+The hardware consists of several boards, connected by a 64 pin +bus interface (DIN 41612, rows a+c). On the bus are 20 address +lines and 8 data lines. /NMI, /IRQ, /RESET, /SO, RDY, SYNC and R/W +are the usual (buffered) 6502 control lines. Phi0, Phi1 and Phi2 +are on the bus as well as a 2Phi2, which is a frequency doubled +phi2. Each low-high transition on 2Phi2 gives a +transition on Phi2. This can, for example, directly be connected +to /RAS of dynamic RAMs. +

+

I/O System

+The CPU boards detects any access to a 4 or 2 kByte sized Area +from $e000 or $e800 to $efff and automatically selects the bus +line /IOSEL, and /MEMSEL otherwise. This way a simple 8 bit +compare with, for example, a single 74688 with the address +lines A4 to A11 selects a 16 byte I/O window for any interface +chip. +/IOINH(ibit) disables this feature, but therefore the I/O +memory has to be detected from normal memory access +(via /MEMSEL) and /EXTIO be activated therefore from an +external circuit. +(Well, the next revision should see /IOSEL as an open collector +output...) +

+All interface circuits, even including the MMU on the CPU +board, are connected to the bus lines. The CPU +can be cut off from the bus with /BE, thus allowing other +CPUs or bus masters to take the bus and even access the MMU. +The CPU has to be shutdown with +RDY for this, though. +

+

MMU subsystem

+The 74ls610 (used to be on the COCOM list, haha...) is +a set of 16 12 bit registers, where only 8 bit are used +here. During Phi2 low the CPU address lines A12 to A15 +are used to select the appropriate register and latch its +contents to the output address lines A12-A19. Unfortunately +this chip is quite slow (I'd say that a hand-constructed thing +would be much faster...) so that for 2 MHz CPU clock +a 4 MHz (CMOS) CPU has to be used. +During Phi2 high the I/O access +to read and write the registers from the bus takes place. +At RESET the MMU is set to 'through' mode, i.e. the +CPU address lines A12 to A15 are passed through and +A16 to A19 are left zero, to allow a defined RESET +condition. The first I/O write on the MMU registers +then enables it. +Then the CPU memory is divided into 16 4 kByte blocks, that +can each be mapped from one of the 256 4 kByte Blocks in the +1 MByte bus address space by setting the MMU registers. +

+

+

I/O boards

+The video board has 64 kByte dynamic RAM that is used as +video and CPU memory and a 6545/6845 video CRT controller. +The memory access is twice as fast as the CPU access, so that +during Phi2 low the video readout is done and at Phi2 high +the usual CPU access takes place. The lowest address bits +are connected to the row, so that the video access +automatically refreshes the RAM. With 1 MHz CPU clock +40 columns are displayed, with 2 Mhz 80 columns can +be seen. The CRT is located at $e880 in I/O space, and +a write only control port at $e888. This port gives the +missing address lines A14 and A15 for the CRT, 2 bits +to select the charset (located in an EPROM on the board +that can not be read by the CPU) and 2 bits to invert +the HSYNC and VSYNC signals if necessary. +The last used bit maps the CRT row select lines +RA0 and RA1 (that normally select the character row +in the charset) +to the RAM/CPU address lines A12 and A13. This way - +and with a 1 to 1 charset - some high +resolution mode with 640x200 pixel is possible, with +a rather strange memory map, though. +This is necessary due to the 127 row limit in the CRT. +

+An IEEE 488 board with a 6821 PIA at $e82x and a 6522 VIA +at $e84x makes up a mostly Commodore PET 3032 compatible +IEEE 488 interface. The PIA is used for the data transfer, +while the VIA port A is used for the control lines. +VIA port B controls a Commodore serial IEC bus interface. +Both interfaces can be used as master or slave, i.e. +the have the circuitry to set NRFD/NDAC on the IEEE 488 +and the DATA (?) line on the serial bus, if ATN on the bus +is set. So the master can see that there is a device on +the bus, even if it isn't ready to serve the request. +VIA CA2 can be externally connected to the +video card to allow PET compatible switching between +upper/lowercase and uppercase/graphics charset. +VIA CB2 drives, PET compatible of course, a piezo beeper ;-) +

+At $e810-$e817 is, as in a PET, a 6821 PIA to handle the +keyboard, while on the same board, at $e818-$e81f, a +6551 ACIA (which is not in a PET ;-) to handle a serial +interface is located. +

+The same ACIA is also located on the BIOS board, that also contains +32k ROM and 32k RAM that make up the lowest 64 kByte of the +Megabyte bus address space. This BIOS card together with +the CPU makes up a complete computer. The ACIA is at $efe8-$efef, +while at $efe0 a control port is located. +One bit allows the detection of an IRQ (e.g. to stop the irq +routine if all interrupts are served), two others are used +to control and sense a 50 Hz (line frequency in Europe, which +is put on the bus by the power supply) interrupt. +Two other bits control the /IOINH line and allow the I/O address +space to be located in $0e000-$0effff in bus (!) address space, +so that it can be mapped anywhere in CPU address space. +

+On the floppy board a WD 1770 (like in the Commodore +VC1571) chip at $e8fx can control PC compatible disk drives. +A 6522 VIA at $e8fx supplies the timers and some additional +I/O lines and also gives a simple 8 bit parallel interface +(for e.g. printers). +

+A special interface board emulates a 6502 in another computer +(restricted to 1 MHz or below). A 40 line cable is used +to connect the socket for the 6502, e.g. in a VC1541, with the +board. The 64 kByte address space of this VC1541 is then +mapped into the bus address space $02000-$02ffff. So you can, +for example, test new ROMs by putting the new ROM image in +the CS/A RAM and then remapping it for the old ROMs. +

+The C64 uses 8 select lines to select the keyboard rows. +The return value is then read in by 8 column port lines. +This simply is a RAM readout scheme - so that a +RAM can simulate a keyboard for the C64. +The keyboard simulator board provides such a RAM. It can +be written or read by the CPU during Phi2 high, and the +row select address from the C64 is read at Phi2 low and +latched. So, for example, the C64 can be controlled remotely. +

+

Porting to other platforms

+Currently two ports have been done. One is a port to the CS/A65 without +MMU, to use it in embedded applications I had in mind. The other one +is the C64 port. +

+

NOMMU-Port

+The port to a system without MMU is one of the more difficult. +The problem is, that global variables cannot be mapped to different +physical memory locations for different tasks. So this has to be +avoided. Unfortunately there are global variables used to communicate +with the kernel nearly everywhere. So these variables have to be +protected by semaphores. Another thing is that a binary can normally +only be invoced once. All variables would otherwise be the same for all +invocations and running different tasks on them would normally +give a real mess. More on this issue can be found in +nommu.html. +

+

C64-Port

+After porting it to a system without MMU, there was only a small step +porting it to the C64. The first implementation used the Commodore +parallel IEEE488 interface, as it's easier to program - and simulate +in an emulator... But after all, it has the same deficiencies as any +other system without MMU. More details on the actual implementation +can be found in README.c64.

+On the other hand, to be really useful without an MMU besides +embedded applications, some things are still missing. +A program relocator, for example, would make it much easier in that +the applications don't have to be assembled to a certain memory area. +Instead they could be relocated to some free memory when being loaded. +

+

What about a C128-Port?

+The C128, for example, would surely be a good candidate for a new +version: It can map the zeropage and the stack anywhere in memory and +can thus have different ones for each task. In addition to this, a +relocator would have to be implemented, to be able to load programs to +any address. The (to be implemented new) memory manager then has to +keep track of which memory is used for each program. If one says that +read/write memory (i.e. global variables, except zeropage) should only +be dynamically allocated, one could even use shared read only binaries. +I.e. several invocations would only use one copy of the binary while +running. Global variables used would be global to all invocations, +giving some kind of task shared memory. A flag in the file header could +indicate the relocator and/or shared binary mode. +

+

What about the next version?

+Well, a next version is not planned currently. But then the whole +stuff is under the GNU public license and could be used by anyone. +

+The new binary format with relocation would surely justify a jump +to version 1.4. This would make it much more usable for the C64. But +for this not only the relocator has to be written, but also the assembler +has to be changed to write out a relocatable file format. +This would also imply an extended memory manager, that keeps track +which memory is used by which task. And it would also use a smaller +block size than 4kByte. +

+

Are there known bugs?

+Well, there used to be some very few spurious BRK executions in a task. +That's why I reduced the maximum number of tasks from 6 to 5, increasing +the individual stack size to 40. The previously smaller stack size of +32 seemed to cause this problem, which seems to be gone now. The problem +is that a normal +interrupt alone needs 10 bytes on each tasks stack - one can reduce +that, but with some effort only.
+When pressing the return key, sometimes the invers cursor stays on the +screen, causing the program to give a syntax error or whatsoever +when it reads a $a0 from its input stream.
+

+But other than that, none. But I haven't tested the C64 version +as much as the one for my selfbuilt computer. So there might still +be bugs in the serial bus handling or in the stuff special to computers +without MMU. +

+Ok, when starting up the ROM, the initial tasks are set up and then the +scheduler is started. This might cause problems when e.g. a filesystem +is not fast enough detecting its drives during the first scheduled +timeslice. Another filesystem might come in between so that the drive +numbers could be assigned in a different order. +

+Possible improvements are: +

    +
  • A malloc() equivalent, that could be located in the STDIO lib. +At least some kind of sbrk() call we already have in the kernel. +
  • A relocator to be able to load binaries to different memory locations, +esp. for the versions without an MMU. +
  • There currently is no way to handle shared memory (in the MMU version) +in a generalized manner. I think of somethink like a Unix (Linux) mmap() +equivalent. +
  • The data transfer via streams is quite slow. Another interface +to handle block transfer would surely improve things. Something like +'copy memory from task A, address x length l to task B, address y'. +
  • Starting a new task from within the shell is way too slow. Reading +a file and writing it to another environments memory with the WRITE +system function takes its time. Instead the shell should just load a small +loader program into the new environment. This then reads the program +from the stream and executes it. +
+ + diff --git a/dump/oa-2.0.9/doc/oldlib.html b/dump/oa-2.0.9/doc/oldlib.html new file mode 100644 index 0000000..9d20c72 --- /dev/null +++ b/dump/oa-2.0.9/doc/oldlib.html @@ -0,0 +1,59 @@ + + OS/A65 Standard Library + +

OS/A65 Standard Library

+

(c) 1989-98 Andre Fachat

+
+
+The CS/A65 standard library is a set of routines that run in user space and
+can be called if the appropriate memory page ($e000-$e7ff) is mapped in
+from the system ROM (at $0e000 bus address space).
+The zeropage addresses $10-$28 are being used by the library at this
+time.
+
+$e7fd	Fgetc	Get a byte from a stream, and wait until the byte is ready,
+		using YIELD. parameter: stream number in x, returns
+		the read byte in a
+$e7fa	Fputc	Write a byte on a stream, waiting until it can be delivered
+		parameter: stream number in x, data byte in a
+$e7f7	Getc	same as Fgetc, for STDIN
+$e7f4	Putc	same as Fputc, for STDOUT
+$e7f1	Txtout	Write a null terminated string up to 254 byte to STDOUT
+		parameter: a/y=address of string (a=lowbyte, y=highbyte)
+$e7ee	Hexout	Write a byte to STDOUT in hex. parameter: byte in a
+$e7eb	Crlfout	Write carriage return and line feed to STDOUT
+$e7e8	Serbrk	reads the status of STDIN and tests if it is E_SEMPTY
+		If it is, carry is cleared, otherwise it is set.
+$e7e5	Dezbout	writes a byte in decimal to STDOUT
+$e7e2	Assign	handles a 10 byte table, that is e.g. used to implement
+		the assign command in fsiec
+		(carry=0): reads a table entry. parameter: table index in x,
+		returns new value in x (a and y are preserved)
+		(carry=1, x<0): initialize table with a[i]=i
+		(carry=1, 0<=x<10): write new table value
+		parameter: table index in x, new value in a
+$e7df	Getname	reads a string from memory and tries to interpret it as
+		a filename (with possibly leading 'drive:' and paths...)
+		leading spaces are ignored. The filename is saved in
+		PCBUF+FS_OPEN_NAME. If a drive is given, it is put
+		into PCBUF+FS_OPEN_DRV. Otherwise this is set to -1
+		parameter: a/y=address of string, returns PCBUF+...
+$e7de	Chdir	takes the contents of PCBUF+FS_CMD_* and interprets it as
+		a 'change directory' operation, to be done to a given
+		path. "." and ".." are interpreted as usual.
+		parameter: a/y=address of path, x maximal length of path
+$e7d9	Usedir	Takes a path and applies it to a filename in PCBUF.
+		If the filename in PCBUF contains a drive or an absolut
+		filename is given, nothing is done. Otherwise the 
+		the path is put in front of the filename and is put
+		into PCBUF again. The path is not changed. "." and ".."
+		are not removed here.
+		parameter: a/y=address of path, PCBUF+...
+		returns new filename in PCBUF+...
+$e7d6	Set2name copies a string into PCBUF
+		parameter: a/y=address of null terminated string, 
+		position the name has to be copied to in PCBUF in x.
+
+
+ + diff --git a/dump/oa-2.0.9/doc/shell.html b/dump/oa-2.0.9/doc/shell.html new file mode 100644 index 0000000..f3f2b5f --- /dev/null +++ b/dump/oa-2.0.9/doc/shell.html @@ -0,0 +1,63 @@ + + OS/A65 Shell Commands + +

OS/A65 Shell Commands

+

(c) 1989-98 Andre Fachat

+

+The shell reads its commands from STDIN line by line and executes them. +First internal commands are compared with the input. Then, if no +internal command has been found, the actual directory is searched +for the file to be executed. The file is then loaded and executed +in its own environment. The shell waits for its completion, if the +command line is not ended with an ampersand '&'. Then the command +is executed in the background. The STD* streams can be redirected +with "<", ">", "!" for STDIN, STDOUT and STDERR respecitvely. +A "|" between two external comands pipes the STDOUT of the first +program to the STDIN of the second command. +

+Shell commands: +

+x:			sets drive to 'x:'
+DIR d:name?.*		shows directory
+TYPE filename		print file on STDOUT
+DEL filename		delete file
+FORMAT/x d:name		format disk in drive d:, format x (which is a 
+			number, see fsibm), and gives it a the name 
+			'name'.
+CHKDSK d:		check disk
+RENAME name1 name2	renames 'name1' to 'name2'
+B filename
+BATCH filename		Switches STDIN to filename, until an EOF is 
+			read, then returns to normal STDIN
+MONITOR			switch to machine language monitor
+LOGOFF			exit shell
+COPYCON filename	writes the terminal input to a file, until
+			a line with a "@" is read.
+DUP >file1 <file2 !file3
+			redirects STDOUT to file1, STDIN to file2, and
+			STDERR to file3. STDOUT and STDERR can be redirected
+			to the same file with ">!".
+CHDIR newdir
+CD newdir		change to a new directory
+DEVCMD dev cmd par	calls the DEVCMD kernel call. The device is given
+			as name, cmd as one of IRQ, RES, GETSTR, PUTSTR,
+			RXON, RXOFF, TXON, TXOFF, SPEED, HANDSHAKE, STATUS
+			and EXIT.
+COPY file1 file2	copy file1 to file2 in background
+			(for multiple files better use mcopy, as 
+			copying in the background eats up system resources
+			if too many files are copied)
+GETSTR			get a free stream
+FRESTR x		release the stream
+SETMEM x		set memory size of task to x times 4kByte
+INFO			prints the information given by GETINFO kernel
+			call bug: currently only ten tasks are printed 
+			due to earlier revision restrictions.
+KILL x			kill task x
+MKDIR dirname		make a new directory
+RMDIR dirname		remove a directory
+ROM filename            reads memory mapping information (like the OS/A65
+                        ROM boot entry) and starts the file from ROM.
+
+ + diff --git a/dump/oa-2.0.9/include/README b/dump/oa-2.0.9/include/README new file mode 100644 index 0000000..e3134ed --- /dev/null +++ b/dump/oa-2.0.9/include/README @@ -0,0 +1,13 @@ + +The chips directory keeps the register definitions +for the several used chips. + +Other include files are OS structures that are used by other +programs. + +Here also go include files from programs that need their stuff +exported to other programs. + +Architecture dependent stuff goes to the arch directories + + diff --git a/dump/oa-2.0.9/include/chips/acia6551.i65 b/dump/oa-2.0.9/include/chips/acia6551.i65 new file mode 100644 index 0000000..eab1a61 --- /dev/null +++ b/dump/oa-2.0.9/include/chips/acia6551.i65 @@ -0,0 +1,34 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef ACIA_DR + +/* ACIA 6551 */ + +#define ACIA_DR 0 +#define ACIA_SR 1 +#define ACIA_CMD 2 +#define ACIA_CTRL 3 + +#endif + diff --git a/dump/oa-2.0.9/include/chips/cia6526.i65 b/dump/oa-2.0.9/include/chips/cia6526.i65 new file mode 100644 index 0000000..e8ac656 --- /dev/null +++ b/dump/oa-2.0.9/include/chips/cia6526.i65 @@ -0,0 +1,46 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef CIA_PRA + +/* CIA 6526 */ + +#define CIA_PRA 0 +#define CIA_PRB 1 +#define CIA_DDRA 2 +#define CIA_DDRB 3 +#define CIA_TAL 4 +#define CIA_TAH 5 +#define CIA_TBL 6 +#define CIA_TBH 7 +#define CIA_TOD_10TH 8 +#define CIA_TOD_SEC 9 +#define CIA_TOD_MIN 10 +#define CIA_TOD_HR 11 +#define CIA_SDR 12 +#define CIA_ICR 13 +#define CIA_CRA 14 +#define CIA_CRB 15 + +#endif + diff --git a/dump/oa-2.0.9/include/chips/pia6521.i65 b/dump/oa-2.0.9/include/chips/pia6521.i65 new file mode 100644 index 0000000..22b0f09 --- /dev/null +++ b/dump/oa-2.0.9/include/chips/pia6521.i65 @@ -0,0 +1,34 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef PIA_PA + +/* Struct PIA 6821 */ + +#define PIA_PA 0 +#define PIA_CRA 1 +#define PIA_PB 2 +#define PIA_CRB 3 + +#endif + diff --git a/dump/oa-2.0.9/include/chips/tpi6525.i65 b/dump/oa-2.0.9/include/chips/tpi6525.i65 new file mode 100644 index 0000000..d194582 --- /dev/null +++ b/dump/oa-2.0.9/include/chips/tpi6525.i65 @@ -0,0 +1,38 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef TPI_PA + +/* TPI 6525 */ + +#define TPI_PA 0 +#define TPI_PB 1 +#define TPI_PC 2 +#define TPI_DDPA 3 +#define TPI_DDPB 4 +#define TPI_DDPC 5 +#define TPI_CREG 6 +#define TPI_AIR 7 + +#endif + diff --git a/dump/oa-2.0.9/include/chips/uart16550.i65 b/dump/oa-2.0.9/include/chips/uart16550.i65 new file mode 100644 index 0000000..b117de7 --- /dev/null +++ b/dump/oa-2.0.9/include/chips/uart16550.i65 @@ -0,0 +1,41 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef UART_RXTX + +/* UART 16550 */ + +#define UART_RXTX 0 /* DLAB=0 */ +#define UART_IER 1 /* DLAB=0 */ +#define UART_DLL 0 /* divisor latch low, DLAB=1 */ +#define UART_DLH 1 /* divisor latch high, DLAB=1 */ +#define UART_IIR 2 /* Irq Ident. Reg., read only */ +#define UART_FCR 2 /* FIFO Ctrl Reg., write only */ +#define UART_LCR 3 /* Line Ctrl Reg */ +#define UART_MCR 4 /* Modem Ctrl Reg */ +#define UART_LSR 5 /* Line Status Reg */ +#define UART_MSR 6 /* Modem Status Reg */ +#define UART_SCR 7 /* 'scratchpad', i.e. unused */ + +#endif + diff --git a/dump/oa-2.0.9/include/chips/via6522.i65 b/dump/oa-2.0.9/include/chips/via6522.i65 new file mode 100644 index 0000000..56078fb --- /dev/null +++ b/dump/oa-2.0.9/include/chips/via6522.i65 @@ -0,0 +1,46 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef VIA_DRB + +/* Struct VIA 6522 */ + +#define VIA_DRB 0 +#define VIA_DRA 1 +#define VIA_DDRB 2 +#define VIA_DDRA 3 +#define VIA_T1CL 4 +#define VIA_T1CH 5 +#define VIA_T1LL 6 +#define VIA_T1LH 7 +#define VIA_T2CL 8 +#define VIA_T2CH 9 +#define VIA_SR 10 +#define VIA_ACR 11 +#define VIA_PCR 12 +#define VIA_IFR 13 +#define VIA_IER 14 +#define VIA_DRBX 15 + +#endif + diff --git a/dump/oa-2.0.9/include/chips/vicii.i65 b/dump/oa-2.0.9/include/chips/vicii.i65 new file mode 100644 index 0000000..b3e47d8 --- /dev/null +++ b/dump/oa-2.0.9/include/chips/vicii.i65 @@ -0,0 +1,55 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef _VICII_H_ +#define _VICII_H_ + +#define VIC_SPRITE_X 0 +#define VIC_SPRITE_Y 1 +#define VIC_SPRITE_XMSB 16 +#define VIC_CR1 17 +#define VIC_RASTERIRQ 18 +#define VIC_LPEN_X 19 +#define VIC_LPEN_Y 20 +#define VIC_SPRITE_EN 21 +#define VIC_CR2 22 +#define VIC_SPRITE_YEXP 23 +#define VIC_BASE 24 +#define VIC_IRR 25 +#define VIC_IMR 26 +#define VIC_SPRITE_PRIO 27 +#define VIC_SPRITE_MCOL 28 +#define VIC_SPRITE_XEXP 29 +#define VIC_SPRITE_SPR 30 +#define VIC_SPRITE_BGND 31 +#define VIC_EXT_COL 32 +#define VIC_BGND_COL0 33 +#define VIC_BGND_COL1 34 +#define VIC_BGND_COL2 35 +#define VIC_BGND_COL3 36 +#define VIC_SPRITE_MC0 37 +#define VIC_SPRITE_MC1 38 +#define VIC_SPRITE_COL 39 /* +0, ... ,+7 */ + +#endif + diff --git a/dump/oa-2.0.9/include/chips/wd1770.i65 b/dump/oa-2.0.9/include/chips/wd1770.i65 new file mode 100644 index 0000000..8ee1257 --- /dev/null +++ b/dump/oa-2.0.9/include/chips/wd1770.i65 @@ -0,0 +1,35 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef WD_CMD + +/* Struct WD 1772 */ + +#define WD_CMD 0 +#define WD_ST 0 +#define WD_TRCK 1 +#define WD_SECT 2 +#define WD_DATA 3 + +#endif + diff --git a/dump/oa-2.0.9/include/fdefs.i65 b/dump/oa-2.0.9/include/fdefs.i65 new file mode 100644 index 0000000..8d2c934 --- /dev/null +++ b/dump/oa-2.0.9/include/fdefs.i65 @@ -0,0 +1,101 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#define DIRSIGN "/" /* directory separator */ + +/* commands to the filesystem */ + +#define FS_OPEN_RD 1 /* open file for read */ +#define FS_OPEN_WR 2 /* open file for write */ +#define FS_OPEN_RW 3 /* open file for read and write */ +#define FS_OPEN_OW 4 /* open file for overwrite */ +#define FS_OPEN_AP 5 /* open file for append */ +#define FS_OPEN_DR 6 /* open directory for read */ +#define FS_RENAME 7 /* rename file */ +#define FS_DELETE 8 /* delete file */ +#define FS_FORMAT 9 /* format disk */ +#define FS_CHKDSK 10 /* check disk */ +#define FS_CLOSE 11 /* close file (only for read/write) */ +#define FS_RMDIR 12 /* remove subdirectory */ +#define FS_MKDIR 13 /* create subdirectory */ +#define FS_CHDIR 14 /* change directory */ +#define FS_ASSIGN 15 /* ---- */ + +/* + * non-overlapping net server commands follow + * by not overlapping them with filesytem commands, one process can + * register as fs _and_ net server + */ + +#define FS_OPEN_TCP 32 /* ---- */ + +/* + * user-defined codes after that + */ +#define FS_LASTCODE 64 + +/************************************************************************/ + +/* struct to be sent with FS_OPEN_* */ + +#define FS_OPEN_DRV 0 /* drive = FM_OPEN_DRV */ +#define FS_OPEN_STR 1 /* data stream */ +#define FS_OPEN_PFAD 2 /* ---- */ +#define FS_OPEN_NAME 3 /* filename, ended with null byte */ + +/* struct that is returned */ + +#define FS_X_ERR 0 /* error number, also in AC */ +#define FS_X_ENV 1 /* task number of the filesystem */ +#define FS_X_FIL 2 /* file handle (read/write only) */ +#define FS_X_SLEN 3 /* length of struct */ + +/* struct of a dir entry in a directory file */ + +#define FS_DIR_LEN 0 /* length in bytes, 4 bytes, lo first */ +#define FS_DIR_YEAR 4 /* year minus 1900 */ +#define FS_DIR_MONTH 5 /* month */ +#define FS_DIR_DAY 6 /* day */ +#define FS_DIR_HOUR 7 /* hour */ +#define FS_DIR_MIN 8 /* minute */ +#define FS_DIR_SEC 9 /* second of last change */ +#define FS_DIR_MODE 10 /* kind of dir entry */ +#define FS_DIR_NAME 11 /* start of name, ended with null byte */ + +/* kind of directory entry */ + +#define FS_DIR_MOD_FIL 0 /* file */ +#define FS_DIR_MOD_NAM 1 /* disk name */ +#define FS_DIR_MOD_FRE 2 /* disk free bytes in FS_DIR_LEN */ +#define FS_DIR_MOD_DIR 3 /* subdirectory */ + +/* struct to be sent except for FS_OPEN_* */ +/* only FS_CMD_NAME (must be ==FS_OPEN_NAME for fstcp) used */ + +#define FS_CMD_DRV 0 +#define FS_CMD_PFAD 1 +#define FS_CMD_FIL 2 +#define FS_CMD_NAME 3 /* after nullbyte of the first filename */ + /* comes the second filename for RENAME */ + diff --git a/dump/oa-2.0.9/include/file_o65.def b/dump/oa-2.0.9/include/file_o65.def new file mode 100644 index 0000000..9e5047e --- /dev/null +++ b/dump/oa-2.0.9/include/file_o65.def @@ -0,0 +1,36 @@ + +/* These definitions are without the two leading version/marker bytes, + * length is without options + */ +#define HDR_MAGIC 0 +#define HDR_VERSION 3 +#define HDR_MODE 4 +#define HDR_TBASE 6 +#define HDR_TLEN 8 +#define HDR_DBASE 10 +#define HDR_DLEN 12 +#define HDR_BBASE 14 +#define HDR_BLEN 16 +#define HDR_ZBASE 18 +#define HDR_ZLEN 20 +#define HDR_STACKLEN 22 +#define HDR_LEN 24 + +#define A_ADR $80 +#define A_HIGH $40 /* or'd with the low byte */ +#define A_LOW $20 +#define A_MASK $e0 /* reloc type mask */ +#define A_FMASK $0f /* segment type mask */ + +#define SEG_UNDEF 0 +#define SEG_ABS 1 +#define SEG_TEXT 2 +#define SEG_DATA 3 +#define SEG_BSS 4 +#define SEG_ZERO 5 + +#define FM_OBJ %00010000 +#define FM_SIZE %00100000 +#define FM_RELOC %01000000 +#define FM_CPU %10000000 + diff --git a/dump/oa-2.0.9/include/fsdef.i65 b/dump/oa-2.0.9/include/fsdef.i65 new file mode 100644 index 0000000..15c647d --- /dev/null +++ b/dump/oa-2.0.9/include/fsdef.i65 @@ -0,0 +1,53 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef FSDEV_H_ +#define FSDEV_H_ +/* + * These are some definitions common for most/all filesystems + * if we introduce shared mem, we could probably have a 'virtual filesystem' + * with only one set of routines managing the data transfer from streams + * to these buffers and vice versa - or somehow rewrite those for + * (to be implemented) kernel block transfer modes. + */ + +#define F_FL 0 ; state of buffer +#define F_DEV 1 +#define F_DRV 2 +#define F_STR 3 +#define F_LEN 4 ; number of bytes in buffer +#define F_BYT 5 ; current byte +#define F_MODE 6 ; 0=read,1=write +#define F_SLEN 8 + +#define F_FL_OK 0 +#define F_FL_DIR 1 +#define F_FL_EOF 2 +#define F_FL_DO 3 +#define F_FL_DOX 4 +#define F_FL_FRE 255 +#define F_MODE_RD 0 +#define F_MODE_WR 1 + +#endif + diff --git a/dump/oa-2.0.9/include/fsibm.i65 b/dump/oa-2.0.9/include/fsibm.i65 new file mode 100644 index 0000000..09c118c --- /dev/null +++ b/dump/oa-2.0.9/include/fsibm.i65 @@ -0,0 +1,47 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef _FSIBM_H_ +#define _FSIBM_H_ + +#define IE_CMD <-65 +#define IE_Q <-66 +#define IE_GT <-67 +#define IE_RD <-68 +#define IE_WR <-69 +#define IE_V <-70 +#define IE_FT <-71 + +#define IE_NOCLUS <-72 /* no more cluster available (disk full) */ +#define IE_INVDATA <-73 /* inconsistent data on disk */ +#define IE_ILLCLUS <-74 /* Cluster# ==1 or >F_CLUS */ +#define IE_VALBUF <-75 /* try to write valid buffer with XW (??)*/ +#define IE_FILEXIST <-76 /* file exists */ +#define IE_DISKFULL <-77 /* disk full */ +#define IE_DNEMPTY <-78 /* subdirectory not empty when rmdir */ +#define IE_NOFILE <-79 /* no more file structrure (internal) */ +#define IE_ILLNAM <-80 /* name with joker ("*","?","\"") */ +#define IE_FOPEN <-81 /* file locked */ + +#endif + diff --git a/dump/oa-2.0.9/include/inet.i65 b/dump/oa-2.0.9/include/inet.i65 new file mode 100644 index 0000000..fce8fd8 --- /dev/null +++ b/dump/oa-2.0.9/include/inet.i65 @@ -0,0 +1,58 @@ + +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef _INET_H_ +#define _INET_H_ + +/* + * command codes for kernel network interface - must be between + * filesystem command codes and FS_LASTCODE + */ + +#define FS_CONNECT 32 +#define FS_LISTEN 33 /* open listen port */ +#define FS_UNLISTEN 34 /* close listenport */ +#define FS_ACCEPT 35 + +/* + * protocol definitions for lib6502 and kernel netwaork calls + */ + +#define IPV4_TCP 0 +#define IPV4_UDP 1 + +/* + * message format for kernel net server calls + */ + +#define FSN_PROT 0 /* network protocol for accept */ +#define FSN_RET 0 /* return value for accept/listen */ +#define FSN_PORT 1 /* network port for (un)listen */ +#define FSN_RXSTR 2 /* stream where network writes */ +#define FSN_TXSTR 3 /* stream where network reads */ +#define FSN_ADDR 4 /* network address, depends on prot. */ + +#endif + diff --git a/dump/oa-2.0.9/include/irtx.i65 b/dump/oa-2.0.9/include/irtx.i65 new file mode 100644 index 0000000..813e383 --- /dev/null +++ b/dump/oa-2.0.9/include/irtx.i65 @@ -0,0 +1,215 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef _IRTX_H_ +#define _IRTX_H_ + +/* these definitions are for using the SEND/RECEIVE interface to send + commands to the irtx task and thus to the remote device */ + +#define SEND_IRTX $FB /* pseudo-task ID */ + +#define ITX_KIND 0 /* PCBUF+ITX_KIND = type of device */ +#define ITX_MSG 1 /* PCBUF+ITX_MSG = message number */ + +/* remote device types */ +#define IK_SONY 0 /* of type Sony */ +#define IM_SY_SLEN 2 /* length of message number */ + +/************************ Sony Master Control ******************************/ + +#define SY_MC_VOLU $812 /*$4810*/ +#define SY_MC_VOLD $813 /*$c810*/ +#define SY_MC_MUTE $814 /*$2810*/ +#define SY_MC_CD $825 /*$a410*/ +#define SY_MC_TUNER $821 /*$8410*/ +#define SY_MC_PHONO $820 /*$0410*/ +#define SY_MC_TAPE $823 /*$c410*/ +#define SY_MC_DAT $846 /*$6210*/ +#define SY_MC_VIDEO1 $822 /*$4410*/ +#define SY_MC_VIDEO2 $81e /*$7810*/ +#define SY_MC_VIDEO3 $842 /*$4210*/ +#define SY_MC_P_LDP $315 /*$a8c0*/ +#define SY_MC_P_VTR $115 /*$a880*/ +#define SY_MC_P_TV $095 /*$a900*/ +#define SY_MC_P_AUDIO $815 /*$a810*/ + +/************************ Sony CD-Player CDP-450 ***************************/ + +#define SY_CD_CONT $89d /*$b910*/ +#define SY_CD_PGM $89f /*$f910*/ +#define SY_CD_SHUFF $8b5 /*$ad10*/ +#define SY_CD_CLR $8ac /*$3510*/ +#define SY_CD_AB $8aa /*$5510*/ +#define SY_CD_DISP $8a8 /*$1510*/ +#define SY_CD_G16 $8a7 /*$e510*/ +#define SY_CD_PLAY $8b2 /*$4d10*/ +#define SY_CD_PAUSE $8b9 /*$9d10*/ +#define SY_CD_STOP $8b8 /*$1d10*/ +#define SY_CD_AMSZ $8b0 /*$0d10*/ +#define SY_CD_AMSV $8b1 /*$8d10*/ +#define SY_CD_INDZ $8b6 /*$6d10*/ +#define SY_CD_INDV $8b7 /*$ed10*/ +#define SY_CD_FASTZ $8b3 /*$cd10*/ +#define SY_CD_FASTV $8b4 /*$2d10*/ +#define SY_CD_SKIP $8be /*$7d10*/ /* Nicht auf der alten RC -> No effect */ +#define SY_CD_XZ $8ba /*$5d10*/ /* " Effekt wie FastZ */ +#define SY_CD_XV $8bb /*$dd10*/ /* " Effekt wie FastV */ +#define SY_CD_1 $880 /*$0110*/ +#define SY_CD_2 $881 /*$8110*/ +#define SY_CD_3 $882 /*$4110*/ +#define SY_CD_4 $883 /*$c110*/ +#define SY_CD_5 $884 /*$2110*/ +#define SY_CD_6 $885 /*$a110*/ +#define SY_CD_7 $886 /*$6110*/ +#define SY_CD_8 $887 /*$e110*/ +#define SY_CD_9 $888 /*$1110*/ +#define SY_CD_10 $8a0 /*$0510*/ +#define SY_CD_11 $8a1 /*$8510*/ +#define SY_CD_12 $8a2 /*$4510*/ +#define SY_CD_13 $8a3 /*$c510*/ +#define SY_CD_14 $8a4 /*$2510*/ +#define SY_CD_15 $8a5 /*$a510*/ +#define SY_CD_16 $8a6 /*$6510*/ + +/***************************** Sony LDP ************************************/ + +#define SY_LD_PLAY $31a /*$58c0*/ +#define SY_LD_STOP $318 /*$18c0*/ +#define SY_LD_AMSZ $335 /*$acc0*/ +#define SY_LD_AMSV $334 /*$2cc0*/ +#define SY_LD_XZ $31b /*$d8c0*/ +#define SY_LD_XV �31c /*$38c0*/ + +/****************************** Sony TV ************************************/ + +#define SY_TV_TVIDEO $0a5 /*$a500*/ +#define SY_TV_VOLU $092 /*$4900*/ +#define SY_TV_VOLD $093 /*$c900*/ +#define SY_TV_PRGU $090 /*$0900*/ +#define SY_TV_PRGD $091 /*$8900*/ +#define SY_TV_ENTER $08b /*$d100*/ +#define SY_TV_1 $080 /*$0100*/ +#define SY_TV_2 $081 /*$8100*/ +#define SY_TV_3 $082 /*$4100*/ +#define SY_TV_4 $083 /*$c100*/ +#define SY_TV_5 $084 /*$2100*/ +#define SY_TV_6 $085 /*$a100*/ +#define SY_TV_7 $086 /*$6100*/ +#define SY_TV_8 $087 /*$e100*/ +#define SY_TV_9 $088 /*$1100*/ +#define SY_TV_0 $089 /*$9100*/ + +/****************************** Sony Tuner *********************************/ + +#define SY_TU_SHIFT $6b3 /*$cd60*/ +#define SY_PRESU $690 /*$0960*/ +#define SY_PRESD $691 /*$8960*/ + +/****************************** Sony Deck A ********************************/ + +#define SY_DA_FASTZ $833 /*$cc10*/ +#define SY_DA_FASTV $834 /*$2c10*/ +#define SY_DA_RPLAY $837 /*$ec10*/ +#define SY_DA_PLAY $832 /*$4c10*/ +#define SY_DA_STOP $838 /*$1c10*/ +#define SY_DA_PAUSE $839 /*$9c10*/ +#define SY_DA_REC $836 /*$6c10*/ +#define SY_DA_AUX $83f /*$fc10*/ /* ???? */ + +/****************************** Sony Deck B ********************************/ + +#define SY_DB_FASTZ $71b /*$d8e0*/ +#define SY_DB_FASTV $71c /*$38e0*/ +#define SY_DB_RPLAY $720 /*$04e0*/ +#define SY_DB_PLAY $71a /*$58e0*/ +#define SY_DB_STOP $718 /*$18e0*/ +#define SY_DB_PAUSE $719 /*$98e0*/ +#define SY_DB_REC $71e /*$78e0*/ +#define SY_DB_AUX $71f /*$f8e0*/ /* ???? */ + +/****************************** Sony DAT ***********************************/ + +#define SY_DAT_FASTZ $e3b /*$dc70*/ +#define SY_DAT_FASTV $e3c /*$3c70*/ +#define SY_DAT_PLAY $e3a /*$5c70*/ +#define SY_DAT_STOP $e38 /*$1c70*/ +#define SY_DAT_PAUSE $e39 /*$9c70*/ +#define SY_DAT_REC $e3d /*$bc70*/ +#define SY_DAT_AUX $e3f /*$fc70*/ /* ???? */ + +/****************************** Sony Video1 ********************************/ + +#define SY_V1_CHU $110 /*$0880*/ +#define SY_V1_CHD $111 /*$8880*/ +#define SY_V1_ANTVTR $12a /*$5480*/ +#define SY_V1_FASTZ $11b /*$d880*/ +#define SY_V1_FASTV $11c /*$3880*/ +#define SY_V1_PLAY $11a /*$5880*/ +#define SY_V1_STOP $118 /*$1880*/ +#define SY_V1_PAUSE $119 /*$9880*/ + +/****************************** Sony Video2 ********************************/ + +#define SY_V2_CHU $390 /*$09c0*/ +#define SY_V2_CHD $391 /*$89c0*/ +#define SY_V2_ANTVTR $3aa /*$55c0*/ +#define SY_V2_FASTZ $39b /*$d9c0*/ +#define SY_V2_FASTV $39c /*$39c0*/ +#define SY_V2_PLAY $39a /*$59c0*/ +#define SY_V2_STOP $398 /*$19c0*/ +#define SY_V2_PAUSE $399 /*$99c0*/ + +/****************************** Sony Video3 ********************************/ + +#define SY_V3_CHU $590 /*$09a0*/ +#define SY_V3_CHD $595 /*$a9a0*/ +#define SY_V3_ANTVTR $5aa /*$55a0*/ +#define SY_V3_FASTZ $59b /*$d9a0*/ +#define SY_V3_FASTV $59c /*$39a0*/ +#define SY_V3_PLAY $59a /*$59a0*/ +#define SY_V3_STOP $598 /*$19a0*/ +#define SY_V3_PAUSE $599 /*$99a0*/ + +/***************************** Universum Fernseher *************************/ + +#define UNI_TV_POWER $e +#define UNI_TV_VIDEO $d +#define UNI_TV_MUTE $9 +#define UNI_TV_VOLD $4 +#define UNI_TV_VOLU $3 +#define UNI_TV_1 $10 +#define UNI_TV_2 $11 +#define UNI_TV_3 $12 +#define UNI_TV_4 $13 +#define UNI_TV_5 $14 +#define UNI_TV_6 $15 +#define UNI_TV_7 $16 +#define UNI_TV_8 $17 +#define UNI_TV_9 $18 +#define UNI_TV_10 $19 +#define UNI_TV_11 $1a +#define UNI_TV_12 $1b + +#endif + diff --git a/dump/oa-2.0.9/include/kdefs.i65 b/dump/oa-2.0.9/include/kdefs.i65 new file mode 100644 index 0000000..5e8c798 --- /dev/null +++ b/dump/oa-2.0.9/include/kdefs.i65 @@ -0,0 +1,396 @@ +/**************************************************************************** + + OS/A65 Version 1.4.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef P_KIND + +/**************************************************************************/ +/* Kernel saved areas */ + +/* + * These memory locations are saved for each environment/task/thread + */ + +#define ENVSAVE 2 +#define TASKSAVE 4 +#define THREADSAVE 6 + +/**************************************************************************/ +/* Prg-Header, ROM style */ + +#define P_KIND 0 /* type of file */ +#define P_ADDR 1 /* start address to load file to */ +#define P_RAM 3 /* needed amount of memory (not for + device */ +#define P_SHARED 4 /* size of shared memory from top */ +#define P_PRIORITY 5 /* priority of task */ +#define P_DEV 6 /* two byte reserved - in the ROM, the + first byte gives the device number + the stdin have to be directed + to, the second byte is for stdout */ +#define P_NAME 8 /* name of program, ended by nullbyte; + after that follows the command line + that starts the program. */ + +/* type of file in ROM */ + +#define PK_PRG 0 /* simple executable */ +#define PK_DEV 1 /* device block */ +#define PK_FS 2 /* filesystem/daemon, i.e. stdio is + ignored */ +#define PK_INIT 3 /* init process (no stdio, no PCBUF + with command line) */ +#define PK_LIB 4 /* process started with lib6502 */ +#define PK_BIN 5 /* non-executable file */ + +/* execution bits */ + +#define PK_AUTOEXEC $80 +#define PK_RESTART $40 + +/**************************************************************************/ +/* Hardware-Errors */ + + +#define HE_ZP <-1 /* Zeropage RAM defective */ +#define HE_RAM <-2 /* not enough RAM (may be defective) */ +#define HE_ROM <-3 /* not enough Streams/Envs to handle all + ROM autostart requests */ +#define HE_DEV <-4 /* error registering ROM device */ +#define HE_TASK <-5 /* no more active task! */ + + +/* Software-Errors */ + +/* general OS/kernel errors */ + +#define E_OK 0 /* no error */ +#define E_NOTIMP <-1 /* feature/function not implemented */ +#define E_CONFIG <-2 /* in this configuration not available */ +#define E_ILLPAR <-3 /* illegal parameter */ +#define E_NOMEM <-4 /* no more memory */ + +/* stream handling errors */ +#define E_NOSTR <-5 /* no more streams available */ +#define E_SFULL <-6 /* stream is full */ +#define E_SEMPTY <-7 /* stream is empty */ +#define E_SLWM <-8 /* stream below low-water-mark (1/4) */ +#define E_SHWM <-9 /* stream above high-water-mark (3/4) */ +#define E_EOF <-10 /* last byte read, other side has closed */ +#define E_NUL <-11 /* noone listening on stream */ + +/* device handling errors */ +#define E_NODEV <-12 /* illegal device number */ +#define E_DON <-13 /* device already in use */ +#define E_DOFF <-14 /* device not in use */ +#define E_NOTX <-15 /* device doesn't send */ + +/* misc errors */ + +#define E_NOENV <-16 /* no more free environment/task ID */ +#define E_NOSEM <-17 /* no more free semaphore */ +#define E_SEMSET <-18 /* semaphore is already set (with PSEM) */ + +#define E_NOIRQ <-19 /* irq routine has not removed irq source */ +#define E_VERSION <-20 /* wrong (executable file) version */ + +#define E_NOTASK <-21 /* no more free task */ +#define E_INT <-22 /* interrupted (by signal) system call */ + +#define E_ILLSIG <-23 /* illegal signal number */ + +#define E_TRYAGAIN <-24 /* try again */ + +/* file handling errors */ + +#define E_FNODRV <-32 /* illegal drive number */ +#define E_FNOPATH <-33 /* wrong path */ +#define E_FILLNAM <-34 /* illegal name (joker "*","?","\"") */ +#define E_FNAMLEN <-35 /* name too long */ +#define E_FNOFIL <-36 /* file not found */ +#define E_FWPROT <-37 /* file write protected */ +#define E_FILEXIST <-38 /* file exists */ +#define E_FDISKFULL <-39 /* disk full */ +#define E_FDNEMPTY <-40 /* subdirectory not empty when rmdir */ +#define E_FLOCKED <-41 /* file locked */ +#define E_FMEDIA <-42 /* media error */ +#define E_FLOGICAL <-43 /* bad logical structure on media */ +#define E_FINTERNAL <-44 /* internal error - should not happen! */ + +#define E_LASTERR <-96 /* for customized error numbers */ + +#define E_ILLADDR <-64 /* illegal address for lib6502 mfree */ +#define E_NOFILE <-65 /* illegal file number for lib6502 */ +#define E_NOSEEK <-66 /* file not seekable */ +#define E_NOREAD <-67 /* read on file would block */ +#define E_NOWRITE <-68 /* write on file would block */ +#define E_FVERSION <-69 /* file version number not supported */ + + +/**************************************************************************/ +/* Stream-Commands */ + +#define SC_GET 0 +#define SC_REG_RD 1 +#define SC_REG_WR 2 +#define SC_CLR 3 +#define SC_EOF 4 +#define SC_NUL 5 +#define SC_FRE 6 +#define SC_STAT 7 +#define SC_GANZ 8 +#define SC_RWANZ 9 +#define SC_ESTAT 10 /* get error state */ +#define SC_SSTAT 11 /* set error state */ +#define SC_CSTAT 12 /* clear error state */ + +#define SCE_PULL %10000000 /* reader pulls */ +#define SCE_PUSH %01000000 /* writer pushes */ +#define SCE_BRK %00100000 /* writer signals break */ +#define SCE_RERRM %00001100 /* reader has error condition mask */ + /* %00 = no error, != $00 error, to be def'd */ +#define SCE_WERRM %00000011 /* writer has error condition (read error,..)*/ + /* %00 = no error, != $00 error, to be def'd */ + +/* Device-Commands */ + +#define DC_IRQ 0 +#define DC_RES 1 +#define DC_GS 2 +#define DC_PS 3 +#define DC_RX_ON 4 +#define DC_TX_ON 5 +#define DC_RX_OFF 6 +#define DC_TX_OFF 7 +#define DC_SPD 8 +#define DC_HS 9 +#define DC_ST 10 +#define DC_EXIT 11 +#define DC_BRKKEY 12 + +#define DC_GNAM 16 +#define DC_GNUM 17 +#define DC_REGDEV 18 + +#define DC_SW_RX %10000000 +#define DC_SW_TX %01000000 + +/* +#define REGDEV_MPOS 0 +#define REGDEV_MBLK 1 +#define REGDEV_ADR 2 +*/ + +/* NMI commands, to be passed to CTRLNMI */ + +#define NMI_ON 0 /* beq */ +#define NMI_OFF 1 + +/* task state */ + +#define TS_FREE 0 +#define TS_ENV 1 /* allocated but not running */ +#define TS_IBRK 2 /* task has BRK'd in IRQ routine */ +#define TS_BRK 3 /* task has BRK'd */ +#define TS_RDY 4 /* task did YIELD call */ +#define TS_IRQ 5 /* task is interrupted */ +#define TS_WFRX 6 /* waiting for other task to RECEIVE */ +#define TS_WFTX 7 /* waiting for other task to SEND */ +#define TS_WXTX 8 /* wait for certain task to SEND */ +#define TS_WFSEM 9 /* wait for semaphore */ +#define TS_WSIG 10 /* wait for signal */ + +/* GETINFO-struct */ + +#define ANZ_ENV 15 /* number of valid entries */ + +#define TN_PID 0 /* process ID */ +#define TN_NTHREADS 1 /* task state */ +#define TN_ENV 2 /* environment number */ +#define TN_PARENT 3 /* parent task */ +#define TN_MEM 4 /* used amount of memory */ +#define TN_SIGNAL 5 /* interrupt routine address */ +#define TN_STDIN 7 /* stdin stream */ +#define TN_STDOUT 8 /* stdout stream */ +#define TN_STDERR 9 /* stderr stream */ +#define TN_SIGMASK 10 /* signal mask */ +#define TN_NAME 11 /* start of program name (if avail.) */ +#define TN_SLEN 17 /* length of one entry */ + +#define TNAMLEN (TN_SLEN-TN_NAME) /* length of name */ + +/* Terminal Commands */ + +#define TC_BEL 7 +#define TC_BS 8 +#define TC_HT 9 +#define TC_LF 10 +#define TC_VT 11 +#define TC_FF 12 +#define TC_CR 13 +#define TC_ESC 27 + +#define TC_CLFT $80 +#define TC_CRGT $81 +#define TC_CUP $82 +#define TC_CDWN $83 +#define TC_HOME $84 +#define TC_CLR $85 +#define TC_DEL $86 +#define TC_INS $87 +#define TC_WLO $88 +#define TC_WRU $89 +#define TC_WCLS $8a +#define TC_EOL $8b +#define TC_CLL $8c + +#define TC_ECHO $8d /* device shall echo: terminal = full screen */ +#define TC_NOECHO $8e /* appl. echos: full appl. control */ + +#define TC_CPOS $8f /* next chars are row and column */ + +/*********************** System Semaphores *************************/ +/* System semaphores cannot be allocated and/or freed with + * GETSEM/FRESEM, but can be used with PSEM and VSEM. + * + * The semaphores marked with '(NOMMU)' need only be used without + * MMU, while the others should be used anyway, to share the resource + * between any tasks. + */ + +#define SEM_SENDBUF <-1 /* Send buffer (NOMMU) */ + +/* + * the following semaphore numbers are defined, but not (yet) really + * used by the current implementation. Especially the SERIEC semaphore + * can be used to share the serial bus between fsiec for CBM floppies + * and fsibm (with changed interface for VC1571) for PC style disks. + */ + +#define SEM_STDIO <-2 /* parts of the STDIO library (NOMMU) */ +#define SEM_PARIEC <-3 /* parallel IEC bus */ +#define SEM_SERIEC <-4 /* serial IEC bus */ +#define SEM_IBMDISK <-5 /* IBM floppy interface */ + +/*********************** SIGNALS *********************************** + * Signal codes + */ + +#define SIG_INTABLE %10000000 /* interruptable system call mask */ +#define SIG_CHLD %01000000 /* child has terminated */ +#define SIG_KILL %00100000 /* process shall terminate */ +#define SIG_BRK %00010000 /* ctrl-C received */ + +#define SIG_USR4 %00001000 /* 4 user signals */ +#define SIG_USR3 %00000100 +#define SIG_USR2 %00000010 +#define SIG_USR1 %00000001 + +/*********************** SEND SYSTEM ******************************* + * SysProcCalls + * + * Some system calls can also be called via the SEND interface + */ + +#define SEND_SYS $ff + +#define PCBUF $200 + +/* AC = function number */ +#define SP_FORK 0 +#define SP_SETIRQ 1 +#define SP_RESET 2 + +/* struct in PCBUF when FORK'ing */ +#define FORK_SIZE 0 /* size of needed memory in blocks (256 + byte) from address 0 up */ +#define FORK_SHARED 1 /* size of shared memory mapping in + blocks from address $ffff down */ +#define FORK_PRIORITY 2 /* priority of task - 0 = parent's */ +#define FORK_STDIN 3 /* stdin stream */ +#define FORK_STDOUT 4 /* stdout stream */ +#define FORK_STDERR 5 /* stderr stream */ +#define FORK_ADDR 6 /* startaddress of task execution */ +#define FORK_NAME 8 /* task name (ended with nullbyte) */ + +/* struct in PCBUF when SETIRQ */ +#define SETIRQ_ENV 0 /* env to set irq address in */ +#define SETIRQ_ADR 1 /* irq address to set */ +#define SETIRQ_SLEN 3 + +/* struct in PCBUF when RESET */ +#define RESET_ENV 0 /* env to restart */ +#define RESET_ADR 1 /* start address for execution */ +#define RESET_SLEN 3 + +/* StdStream */ + +#define STDNUL $fc /* is ignored (see PK_FS) */ +#define STDIN $fd +#define STDOUT $fe +#define STDERR $ff + +/* Own Task ID */ + +#define OWNTASK $ff + +/* FileManager */ + +#define SEND_FM $fe + +#define FM_REG 0 /* in AC when registering new fs */ + +#define FM_REG_DRVS 0 /* number of drives to register */ +#define FM_REG_ENV 1 /* to task number */ + +#define FM_OPEN_DRV 0 + +/* TimeTask */ + +#define SEND_TIME $fc + +/* AC = command */ +#define TI_SET 0 +#define TI_GET 1 + +/* struct in PCBUF */ +#define TE_SG_YEAR 0 +#define TE_SG_MONTH 1 +#define TE_SG_DAY 2 +#define TE_SG_HOUR 3 +#define TE_SG_MIN 4 +#define TE_SG_SEC 5 + +/* (Inter)Net Connectivity */ + +#define SEND_NET $fb + +/* Net server use an interface similar to the filesystem interface. + * In fact, after an open there is no real difference, and due to the + * non-overlapping command numbers, one process can register as + * FS _and_ Net server. + * Further defs are found in oa1fs.i65 + */ + +#endif + diff --git a/dump/oa-2.0.9/include/kernel.i65 b/dump/oa-2.0.9/include/kernel.i65 new file mode 120000 index 0000000..f1037f1 --- /dev/null +++ b/dump/oa-2.0.9/include/kernel.i65 @@ -0,0 +1 @@ +../kernel/jmptbl.a65 \ No newline at end of file diff --git a/dump/oa-2.0.9/include/lib6502.i65 b/dump/oa-2.0.9/include/lib6502.i65 new file mode 120000 index 0000000..6922371 --- /dev/null +++ b/dump/oa-2.0.9/include/lib6502.i65 @@ -0,0 +1 @@ +../lib6502/libjmp.a65 \ No newline at end of file diff --git a/dump/oa-2.0.9/kernel/Makefile b/dump/oa-2.0.9/kernel/Makefile new file mode 100644 index 0000000..5078f6b --- /dev/null +++ b/dump/oa-2.0.9/kernel/Makefile @@ -0,0 +1,14 @@ + + +XAINPUT=../include,.. +XA=xa + +kernel.o65: $(wildcard *.a65) + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -bt 61440 oa1.a65 -o kernel.o65 ;\ + if [ $$? -ne 0 ]; then rm -f kernel.o65; fi; \ + ) + +clean: + rm -f kernel.o65 + diff --git a/dump/oa-2.0.9/kernel/devices.a65 b/dump/oa-2.0.9/kernel/devices.a65 new file mode 100644 index 0000000..d5178f8 --- /dev/null +++ b/dump/oa-2.0.9/kernel/devices.a65 @@ -0,0 +1,268 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifdef NO_DEVICE + +devcmd =notimp + +#else + .( + .zero +devzei .word 0 +DZ .word 0 + .text + +#ifdef MAP_ZERO + .zero +#else + .data +#endif +&adev .byt 0 +ANZDEV .byt 0 +cnt .byt 0 +freq .byt 0 +hidigit .byt 0 +DZ2 .word 0 + .text + +#define DVT_ADRL 0 +#define DVT_ADRH MAXDEV +#define DVT_ENV (2*MAXDEV) +#define DVT_SLEN 3 + + .data +&DEVTAB .dsb MAXDEV*DVT_SLEN + .text + +&inidev sta freq + ldx #0 + stx ANZDEV + dex + stx adev + clc + rts + +&irqdev .( + ldx ANZDEV + stx cnt +l1 dec cnt + bmi dendirq + ldx cnt + lda #DC_IRQ + ldy freq + jsr exejmp +#ifndef NOSYSPORT + jsr testirq + beq l1 +#else + bcs l1 ; irq source removed -> ac=0 -> c=0 +#endif +dendirq clc + rts + .) + +&devcmd jsr memsys + php + sei + cmp #DC_GNUM ; get number of devices + beq devgnum + cmp #DC_REGDEV ; register a new device + bne x1 + jmp regdev +x1 cpx ANZDEV ; check device number + bcs idcex + cmp #DC_GNAM ; get name of device + beq devgnam + jsr exejmp ; execute all others + bcs idce +idcok lda #E_OK + .byt $2c +idcex lda #E_NODEV +idce + plp + cmp #1 + jmp memtask + +devgnum .( + MAPSYSBUF + + ldx #0 +gu1 stx cnt + cpx ANZDEV + bcs idcex + jsr setnam + ldx cnt +gu2 lda (devzei),y + cmp SYSBUF-3,y + bne gun + cmp #0 + beq idcok + iny + bne gu2 +gun inx + bne gu1 + .) + +setnam .( + lda DEVTAB+DVT_ADRL,x + pha + lda DEVTAB+DVT_ADRH,x + tay + lda DEVTAB+DVT_ENV,x + tax + pla + MAPENV() + sta devzei + sty devzei+1 + ldy #3 + rts + .) + +devgnam .( + MAPSYSBUF + + jsr setnam +gn1 lda (devzei),y + sta SYSBUF-3,y + iny + cmp #0 + bne gn1 +gn2 tya + sec + sbc #3 + tax + jmp idcok + .) + +regdev .( + txa +loop + sta DZ2 + sty DZ2+1 + MAPAENV() + sta DZ + sty DZ+1 + + ldy #0 + lda (DZ),y + iny + and (DZ),y + tay + iny + beq enddev + + lda ANZDEV + cmp #MAXDEV + bcs enddev + tax + + lda DZ2 + clc + adc #2 + sta DEVTAB+DVT_ADRL,x + lda DZ2+1 + adc #0 + sta DEVTAB+DVT_ADRH,x + + GETACTENV() + + sta DEVTAB+DVT_ENV,x + ldx ANZDEV + inc ANZDEV + ldy freq + lda #DC_RES + jsr DEVCMD + + lda DZ2 + ldy DZ2+1 + MAPAENV() + sta DZ + sty DZ+1 + + ldy #0 + lda (DZ),y + pha + iny + lda (DZ),y + tay + pla + jmp loop + +sE_CONFIG lda #E_CONFIG + .byt $2c +enddev lda #E_OK + plp + cmp #1 + jmp memtask + ;jsr memtask + ;rts + .) + +exejmp .( +#ifdef MAP_ZERO + .zero +#else + .data +#endif +cmd .byt 0 +par .byt 0 + .text + + sta cmd + sty par + lda adev + pha + lda Syscnt + pha + lda #0 + sta Syscnt ; Aufrufe von Device wie von Task + stx adev ; Dev-No for memtask + +/* TODO: in CS/A65, make non-ROM-started devices work! */ + + lda DEVTAB+DVT_ADRL,x + ldy DEVTAB+DVT_ADRH,x + pha + lda DEVTAB+DVT_ENV,x + tax + pla + MAPENV() + sta devzei + sty devzei+1 + lda cmd + ldy par + jsr jmpzei + sta cmd + pla + sta Syscnt + pla + sta adev + lda cmd + cmp #1 + rts + +jmpzei jmp (devzei) + .) + + .) +#endif diff --git a/dump/oa-2.0.9/kernel/end.a65 b/dump/oa-2.0.9/kernel/end.a65 new file mode 100644 index 0000000..b09eb6e --- /dev/null +++ b/dump/oa-2.0.9/kernel/end.a65 @@ -0,0 +1,41 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifdef EOK_NOFILL + +eok_addr =* + +#else + +#if * < $fff4 + .dsb $fffa-*-6,<-1 +#else +#echo "Warning: ROM too large!" +#endif + +#endif + + .byt D_D,D_M,D_Y,VA,VB,VC + .word pnmi /*NMI*/,RESET,pirq + + diff --git a/dump/oa-2.0.9/kernel/files.a65 b/dump/oa-2.0.9/kernel/files.a65 new file mode 100644 index 0000000..8f049eb --- /dev/null +++ b/dump/oa-2.0.9/kernel/files.a65 @@ -0,0 +1,100 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#ifndef NO_FSM + + .( + +#ifdef MAP_ZERO + .zero +#else + .data +#endif +anzfs .byt 0 + + .data + +fstab .dsb MAXFS+1 +fstask .dsb MAXFS+1 + + .text + +&fminit lda #0 + sta anzfs + sta fstab + clc + rts + ++fm +#ifdef MAPSYSBUF + pha + MAPSYSBUF + pla +#endif + cmp #FM_REG + bne fm1 + + ldy anzfs + lda SYSBUF+FM_REG_DRVS + bne fmreg + lda fstab,y + sec + rts +fmreg + cpy #MAXFS + bcs fme1 + ; clc + adc fstab,y + sta fstab+1,y + inc anzfs + txa + sta fstask,y + lda #E_OK + .byt $2c +fme1 lda #E_NOMEM + .byt $2c +fme2 lda #E_NODEV + sec + rts + +fm1 + lda SYSBUF+FM_OPEN_DRV + ldy #0 +fm2 cpy anzfs + bcs fme2 + cmp fstab+1,y + bcc fmok + iny + bne fm2 + +fmok sec + sbc fstab,y + sta SYSBUF+FM_OPEN_DRV + lda fstask,y + tax + clc + rts + .) + +#endif /* NO_FSM */ + diff --git a/dump/oa-2.0.9/kernel/init.a65 b/dump/oa-2.0.9/kernel/init.a65 new file mode 100644 index 0000000..920805f --- /dev/null +++ b/dump/oa-2.0.9/kernel/init.a65 @@ -0,0 +1,672 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef MEMINIVAL +#define MEMINIVAL 0 /* reset value of RAM content */ +#endif + +#ifndef NOMMU + +#ifdef NMIDEV +#echo Warning, nmidev only without mmu - disabling it +#undef NMIDEV +#endif + +#ifndef NMIRESET +#echo Warning, no nmireset only without mmu - disabling nmi services +#define NMIRESET +#endif + +#endif + +/*************************************************************************** + * + * Hardware initialization + * + */ + + .( + .zero +pz .word 0 +; cnt .byt 0 + .text + +#ifdef MAP_ZERO + .zero +#else + .data +#endif +s1 .byt 0 +s2 .byt 0 + + .text + +¬imp lda #E_NOTIMP + sec + rts + +&preset sei + cld +/* + * initializes the hardware memory mapping, the system (preemption) timer + * and the memory management, if needed. Also the macros + * GETFREQ(), LEDPORT, LED_LED, H_ERROR, and CLRTIMER() are defined. + * It jumps to he_ram if there is not enough RAM available. + */ +#include "kernel/kinit.a65" + +; cmp #MIN_MEM ; memory size at least needed +; bcc he_ram +; sta cnt + +/* still a lot TODO! */ +#if 0 /* def NOMMU */ + ;sta cnt + sec + sbc #>startmem+255 + tay + ldx #>startmem+255 + jsr binit + + lda #startzero + jsr zinit + + lda cnt +#endif + jmp prgstart + +he_zero ldx #HE_ZP + .byt $2c +he_ram ldx #HE_RAM + .byt $2c +;e1 ldx #HE_IMEM +; .byt $2c +;e2 ldx #HE_IDEV +; .byt $2c +;e3 ldx #HE_ISTR +; .byt $2c +;e4 ldx #HE_IENV +; .byt $2c +erom ldx #HE_ROM + .byt $2c +edev ldx #HE_DEV + + jmp HERROR + +/*************************************************************************** + * + * ROM initialization + * + */ + +prgstart /* get system speed */ + GETFREQ() + sta s1 + +#ifdef LEDPORT + jsr LEDOFF +#endif + +#ifdef NMIDEV + jsr ininmi +#endif + jsr initthreads + jsr inienv + ;bcs e4 +#ifndef NO_DEVICE + lda s1 + jsr inidev + ;bcs e2 +#endif +#ifndef NO_STREAMS + jsr inistream + ;bcs e3 +#endif +#ifndef NO_SEM + jsr inisem +#endif +#ifndef NO_FSM + jsr fminit +#endif + +#ifdef STARTMEM + ; lda cnt + STARTMEM() +#endif +;.byt 2 + lda #ROMSTART + sta pz+1 + +startloop +;.byt 2 + ldy #0 + lda (pz),y + iny + and (pz),y + cmp #$ff + bne slx1 +;jmp edev + jmp pstart +xerr + jmp edev +endloop jmp erom + +slx1 ldy #P_KIND+2 + lda (pz),y + bpl slx2 + and #$7f + ; cmp #PK_PRG + ; beq iprg + cmp #PK_DEV + beq idev + cmp #PK_INIT ; PK_FS + beq ifs +slx2 jmp inext + +idev + ldy #P_ADDR+2 + lda (pz),y + tax ;sta PCBUF+REGDEV_ADR + iny + lda (pz),y + tay ;sta PCBUF+REGDEV_ADR+1 + lda #DC_REGDEV + jsr DEVCMD + bcs xerr + jmp inext + +ifs + +#if 0 + ldx #STDNUL + stx s1 + stx s2 + bne ifs1 + +iprg jsr GETSTR + bcs endloop + stx s1 + jsr GETSTR +endloopx bcs endloop + stx s2 + ldy #P_DEV+2 + lda (pz),y + tax + ldy s2 + lda #DC_GS + jsr DEVCMD + ldy #P_DEV+2 + lda (pz),y + tax + ldy s1 + lda #DC_PS + jsr DEVCMD + ldy #P_DEV+2 + lda (pz),y + pha + tax + lda #DC_RX_ON + jsr DEVCMD +#ifdef CMOSCPU + plx +#else + pla + tax +#endif + lda #DC_TX_ON + jsr DEVCMD + + +ifs1 lda s2 + sta PCBUF+FORK_STDOUT + sta PCBUF+FORK_STDERR + lda s1 + sta PCBUF+FORK_STDIN +#endif + + lda #STDNUL + sta PCBUF+FORK_STDERR + sta PCBUF+FORK_STDOUT + sta PCBUF+FORK_STDIN + + ldy #P_PRIORITY+2 + lda (pz),y + sta PCBUF+FORK_PRIORITY + + ldy #P_RAM+2 + lda (pz),y + sta PCBUF+FORK_SIZE + iny + lda (pz),y + sta PCBUF+FORK_SHARED + + ldy #P_ADDR+2 + lda (pz),y + sta PCBUF+FORK_ADDR + iny + lda (pz),y + sta PCBUF+FORK_ADDR+1 + + lda #0 + sta PCBUF+FORK_NAME + sta PCBUF+FORK_NAME+1 +#if 0 + ldy #P_NAME+1 + ldx #2 +cmdn iny + lda (pz),y + sta PCBUF+FORK_NAME-P_NAME-2,y + bne cmdn + dex + bne cmdn + iny +#endif + jsr FORK +#if 0 + ldx s1 + lda #SC_NUL + jsr STRCMD + ldx s2 + lda #SC_EOF + jsr STRCMD +#endif + +inext + ldy #0 + lda (pz),y + tax + iny + lda (pz),y + sta pz+1 + stx pz + jmp startloop + +/*************************************************************************** + * + * Error handling + * + */ + +#ifdef LEDPORT ++LEDOFF lda LEDPORT + ora #LED_LED + sta LEDPORT + rts +#endif + ++HERROR .( ; xr=Fehlernummer -1=1mal aus, -2=2mal aus etc +#ifdef EMUTEST +.byt 2 +#endif +#ifdef LEDPORT + LDA LEDPORT:EOR #LED_LED + STA LEDPORT + LDY #0:TYA +PRE2 ADC #1:BNE PRE2 + INY:BNE PRE2 + LDA LEDPORT:EOR #LED_LED + STA LEDPORT + LDA #0:TAY +PRE3 ADC #1:BNE PRE3:INY + BNE PRE3:inx:BNE HERROR + ldx #15 + lda #0:tay +pre5 adc #1:bne pre5 + iny:bne pre5 + dex:bne pre5 +#else + H_ERROR +#endif + +#ifdef EMUTEST /* then save some process info and restart CS/A */ +.( +lda #$11 +sta $eff2 +ldx #0 +cp1 lda $eff0,x +sta $2000,x +inx +cpx #16 +bcc cp1 +pla +sta $2010 +pla +sta $2011 +tsx +stx $2012 +l0 jmp l0 +.) + +#endif + JMP RESET + + .) + +/*************************************************************************** + * + * NMI handling + * + */ + .( +&&pnmi +#ifdef NMIRESET + jmp RESET +&&ctrlnmi +&&setnmi lda #E_NOTIMP + sec + rts +#else +#ifdef NMIDEV + jmp (nmiadr) + + .data +nmiadr .word 0 +nmicnt .byt 0 + .text + +&ininmi ;lda #zend + lda #NMI_ON ; 0 + sta nmicnt +ininmi2 lda #yendnmi +n1 sta nmiadr + sty nmiadr+1 + clc +zend rts + + ; struct for CTRLNMI + .word $ffff + .word zend +yendnmi rti + +&&setnmi jsr memsys + bcc n2 + tax + lda nmiadr + pha + lda nmiadr+1 + pha + + php + sei + lda #NMI_OFF + jsr CTRLNMI ; before we mess with the NMI pointer, switch it off + + txa + jsr n1 + + lda nmiadr + sec + sbc #4 + sta tmp + lda nmiadr+1 + sbc #0 + sta tmp+1 + + ldy #0 + lda (tmp),y + sta tmp2 + iny + lda (tmp),y + sta tmp2+1 + + tsx + lda $0102,x + sta (tmp2),y + dey + lda $0103,x + sta (tmp2),y + + ldy #2 + lda (tmp),y + sta tmp2 + iny + lda (tmp),y + sta tmp2+1 + + lda #NMI_OFF + jsr c2 ; init new device with NMI off + + lda #NMI_ON ; now switch on again, if allowed + jsr CTRLNMI + plp + + pla + tay + pla + jmp ne +n2 jsr ininmi2 +ne jmp memtask + ;jsr memtask + ;rts + + .zero +tmp .word 0 +tmp2 .word 0 + .data +cmd .byt 0 + .text + +&&ctrlnmi + jsr memsys + php + sei + cmp #NMI_ON + beq con + cmp #NMI_OFF + beq coff + lda #E_NOTIMP + .byt $2c +crts lda #E_OK + plp + cmp #1 + jmp memtask + ;jsr memtask + ;rts + +con lda nmicnt + beq crts + dec nmicnt + bne crts + lda #NMI_ON + beq nmicmd2 + +coff clc + lda nmicnt + inc nmicnt + cmp #0 + bne crts + lda #NMI_OFF +nmicmd2 + jsr nmicmd ; nmicmd is only called at state change! + jmp crts + +nmicmd + sta cmd + tya + pha + txa + pha + lda nmiadr + ldx nmiadr+1 + +ctrl0 sec + sbc #4 + sta tmp + txa + sbc #0 + sta tmp+1 + + ldy #2 + lda (tmp),y + sta tmp2 + iny + lda (tmp),y + sta tmp2+1 + + lda cmd + jsr c2 + + ldy #0 + lda (tmp),y + sta tmp2 + iny + lda (tmp),y + sta tmp2+1 + and tmp2 + cmp #$ff ; address $ffff ? + beq ce + lda (tmp2),y + tax + dey + lda (tmp2),y + jmp ctrl0 + +ce clc + pla + tax + pla + tay + lda cmd + clc + rts + +c2 jmp (tmp2) + +#else /* NMIDEV */ + rti +&&ctrlnmi +&&setnmi lda #E_NOTIMP + sec + rts +#endif +#endif /* NMIRESET */ + .) + +/*************************************************************************** + * + * IRQ handling + * + */ + .( +&&pirq +#ifdef CMOSCPU + pha + phx + phy +#else + pha + txa + pha + tya + pha +#endif + tsx + lda $104,x + and #$10 + beq pb1 +&petbrkjmp + cld +#ifdef EMUTEST + .byt 2 +#endif + jmp pbrk +&petirqjmp +pb1 + cld + jsr memsys + +#ifdef SAVEMEM + KERNELIRQ() + bne taski + SAVEMEM +taski +#endif + +#ifndef NOSYSPORT + lda SYSPORT ; save timer-irq state + pha +#endif + +il +#ifndef NO_DEVICE + jsr irqdev +#endif + +#ifndef NOSYSPORT + pla + ora SYSPORT ; no timer-irq? + pha ; save it + + CLRTIMER() + + jsr testirq ; irq line still set? + beq il ; yes, than back to loop + + pla + bpl endirq2 ; no timer-irq -> no task switch! +#else + + CLRTIMER() +#endif + + KERNELIRQ() + bne endirq + +#ifdef SAVEMEM + RESTOREMEM() +#endif +#ifndef NO_DEVICE + bit adev + bpl endirq ; Device Interrupted -> no Task-switch +#endif +;jmp endirq + jmp irqloop + +#ifndef NOSYSPORT +endirq2 +#ifdef SAVEMEM + KERNELIRQ() + bne taski2 + RESTOREMEM() +taski2 +#endif +#endif + +endirq + jmp retirq + .) + +#ifndef NOSYSPORT ++testirq .( + lda SYSPORT + and #SYS_IRQ + rts + .) +#endif + .) + diff --git a/dump/oa-2.0.9/kernel/jmptbl.a65 b/dump/oa-2.0.9/kernel/jmptbl.a65 new file mode 100644 index 0000000..b2d2f13 --- /dev/null +++ b/dump/oa-2.0.9/kernel/jmptbl.a65 @@ -0,0 +1,140 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef _KERNEL_H_ +#define _KERNEL_H_ + +#echo "kernel jump table" + +#define OSA_VERSION "2.0" +#define OSA_NAME "GeckOS/A65" + +#define RESET OSA2KERNEL + +#define ENMEM OSA2KERNEL+$3 +#define SETBLK OSA2KERNEL+$6 + +#define GETSTR OSA2KERNEL+$9 +#define FRESTR OSA2KERNEL+$c +#define PUTC OSA2KERNEL+$f +#define GETC OSA2KERNEL+$12 +#define UNGETC OSA2KERNEL+$15 +#define STRCMD OSA2KERNEL+$18 + +#define DEVCMD OSA2KERNEL+$1b + +#define FORK OSA2KERNEL+$1e +#define TERM OSA2KERNEL+$21 +#define KILL OSA2KERNEL+$24 +#define YIELD OSA2KERNEL+$27 +#define FORKT OSA2KERNEL+$2a +#define SBRK OSA2KERNEL+$2d + +#define GETINFO OSA2KERNEL+$30 + +#define DUP OSA2KERNEL+$33 + +#define GETSEM OSA2KERNEL+$36 +#define FRESEM OSA2KERNEL+$39 +#define PSEM OSA2KERNEL+$3c +#define VSEM OSA2KERNEL+$3f + +#define SEND OSA2KERNEL+$42 +#define RECEIVE OSA2KERNEL+$45 + +#define SETSIG OSA2KERNEL+$48 +#define SENDSIG OSA2KERNEL+$4b + +#define TDUP OSA2KERNEL+$4e +#define XRECEIVE OSA2KERNEL+$51 + +#define SETNMI OSA2KERNEL+$54 +#define CTRLNMI OSA2KERNEL+$57 + +#define GETPID OSA2KERNEL+$5a + +#define SLOCK OSA2KERNEL+$5d +#define RENICE OSA2KERNEL+$60 +#define CHECKCHLD OSA2KERNEL+$63 + +#endif + +#ifdef SYSTEM + + +#if *-OSA2KERNEL +echo Warning: Kernel jump table at wrong address! +#endif + +jmp preset + +jmp enmem +jmp setblk + +jmp getstr +jmp frestr +jmp putc +jmp getc +jmp ungetc +jmp gets + +jmp devcmd + +jmp fork +jmp kterm +jmp kkill +jmp suspend +jmp forkt +jmp sbrk + +jmp getinfo + +jmp kdup + +jmp getsem +jmp fresem +jmp kpsem +jmp kvsem + +jmp ksend +jmp kreceive + +jmp setsig +jmp sendsig + +jmp tdup +jmp xreceive + +jmp setnmi +jmp ctrlnmi + +jmp kgetpid + +jmp slock +jmp renice +jmp checkchld + +#endif + + diff --git a/dump/oa-2.0.9/kernel/kernel.a65 b/dump/oa-2.0.9/kernel/kernel.a65 new file mode 100644 index 0000000..79eca51 --- /dev/null +++ b/dump/oa-2.0.9/kernel/kernel.a65 @@ -0,0 +1,137 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +#echo OS/A65 kernel + +/**************************************************************************/ +/* OS/A 1.4.0 */ +/* */ +/* The following kernel options are available: */ +/* General options: */ +/* ROM without ROM, all options are set in this file */ +/* CMOSCPU for (Rockwell) CMOS CPU */ +/* NMIDEV allows handling of NMIs in devices - without MMU only */ +/* NMIRESET calls RESET when an NMI is received */ +/* STACKCOPY without MMU, split stack in 2 pieces only and save */ +/* task stack each time the context is switched */ +/* Gives larger stack space per process and more */ +/* processes but is slower */ +/* */ +/* Memory options: */ +/* RAMSIZE Size of the RAM */ +/* MIN_MEM minimum needed size of RAM to start */ +/* ROMTEST if ROMTEST is defined, the MMU is not loaded, the RAM */ +/* is not tested, and RAMSIZE is assumed to be the real */ +/* RAM size. The memory blocks in MMU registers $8-$f */ +/* are secured with GETBLK */ +/* RAMTEST if set, the RAM from address 2 up is being tested up */ +/* to RAMSIZE. If not set, RAMSIZE is assumed to be the */ +/* real RAM size. */ +/* If set, then BATMEM, MEMINIVAL, and NOMIRRORMEM can */ +/* be used */ +/* BATMEM during memory test the main memory is not cleared, */ +/* the value is kept intact (for battery buffered RAM) */ +/* NOMIRRORMEM can be set if definitely _no_ mirrored memory is */ +/* there. Should definitely be set when a 32k RAM socket */ +/* can be fed with an 8 kByte RAM. */ +/* MEMINIVAL value to fill RAM with after RAM test (0 if not set) */ +/* */ +/* Architecture options: */ +/* NOMMU computer without MMU */ +/* NOSYSPORT computer without SYSPORT ($efe0) */ +/* */ +/* Architecture defines - these are defined in arch/x/devices/kinit.a65: */ +/* LEDPORT Address of the port where an LED can be switched on */ +/* LED_LED The bit of the LED in the LEDPORT. 0 means on, */ +/* != 0 means off */ +/* can be set to SYSPORT, SYS_LED for example */ +/* H_ERROR If LEDPORT is not defined, then H_ERROR must be */ +/* defined as routine to signal hardware errors */ +/* INITIMER Routine to init kernel timer, i.e. the preemption */ +/* timer */ +/* CLRTIMER clear the irq line from the kernel timer signal */ +/* */ +/**************************************************************************/ + + +/***************************************************************************/ + +#ifndef ROM /* to allow independend test assembles */ +#define ROM + + .word $2000 + *= $f000 + +#define CMOSCPU +#define NOMMU +#define NOSYSPORT +#define NMIDEV + +#ifndef ROMSTART +#define ROMSTART $8000 +#endif + +#include "arch/config.i65" +#include "kdefs.i65" + +#endif /* ROM */ + +/***************************************************************************/ + +#define VA 1 +#define VB 4 +#define VC 0 + +#define D_Y 97 +#define D_M 03 +#define D_D 20 + +#define SYSTEM + ++OSA2KERNEL =* + +#include "kernel/jmptbl.a65" +#include "kernel/init.a65" +#include "kernel/tasks.a65" +#include "kernel/streams.a65" +#include "kernel/devices.a65" +#include "kernel/files.a65" + +POT2 .byt 1,2,4,8,$10,$20,$40,$80 + +#if * > $fff4 +#echo ROM is to long! +#print *+12 +#endif + + .bss +startmem=* + .zero +startzero=* + + .text + +#ifndef EOK_SEPARATE +#include "kernel/end.a65" +#endif + diff --git a/dump/oa-2.0.9/kernel/ramtest.a65 b/dump/oa-2.0.9/kernel/ramtest.a65 new file mode 100644 index 0000000..18b0760 --- /dev/null +++ b/dump/oa-2.0.9/kernel/ramtest.a65 @@ -0,0 +1,115 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This is a main RAM test routine to be included by kinit, if necessary. + * if BATMEM is defined, memory is not erased, rather restored + * to the previous state. The memory is then set to MEMINIVAL. + * Memory is checked from page 1 up to RAMSIZE. + * If NOMIRRORMEM is set, it is assumed that we do not have mirrored + * memory areas and this is not checked. + */ + + .( + ; test mirrored memory, 256-byte-wise + + lda #0 + sta pz +#ifndef NOMIRRORMEM + sta pz+2 ; test location + ldy #pz+2 ; address of test location relative to page + tax + inx + stx pz+1 +m1 +#ifdef BATMEM + lda (pz),y + tax +#endif + lda pz+1 + sta (pz),y + lda pz+2 + +#ifdef BATMEM + php + txa + sta (pz),y + plp +#endif + bne me ; write to high location changed test location -> end + + inc pz+1 + ;bpl m1 ; up to 32 kByte + lda pz+1 + cmp #RAMEND + bcc m1 + +me lda pz+1 +#else + lda #RAMEND +#endif /* NOMIRRORMEM */ + sta cnt +#ifdef RAMSTART + lda #RAMSTART +#else + lda #1 +#endif + sta pz+1 +mtlx +#ifdef BATMEM + lda (pz),y + tax +#endif +#ifdef SHORTRAMTEST + lda #MEMINIVAL ^ $ff +#else + lda #$55 +#endif + sta (pz),y + cmp (pz),y + bne mtly +#ifndef SHORTRAMTEST + asl + sta (pz),y + cmp (pz),y + bne mtly +#endif +#ifdef BATMEM + txa +#else + lda #MEMINIVAL +#endif + sta (pz),y + cmp (pz),y + bne mtly + iny + bne mtlx + inc pz+1 + lda pz+1 + cmp cnt + bcc mtlx +mtly lda pz+1 + .) + + + diff --git a/dump/oa-2.0.9/kernel/streams.a65 b/dump/oa-2.0.9/kernel/streams.a65 new file mode 100644 index 0000000..b79c1fb --- /dev/null +++ b/dump/oa-2.0.9/kernel/streams.a65 @@ -0,0 +1,603 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* TODO: make strcmd compares a lookup table */ + +#ifdef NO_STREAMS /* embedded kernals probably don't need them */ + +&&getc =notimp +&&putc =notimp +&&gets =notimp +&&ungetc =notimp +&&getstr =notimp +&&frestr =notimp + +#else /* NO_STREAMS */ + +/* Struct StreamData */ + +#define S_II 0*ANZSTRM +#define S_IO 1*ANZSTRM +#define S_CNTW 2*ANZSTRM /* number of Writer */ +#define S_CNTR 3*ANZSTRM /* number of Reader */ +#define S_ESTAT 4*ANZSTRM /* error state byte */ +#define S_SLEN 5*ANZSTRM /* Length of struct */ + +/* + * The stream buffer length must be a power of two, 64 or 128 (tested). + * S_AMASK is the valid bit mask for the stream buffer index. + */ +#define S_AMAX $40 /* $80 */ +#define S_AMASK $3f /* $7f */ +/* + * The watermarks are for rts/cts checking for example. High Water Mark + * must be something around 32 bytes before buffer full, for 9600 baud + * UART operation... + */ +#define S_AHWM $20 /* $60 */ +#define S_ALWM $01 /* $20 */ + + .( + + .zero +SZEI .word 0 +BZEI .word 0 + .text + +#ifdef MAP_ZERO + .zero +#else + .data +#endif +SYR .byt 0 +SAC .byt 0 +STRM .dsb S_SLEN + + .bss +blocks .dsb ANZSTRM*S_AMAX + + .text + .( +&&inistream + lda #0 + tax +l1 sta STRM,x + inx + cpx #S_SLEN + bcc l1 + clc + rts ; jmp inifstr + .) + +#if S_AMAX = $80 +setstream .( + cpx #ANZSTRM + bcc ssok + rts +ssok + txa + lsr + pha + lda #0 + ror ; clears carry + adc #blocks + sta SZEI+1 + clc + rts + .) +#endif +#if S_AMAX = $40 +setstream .( + cpx #ANZSTRM + bcc ssok + rts +ssok + lda #0 + sta SZEI + txa + lsr + ror SZEI + lsr + ror SZEI ; clears carry + pha + lda SZEI + adc #blocks + sta SZEI+1 + clc + rts + .) +#endif + + .( +&&getc .( + jsr memsys + php + sei + sty SYR + jsr teststd + jsr setstream + bcs putnostr + lda STRM+S_IO,x + cmp STRM+S_II,x + beq empty + tay + lda (SZEI),y + pha + iny + tya + and #S_AMASK + sta STRM+S_IO,x + pla + ldy SYR + plp + clc + jmp memtask + ;jsr memtask + ;rts + +&empty lda STRM+S_CNTW,x + bne empt1 + lda #E_EOF + .byt $2c +empt1 lda #E_SEMPTY + jmp xerr + .) + +&&putc .( +#if 0 +.( +cpx #7 +bne xx +cmp #$80 +bcc xx +.byt 2 +xx +.) +#endif + jsr memsys + php + sei + sty SYR + jsr teststd + sta SAC + jsr setstream + bcs putnostr + lda STRM+S_CNTR,x + beq snul ; NUL-Status dann ende + lda STRM+S_II,x + tay + lda SAC + sta (SZEI),y + iny + tya + and #S_AMASK + cmp STRM+S_IO,x + beq full + sta STRM+S_II,x + ldy SYR + lda SAC + plp + clc + jmp memtask + .) + +snul lda #E_NUL + .byt $2c +&putnostr lda #E_NOSTR + .byt $2c +full lda #E_SFULL + jmp xerr + +#ifdef NEED_UNGETC + +&&ungetc .( + jsr memsys + php + sei + sty SYR + jsr teststd + sta SAC + jsr setstream + bcs putnostr + lda STRM+S_CNTR,x + beq snul ; NUL-Status dann ende + lda STRM+S_IO,x + sec + sbc #1 + and #S_AMASK + cmp STRM+S_II,x + beq full + sta STRM+S_IO,x + tay + lda SAC + sta (SZEI),y + ldy SYR + plp + clc + jmp memtask + .) + +#else + +&&ungetc =notimp + +#endif + + .) + + .( +&&getstr lda #SC_GET + .byt $2c +&&frestr lda #SC_FRE + +&&gets + jsr memsys + php + sei + + sty SYR + + cmp #SC_GET + bne a0 + jmp findnew + +a0 jsr teststd + sta SAC + jsr setstream + bcs putnostr + ldy SYR + lda SAC + + cmp #SC_STAT + bne andere +sc_stat + lda STRM+S_CNTR,x + beq nul + lda STRM+S_II,x + sec + sbc STRM+S_IO,x + beq empty + and #S_AMASK + cmp #S_AMAX-1 + beq full + cmp #S_ALWM + bcc low + cmp #S_AHWM + bcc ok + bcs high +empty lda STRM+S_CNTW,x + beq eof + lda #E_SEMPTY + .byt $2c +eof lda #E_EOF + .byt $2c +high lda #E_SHWM + .byt $2c +nul lda #E_NUL + .byt $2c +ok lda #E_OK + .byt $2c +low lda #E_SLWM + .byt $2c +full lda #E_SFULL + .byt $2c +illcode lda #E_NOTIMP +&xerr ret ldy SYR +retx + plp + cmp #1 + jmp memtask + +andere + cmp #SC_GANZ + bne a00 + sec + lda STRM+S_IO,x + sbc STRM+S_II,x + sec + sbc #1 + and #S_AMASK + jmp ret + +a00 cmp #SC_EOF + bne a1 + lda STRM+S_CNTW,x + beq illcode + dec STRM+S_CNTW,x + jmp ok + +a1 cmp #SC_CLR + bne a2 +clrstr lda #0 + sta STRM+S_II,x + sta STRM+S_IO,x + sta STRM+S_ESTAT,x + beq ok1 + +a2 cmp #SC_FRE + bne a3 + lda STRM+S_CNTW,x + beq a2a + dec STRM+S_CNTW,x +a2a jmp frer + +a3 cmp #SC_REG_RD + bne a4 + inc STRM+S_CNTR,x + bne ok1 + +a4 cmp #SC_REG_WR + bne a5 + inc STRM+S_CNTW,x + bne ok1 + +a5 cmp #SC_NUL + bne a6; illcode +frer lda STRM+S_CNTR,x + beq illcode + dec STRM+S_CNTR,x +ok1 jmp ok + +a6 cmp #SC_RWANZ + bne estat + ldy STRM+S_CNTR,x + lda STRM+S_CNTW,x + jmp retx + +nofrex lda #E_NOSTR + bne ret + +estat + cmp #SC_ESTAT ; get error stat byte in yr + bne sestat + lda STRM+S_ESTAT,x + sta SYR + jmp sc_stat +sestat cmp #SC_SSTAT ; set error stat byte + bne cestat + tya + ora STRM+S_ESTAT,x + sta STRM+S_ESTAT,x + jmp ret +cestat cmp #SC_CSTAT ; clear error stat byte + bne illcode1 + tya + eor #$ff + and STRM+S_ESTAT,x + sta STRM+S_ESTAT,x + jmp ret + +illcode1 jmp illcode + +findnew ldx #0 +lx lda STRM+S_CNTW,x + ora STRM+S_CNTR,x + beq ly + inx + cpx #ANZSTRM + bcc lx + bcs nofrex +ly inc STRM+S_CNTR,x + inc STRM+S_CNTW,x + jmp clrstr + .) + +#if 0 + .( +&&getb .( + jsr memsys + php + sei + sty SYR + jsr teststd + + sta SAC + + jsr setstream + bcs putnostr3 + + lda STRM+S_II,x + cmp STRM+S_IO,x + beq empty3 + +#ifndef NO_MMU + lda #0 + jsr setmmu1 + ldy SYR + lda BLKSIZ,y + sec + sbc STRM+S_IO,x + sta BZEI + php + lda BLKSIZ+1,y + sta BZEI+1 + lsr + lsr + lsr + lsr + jsr setmmu1 + lda BZEI+1 + and #$0f + ora #$01 + plp + sbc #0 + sta BZEI+1 +#else + ldy SYR + sec + lda 0,y + sbc STRM+S_IO,x + sta BZEI + lda 1,y + sbc #0 + sta BZEI+1 +#endif + lda SAC + sta SYR + + ldy STRM+S_IO,x +l0 + lda (SZEI),y + sta (BZEI),y + iny + tya + bpl l1 ; this heavily depends on Streamsize = 128!! + clc + adc BZEI + sta BZEI + lda #0 + bcc l1 + inc BZEI+1 +l1 tay + cmp STRM+S_II,x + beq end +l2 dec SYR + bne l0 +end + tya + sta STRM+S_IO,x + lda SAC + sec + sbc SYR + clc + + plp + clc + jmp memtask + ;jsr memtask + ;rts + .) + +snul3 lda #E_NUL + .byt $2c +putnostr3 lda #E_NOSTR + .byt $2c +full3 lda #E_SFULL + .byt $2c +empty3 lda #E_SEMPTY + jmp xerr + +&&putb .( + jsr memsys + php + sei + sty SYR + jsr teststd + + sta SAC + + jsr setstream + bcs putnostr3 + lda STRM+S_CNTR,x + beq snul3 ; NUL-Status dann ende + + ldy STRM+S_II,x + iny + tya + and #$7f + cmp STRM+S_IO,x + beq full3 + +#ifndef NO_MMU + lda #0 + jsr setmmu1 + ldy SYR + lda BLKSIZ,y + sec + sbc STRM+S_II,x + sta BZEI + php + lda BLKSIZ+1,y + sta BZEI+1 + lsr + lsr + lsr + lsr + jsr setmmu1 + lda BZEI+1 + and #$0f + ora #$01 + plp + sbc #0 + sta BZEI+1 +#else + ldy SYR + sec + lda 0,y + sbc STRM+S_II,x + sta BZEI + lda 1,y + sbc #0 + sta BZEI+1 +#endif + + lda SAC + sta SYR + + ldy STRM+S_II,x +l0 + lda (BZEI),y + sta (SZEI),y + iny + tya + bpl l1 ; this heavily depends on Streamsize = 128!! + clc + adc BZEI + sta BZEI + lda #0 + bcc l1 + inc BZEI+1 +l1 tay + cmp STRM+S_IO,x + bne l2 + dey + jmp end +l2 dec SYR + bne l0 +end + tya + sta STRM+S_II,x + lda SAC + sec + sbc SYR + clc + + plp + clc + jmp memtask + ;jsr memtask + ;rts + .) + + .) +#endif /* endif 0 to disable getb/putb */ + .) + +#endif /* NO_STREAMS */ + diff --git a/dump/oa-2.0.9/kernel/tasks.a65 b/dump/oa-2.0.9/kernel/tasks.a65 new file mode 100644 index 0000000..431c765 --- /dev/null +++ b/dump/oa-2.0.9/kernel/tasks.a65 @@ -0,0 +1,1377 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* Struct Task Environment Entry */ + +/* we have three structs now: + * TE_* for task environment handling - not needed for system without + * memory management + * TT_* task table, contains STD streams, etc + * TH_* thread table, has stack info and state + */ + +/* We have a significant change in kernel ID allocation. Task and Thread + * IDs now are directly pointers into the corresponding tables! + * Illegal kernel parameters may do some damage now, but it is supposed to be + * faster. + * If we need consecutive task IDs (probably lower 5 bits local, upper + * three bits net node number), a simple lookup table should be the fastest + * and shortest way. + * + * When entering the kernel, the tasks PCBUF is copied or mapped to SYSBUF + * + * The Environment number 0 is the system environment, where the kernel + * and all the devices operate. On simple systems (without MMU) the same + * environment is used for all tasks. + * + * The scheduler changed in that all the waiting threads are just + * ignored. Instead the thread state must be set at, e.g. VSEM, or + * SEND/RECEIVE by checking for waiting threads. + */ + +#define TT_STDIN 0 /* Stdin */ +#define TT_STDOUT 1 /* Stdout */ +#define TT_STDERR 2 /* Stderr */ +#define TT_PARENT 3 /* parent process ID */ +#define TT_SIGADR 4 /* addr of signal routine */ +#define TT_LIBSAVE 6 /* 2 byte stdlib pointer to process info */ +#define TT_ENV 8 /* environment number */ +#define TT_NTHREADS 9 /* number of running threads */ +#define TT_SIGMASK 10 /* mask of allowed signals */ +#define TT_SIGPEND 11 /* mask of pending signals */ +#define TT_PRIORITY 12 /* priority (i.e. irqcnt) of task */ +#define TT_RETCODE 13 /* return code after kill */ +#define TT_SLEN 14 /* length of task struct */ + +#define TH_ST 0 /* thread state */ +#define TH_TASK 1 /* task ID */ +#define TH_SP 2 /* stack pointer */ +#define TH_LIBSAVE 3 /* 2 byte saved to make stdlib thread save */ +#define TH_PAR 5 /* 3 byte kernel parameter space */ +#define TH_SLEN 8 /* length of thread struct */ + +#ifndef ST_LEN +#define ST_LEN 128 /* stack length */ +#endif + + .( + +#ifdef MAP_ZERO + .zero +#else + .data +#endif + +actTask .byt 0 +actThread .byt 0 + +&Syscnt .byt 0 +Irqcnt .byt 0 +#ifdef NEED_SLOCK +lockfl .byt 0 +#endif + +div .byt 0 +div2 .byt 0 +div3 .byt 0 + + .data + +Xenv .dsb ANZXENV +taskTab .dsb MAXNTASKS * TT_SLEN +threadTab .dsb MAXNTHREADS * TH_SLEN + + .text + +/******************************************************************/ +/* here are the routines to handle the task and thread tables */ + +&initthreads .( + ldx #0 + txa +l0 sta threadTab,x + inx + cpx #MAXNTHREADS * TH_SLEN + bcc l0 + + tax +l1 sta taskTab,x + inx + cpx #MAXNTASKS * TT_SLEN + bcc l1 + rts + .) + +getthread .( + ldy #0 +l0 + lda threadTab + TH_ST,y + beq found + jsr ynextthread + bcc l0 + rts +found + ; lda #0 + sta threadTab + TH_LIBSAVE,y + sta threadTab + TH_LIBSAVE+1,y + clc + rts + .) + +gettask .( + ldx #0 +l0 + lda taskTab + TT_NTHREADS,x + beq found + txa + clc + adc #TT_SLEN + tax + cmp #MAXNTASKS * TT_SLEN + bcc l0 + rts +found + ; lda #0 + sta taskTab + TT_SIGADR,x + sta taskTab + TT_SIGADR+1,x + sta taskTab + TT_SIGMASK,x + sta taskTab + TT_SIGPEND,x + sta taskTab + TT_LIBSAVE,x + sta taskTab + TT_LIBSAVE+1,x + clc + rts + .) + +/* + * returns next thread ID in a and y. + * zero flag and carry flag are set when overrun to thread no 0 + */ +ynextthread .( + tya +&anextthread + clc + adc #TH_SLEN + cmp #MAXNTHREADS * TH_SLEN + bcc l0 + lda #0 +l0 tay + rts + .) + +/************************************************************************/ +/* memory management related, but architecture specific parts + */ + +#include "kernel/kenv.a65" + +/************************************************************************/ + +/* fork a new task */ + +&&fork .( + jsr memsys + sty div + MAPSYSBUF + + ldx SYSBUF+FORK_STDIN + jsr teststd + stx SYSBUF+FORK_STDIN + ldx SYSBUF+FORK_STDOUT + jsr teststd + stx SYSBUF+FORK_STDOUT + ldx SYSBUF+FORK_STDERR + jsr teststd + stx SYSBUF+FORK_STDERR + + lda SYSBUF+FORK_SIZE + ldy SYSBUF+FORK_SHARED + jsr kgetenv + bcc env + jmp noenv +env stx div3 + + jsr gettask + bcs nothread2 + stx div2 + ; x is new task + + lda SYSBUF+FORK_PRIORITY + bne prio_ok + ldy actTask + cpy #<-1 + beq prio_def + lda taskTab + TT_PRIORITY,y + .byt $2c +prio_def lda #IRQCNT +prio_ok sta taskTab + TT_PRIORITY,x + lda actTask + sta taskTab + TT_PARENT,x + + jsr getthread +nothread2 bcs nothread + ; y has thread no + sty div + + + lda div2 ; task id + sta threadTab + TH_TASK,y ; new task id for thread + tax + lda #1 + sta taskTab + TT_NTHREADS,x ; reserve task + + lda div3 + sta taskTab + TT_ENV,x ; save env + + lda #TS_RDY + sta threadTab + TH_ST,y ; reserve thread + txa + sta threadTab + TH_PAR,y + + lda SYSBUF+FORK_STDIN + sta taskTab+TT_STDIN,x + lda SYSBUF+FORK_STDOUT + sta taskTab+TT_STDOUT,x + lda SYSBUF+FORK_STDERR + sta taskTab+TT_STDERR,x + + ldx div ; init new threads stack + jsr initsp + + lda actThread + pha + + lda div + jsr setthread + + lda SYSBUF+FORK_ADDR + clc + adc #$ff + pha + lda SYSBUF+FORK_ADDR+1 + adc #$ff + jsr push + pla + jsr push + + pla + jsr setthread + + CPFORKBUF() + + ldx div2 ; return task ID + lda #E_OK + beq fend +nothread + ldx div3 + jsr freenv + lda #E_NOTASK + .byt $2c +noenv lda #E_NOENV +fend cmp #1 + jmp memtask + ;jsr memtask + ;rts + .) + +&&forkt .( + jsr memsys + clc + adc #$ff ; prepare for RTS + pha + tya + adc #$ff + pha + + lda actThread + sta div + + jsr getthread + bcs nothread + ; y has new thread no + lda actTask + sta threadTab + TH_TASK,y + tax + inc taskTab + TT_NTHREADS,x + + tya + tax + jsr initsp + + txa + jsr setthread + + pla + jsr push + pla + jsr push + + ldy actThread + +; ldx actTask +; txa +; sta threadTab + TH_TASK,y +; inc taskTab + TT_NTHREADS,x + + tya + pha + + lda #TS_RDY + sta threadTab + TH_ST,y + + lda div + jsr setthread + + pla + tax + + lda #E_OK + clc + jmp memtask + ;jsr memtask + ;rts + +nothread pla + pla + lda #E_NOENV + sec + jmp memtask + .) +&&kterm ; active thread terminates + .( + jsr memsys +;.byt 2 + ldx actTask + tay + lda taskTab + TT_NTHREADS,x + cmp #1 + beq suicide + + dec taskTab + TT_NTHREADS,x + + ldy actThread + lda #TS_FREE + sta threadTab + TH_ST,y + + jmp nexttask + .) + +/* TODO: setup last thread to clean up library! */ +suicide ldx actTask + tya ; ac = return code + jmp k1 +&&kkill jsr memsys +k1 .( + sta taskTab + TT_RETCODE,x + stx div2 + + .( + ldy #0 +k2 txa + cmp threadTab + TH_TASK,y + bne kn + lda #TS_FREE + sta threadTab + TH_ST,y + dec taskTab + TT_NTHREADS,x + beq ke +kn jsr ynextthread + bcc k2 +ke .) + .( + lda #0 +k3 tax + lda div2 + cmp taskTab + TT_PARENT,x + bne k4 + lda #<-1 + sta taskTab + TT_PARENT,x + cmp taskTab + TT_NTHREADS,x ; waiting for checkchld + bne k4 + inc taskTab + TT_NTHREADS,x +k4 txa + clc + adc #TT_SLEN + cmp #TT_SLEN*MAXNTASKS + bcc k3 + .) + + .( + ldy div2 + ldx taskTab+TT_STDIN,y + lda #SC_NUL + jsr STRCMD + ldx taskTab+TT_STDOUT,y + lda #SC_EOF + jsr STRCMD + ldx taskTab+TT_STDERR,y + lda #SC_EOF + jsr STRCMD + .) + + .( + ldy div2 + ldx taskTab + TT_PARENT,y + cpx #<-1 + beq nosig + lda #SIG_CHLD + and taskTab + TT_SIGMASK,x + beq nosig + lda #SIG_CHLD + php + sei + ora taskTab + TT_SIGPEND,x + sta taskTab + TT_SIGPEND,x + plp + lda #<-1 + sta taskTab + TT_NTHREADS,y +nosig .) + + ldy div2 + ldx taskTab + TT_ENV,y + jsr freenv + + jmp nexttask + .) + + /************************************************************************/ +/* The scheduler */ + + +nexttask .( ; the next thread should be scheduled + +#ifdef MAP_ZERO + .zero +#else + .data +#endif +schedThread .byt 0 /* ??? current scheduled thread number */ + + .text + + lda actThread ; schedThread +#ifdef NEED_SLOCK + bit lockfl + bmi ok +#endif + jsr anextthread + bcc ok +&&pstart ; the scheduler is started here + ldy #<-1 + tya +psi iny + sta Xenv,y + cpy #ANZXENV-1 + bcc psi + + lda #0 +#ifdef NEED_SLOCK + sta lockfl +#endif + jsr setthread + lda actThread +ok tay + sta schedThread + cld + cli + + ; sty schedThread +psl + lda threadTab + TH_ST,y + beq next + + ldx threadTab + TH_TASK,y + lda taskTab + TT_SIGMASK,x + beq nosig + sty schedThread ; signals can be sent by devices...! + lda taskTab + TT_SIGPEND,x + beq nosig + jsr checksig + ldy schedThread +nosig lda threadTab + TH_ST,y + + cmp #TS_RDY ; thread ready + beq s1 ; then start + + cmp #TS_IRQ ; thread Interrupted + beq s2 ; then start + +next ; check next thread + jsr ynextthread + cmp schedThread ; test if we started the loop with this + ; thread - if yes, none is able to run... + bne psl + + ldx #HE_TASK ; no task runnable - reset machine (will change!) + jmp HERROR + .) + + .( +&s1 + ldx threadTab + TH_TASK,y + lda taskTab + TT_PRIORITY,x + sta Irqcnt + tya + jsr setthread + + ldy actThread + lda threadTab+TH_PAR+2,y + pha + lda threadTab+TH_PAR,y + tax + lda threadTab+TH_PAR+1,y + tay + pla + clc + cli + jmp memtask + .) + + .( +&&irqloop ; scheduler is called in interrupt routine + dec Irqcnt ; simple priority counter... + bne s2a + + ldy actThread + lda #TS_IRQ + sta threadTab+TH_ST,y + jmp nexttask +&s2 + ldx threadTab + TH_TASK,y + lda taskTab + TT_PRIORITY,x + sta Irqcnt + tya + jsr setthread + +s2a ;jmp endirq +&&retirq + MEMTASK2() + +#ifdef CMOSCPU + ply + plx + pla +#else + pla + tay + pla + tax + pla +#endif + rti + + .) +/* +&&irqenv .( + rts + .) +*/ + +/*********************************************************************/ + +&&suspend .( + jsr memsys + sty div + ldy actThread + sta threadTab+TH_PAR+2,y + txa + sta threadTab+TH_PAR,y + lda div + sta threadTab+TH_PAR+1,y + lda #TS_RDY +&wsigentry + sta threadTab+TH_ST,y + jmp nexttask + .) + +/*********************************************************************/ + +#ifdef NEED_RENICE + +&renice .( + jsr memsys + ldy actTask + ldx taskTab + TT_PRIORITY,y + clc + adc taskTab + TT_PRIORITY,y + sta taskTab + TT_PRIORITY,y + txa + clc + jmp memtask + ;jsr memtask + ;rts + .) + +#else + +&renice =notimp + +#endif + +/*********************************************************************/ +/* We don't really need this after making fork transfer the PCBUF! */ + +#ifdef NEED_SLOCK + +&slock .( + jsr memsys + bcc unlock + lda #$ff + .byt $2c +unlock lda #0 + sta lockfl + clc + jmp memtask + .) + +#else + +&slock =notimp + +#endif + +/*********************************************************************/ + +#ifdef NEED_CHECKCHLD + +&&checkchld .( + jsr memsys + lda #0 +loop tax + lda actTask + cmp taskTab + TT_PARENT,x + bne next + lda #<-1 + cmp taskTab + TT_NTHREADS,x + bne next + lda taskTab + TT_RETCODE,x ; error code + inc taskTab + TT_NTHREADS,x + clc + beq end +next txa + clc + adc #TT_SLEN + cmp #TT_SLEN*MAXNTASKS + bcc loop +end jmp memtask + .) + +#else + +&checkchld =notimp + +#endif + +/*********************************************************************/ + +#ifdef NEED_GETINFO + +&&getinfo + .( + jsr memsys + MAPSYSBUF + ldy #0 + sty div +loop + GETTASKMEM + ldx div + sta SYSBUF + TN_MEM,x + tya + sta SYSBUF + TN_PID,x + lda taskTab + TT_ENV,y + sta SYSBUF + TN_ENV,x + lda taskTab + TT_PARENT,y + sta SYSBUF + TN_PARENT,x + lda taskTab + TT_NTHREADS,y + sta SYSBUF + TN_NTHREADS,x + + lda taskTab + TT_STDIN,y + sta SYSBUF + TN_STDIN,x + lda taskTab + TT_STDOUT,y + sta SYSBUF + TN_STDOUT,x + lda taskTab + TT_STDERR,y + sta SYSBUF + TN_STDERR,x + + lda taskTab + TT_SIGADR,y + sta SYSBUF + TN_SIGNAL,x + lda taskTab + TT_SIGADR + 1,y + sta SYSBUF + TN_SIGNAL + 1,x + + lda taskTab + TT_SIGMASK,y + sta SYSBUF + TN_SIGMASK,x + + txa + clc + adc #TN_SLEN + sta div + tya + clc + adc #TT_SLEN + tay +#if MAXNTASKS <= ANZ_ENV + cpy #TT_SLEN * MAXNTASKS +#else + lda div + cmp #TN_SLEN * ANZ_ENV +#endif + bcc loop + clc + jmp memtask + + .) +#else + +&getinfo = notimp + +#endif + +/************************************************************************/ + +#ifdef NO_SEND /* no SEND/RECEIVE/XRECEIVE calls */ + +&&ksend =notimp +&&xreceive =notimp +&&kreceive =notimp + +#else /* NO_SEND */ + +&&ksend .( + jsr memsys + cpx #SEND_SYS + beq serr + sty div + ldy actThread + sta threadTab + TH_PAR+2,y +#ifndef NO_FSM + cpx #SEND_FM + bne send1 + ldx actTask + jsr fm ; needs ac for FM_REG check + bcs serr2 +#endif +send1 jsr testenv + bcs serr + cpx actTask + beq serr + ldy actThread + txa + sta threadTab + TH_PAR,y + lda div + sta threadTab + TH_PAR+1,y + + ldy #0 +l0 txa + cmp threadTab + TH_TASK,y + bne next + lda threadTab + TH_ST,y + cmp #TS_WFTX + beq copy + cmp #TS_WXTX + bne next + lda threadTab + TH_PAR,y + cmp actTask + beq copy +next + jsr ynextthread + bcc l0 + ldx actThread + lda #TS_WFRX + sta threadTab,x + jmp nexttask + +serr lda #E_NOENV +serr2 cmp #1 + jmp memtask + ;jsr memtask + ;rts +copy +#ifdef CPPCBUFTX + sty div + CPPCBUFTX() + ldy div +#endif + lda actTask + sta threadTab + TH_PAR,y + ldx actThread + lda threadTab + TH_PAR+2,x + sta threadTab + TH_PAR+2,y + lda threadTab + TH_PAR+1,x + sta threadTab + TH_PAR+1,y + lda #TS_RDY + sta threadTab + TH_ST,y + + ldx threadTab + TH_TASK,y + + lda #0 + beq serr2 + .) + +&&xreceive + lda #<-1 + .byt $2c +&&kreceive .( + lda #0 ; TS_WFTX + jsr memsys + php + sta div2 + + sty div + ldy actThread + txa + sta threadTab + TH_PAR,y + lda div + sta threadTab + TH_PAR+1,y + + ldy #0 +l0 lda threadTab + TH_ST,y + cmp #TS_WFRX + bne next + lda actTask + cmp threadTab + TH_PAR,y + bne next + bit div2 + bpl copy + txa + cmp threadTab + TH_TASK,y + beq copy +next + jsr ynextthread + bcc l0 + plp + bcc nowait + lda #TS_WFTX + bit div2 + bpl l1 + lda #TS_WXTX +l1 ldy actThread + sta threadTab + TH_ST,y + jmp nexttask + +nowait lda #E_NOTX + sec + jmp memtask + +copy plp +#ifdef CPPCBUFRX + sty div + CPPCBUFRX() + ldy div +#endif + lda #TS_RDY + sta threadTab + TH_ST,y + lda actTask + sta threadTab + TH_PAR,y + + lda threadTab + TH_PAR+2,y + pha + lda threadTab + TH_TASK,y + tax + lda threadTab + TH_PAR+1,y + tay + pla + clc + jmp memtask + .) + +#endif /* NO_SEND */ + +/*********************************************************************/ +/* Signal handling */ + +&setsig .( + jsr memsys + ldx actTask + sty div + bcs setadr + ldy taskTab + TT_SIGMASK,x + sta taskTab + TT_SIGMASK,x + tya + ldy div + clc + jmp memtask + ;jsr memtask + ;rts +setadr php ; this address might be used in IRQ and exchange is + sei ; _not_ atomic without this SEI! + ldy taskTab + TT_SIGADR,x + sta taskTab + TT_SIGADR,x + tya + pha + ldy taskTab + TT_SIGADR+1,x + lda div + sta taskTab + TT_SIGADR+1,x + pla + plp + clc + jmp memtask + ;jsr memtask + ;rts + .) + +/* + * sendsig can also be called from a device or interrupt routine, + * therefore we only save the signal and let the scheduler do all + * the resolving + */ + +&sendsig .( ; ac = signal mask, xr = target task + jsr memsys + bcs sends + lda #TS_WSIG + jmp wsigentry +sends + ldy taskTab + TT_NTHREADS,x + beq not + tay + and taskTab + TT_SIGMASK,x + beq ok + tya + php ; make operation atomic + sei + ora taskTab + TT_SIGPEND,x + sta taskTab + TT_SIGPEND,x + plp +ok lda #E_OK + .byt $2c +not lda #E_NOTASK + clc + jmp memtask + ;jsr memtask + ;rts + .) + +/* + * checksig is called when the scheduler sees that a signal is pending + * when putting a thread to running again + */ + +checksig .( + lda taskTab + TT_SIGADR,x + ora taskTab + TT_SIGADR+1,x + beq clear + + lda threadTab + TH_ST,y + cmp #TS_RDY + beq sigrdy + cmp #TS_WSIG + beq sigrdy + cmp #TS_IRQ + beq sigirq + + lda taskTab + TT_SIGMASK,x + and #SIG_INTABLE + beq none + + lda threadTab + TH_ST,y + cmp #TS_WFRX + beq sigint + cmp #TS_WXTX + beq sigint + cmp #TS_WFTX + beq sigint + cmp #TS_WFSEM + beq sigint +none rts /* TODO: check interruptable flag, interrupt */ + +sigrdy .( + tya + jsr setthread + jsr incretadr + lda #0 + jsr push ; status reg for RTI + ldy actThread + lda threadTab + TH_PAR+2,y + jsr push ; ac for PLA +&sig1 ldx actTask + lda taskTab + TT_SIGPEND,x + ldy actThread + sta threadTab + TH_PAR+2,y ; ac for signal routine + lda taskTab + TT_SIGADR,x + clc + adc #<-1 + pha + lda taskTab + TT_SIGADR+1,x + adc #>-1 + jsr push + pla + jsr push +&clear lda #0 + ldx actTask + sta taskTab + TT_SIGPEND,x +&rtsad rts + .) + +sigirq .( + tya + jsr setthread + jsr pull ; xr + ldy actThread + sta threadTab + TH_PAR,y + jsr pull ; yr + ldy actThread + sta threadTab + TH_PAR+1,y ; ac and sr still on stack +&sig2 lda #TS_RDY + sta threadTab + TH_ST,y + bne sig1 ; always + .) + +sigint .( ; interrupted system call + tya + jsr setthread + jsr incretadr + lda #1 ; status register for RTI (c=1) + jsr push + lda #E_INT + jsr push ; return code for kernel call + ldy actThread + jmp sig2 + .) + +incretadr .( + jsr pull + clc + adc #1 + bcc l1 + pha + jsr pull + tay + iny + tya + jsr push + pla +l1 jmp push + .) + + .) + +/*********************************************************************/ +/* Semaphore handling */ + +#ifdef NO_SEM /* no semaphore code */ + +&&getsem =notimp +&&fresem =notimp +&&kpsem =notimp +&&kvsem =notimp + +#else /* NO_SEM */ + + .( +#ifdef MAP_ZERO + .zero +#else + .data +#endif +SEMFRE .dsb (ANZSEM+7)/8 +SEMVAL .dsb (ANZSEM+SYSSEM+7)/8 + + .text + +&&kpsem .( + jsr memsys + bcc ps1 + jsr tstnset + jmp memtask +ps1 + ldy actThread + txa + sta threadTab+TH_PAR,y ; Semaphor-Nummer + jsr tstnset + bcc rtask + ldy actThread + lda #TS_WFSEM + sta threadTab+TH_ST,y + jmp nexttask +rtask jmp memtask + ;jsr memtask + ;rts + .) + +&&kvsem .( + jsr memsys + ; x has semaphore number + + ldy actThread +l0 lda threadTab + TH_ST,y + cmp #TS_WFSEM + bne next + txa + cmp threadTab + TH_PAR,y + beq gotone +next jsr ynextthread + cpy actThread + bne l0 + + txa + clc + adc #SYSSEM + cmp #ANZSEM+SYSSEM + bcs illpar + jsr asetxy + eor #$ff + and SEMVAL,x + sta SEMVAL,x + jmp ok + +gotone lda #TS_RDY + sta threadTab + TH_ST,y +ok + lda #E_OK + clc + jmp memtask + ;jsr memtask + ;rts + .) + +/* Semaphore administration (alloc, free) */ + + +&&getsem .( + jsr memsys + ldx #0 +l2 lda SEMFRE,x + beq gnext + ldy #0 +l3 lsr + bcs found + iny + cpy #8 + bcc l3 +found lda POT2,y + eor #<-1 + and SEMFRE,x + sta SEMFRE,x + txa + asl + asl + asl + sta div + tya + clc + adc div + tax + lda #E_OK +gne cmp #1 + jmp memtask + ;jsr memtask + ;rts +gnext inx + cpx #(ANZSEM+7)/8 + bcc l2 + lda #E_NOSEM + bcs gne + .) + +&gsetxy txa +asetxy tax + and #7 + tay + txa + lsr + lsr + lsr + tax + lda POT2,y + rts + +&&fresem .( + jsr memsys + cpx #ANZSEM + bcs illpar + jsr gsetxy + ora SEMFRE,x + sta SEMFRE,x + lda #E_OK + .byt $2c +&illpar lda #E_NOSEM + cmp #1 + jmp memtask + ;jsr memtask + ;rts + .) + +&&inisem .( + ldy #(ANZSEM+SYSSEM+7)/8-1 + lda #0 +i1 sta SEMVAL,y + dey + bpl i1 + + lda #$ff + ldy #(ANZSEM+7)/8-1 +if1 sta SEMFRE,y + dey + bpl if1 + clc + rts + .) + +tstnset .( + txa + clc + adc #SYSSEM + cmp #ANZSEM+SYSSEM + bcs illpar1 + jsr asetxy + and SEMVAL,x + bne set + lda POT2,y + ora SEMVAL,x + sta SEMVAL,x + lda #E_OK + .byt $2c +illpar1 lda #E_NOSEM + .byt $2c +set lda #E_SEMSET + cmp #1 + rts + .) + + .) + +#endif /* NO_SEM */ + +/************************************************************************/ + + .( +&&teststd php + ldy actTask + cpy #<-1 + beq stdok + cpx #STDIN + bcc stdok + pha + txa + sec + sbc #STDIN + clc + adc actTask + tax + lda taskTab+TT_STDIN,x + tax + pla +stdok plp + rts + .) + +&kgetpid .( + jsr memsys + ldx actTask + ldy actThread + jmp memtask + .) + + .( +&testenv cpx #OWNTASK + bne te1 + ldx actTask + clc + rts +te1 cpx #$fe-ANZXENV + bcc te2 + cpx #$fe + bcs te2 + pha + lda Xenv-($fe-ANZXENV),x + tax + pla + cpx #$fe-ANZXENV +te2 rts ; c=1 on error + .) + +&tdup .( + jsr memsys + cpx #$fe-ANZXENV + bcc tdx + cpx #$fe + bcs tdx + sta Xenv-($fe-ANZXENV),x + clc + .byt $24 +tdx sec + jmp memtask + ;jsr memtask + ;rts + .) + +/************************************************************************/ + + .( +#ifdef MAP_ZERO + .zero +#else + .data +#endif +d .byt 0 + + .text + +&&kdup jsr memsys + php + cpx #STDIN + bcc duperr + stx d + tax + jsr teststd +#ifdef CMOSCPU + phx +#else + txa + pha +#endif + lda d + clc + adc #<-STDIN + clc + adc actTask + tax + lda taskTab+TT_STDIN,x + tay + pla + plp + bcc dupget + sta taskTab+TT_STDIN,x +dupget tya + clc + jmp memtask + ;jsr memtask + ;rts +duperr plp + sec + lda #E_NOSTR + jmp memtask + ;jsr memtask + ;rts + .) + + .( +&&pbrk + jsr memsys + lda #TS_BRK + ldy actThread + sta threadTab+TH_ST,y + jmp nexttask + .) + + .) + + diff --git a/dump/oa-2.0.9/kernel/zerotest.a65 b/dump/oa-2.0.9/kernel/zerotest.a65 new file mode 100644 index 0000000..4773a42 --- /dev/null +++ b/dump/oa-2.0.9/kernel/zerotest.a65 @@ -0,0 +1,70 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This is a zeropage RAM test routine to be included by kinit, if necessary. + * if BATMEM is defined, memory is not erased, rather restored + * to the previous state. The memory is then set to MEMINIVAL + * + * Could probably be made up to check not for the full zeropage, + * but only a part of it... + */ + + .( + ldx #2 +mtl1 +#ifdef BATMEM + lda 0,x + tay +#endif +#ifdef SHORTRAMTEST + lda #MEMINIVAL ^ $ff +#else + lda #$55 +#endif + sta 0,x + cmp 0,x + bne he_zero1 +#ifndef SHORTRAMTEST + asl + sta 0,x + cmp 0,x + bne he_zero1 +#endif +#ifdef BATMEM + tya +#else + lda #MEMINIVAL +#endif + sta 0,x + cmp 0,x + bne he_zero1 + inx + bne mtl1 + beq end +he_zero1 jmp he_zero +end + .) + + + diff --git a/dump/oa-2.0.9/lib6502/lib6502.a65 b/dump/oa-2.0.9/lib6502/lib6502.a65 new file mode 100644 index 0000000..d928937 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/lib6502.a65 @@ -0,0 +1,74 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This is the includer for the lib6502 standard library. + * It takes the preprocessor-define STDIOADDR as the address where + * the code should end. It sets the define LIB6502 as the start address + * of the library jump table. + */ + + .( + +#include "kernel.i65" +#include "lib6502.i65" + +#include "lib6502/libdef.a65" +#include "lib6502/libglob.a65" +#include "lib6502/libmem.a65" +#include "lib6502/libsem.a65" +#include "lib6502/libsig.a65" +#include "lib6502/libfile.a65" +#include "lib6502/libexec.a65" +#include "lib6502/libloader.a65" +#include "lib6502/libnet.a65" +#include "lib6502/libenv.a65" + +notimp lda #E_NOTIMP + sec + rts + +#define LIB6502BIN + +#ifdef STDIOADDR + +#define LIB6502BINADDR STDIOADDR-3*(LIBCALLNUM+LIBOSACALLS) + +#print LIB6502BINADDR +#print * + +#if * < LIB6502BINADDR + .dsb LIB6502BINADDR-*,<-1 +#else +#echo "Warning: lib6502 too large!" +#endif + +#endif /* STDIOADDR */ + +#include "lib6502/libjmp.a65" + +#undef LIB6502BIN + + .) + diff --git a/dump/oa-2.0.9/lib6502/libdef.a65 b/dump/oa-2.0.9/lib6502/libdef.a65 new file mode 100644 index 0000000..7bcbbe3 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libdef.a65 @@ -0,0 +1,59 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* as LT_ENV is $fc, initializing only 256 bytes to 0 will also set + * two bytes in LT_ENV to zero, clearing the env list. + * If LT_ENV increases, this will be bugged in taskinit (libglob.a65) + */ +#define NUMOFSIG 5 /* number of handled signals */ +#define PATHLEN 64 /* 64 byte max path len, incl drive byte */ +#define MAXFILES 16 /* number of open files */ +#define CMDLEN 128 /* maximum length of command line saved */ +#define ENVLEN 192 /* size of env var list (max 256 byte) */ + + +#define LT_SIGADDR 0 /* signal addresses */ +#define LT_NTHREADS 0+(NUMOFSIG*2) /* number of active threads */ +#define LT_INISTACK 1+LT_NTHREADS /* number of active threads */ +#define LT_FTAB 2+LT_NTHREADS /* table with file modes */ +#define LT_FSTRR 0+(LT_FTAB+MAXFILES) /* table with read streams */ +#define LT_FSTRW 0+(LT_FTAB+2*MAXFILES) /* table with write streams */ +#define LT_PATH 0+(LT_FTAB+3*MAXFILES) /* PATHLEN byte path */ +#define LT_CMDPARS 0+LT_PATH+PATHLEN /* command line parameter */ +#define LT_ENV 0+(LT_CMDPARS+CMDLEN) /* environment var list */ +#define LT_SLEN LT_ENV+ENVLEN /* length of struct */ + +zta = TASKSAVE +zth = THREADSAVE +zen = ENVSAVE + +#define LSEM_MEM %00000001 /* semaphore for mem subsystem */ +#define LSEM_FILE %00000010 /* semaphore for file subsystem */ +#define LSEM_LOAD %00000100 /* semaphore for o65 loader */ +#define LSEM_EXEC %00001000 /* semaphore for exec */ +#define LSEM_ENV %00010000 /* semaphore for env handling */ + +#define PATH_DRV 0 +#define PATH_NAME 1 + diff --git a/dump/oa-2.0.9/lib6502/libenv.a65 b/dump/oa-2.0.9/lib6502/libenv.a65 new file mode 100644 index 0000000..f4ee85c --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libenv.a65 @@ -0,0 +1,273 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/********************************************************************** + * Environment handling for lib6502 + * exports + * Getenv, Putenv + * + */ + .( + .zero +p .word 0 +p2 .word 0 + .text + +&Getenv .( +; .byt 2 + sta zth + sty zth+1 + + jsr taskinit + + lda #LSEM_ENV + jsr llock + + jsr firstv +vloop + ldy #0 + lda (p),y + beq notf + + jsr cmpv + bcs next + sta zth + sty zth+1 +ret + lda #LSEM_ENV + jsr lunlock + + lda zth + ldy zth+1 + clc + rts + +next jsr nextv + bcc vloop + +notf lda #0 + sta zth + sta zth+1 + beq ret ; branch always + .) + + +cmpv .( + ldy #0 +nloop + lda (zth),y + beq end1 + cmp (p),y + bne next + cmp #"=" + beq end1 + iny + bne nloop +end1 + lda (p),y + cmp #"=" + bne next + iny + + tya + clc + adc p + pha + lda p+1 + adc #0 + tay + pla + clc + rts +next sec + rts + .) + +firstv .( + lda zta + clc + adc #LT_ENV + sta p+1 + rts + .) + +nextv .( + ldy #0 +l0 lda (p),y + beq ende + iny + bne l0 + sec + rts +ende iny + tya + clc + adc p + sta p + bcc l1 + inc p+1 +l1 clc + rts + .) + +&Putenv .( +; .byt 2 + sta zth + sty zth+1 + + ldy #0 + lda (zth),y + bne doit + lda #E_ILLPAR + sec + rts +doit + lda #LSEM_ENV + jsr llock + + /* first try to find var in env. */ + + jsr firstv +vloop + ldy #0 + lda (p),y + beq notf + + jsr cmpv + bcc found +next + jsr nextv + bcc vloop + bcs notf + + /* if found, remove old variable (address in p) */ +found + ldy #0 +l1 lda (p),y + beq len + iny + bne l1 +len iny + tya + clc + adc p + sta p2 + lda p+1 + adc #0 + sta p2+1 ; now p2 has the address of the following var. + + ldy #0 +l2 lda (p2),y + beq endl +l3 lda (p2),y + sta (p),y + iny + cmp #0 + bne l3 + beq l2 +endl ; copy finished + + /* now add variable at the end of the list */ +notf +; .byt 2 + jsr firstv + + ldy #0 +l4 lda (p),y + beq ende +l5 iny + lda (p),y + bne l5 + iny + beq l4 +ende + sty p2 + ldy #0 +l6 lda (zth),y + beq l7 + iny + bne l6 +l7 iny + iny + clc + adc p2 +#if ENVLEN <> 256 + cmp #ENVLEN +#endif + bcs nomem + + lda p2 + clc + adc p + sta p2 + lda p+1 + adc #0 + sta p2+1 + + ldy #0 +l8 lda (zth),y + sta (p2),y + iny + cmp #0 + bne l8 + sta (p2),y + + lda #E_OK + .byt $2c +nomem lda #E_NOMEM + pha + lda #LSEM_ENV + jsr lunlock + pla + cmp #1 + rts + .) + +&Getenvp .( + lda zta + clc + adc #LT_ENV + tay + pla + rts + .) + +&Getos .( + lda #ostxt + rts + +ostxt .asc OSA_NAME, 32, OSA_VERSION, 32, OSA_CPU, 32 + .asc OSA_ARCH, 32 + .asc "lib6502",32,"0.6",0 + .) + + .) + diff --git a/dump/oa-2.0.9/lib6502/libexec.a65 b/dump/oa-2.0.9/lib6502/libexec.a65 new file mode 100644 index 0000000..c8fb6da --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libexec.a65 @@ -0,0 +1,598 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/********************************************************************** + * Exec handling for lib6502 + * exports + * Exec, Forkto, Forkthread, Term, Kill, Getpid + * + */ + + .( + +/********************************************************************** + * Forkto forks a new thread and executes the executable given. + * No open files are inherited. + * + * It forks a new OS task and sets it to run at a library routine + * that communicates with the local library routine by a stream. + * The task environment is transfered this way. + * + * The forked task then opens the executable and invokes the + * exec code to start the new executable. + * + * The forked task closes the comm. stream without error if everything + * went right, or sets the error bits if there was an error. If there + * was an error, the forked task writes the error code to the stream + * which the forking task can read before closing it. + * + */ + + .( +strerr rts + +&&Forkto + sta zth + sty zth+1 + + jsr GETSTR + bcs strerr + txa + pha + + ldx #SEM_SENDBUF + clc + jsr PSEM ; get the sendbuf which we need to FORK + + pla + sta PCBUF+FORK_NAME ; - no name, give comm stream as parameter + pha ; save for later + + ldy #0 + lda (zth),y + tax + jsr checkfd_r + bcs ferr2 + stx PCBUF+FORK_STDIN + + ldy #1 + lda (zth),y + tax + jsr checkfd_w + bcs ferr2 + stx PCBUF+FORK_STDOUT + + ldy #2 + lda (zth),y + tax + jsr checkfd_w +ferr2 bcs ferr + stx PCBUF+FORK_STDERR + + ldx PCBUF+FORK_STDIN + lda #SC_REG_RD + jsr STRCMD + ldx PCBUF+FORK_STDOUT + lda #SC_REG_WR + jsr STRCMD + ldx PCBUF+FORK_STDERR + lda #SC_REG_WR + jsr STRCMD + + pla +&&init_forkto_i ; this is a ROM entry only for init + ; which has to start lib6502 progs without + ; too much support + pha + + ldy #3 + ldx #FORK_NAME+1 ; copy cmdline + parameter +l0 lda (zth),y +l1 sta PCBUF,x + iny + inx + beq lerr + cmp #0 + bne l0 + cpx #FORK_NAME+2 ; first char + beq l0 + lda PCBUF-2,x + bne l0 + + pla +&&mon_forkto_i ; this is a ROM entry for the monitor + ; ac = comm stream, xr = length of fork + ; struct in PCBUF. First byte of filename + ; is comm stream + pha + + lda #>Memend ; initial RAM size + sta PCBUF+FORK_SIZE + lda #0 + sta PCBUF+FORK_PRIORITY +#ifndef LIB6502_SHAREDZERO + lda #>-ROMSTART ; shared ROM size +#endif + sta PCBUF+FORK_SHARED + + lda #libfork + sta PCBUF+FORK_ADDR+1 + + txa + tay +;.byt 2 + jsr FORK +;.byt 2 + bcc ok + pha + + ldx PCBUF+FORK_STDIN + lda #SC_NUL + jsr STRCMD + ldx PCBUF+FORK_STDOUT + lda #SC_EOF + jsr STRCMD + ldx PCBUF+FORK_STDERR + lda #SC_EOF + jsr STRCMD + + pla + .byt $2c +lerr lda #E_FNAMLEN +ferr + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + tay + pla + tax + jsr FRESTR + tya + sec + rts +ok + pla ; stream number + sta zth + stx zth+1 + + ; copy cwd to communication stream + lda zta ; check if task is lib6502, otherwise + ora zta+1 ; just send empty path (when called from init) + bne initd + + lda #0 + ldx zth + jsr eputc ; empty path (drive byte + zero-length path) + jsr eputc + jsr eputc ; empty environment + jsr eputc +;.byt 2 + jmp l2 +initd + ldy #LT_PATH + lda (zta),y + ldx zth + jsr eputc + +ll iny + lda (zta),y + jsr eputc + cmp #0 + bne ll + + ; copy env to communication stream + + lda zth + tax + pha + lda zth+1 + pha + lda zta + clc + adc #LT_ENV + sta zth+1 + + ldy #0 + lda (zth),y + jsr eputc +le iny + lda (zth),y + jsr eputc + cmp #0 + bne le + dey + lda (zth),y + beq lee + iny + jmp le +lee + pla + sta zth+1 + pla + sta zth + +l2 jsr YIELD + ; wait till forked thread returns error code - indicated by PUSH flag. + ldx zth + lda #SC_ESTAT + jsr STRCMD + tya + and #SCE_PUSH + beq l2 + + ldx zth + jsr GETC + pha + + ; close comm. stream + ldx zth + lda #SC_NUL + jsr STRCMD + + pla + ldx zth+1 + ldy #0 + cmp #1 + rts + +eputc .( + pha + jsr PUTC + bcc eok + cmp #E_NUL + beq cerr + jsr YIELD + pla + jmp eputc +cerr +eok pla + rts + .) + +egetc .( + jsr GETC + bcc eok + cmp #E_EOF + beq cerr + jsr YIELD + jmp egetc +cerr +eok rts + .) + + +libfork .( /* this is the routine where the new task is started */ + cli + lda PCBUF+FORK_NAME + pha +;.byt 2 + jsr taskinit +;.byt 2 + ; read cwd from parent + pla + pha + tax + jsr egetc + ldy #LT_PATH ; drive byte + sta (zta),y +rd iny + jsr egetc ; nullbyte terminated path + sta (zta),y + cmp #0 + bne rd + ; read env from parent + lda zta + clc + adc #LT_ENV + sta zth+1 + pla + pha + tax + ldy #0 + jsr egetc + sta (zth),y ; at least one byte long - now dey below always works +re iny + jsr egetc + sta (zth),y + cmp #0 + bne re + dey + lda (zth),y + beq endenv ; last one was zero too -> end of environment + iny + jmp re +endenv + ; call exec routine + lda #PCBUF+FORK_NAME+1 + jsr doload +;.byt 2 + tax + + pla + sta zth ; comm stream number + txa + + php + pha + tya + pha + bcc noerr + txa + .byt $2c +noerr lda #0 + + ldx zth + jsr PUTC + ldy #SCE_PUSH + lda #SC_SSTAT + jsr STRCMD + lda #SC_EOF + jsr STRCMD + + pla + sta zth+1 + pla + sta zth + plp + bcs loaderr + + lda #>term-1 + pha + lda #LT_CMDPARS + tay + pla ; pointer to cmd line + jmp (zth) + +loaderr +;.byt 2 + jsr GETPID + jsr bcleanpid ; free all memory allocated by this task + jmp TERM + + .) + + .) + +/********************************************************************** + * + */ + +&Forkthread .( + sta zth + sty zth+1 + ldy #LT_NTHREADS + lda (zta),y + clc + adc #1 + sta (zta),y + + lda zth + ldy zth+1 + jsr FORKT + bcs error + rts +error pha + ldy #LT_NTHREADS + lda (zta),y + sec + sbc #1 + sta (zta),y + pla + sec + rts + .) + +&Kill .( + cpx #MYTASK + beq Term +nosuicide + lda #E_NOTIMP + sec + rts + .) + +&Term .( + pha + jsr taskinit ; well, if necessary...? + ldy #LT_NTHREADS + lda (zta),y + beq errzero + sec + sbc #1 + sta (zta),y + beq cleanup +errzero pla + jmp TERM +cleanup + ldy #LT_FTAB +l0 lda (zta),y + bne closefd +l1 iny + cpy #LT_FTAB+MAXFILES + bcc l0 + + jsr GETPID + jsr bcleanpid ; free all memory allocated by this task + pha + jmp TERM + +closefd + and #5 + beq nord + tya + pha + clc + adc #MAXFILES + tay + lda (zta),y + tax + lda #SC_NUL + jsr STRCMD + pla + tay +nord lda (zta),y + and #2 + beq nowr + tya + pha + clc + adc #2*MAXFILES + tay + lda (zta),y + tax + lda #SC_EOF + jsr STRCMD + pla + tay +nowr lda #0 + sta (zta),y + beq l1 + .) + +&Getpid .( + jsr GETPID + ldy #0 + rts + .) + +doload .( + .zero +cp .word + .text + + sta zth + sty zth+1 + + /* copy parameter to save area */ + lda #LSEM_EXEC + jsr llock + + lda zta + clc + adc #LT_CMDPARS + sta cp+1 + + ldy #0 +c0 lda (zth),y + sta (cp),y + iny + cpy #CMDLEN + bcc c0 + + lda #LSEM_EXEC + jsr lunlock + + ldx #0 + jsr fopen2 ; like fopen, does not release PCBUF + + + php + txa + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + plp + + bcs ende + pha + tax + + jsr loader + + sta zth + pla + tax + lda zth + + php + pha + tya + pha + jsr fclose + pla + tay + pla + plp +ende rts + .) + +&Exec .( + sta zth + sty zth+1 + + jsr GETPID + + ldy #LT_INISTACK + lda (zta),y + tax + txs + + lda zta + ldy zta+1 +;.byt 2 + jsr bcleanpida ; clean all allocated mem except addr in a/y + + lda zth + ldy zth+1 + + jsr doload + bcs end +;.byt 2 + sty zth+1 + sta zth + jsr doit + jmp term +doit + jmp (zth) + +end + rts + .) + + .) + diff --git a/dump/oa-2.0.9/lib6502/libfile.a65 b/dump/oa-2.0.9/lib6502/libfile.a65 new file mode 100644 index 0000000..a6eebc0 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libfile.a65 @@ -0,0 +1,1679 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/********************************************************************** + * File handling for lib6502 + * exports + * Fgetc, Fputc, Fread, Fwrite + * Fopen, Fclose + * + * Actually many routines just pass through to the kernel, and + * do not check if parameters are right. + * + * Drive names are single char, "a-z" and "A-Z", case independent. + */ + + .( + + .zero +f1 .word 0 +f2 .word 0 + +d =f2 + + .text + +&getfd .( /* this is called by others to get and lock an entry + in the fd table. y then holds the fileno + LT_FTAB */ + jsr fllock + + ldy #LT_FTAB +l0 lda (zta),y + beq foundfd + iny + cpy #LT_FTAB+MAXFILES + bcc l0 + bcs fderror +foundfd lda #8 ; lock temporarily + sta (zta),y + clc +fderror php + jsr flunlock + plp + rts + .) + +&Fclose .( + stx zth + txa + clc + adc #LT_FTAB + sta zth+1 + tay + lda (zta),y + beq nofd + jsr fllock + + asl + asl + asl + sta (zta),y ; clear lower bits to disable access from other threads + + and #8+32 ; read + directory + beq noread + tya + clc + adc #MAXFILES + tay + lda (zta),y + tax + lda #SC_NUL + jsr STRCMD +noread + ldy zth+1 + lda (zta),y + and #16 ; write + beq nowrite + tya + clc + adc #2*MAXFILES + tay + lda (zta),y + tax + lda #SC_EOF + jsr STRCMD +nowrite + jsr flunlock + + ldy zth+1 + lda #0 + sta (zta),y + clc + rts + +nofd lda #E_NOFILE + sec + rts + .) + +/**************************************************************************** + * currently we only have uni-directional opens allowed in this OS, + * with the exception of non-seekable internet connection, which are + * not handled here. We don't have to take care of them during open + * here, only in the other routines. + */ + .( +strerr pha + ldy f1 + lda #0 + sta (zta),y + pla + .byt $2c +fderror lda #E_NOFILE + pha + jsr flunlock + ldx #SEM_SENDBUF + jsr VSEM + sec + pla + rts + + .data +openmode .byt 0 + .text + +&&Fopen + sta zth + sty zth+1 + + txa + pha + + jsr taskinit ; be save... + + clc + ldx #SEM_SENDBUF + jsr PSEM ; this can block, so we do it first. + + pla + tax + jsr fopen2 + + php + pha + txa + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + tax + pla + plp + rts + +&&fopen2 + txa + pha + + jsr fllock + + pla + sta openmode + + ldy #LT_FTAB +l0 lda (zta),y + beq foundfd + iny + cpy #LT_FTAB+MAXFILES + bcc l0 + bcs fderror +foundfd lda #8 ; lock temporarily + sta (zta),y + sty f1 + + jsr GETSTR + bcs strerr + + stx PCBUF+FS_OPEN_STR + + lda f1 + clc + adc #MAXFILES + tay + txa + sta (zta),y ; for reading + tya + clc + adc #MAXFILES + tay + txa + sta (zta),y ; for writing + + lda f1 + pha ; save fd + + jsr getname + + lda zta + clc + adc #LT_PATH + pha + lda zta+1 + adc #0 + tay + pla + jsr usedir ; returns length in x + bcs lengtherr + + lda #0 + sta PCBUF+FS_OPEN_PFAD + + ldy openmode + cpy #4 + bcs cmderr + lda localfscmd,y + bmi cmderr + pha + txa + tay + pla + jsr flunlock ; unlock file lib before thread lock + pha ; save command + + ldx #SEND_FM + jsr SEND + sec + jsr XRECEIVE + + cmp #E_OK + bne fserr + + pla ; get command + cmp #FS_OPEN_RD + beq ord + lda #2 + .byt $2c +ord lda #1 + + tax + pla ; get fd back + tay + txa + sta (zta),y + tya + sec + sbc #LT_FTAB + tax + + lda #E_OK + clc + rts + +cmderr +lengtherr + pla + tay + lda #0 ; we can unlock the fd w/o fllock + sta (zta),y + ldx PCBUF+FS_OPEN_STR + jsr FRESTR + lda #E_FNAMLEN + sec + rts + +fserr tay + pla ; fs command + pla ; fd + tax + tya + pha ; error code + txa + pha ; fd + clc + adc #MAXFILES + tay + lda (zta),y + tax + jsr FRESTR + pla ; fd + tay + lda #0 + sta (zta),y + pla ; error code + sec + rts + +localfscmd + .byt FS_OPEN_RD, FS_OPEN_WR, <-1, FS_OPEN_AP + + .) + +/**************************************************************************** + * Chdir is called with the argument address in a/y + * it is changing the file path in (zta),LT_PATH + * The implementation is horrible, and using PCBUF, but time is pressing... + */ + +&Chdir .( + sta zth + sty zth+1 + + clc + ldx #SEM_SENDBUF + jsr PSEM + + jsr fllock + + lda zta + clc + adc #LT_PATH + sta f1 + lda zta+1 + adc #0 + sta f1+1 + + jsr getname + + lda PCBUF+FS_OPEN_DRV + bmi nodrive ; no drive given + ldy #PATH_DRV + cmp (f1),y + beq nodrive + sta (f1),y + iny + lda #0 + sta (f1),y ; drive given -> clear old path +nodrive inc f1 ; inc f1 over drive byte + bne nd1 + inc f1+1 + ldy #0 + ; Name untersuchen +nd1 ldx #FS_CMD_NAME + lda PCBUF,x + bne ndrx ; kein Name dann Pfad lschen + sta (f1),y + jmp cdend + +ndrx + cmp #DIRSIGN ; Name beginnt mit DIRSIGN + bne nd2 + lda #0 ; dann Pfad loeschen + sta (f1),y + +nd2a inx +nd2 lda PCBUF,x ; weiter Name anschauen + beq ndr ; kein Name dann Ende + cmp #DIRSIGN + beq nd2a ; DIRSIGN ueberlesen + cmp #"." + bne nameok ; kein '.' dann ok + inx + lda PCBUF,x ; hier mindestens ein '.' + beq ndr ; Null dann Ende + cmp #DIRSIGN ; DIRSIGN, + beq nd2a ; dann '.' ignorieren + cmp #"." ; noch'n Punkt ? + bne nerrx ; nein, dann + jsr getpos + ldy d ; Position des letzten DIRSIGNs + lda #0 + sta (f1),y ; loeschen = eine Verzeichnis-Ebene hoeher + beq nd2a ; (absolut) + +nerrx dex +nameok jsr getpos ; y=Laenge des alten Pfads + sty d ; hier Verzeichnis-Name an Pfad anhaengen +no iny + cpy #PATHLEN + bcs nerr + lda PCBUF,x + beq nr + cmp #DIRSIGN + beq nr + sta (f1),y + inx + bne no +nr lda #0 + sta (f1),y + ldy d + lda #DIRSIGN ; alles ok, dann Nullbyte (Ende alter Pfad) mit + sta (f1),y ; DIRSIGN berschreiben + lda PCBUF,x ; Ende des neuen Verzeichnisses + bne nd2a ; nein, dann wieder nach oben +cdend +ndr clc + .byt $24 +nerr sec + php + jsr flunlock + ldx #SEM_SENDBUF + jsr VSEM + plp + lda #E_FNOPATH + rts + +getpos ldy #0 ; holt y=Laenge des alten Pfadnamens + sty d ; und d=Position des letzten DIRSIGNs +no0 lda (f1),y + beq no1 + cmp #DIRSIGN + bne no2 + sty d +no2 iny + bne no0 +no1 rts + .) + +/**************************************************************************** + * cwd returns the current working directory into a given buffer + */ + +&Cwd .( + sta zth + sty zth+1 + + jsr fllock + + dex + stx f2 + cpx #2 + bcc lerr + + lda zta + clc + adc #LT_PATH-1 + sta f1 + lda zta+1 + adc #0 + sta f1+1 + + ldy #1 + lda (f1),y ; path byte (LT_PATH-1+1) + clc + adc #"a" + dey + sta (zth),y + lda #":" + iny + sta (zth),y +loop iny + lda (f1),y + sta (zth),y + beq end + cpy f2 + bcc loop +lerr lda #E_FNAMLEN + .byt $2c +end + lda #E_OK + jsr flunlock + clc + rts + .) + + +/**************************************************************************** + * some of these routines are just grabbed from the oldlib code, as + * they provide all the functionality I need for Fopen... + * They have to be fllock'ed + */ + + +getname .( + /* takes the name from (zth),0+ */ + lda #0 + sta PCBUF+FS_OPEN_NAME + ldy #<-1 + sty PCBUF+FS_OPEN_DRV +g1 iny + lda (zth),y + beq gr + cmp #" " + beq g1 + cmp #":" + beq g1 + cmp #34 ; " + beq g2 + iny + lda (zth),y + dey + cmp #":" + bne g2 + lda (zth),y + cmp #$41 ; "A" + bcc g3 + sbc #1 +g3 and #$0f + sta PCBUF+FS_OPEN_DRV + iny + iny +g2 dey + ldx #FS_OPEN_NAME +; bne g2a + +; &set2name /* x=iobuf, y=pcbuf */ +; sta zp +; sty zp+1 +; ldy #<-1 +;g2a +g2a lda #0 ;#" " + sta d +gn1 iny + lda (zth),y + beq gn3 +; cmp #" " ; remove leading " ". +; beq gn1 +; cmp #">" +; beq gn3 + cmp #34 ; " + bne gn2 + iny + sta d +gn2 lda (zth),y + beq gn3 + cmp d + beq gn3a + sta PCBUF,x + inx + iny + bne gn2 + +gn3a iny +gn3 lda #0 + sta PCBUF,x + inx +gr rts + .) + +usedir .( + sta f1 + sty f1+1 + lda PCBUF+FS_OPEN_DRV + bpl ok ; drive given by user -> no path + + ldy #PATH_DRV + lda (f1),y + sta PCBUF+FS_OPEN_DRV + + ldx #FS_OPEN_NAME + lda PCBUF,x + cmp #DIRSIGN ; path given absolute -> no replacement + beq ok + +ud2 iny ; find the length of the path + lda (f1),y + bne ud2 + sty d +ud4 lda PCBUF,x ; find the length of the name + beq ud3 + inx + bne ud4 +ud3 inx + txa + clc + adc d + sta d + bcs nerr + tay +ud5 lda PCBUF,x ; copy name to new location + sta PCBUF,y + dey + dex + cpx #FS_OPEN_NAME + bcs ud5 + ldy #PATH_NAME +ud6 lda (f1),y + sta PCBUF+FS_OPEN_NAME-PATH_NAME,y + beq ud7 + iny + bne ud6 +ud7 lda #DIRSIGN + sta PCBUF+FS_OPEN_NAME-PATH_NAME,y + ldx d + clc + rts +nerr sec + rts +ok ldx #FS_OPEN_NAME +ok1 lda PCBUF,x + beq oke + inx + bne ok1 +oke inx + clc + rts + .) + +/****************************************************************************/ + +&&Flib2osa_r +&checkfd_r .( /* check if fd in x is ok for read, then return real fd in x. + * otherwise clear stack and return to calling routine */ + /* not allowed to use zth ! */ + lda #1 + .byt $2c +&&&Flib2osa_w +&&checkfd_w /* check for write */ + lda #2 + .byt $2c +&&checkfd_d /* check for directory */ + lda #4 + pha + txa + clc + bmi stdio + adc #LT_FTAB + tay + pla + and (zta),y + beq error + and #2 + beq read + tya + ;clc + adc #2*MAXFILES + bne get +read tya + clc + adc #MAXFILES +get tay + lda (zta),y + tax + rts + +stdio pla + rts + +error + sec + lda #E_NOFILE + rts + .) + + +/****************************************************************************/ + +fllock pha + lda #LSEM_FILE + jsr llock + pla + rts + +flunlock + pha + lda #LSEM_FILE + jsr lunlock + pla + rts + +/****************************************************************************/ + +putf1 + ldy #0 + lda (zth),y + sta f1 + iny + lda (zth),y + sta f1+1 + iny + lda (zth),y + sta f2 + iny + lda (zth),y + sta f2+1 + rts + +getf1 + ldy #0 + lda f1 + sta (zth),y + iny + lda f1+1 + sta (zth),y + iny + lda f2 + sta (zth),y + iny + lda f2+1 + sta (zth),y + rts + +&Fwrite .( + php + sta zth + sty zth+1 + ldy #2 + lda (zth),y + iny + ora (zth),y + bne doit + plp + lda #E_ILLPAR + sec + rts +doit + txa + pha + jsr checkfd_w + bcs xerr +rl + jsr fllock + jsr putf1 +next + ldy #0 + lda (f1),y + jsr PUTC + bcc ok + pha + jsr getf1 + jsr flunlock + pla + cmp #E_NUL + beq xerr ; carry is always set when jumping + pla + plp + php + pha + bcc ret + jsr YIELD + jmp rl +ok + inc f1 + bne o1 + inc f1+1 +o1 lda f2 + bne o2 + dec f2+1 +o2 dec f2 + lda f2 + ora f2+1 + bne next + ; finished job + jsr getf1 + jsr flunlock +ret lda #E_OK + sec + beq xerr +/* +err + tay + pla + tax + tya + plp + cmp #1 + rts +*/ + .) + +&Fread .( + php + sta zth + sty zth+1 + ldy #2 + lda (zth),y + iny + ora (zth),y + bne doit + plp + lda #E_ILLPAR + sec + rts +doit + txa + pha + jsr checkfd_r +&xerr bcs err +rl + jsr fllock + jsr putf1 +next + jsr GETC + bcc ok + pha + jsr getf1 + jsr flunlock + pla + cmp #E_EOF + beq err + pla + plp + php + pha + bcc ret + jsr YIELD + jmp rl +ok + ldy #0 + sta (f1),y + inc f1 + bne o1 + inc f1+1 +o1 lda f2 + bne o2 + dec f2+1 +o2 dec f2 + lda f2 + ora f2+1 + bne next + ; finished job + jsr getf1 + jsr flunlock +ret lda #E_OK +&err + tay + pla + tax + tya + plp + cmp #1 + rts + .) + +/****************************************************************************/ + +&Fputc .( + stx zth + sty zth+1 + pha + php + jsr checkfd_w + bcs err2 + plp + bcs fputw + + pla + jsr PUTC + ldx zth + ldy zth+1 + rts +fputw + pla + pha + jsr PUTC + bcc ok + cmp #E_NUL + beq ok + jsr YIELD + jmp fputw +err2 + plp + sec +ok + tax + pla + txa + ldy zth+1 + ldx zth + rts + .) + +&Fgetc .( + php + stx zth + sty zth+1 + pha + jsr checkfd_r + bcs err + pla +gl + jsr GETC + bcc ok + cmp #E_EOF + beq gcerr + plp + php + bcc gcerr + jsr YIELD + jmp gl +ok + ldy zth+1 + ldx zth + plp + clc + rts +gcerr ldy zth+1 + ldx zth + plp + sec + rts + .) + +/****************************************************************************/ + +&Fseek .( + lda #E_NOSEEK + sec + rts + .) + +/****************************************************************************/ + +&Pipe .( + jsr GETSTR + bcc ok + rts +ok + jsr fllock + + ldy #LT_FTAB +l0 lda (zta),y + beq found1 + iny + cpy #LT_FTAB+MAXFILES + bcc l0 + bcs err1 +found1 sty f1 + tya + clc + adc #MAXFILES + tay + txa + sta (zta),y + + ldy f1 +l1 iny + cpy #LT_FTAB+MAXFILES + bcs err2 + lda (zta),y + bne l1 + + sty f1+1 + tya + clc + adc #2*MAXFILES + tay + txa + sta (zta),y + + ldy f1 + lda #1 + sta (zta),y + tya + sec + sbc #LT_FTAB + pha ; read-fd + + ldy f1+1 + lda #2 + sta (zta),y + tya + sec + sbc #LT_FTAB ; write-fd + + tay + pla + tax + lda #E_OK + jsr flunlock + clc + rts + +err1 err2 + jsr FRESTR + jsr flunlock + lda #E_NOFILE + sec + rts + .) + +/****************************************************************************/ + +&Dup .( + jsr fllock + stx f1 + ldy #LT_FTAB +l0 lda (zta),y + beq found + iny + cpy #LT_FTAB+MAXFILES + bcc l0 + jsr flunlock + lda #E_NOFILE + sec + rts +found + sty f1+1 + lda f1 + bmi stdio + clc + adc #LT_FTAB + sta f1 + tay +found1 + lda (zta),y + ldy f1+1 + sta (zta),y + pha + + lda f1 + clc + adc #MAXFILES + tay + lda (zta),y + tax + lda f1+1 + clc + adc #MAXFILES + tay + txa + sta (zta),y + + pla + pha + and #1 + beq nord + lda #SC_REG_RD + jsr STRCMD +nord + lda f1 + clc + adc #2*MAXFILES + tay + lda (zta),y + tax + lda f1+1 + clc + adc #2*MAXFILES + tay + txa + sta (zta),y + + pla + pha + and #2 + beq nowr + lda #SC_REG_WR + jsr STRCMD +nowr + pla + + lda f1+1 + sec + sbc #LT_FTAB + tax + jsr flunlock + clc + rts + +stdio ldx f1 + clc + jsr DUP + pha + lda f1+1 + clc + adc #MAXFILES + tay + pla + pha + sta (zta),y + tya + clc + adc #MAXFILES + tay + pla + sta (zta),y + lda f1 + cmp #STDIN + bne noin + lda #1 + .byt $2c +noin lda #2 + ldy f1+1 + sta (zta),y + sty f1 + jmp found1 ; copy to itself, increasing rd/wr pointers in this way + .) + +/****************************************************************************/ + +&Stddup .( + jsr fllock + stx f1 + sty f2 + tya + clc + adc #LT_FTAB + sta f1+1 + tay + cpx #STDIN + bne noread + lda (zta),y + and #1 + beq ferr + tya + clc + adc #MAXFILES +x1 tay + sty f1+1 + lda (zta),y + sec + jsr DUP + ldy f1+1 + sta (zta),y + clc + ldx f2 + jsr flunlock + clc + rts +noread + cpx #STDOUT + beq write + cpx #STDERR + bne ferr +write lda (zta),y + and #2 + beq ferr + tya + clc + adc #2*MAXFILES + bne x1 ; always + +ferr jsr flunlock + lda #E_NOFILE + sec + rts + .) + +/****************************************************************************/ + +&Fcntl .( + jsr fllock + stx f1 + sta f1+1 + + cmp #FC_PUSH + bne nopush + jsr checkfd_w + bcs efile + lda #SC_SSTAT + ldy #SCE_PUSH + jsr STRCMD + jmp ret +nopush + cmp #FC_PULL + bne nopull + jsr checkfd_r + bcs efile + lda #SC_SSTAT + ldy #SCE_PULL + jsr STRCMD + +efile lda #E_NOFILE + .byt $2c +enoti lda #E_NOTIMP + .byt $2c +enord lda #E_NOREAD + .byt $2c +enowr lda #E_NOWRITE + .byt $2c +ret lda #E_OK + jsr flunlock + cmp #1 + rts +nopull + cmp #FC_WCHECK + bne nowcheck + jsr checkfd_w + bcs efile + + lda #SC_STAT + jsr STRCMD + cmp #E_SFULL + beq enowr + cmp #E_NUL + bne ret + beq enowr +nowcheck + cmp #FC_RCHECK + bne enoti + jsr checkfd_r + bcc rcok + jsr checkfd_d + bcs efile +rcok lda #SC_GANZ + jsr STRCMD + bcs enord + cmp #0 + bne ret + beq enord + .) + +#if 0 +&Fcntl .( + jsr fllock + stx f1 + sta f1+1 + txa + clc + adc #LT_FTAB + tay + sty f2 + ldx f1+1 + lda (zta),y + + cpx #FC_PUSH + bne nopush + and #2 + beq ferr + tya + clc + adc #2*MAXFILES + tay + lda (zta),y + tax + lda #SC_SSTAT + ldy #SCE_PUSH + jsr STRCMD + jmp ret +nopush + cpx #FC_PULL + bne nopull + and #1 + beq ferr + tya + clc + adc #MAXFILES + tay + lda (zta),y + tax + lda #SC_SSTAT + ldy #SCE_PULL + jsr STRCMD +ret jsr flunlock + lda #E_OK + clc + rts + +ferr lda #E_NOFILE + .byt $2c +nowcheck + lda #E_NOTIMP + .byt $2c +enord lda #E_NOREAD + .byt $2c +enowr lda #E_NOWRITE + jsr flunlock + sec + rts +nopull + cpx #FC_RCHECK + bne norcheck + and #5 ; dir and read + beq ferr + pha + tya + clc + adc #MAXFILES + tay + lda (zta),y + tax + lda #SC_GANZ + jsr STRCMD + tax + pla ; missing check for directory-read + bcs enord + cpx #0 + bne ret + beq enord +norcheck + cpx #FC_WCHECK + bne nowcheck + and #2 + beq ferr + tya + clc + adc #2*MAXFILES + tay + lda (zta),y + tax + lda #SC_STAT + jsr STRCMD + cmp #E_SFULL + beq enowr + cmp #E_NUL + bne ret + beq enowr + .) +#endif + +/****************************************************************************/ + + .( + +lengtherr + pla + lda #E_FNAMLEN + .byt $2c +cmderr lda #E_NOTIMP + jsr flunlock + sec + rts + +&&Fcmd + sta zth + sty zth+1 + txa + pha + + jsr taskinit ; be save... + + clc + ldx #SEM_SENDBUF + jsr PSEM ; this can block, so we do it first. + + jsr fllock + + jsr getname + + lda zta + clc + adc #LT_PATH + pha + lda zta+1 + adc #0 + tay + pla + jsr usedir ; returns length in x + bcs lengtherr + + lda #0 + sta PCBUF+FS_CMD_PFAD + + pla + tay + cpy #FC_CHKDSK+1 + bcs cmderr + cpy #FC_RENAME + bcc cmderr + bne no2nd + tya + pha + ldy #0 +a2 lda (zth),y + beq a3 + iny + bne a2 +a3 iny + inx + lda (zth),y + sta PCBUF-1,x + bne a3 + pla + tay +no2nd + lda localfscmd-FC_RENAME,y + bmi cmderr + + pha + txa + tay + pla + jsr flunlock ; unlock file lib before thread lock + + ldx #SEND_FM + jsr SEND + sec + jsr XRECEIVE + + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + + cmp #1 + rts + + +localfscmd + .byt FS_RENAME, FS_DELETE, FS_MKDIR, FS_RMDIR, FS_FORMAT, FS_CHKDSK + + .) + +/********************************************************************** + * Directory handling for lib6502 + * exports + * Fopendir, Freaddir + * + */ + + .( +strerr pha + ldy f1 + lda #0 + sta (zta),y + pla + .byt $2c +fderror lda #E_NOFILE + pha + jsr flunlock + ldx #SEM_SENDBUF + jsr VSEM + sec + pla + rts + +&&Fopendir + sta zth + sty zth+1 + + jsr taskinit ; be save... + + clc + ldx #SEM_SENDBUF + jsr PSEM ; this can block, so we do it first. + + jsr fllock + + ldy #LT_FTAB +l0 lda (zta),y + beq foundfd + iny + cpy #LT_FTAB+MAXFILES + bcc l0 + bcs fderror +foundfd lda #8 ; lock temporarily + sta (zta),y + sty f1 + + jsr GETSTR + bcs strerr + + stx PCBUF+FS_OPEN_STR + + lda f1 + clc + adc #MAXFILES + tay + txa + sta (zta),y ; for reading + + lda f1 + pha ; save fd + + jsr getname + + lda zta + clc + adc #LT_PATH + pha + lda zta+1 + adc #0 + tay + pla + jsr usedir ; returns length in x + bcs lengtherr + + jsr flunlock ; unlock file lib before thread lock + + lda #0 + sta PCBUF+FS_OPEN_PFAD + + txa + tay + lda #FS_OPEN_DR + ldx #SEND_FM + jsr SEND + sec + jsr XRECEIVE + cmp #E_OK + bne fserr + + ldx #SEM_SENDBUF + jsr VSEM + + pla ; get fd back + tay + lda #4 + sta (zta),y + tya + sec + sbc #LT_FTAB + tax + + lda #E_OK + clc + rts + +;cmderr +lengtherr + pla + tay + lda #0 ; we can unlock the fd w/o fllock + sta (zta),y + ldx PCBUF+FS_OPEN_STR + jsr FRESTR + ldx #SEM_SENDBUF + jsr VSEM + lda #E_FNAMLEN + sec + rts + +fserr tax ; error code + pla ; pull fd + tay + txa + pha ; push error code + tya + pha ; push fd again + clc + adc #MAXFILES + tay + lda (zta),y + tax + jsr FRESTR + pla ; pull fd + tay + lda #0 + sta (zta),y + + ldx #SEM_SENDBUF + jsr VSEM + pla ; pull error code + sec + rts + .) + +&Freaddir .( + php + sta zth + sty zth+1 + txa + pha + jsr checkfd_d ; now x has the real stream number + pla + plp + + ldy #FD_LENGTH +l0 jsr dgetc + bcs dderr + sta (zth),y + iny + cpy #FD_LENGTH+4 + bcc l0 + + ldy #FD_MDATE +l1 jsr dgetc + bcs dderr + sta (zth),y + iny + cpy #FD_MDATE+6 + bcc l1 + + jsr dgetc + bcs dderr + + tay + txa + pha + tya + + asl + tax + ldy #FD_PERM + lda ftype,x + sta (zth),y + iny + lda ftype+1,x + sta (zth),y + pla + tax + + ldy #FD_NAME +l2 jsr dgetc + bcs dderr + sta (zth),y + cmp #0 + beq end + iny + cpy #FD_NAME+MAX_FILENAME + bcc l2 +end + ldy #FD_VALID + lda #FDV_PERM + FDV_MDATE + sta (zth),y + clc + rts +dderr + sec + rts + + +ftype .word S_IFREG + S_IRWXO, S_IFMNAME, S_IFMFREE, S_IFDIR + S_IRWXO + +dgetc .( + jsr GETC + bcs test + rts +test cmp #E_SEMPTY + beq myield + sec + rts +myield jsr YIELD + jmp dgetc + .) + .) + +&getrwfd .( + jsr fllock + + ldy #LT_FTAB +l0 lda (zta),y + beq foundfd + iny + cpy #LT_FTAB+MAXFILES + bcc l0 + bcs fderror +foundfd lda #8 ; lock temporarily + sta (zta),y + sty f1 + + jsr GETSTR + bcs fderr + + lda f1 + clc + adc #MAXFILES + tay + txa + sta (zta),y ; for reading + + jsr GETSTR + bcs strerr + + lda f1 + clc + adc #2*MAXFILES + tay + txa + sta (zta),y ; for writing + + ldy f1 + lda #3 ; reading and writing + sta (zta),y + + tya + sec + sbc #LT_FTAB + + jsr flunlock + tax + + clc + rts + +strerr lda (zta),y ; y is kept in GETSTR + tax + jsr FRESTR +fderr ldy f1 + lda #0 + sta (zta),y +fderror jsr flunlock + lda #E_NOFILE + sec + rts + .) + + .) + diff --git a/dump/oa-2.0.9/lib6502/libglob.a65 b/dump/oa-2.0.9/lib6502/libglob.a65 new file mode 100644 index 0000000..4adadad --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libglob.a65 @@ -0,0 +1,267 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * Here are the global (sub-)routines for the lib6502 implementation. + * + * They include: + * libinit check if lib is initialized and if not, do so + * taskinit check if task is initialized and if not, do so + * + * llock get a lock on a semaphore bit set in ac + * lunlock unlock semaphore bit in ac + * + * zinit init zeropage allocation + * zalloc alloc zeropage area + * zfree free zeropage are + */ + + +libinit .( + php + sei + pha + lda zen + bne done +doit + jsr minit + jsr zinit + inc zen +done + pla + plp + rts + .) + +taskinit .( + jsr libinit + lda zta + ora zta+1 + clc + bne done +doit ; alloc memory block for LT_* struct + lda #LT_SLEN + jsr Malloc + bcs done + sta zta + sty zta+1 + +#if LT_ENV > 256 +#echo environment list too long!! +#endif + ldy #0 + tya +l0 sta (zta),y + iny + ; cpy #LT_SLEN + bne l0 + + ldy #LT_NTHREADS + lda #1 + sta (zta),y + + tsx + inx + inx + txa + ldy #LT_INISTACK + sta (zta),y + + jsr initsig + clc +done rts + .) + +/*************************************************************************/ + +llock .( + php + pha +l1 sei + and zen+1 + bne loop + pla + ora zen+1 + sta zen+1 + plp + rts +loop pla + plp + php + jsr YIELD + pha + jmp l1 + .) + +lunlock .( + php + sei + eor #$ff + and zen+1 + sta zen+1 + plp + rts + .) + +/*************************************************************************/ + + + .( + + .data +zmem .dsb 64 ; each four byte have an owner + .text + +/* + * yr = first available zeropage address + */ + ++zinit .( + ldy #Zerostart + php + sei + lda #<-1 ; all in use + tax + inx +l0 sta zmem,x + inx + cpx #64 + bcc l0 + + tya + clc + adc #3 + lsr + lsr + tay + + lda #0 ; free +l1 sta zmem,y + iny + cpy #64 + bcc l1 + + plp + clc + rts + .) + + +/* + * a = length of needed zeropage area in byte + * returns a= address of zeropage area with c=0 + * or c=1 when no area found + * + */ +&zalloc .( + clc + adc #3 + lsr + lsr + + pha + jsr GETPID + pla + tay + inx + txa + pha + tya + + sei + ldy #0 +l1 + pha + tax +l2 + lda zmem,y + bne notfree + dex + beq found + iny + cpy #64 + bcc l2 + pla + pla + cli + rts + +notfree iny + pla + cpy #64 + bcc l1 + pla + cli + rts + +found + pla + tax + pla + iny +l3 + dey + sta zmem,y + dex + bne l3 + + tya + asl + asl + clc + cli + rts + .) + +/* + * a = address of area to free. All consecutive zeropage addresses + * belonging to this task from a on are free'd. + */ +&zfree .( + clc + adc #3 + lsr + lsr + tay + jsr GETPID + inx + sei +l0 txa + cmp zmem,y + bne ende + lda #0 + sta zmem,y + iny + cpy #64 + bcc l0 +ende + clc + cli + rts + .) + + .) + + diff --git a/dump/oa-2.0.9/lib6502/libjmp.a65 b/dump/oa-2.0.9/lib6502/libjmp.a65 new file mode 100644 index 0000000..52361f7 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libjmp.a65 @@ -0,0 +1,247 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef _LIB6502_H_ +#define _LIB6502_H_ + +#include "kdefs.i65" /* this is for STD* and E_* only */ +#include "inet.i65" /* this is for network stuff */ + +/**************************************************************************/ + +#define MAX_FILENAME 128 + +#define MYTASK -1 + +#define OPEN_RD 0 +#define OPEN_WR 1 +#define OPEN_RW 2 +#define OPEN_AP 3 + +#define FC_PUSH 0 +#define FC_PULL 1 +#define FC_RCHECK 2 +#define FC_WCHECK 3 + +#define FC_RENAME 16 +#define FC_DELETE 17 +#define FC_MKDIR 18 +#define FC_RMDIR 19 +#define FC_FORMAT 20 +#define FC_CHKDSK 21 + +#define FD_VALID 0 +#define FD_PERM 2 +#define FD_OWNER 4 +#define FD_GROUP 6 +#define FD_LENGTH 8 +#define FD_MDATE 12 +#define FD_NAME 18 + +#define S_ISUID $800 /* set user ID on execution */ +#define S_ISGID $400 /* set group ID on execution */ +#define S_ISVTX $200 /* -- (sticky bit) */ + +#define S_IRWXU $1c0 /* rwx mask for user */ +#define S_IRUSR $100 /* read by owner */ +#define S_IWUSR $080 /* write by owner */ +#define S_IXUSR $040 /* exexute by owner */ + +#define S_IRWXG $038 /* rwx mask for group */ +#define S_IRGRP $020 /* read by group */ +#define S_IWGRP $010 /* write by group */ +#define S_IXGRP $008 /* execute by group */ + +#define S_IRWXO $007 /* rwx mask for others */ +#define S_IROTH $004 /* read by others */ +#define S_IWOTH $002 /* write by others */ +#define S_IXOTH $001 /* execute by others */ + +#define S_IFMT $f000 /* file type mask */ +#define S_IFSOCK $c000 /* socket */ +#define S_IFLNK $a000 /* symbolic link */ +#define S_IFREG $8000 /* regular file */ +#define S_IFBLK $6000 /* block device */ +#define S_IFDIR $4000 /* directory */ +#define S_IFCHR $2000 /* character device */ +#define S_IFIFO $1000 /* fifo */ + +#define S_IFMNAME $3000 /* media name */ +#define S_IFMFREE $5000 /* free area on media */ +#define S_IFMSIZE $7000 /* media size */ + +#define FDV_PERM 1 +#define FDV_LENGTH 2 +#define FDV_MDATE 4 +#define FDV_OWNER 8 +#define FDV_GROUP 16 + +/**************************************************************************/ + +#define LIBCALLNUM 45 +#define LIBOSACALLS 4 + + +/* These are actually OS/A specific calls to the internals of lib6502 */ + +#define mon_forkto LIB6502-12 /* mon can start lib6502 prgs here */ +#define init_forkto LIB6502-9 /* init can start lib6502 prgs here */ +#define flib2osa_r LIB6502-6 /* maps lib fileno to OS/A65 stream */ +#define flib2osa_w LIB6502-3 /* maps lib fileno to OS/A65 stream */ + +/* official LIB6502 is here */ + +#define fopen LIB6502+0 +#define fclose LIB6502+3 +#define fgetc LIB6502+6 +#define fputc LIB6502+9 +#define fread LIB6502+12 +#define fwrite LIB6502+15 +#define fseek LIB6502+18 +#define pipe LIB6502+21 +#define flock LIB6502+24 +#define fcntl LIB6502+27 +#define fcmd LIB6502+30 +#define stddup LIB6502+33 +#define dup LIB6502+36 + +#define fopendir LIB6502+39 +#define freaddir LIB6502+42 +#define fgetattr LIB6502+45 +#define fsetattr LIB6502+48 +#define chdir LIB6502+51 +#define cwd LIB6502+54 + +#define connect LIB6502+57 +#define listen LIB6502+60 +#define accept LIB6502+63 + +#define malloc LIB6502+66 +#define mfree LIB6502+69 +#define realloc LIB6502+72 + +#define exec LIB6502+75 +#define forkto LIB6502+78 +#define forkthread LIB6502+81 +#define term LIB6502+84 +#define kill LIB6502+87 +#define getpid LIB6502+90 +#define yield LIB6502+93 + +#define semget LIB6502+96 +#define semfre LIB6502+99 +#define semgetnamed LIB6502+102 +#define psem LIB6502+105 +#define vsem LIB6502+108 + +#define signal LIB6502+111 +#define sendsignal LIB6502+114 + +#define send LIB6502+117 +#define receive LIB6502+120 + +#define getenv LIB6502+123 +#define putenv LIB6502+126 +#define getenvp LIB6502+129 +#define getos LIB6502+132 + +#endif + +/**************************************************************************/ + +#ifdef LIB6502BIN + +#echo lib6502 jump table + +; no more code goes here, as start and end addresses are computed from number of calls + +/* OS/A specific calls */ + +jmp mon_forkto_i +jmp init_forkto_i +jmp Flib2osa_r +jmp Flib2osa_w + +/* official lib6502 is here */ + ++LIB6502=* + +jmp Fopen +jmp Fclose +jmp Fgetc +jmp Fputc +jmp Fread +jmp Fwrite +jmp Fseek +jmp Pipe +jmp notimp ; Flock ; not working on OS/A at this time +jmp Fcntl +jmp Fcmd +jmp Stddup +jmp Dup + +jmp Fopendir +jmp Freaddir +jmp notimp ; Fgetattr ; not working on OS/A at this time +jmp notimp ; Fsetattr ; not working on OS/A at this time +jmp Chdir +jmp Cwd + +jmp Connect +jmp Listen +jmp Accept + +jmp Malloc +jmp Mfree +jmp Realloc + +jmp Exec +jmp Forkto +jmp Forkthread +jmp Term +jmp Kill +jmp Getpid +jmp YIELD + +jmp Semget +jmp Semfre +jmp notimp ; Semgetnamed +jmp Psem +jmp Vsem + +jmp Signal +jmp Sendsignal + +jmp notimp ; Send +jmp notimp ; Receive + +jmp Getenv +jmp Putenv +jmp Getenvp +jmp Getos + +; no more code goes here, as start and end addresses are computed from number of calls +#endif + diff --git a/dump/oa-2.0.9/lib6502/libloader.a65 b/dump/oa-2.0.9/lib6502/libloader.a65 new file mode 100644 index 0000000..8d5a039 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libloader.a65 @@ -0,0 +1,842 @@ + +/************************************************************************** + * + * Loader for 6502 relocatable binary format + * + * The loader supports 16 bit o65 version 1 files without undefined + * references. Also it doesn't like pagewise relocation and 65816 + * code, because there are different/additional relocation entries. + * + * The subroutine 'loader' is called with a file descriptor, that has a + * meaning for the support routines, in the X register. + * The file must already be open. Also binit must have been called before. + * The loader doesn't close the file. + * + * Support routines are: + * + * malloc a/y = length of block needed -> a/y address of block + * + * zalloc a = length of needed zeropage block. returns a=address + * zfree a = address of block to free + * + * fgetc x = file descriptor, returns read byte (c=0) or error (c=1) + * The error is passed through; fgetc blocks if no data + * available + * fgetb x = filedescriptor, a/y = address of block descriptor, + * i.e. a word start address and a word length of block. + * returns (c=0) or error in accu (c=1). + * + **************************************************************************/ + +/************************************************************************** + * Here is the real loader code + * + * we keep it simple and stupid... + * The loader allocated only one memory block for text, data and bss together + * For now there is no align (yet) + * + */ + +#include "file_o65.def" + +#undef DEBUG +#undef UDEBUG +#undef ADEBUG + +#ifdef DEBUG +#define DBL(A) .(:jmp ll2:ll1 .byt A,0:ll2 php:lda #ll1:jsr etxtout:plp:.): +#else +#define DBL(A) +#endif + + +/* +#define E_NOMEM <-40 +#define E_FVERSION <-41 +*/ + +loader .( + + .zero +p1 .word 0 +p2 .word 0 + + .data +tmp .byt 0 +file .byt 0 +amode .byt 0 ; align mode + +header .dsb HDR_LEN + +memory .word 0 +textm .word 0 ; memory block for everything +textd .word 0 ; difference to assemble address +datam .word 0 +numud .word 0 ; number of undef'd references +udlc .byt 0 +datad .word 0 +bssd .word 0 + +zeroa .byt 0 ; address of zeropage block +zerod .word 0 + +reladdr .word 0,0 ; we have two undef'd labels + + .text + + lda #LSEM_LOAD + jsr llock + + jsr l2x + + php + pha + lda #LSEM_LOAD + jsr lunlock + pla + plp + rts + + ;********************************* +l2x + stx file + sec + jsr fgetc + bcs end + sta tmp + sec + jsr fgetc + bcs end + tay + lda tmp + cpy #0 + bne rt + cmp #1 + beq load +rt lda #E_FVERSION ; ok, but not this version + .byt $2c +errhdr lda #E_FLOGICAL +end sec + rts + +load .( + lda #
header + sta p1+1 + lda #HDR_LEN + sta p1+3 + + ldx file + lda #p1 + jsr fgetb + bcs end + ; header loaded, check magic and version + lda header+HDR_MAGIC + cmp #$6f + bne errhdr + lda header+HDR_MAGIC+1 + cmp #"6" + bne errhdr + lda header+HDR_MAGIC+2 + cmp #"5" + bne errhdr + lda header+HDR_VERSION + cmp #0 + bne errhdr + lda header+HDR_MODE+1 + and #%11110000 + bne errhdr + +#ifdef ADEBUG +DBL("^m^jheader=") +ldy #0:lx lda header,y:jsr ehexout:jsr espout:iny:cpy #HDR_LEN:bcc lx +jsr ecrlfout +#endif + + lda header+HDR_MODE +#ifdef ADEBUG +pha:DBL("amode=") +pla:pha:jsr ehexout:jsr ecrlfout:pla +#endif + + and #3 + asl + sta amode ; align mode + ; now allocate buffers + lda header+HDR_TLEN + ldy header+HDR_TLEN+1 ; we have to modify length to keep data aligned + jsr doalign ; align length -> keep text seg. alignement + clc + adc header+HDR_DLEN + pha + tya + adc header+HDR_DLEN+1 + tay + pla + jsr doalign + clc + adc header+HDR_BLEN + pha + tya + adc header+HDR_BLEN+1 + tay + pla + + ; now we have to increase alloc size, as malloc is byte aligned + ldx amode + clc + adc aadd,x + pha + tya + adc aadd+1,x + tay + pla + +#ifdef ADEBUG +pha:tya:pha:DBL("malloc size: ") +pla:tay:jsr ehexout:pla:pha:jsr ehexout:jsr ecrlfout:pla +#endif + jsr malloc + bcc gotmem + rts +gotmem + sta memory ; keep real address + sty memory+1 +#ifdef ADEBUG +DBL("got memory at ") +lda memory+1:jsr ehexout:lda memory:jsr ehexout:jsr ecrlfout +lda memory:ldy memory+1 +#endif + + jsr doalign + sta textm ; text load address + sty textm+1 + +#ifdef ADEBUG +DBL("aligned to ") +lda textm+1:jsr ehexout:lda textm:jsr ehexout:jsr ecrlfout +lda textm:ldy textm+1 +#endif + + + ; compute textd + ; lda textm + sec + sbc header+HDR_TBASE + sta textd + tya ; lda textm+1 + sbc header+HDR_TBASE+1 + sta textd+1 + + ; compute datad + lda header+HDR_TLEN + ldy header+HDR_TLEN+1 + jsr doalign + clc + adc textm + pha + tya + adc textm+1 + tay + pla + sta datam + sty datam+1 + + sec + sbc header+HDR_DBASE + sta datad + tya + sbc header+HDR_DBASE+1 + sta datad+1 + + ; compute bssd + lda header+HDR_DLEN + ldy header+HDR_DLEN+1 + jsr doalign + clc + adc datam + pha + tya + adc datam+1 + tay + pla +#ifdef ADEBUG +pha:tya:pha:DBL("put bss to ") +pla:tay:jsr ehexout:pla:pha:jsr ehexout:jsr ecrlfout:pla +#endif + sec + sbc header+HDR_BBASE + sta bssd + tya + sbc header+HDR_BBASE+1 + sta bssd+1 + + lda header+HDR_ZLEN + beq zero0 + jsr zalloc + bcs no_zero + sec + sbc header+HDR_ZBASE + sta zerod + lda #0 + sta zerod+1 +zero0 + jmp do_load + +&no_file lda zeroa + jsr zfree +no_zero lda memory + ldy memory+1 + jsr mfree + sec + rts + +do_load ; load options (i.e. ignore them now) + ldx file + sec + jsr fgetc + bcs no_file + cmp #0 + beq load_text + tay + dey +optl sec + jsr fgetc + bcs no_file + dey + bne optl + beq do_load + +load_text ; load text segment + lda textm + sta p1 + lda textm+1 + sta p1+1 + lda header+HDR_TLEN + sta p1+2 + lda header+HDR_TLEN+1 + sta p1+3 +#ifdef ADEBUG +DBL("load text: ") +lda p1+1:jsr ehexout:lda p1:jsr ehexout:jsr espout:lda p1+3:jsr ehexout +lda p1+2:jsr ehexout:jsr ecrlfout +#endif + + ldx file + lda #p1 + jsr fgetb ; loads text segment + bcs no_file + + lda datam + sta p1 + lda datam+1 + sta p1+1 + lda header+HDR_DLEN + sta p1+2 + lda header+HDR_DLEN+1 + sta p1+3 + +#ifdef ADEBUG +DBL("load data: ") +lda p1+1:jsr ehexout:lda p1:jsr ehexout:jsr espout:lda p1+3:jsr ehexout +lda p1+2:jsr ehexout:jsr ecrlfout +#endif + ldx file + lda #p1 + jsr fgetb ; loads data segment + bcs no_file2 + + ; check number of undefined references +#if 1 + jsr checkundef + bcc dorel +#else + ldx file + sec + jsr fgetc + bcs no_file2 + cmp #0 + bne no_file2 ; we have some -> not handled + ldx file + sec + jsr fgetc + bcs no_file2 + cmp #0 + beq dorel +#endif +&no_file2 + jmp no_file +dorel + ; ok, text segments loaded, now relocate + + lda textm + sec + sbc #1 + sta p1 + lda textm+1 + sbc #0 + sta p1+1 + jsr trel + + lda datam + ldy datam+1 + sec + sbc #1 + sta p1 + tya + sbc #0 + sta p1+1 + jsr trel + + jsr getmain + bcc foundmain + + lda textm ; return start of text segment + ldy textm+1 +foundmain +#ifdef DEBUG +pha:tya:pha:DBL("exec addr=") +pla:tay:jsr ehexout:pla:pha:jsr ehexout:jsr ecrlfout:pla +#endif + clc + rts + .) + + + +trel .( + ldx file + sec + jsr fgetc +no_file1 bcs no_file2 + cmp #0 + beq reloc_rts + cmp #255 + bne t1 + lda #254 + clc + adc p1 + sta p1 + bcc trel + inc p1+1 + jmp trel +t1 clc + adc p1 + sta p1 + bcc t1a + inc p1+1 +t1a ; p1 is the relocation address + ldx file + sec + jsr fgetc + bcs no_file1 + tay + and #A_MASK + sta tmp + tya + and #A_FMASK + jsr getreldiff + ldy tmp + cpy #A_ADR + bne t2 + + ldy #0 + clc + adc (p1),y + sta (p1),y + iny + txa + adc (p1),y + sta (p1),y + jmp trel +t2 + cpy #A_LOW + bne t3 + ldy #0 + clc + adc (p1),y + sta (p1),y + jmp trel +t3 + cpy #A_HIGH + bne trel + sta p2 + stx p2+1 + ldx file + sec + jsr fgetc + clc + adc p2 ; just get the carry bit + ldy #0 + lda p2+1 ; relocate high byte + adc (p1),y + sta (p1),y + jmp trel + +reloc_rts + clc + rts + .) + +getreldiff .( ; comparing with SEG_UNDEF would give a way + ; to get label value here for undefined refs + cmp #SEG_TEXT + bne notext + lda textd + ldx textd+1 + rts +notext cmp #SEG_DATA + bne nodata + lda datad + ldx datad+1 + rts +nodata cmp #SEG_BSS + bne nobss + lda bssd + ldx bssd+1 + rts +nobss cmp #SEG_ZERO + bne nozero + lda zerod + ldx zerod+1 + rts +nozero cmp #SEG_UNDEF + bne noundef + ldx file + sec + jsr fgetc + bcs err + tay + sec + jsr fgetc + bcs err + cmp #0 + bne err +#ifdef UDEBUG +tya:pha:DBL("found undef:") +pla:pha:jsr ehexout:pla:tay +#endif + tya + asl + tay + lda reladdr+1,y + tax + lda reladdr,y +#ifdef UDEBUG +pha:txa:pha:DB(" addr=") +tsx:lda $0101,x:jsr ehexout:tsx:lda $0102,x:jsr ehexout:jsr ecrlfout +pla:tax:pla +#endif + ; rts +noundef +err rts + .) + +doalign .( ; increase given value to align it + ldx amode + clc + adc aadd,x + and aand,x + pha + tya + adc aadd+1,x + and aand+1,x + tay + pla + rts + +&aadd .word 0, 1, 3, 255 +aand .word $ffff, $fffe, $fffc, $ff00 + .) + +/* check undefined references list for occurances of LIB6502 and OSA2KERNEL */ + +checkundef .( + .data ;.bss +#define LBLEN 12 +lbuf .dsb LBLEN + .text + + ldx file + sec + jsr fgetc + bcs ret + sta numud + + ldx file + sec + jsr fgetc + bcs ret + sta numud+1 + + ora numud + beq ret + + lda numud+1 + bne err + lda numud + cmp #3 + bcc ok +err sec +ret rts + +ok ; numud = 1 oder 2 + lda #0 + sta numud+1 ; numud = number of labs, numud+1 = label counts +okl + ldy #0 +l1 ldx file + sec + jsr fgetc + bcs ret + sta lbuf,y + iny + cpy #LBLEN + bcs err + cmp #0 + bne l1 + +#ifdef UDEBUG +DBL("^m^jundef: ") +lda #lbuf:jsr etxtout:jsr ecrlfout +#endif + + ldx #0 + stx udlc +l3 dex + ldy #<-1 +l4 iny + inx + lda lbuf,y + cmp ul1,x + bne next + cmp #0 + bne l4 + ; found +#ifdef UDEBUG +DBL("udlc=") +lda udlc:jsr ehexout +DBL(" numud=") +lda numud:jsr ehexout +DBL(" numud+1=") +lda numud+1:jsr ehexout:jsr ecrlfout +#endif + lda udlc + asl + tax + lda numud+1 + asl + tay + lda ud1,x + sta reladdr,y + lda ud1+1,x + sta reladdr+1,y + + inc numud+1 + dec numud + beq nook + jmp okl +nook + clc + rts + +next lda ul1,x + beq fn + inx + bne next +fn inc udlc + inx + lda ul1,x + beq nol3 + jmp l3 +nol3 + sec ; label not found at all + rts + +ul1 .asc "OSA2","KERNEL",0, "LIB","6502",0, 0 +ud1 .word OSA2KERNEL, LIB6502 + .) + +getmain .( + ldx file + sec + jsr fgetc + bcs err + sta numud + sec + jsr fgetc + bcs err + sta numud+1 + ora numud + beq err + + ; we only try to read the file until we get the "main" value + +l2 ldy #0 +l0 sec + jsr fgetc + bcs err + cmp mtxt,y + bne nextl + iny + cmp #0 + bne l0 + sec + jsr fgetc + bcs err + cmp #2 ; check for text segment + bne err + sec + jsr fgetc + bcs err + tay + sec + jsr fgetc + bcs err + tax + tya + clc + adc textd + pha + txa + adc textd+1 + tay + pla + clc + rts + +nextl sec + jsr fgetc + bcs err + cmp #0 + bne nextl + ldy #3 +l1 sec + jsr fgetc + bcs err + dey + bne l1 + jmp l2 + +err sec + rts + +mtxt .asc "main",0 + .) + + .) + +/************************************************************************** + * Here come the support routines + * + * first is a simple and basic implementation of fgetb, just using fgetc + */ + +fgetb .( + .zero +p .word 0 + .data +file .byt 0 +l .word 0 + .text + + stx file ; x=file, a/y=addr of addr/len struct + sta p + sty p+1 + ldy #3 + lda (p),y + sta l+1 + dey + lda (p),y + sta l + ora l+1 + beq ende + dey + lda (p),y + pha + dey + lda (p),y + sta p + pla + sta p+1 + +loop ldx file + sec + jsr fgetc ; this is a simple implementation + bcs end + ldy #0 + sta (p),y + inc p + bne l0 + inc p+1 +l0 + lda l + bne l1 + dec l+1 +l1 dec l + + lda l + ora l+1 + bne loop +ende clc +end + rts + .) + +#ifdef DEBUG +ehexout .( + pha + lsr + lsr + lsr + lsr + jsr nibout + pla + and #$0f +nibout clc + adc #"0" + cmp #"9"+1 + bcc ok + adc #6 +ok ldx #STDERR + sec + jmp fputc + .) + +etxtout .( + .zero +tp .word 0 + .text + + sta tp + sty tp+1 + ldx #STDERR + ldy #0 +l0 lda (tp),y + beq ende + sec + jsr fputc + iny + bne l0 +ende rts + .) + +ecrlfout + lda #13 + jsr ecout + lda #10 + .byt $2c +espout lda #" " +ecout .( + ldx #STDERR + sec + jmp fputc + .) +#endif + diff --git a/dump/oa-2.0.9/lib6502/libmem.a65 b/dump/oa-2.0.9/lib6502/libmem.a65 new file mode 100644 index 0000000..0fab847 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libmem.a65 @@ -0,0 +1,652 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/********************************************************************** + * Memory management for lib6502 + * exports + * binit + * balloc, bfree, btrunc, bsplit, brealloc + * getbadr, getblen + * bcleanpid, bcleanpida + * + * The routines are _not_ threadsave! + * Alas they use a spin-lock on an environment semaphore. + * We use a spin-lock as a memory routine should be fast enough + * for that. + * + * The memory management is initialized when the library is initialized + * in an environment. It gets the available memory from the SBRK system + * call, and knows the start of the available memory from assemble time. + * + * The memory list is a linked list of memory blocks. Each memory block + * has at its beginning the pointer to the next block, a magic number, + * the length of the block, the task id of the owner and a flag if it is + * free or not. + * + * two external variables must be defined, + * Memstart + * Memend + * which hold the start and end addresses of the free RAM + */ + +#define LM_P 0 /* pointer to next struct */ +#define LM_MAGIC 2 /* magic number for a valid struct */ +#define LM_LEN 4 /* length of memory block */ +#define LM_TASK 6 /* task the block belongs to */ +#define LM_FL 7 /* 0 = free, 1 = in use */ +#define LM_SLEN 8 /* length of struct */ + +#define LM_MAGIC_VAL $AF98 + +#define MINBUF 8 /* minimum size of memory block */ +#define MINMASK %11111000 /* address mask bit of memory block */ + +#define MINLEN (MINBUF+LM_SLEN) + +#ifndef MEMINIVAL +#define MEMINIVAL 0 +#endif + +#undef DEBUGMEM +#undef DB +#define DB(a) + + .( + + .zero +p1 .word 0 +p2 .word 0 +p3 .word 0 +p4 .word 0 +p5 .word 0 + .text + +&minit .( + lda #Memstart + sta p1+1 + + ldy #LM_P + lda #<-1 + sta (p1),y + iny + sta (p1),y + iny + lda #LM_MAGIC_VAL + sta (p1),y + iny + lda #Memend-Memstart-LM_SLEN + sta (p1),y + iny + lda #<-1 + sta (p1),y ; no task + iny + lda #0 + sta (p1),y ; fl = 0 + rts + .) + +&Malloc .( + pha + lda #LSEM_MEM + jsr llock ; lock memory subsystem + pla + sta p2 ; length of needed memory block + sty p2+1 + sec + +&alloc php ; trick to not unlock when realloc + + lda #Memstart + sta p1+1 +l0 ldy #LM_FL + lda (p1),y + bne next + ldy #LM_LEN+1 + lda (p1),y + cmp p2+1 + bcc next + bne found + dey + lda (p1),y + cmp p2 + bcs found +next + ldy #LM_P + lda (p1),y + pha + iny + lda (p1),y + sta p1+1 + pla + sta p1 + and p1+1 + cmp #$ff + bne l0 + + plp ; alloc/realloc switch discarded + DB("Didn't find appropriate memory block!^m^j") + lda #LSEM_MEM + jsr lunlock + lda #E_NOMEM + sec + rts + +found ; now split memory block in two + jsr split + + ldy #LM_FL + lda #1 + sta (p1),y + jsr GETPID + txa + ldy #LM_TASK + sta (p1),y + + plp + bcc reallocr + + lda p1 + clc + adc #LM_SLEN + pha + lda p1+1 + adc #0 + tay + lda #LSEM_MEM + jsr lunlock + pla +reallocr + clc + rts + .) + +&Mfree .( + pha + lda #LSEM_MEM + jsr llock + pla + sec + sbc #LM_SLEN + sta p2 + sta p1 + tya + sbc #0 + sta p2+1 + sta p1+1 + + jsr checkblk ; returns only on success, checks (p1) + + sec +&free php + + ldy #LM_TASK + lda #<-1 + sta (p2),y + iny + lda #0 + sta (p2),y + + jsr merge ; sees if (p2) can be merged with following block + ; leaves p1 unchanged + + lda #Memstart + sta p2 + stx p2+1 + + cmp p1 + bne l1 + cpx p1+1 + beq endpm +l1 + ldy #LM_P+1 + lda (p2),y + tax + dey + lda (p2),y + + cmp p1 + bne next + cpx p1+1 + beq domerge +next + sta p2 + stx p2+1 + and p2+1 + cmp #$ff + bne l1 + beq endpm +domerge + ldy #LM_FL + lda (p2),y + bne endpm ; if not free, no merge! + + jsr merge +endpm + plp + bcc reallocr + + lda #LSEM_MEM + jsr lunlock + clc +reallocr + rts + .) + +&Realloc .( + pha + lda #LSEM_MEM + jsr llock + pla + sec + sbc #LM_SLEN + sta p1 + tya + sbc #0 + sta p1+1 + lda 0,x + sta p2 + lda 1,x + sta p2+1 + + jsr checkblk ; returns only on success, checks (p1) + + jsr split + bcs large ; now we need a larger array -> call malloc + + ;clc + lda p1 + adc #LM_SLEN + pha + lda p1+1 + adc #0 + tay + lda #LSEM_MEM + jsr lunlock + pla + clc + rts +large ; call malloc... + lda p1 + pha + lda p1+1 + pha + clc + jsr alloc + bcc found + tay + pla + pla + tya + rts +found ; new address in p1 + pla ; old address in p2 + sta p2 + pla + sta p2+1 + ldy #LM_LEN ; length of data to copy to p3 + lda (p2),y + sta p3 + iny + lda (p2),y + sta p3 + + clc + lda p1 + adc #LM_SLEN + sta p4 + lda p1+1 + adc #0 + sta p4+1 + + clc + lda p2 + adc #LM_SLEN + sta p5 + lda p2+1 + adc #0 + sta p5+1 + ; copy old block to new block + ldy #0 +loop lda (p5),y + sta (p4),y + iny + bne l1 + inc p4+1 + inc p5+1 +l1 ; decrease number to copy + lda p3 + bne l2 + dec p3+1 +l2 dec p3 + lda p3 + ora p3 + bne loop + + clc + jsr free ; p1 is preserved, p2 is freed + + lda p1 + sec + sbc #LM_SLEN + pha + lda p1+1 + sbc #0 + tay + + lda #LSEM_MEM + jsr lunlock + + pla + clc + rts + .) + +/********************* internal functions *************************/ + +checkblk .( + ldy #LM_MAGIC + lda (p1),y + cmp #LM_MAGIC_VAL + beq ok +illaddr + pla + pla + DB("illegal pointer for free/realloc^m^j") + lda #LSEM_MEM + jsr lunlock + lda #E_ILLADDR + sec + rts +ok + jsr GETPID + txa + ldy #LM_TASK + cmp (p1),y + bne illaddr + rts + .) + + +/* splits the memory block pointed to by p1 into one the length of p2 + * and the rest. Returns c=0 on success and c=1 if p2 > length of block. + * The second block is set as free. + * p2, p3 are overwritten, if p2 is not too large */ +split .( + ldy #LM_LEN + sec + lda (p1),y + sbc p2 + iny + lda (p1),y + sbc p2+1 + bcs ok ; otherwise p2 > len(p1) + + DB("split: newlen > oldlen^m^j") + sec + rts +ok + ldy #LM_LEN + lda p2 + sta (p1),y + iny + lda p2+1 + sta (p1),y + ; sets p3 to the end of the memory block + ldy #LM_P + lda (p1),y + sta p3 + iny + lda (p1),y + sta p3+1 + and p3 + cmp #$ff + bne noend + lda #Memend + sta p3+1 +noend ; find the address of the possible new block -> p2 + clc + lda p1 + adc #LM_SLEN + sta p2 + lda p1+1 + adc #0 + sta p2+1 + clc + lda p2 + ldy #LM_LEN + adc (p1),y + sta p2 + iny + lda p2+1 + adc (p1),y + sta p2+1 + ; check if the length is ok (p3-p2)>MINLEN + sec + lda p3 + sbc p2 + sta p3 + lda p3+1 + sbc p2+1 + sta p3+1 + bne lok + lda p3 + cmp #MINLEN + bcs lok + rts +lok ; yes, then create new block + ldy #LM_P + lda (p1),y ; pointer to next block + sta (p2),y + iny + lda (p1),y + sta (p2),y + iny ; magic number + lda (p1),y + sta (p2),y + iny + lda (p1),y + sta (p2),y + iny + sec ; length of memory block + lda p3 + sbc #LM_SLEN + sta (p2),y + iny + lda p3+1 + sbc #0 + sta (p2),y + iny ; task + lda #<-1 + sta (p2),y + iny ; flag = 0 -> free + lda #0 + sta (p2),y + + ldy #LM_P + lda p2 + sta (p1),y + iny + lda p2+1 + sta (p1),y + ; now check if we can merge with following block +&merge ldy #Memend + sta p3+1 +notend ; get length of block + sec + lda p3 + sbc p2 + sta p3 + lda p3+1 + sbc p2+1 + sta p3+1 + sec + ldy #LM_LEN + lda p3 + sbc #LM_SLEN + sta (p2),y + iny + lda p3+1 + sbc #0 + sta (p2),y + clc + rts + .) + +&bcleanpida .( + .data ;.bss +taddr .word 0 +fl .byt 0 +pid .byt 0 + .text + + clc + .byt $24 + +&&bcleanpid ; clean all memory blocks of PID in xr. + sec + php + pha + lda #LSEM_MEM + jsr llock ; lock memory subsystem + stx pid + pla + sta taddr + sty taddr+1 + lda #0 + sta fl + plp + ror fl ; put carry to bit 7 of fl +l1 + lda #Memstart + sta p1+1 + +l0 ldy #LM_FL + lda (p1),y + beq next + lda pid + ldy #LM_TASK + cmp (p1),y + beq found +next + ldy #LM_P + lda (p1),y + pha + iny + lda (p1),y + sta p1+1 + pla + sta p1 + and p1+1 + cmp #$ff + bne l0 + + lda #LSEM_MEM + jsr lunlock + rts + +found bit fl + bmi notest + lda p1 + clc + adc #LM_SLEN + tay + pla + cmp taddr + bne notest + cpy taddr+1 + beq next +notest + ldx p1 + ldy p1+1 + stx p2 + sty p2+1 + clc + jsr free + jmp l1 + .) + + .) + + diff --git a/dump/oa-2.0.9/lib6502/libnet.a65 b/dump/oa-2.0.9/lib6502/libnet.a65 new file mode 100644 index 0000000..ba73af6 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libnet.a65 @@ -0,0 +1,353 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/********************************************************************** + * Network handling for lib6502 + * exports + * Connect, Listen, Accept + * + */ + +#ifdef LIB6502_NONET + +Accept jmp notimp +Listen jmp notimp +Connect jmp notimp + +#else + +#include "inet.i65" + + .( + +&Accept .( + sta zth + sty zth+1 + txa + bcc doitnow +wloop + pha + jsr doitnow + bcc wret + cmp #E_NOFILE + bne wret + pla + jsr YIELD + jmp wloop + +wret sta zth + pla + lda zth + cmp #1 + rts + +doitnow + pha + ldx #SEM_SENDBUF + clc + jsr PSEM + + pla + sta PCBUF+FSN_PORT + + jsr getfd ; y has fileno + LT_FTAB + bcs nofile + tya + pha + + ldy #FSN_PORT+1 + lda #FS_ACCEPT + ldx #SEND_NET + jsr SEND + bcs nosend + sec + jsr XRECEIVE + lda PCBUF+FSN_RET + bne reterr +;.byt 2 + tya + sec + sbc #FSN_ADDR-1 + ldy #0 + cmp (zth),y ; length of buffer + bcc lenok + jsr eclose + lda #E_NOMEM + bne reterr +lenok + tay +ll lda PCBUF+FSN_ADDR-1,y + sta (zth),y + dey + bne ll + + pla + pha + tay + lda #3 + sta (zta),y + tya + clc + adc #MAXFILES + tay + lda PCBUF+FSN_RXSTR + sta (zta),y + tya + clc + adc #MAXFILES + tay + lda PCBUF+FSN_TXSTR + sta (zta),y + + ldx #SEM_SENDBUF + jsr VSEM + pla + sec + sbc #LT_FTAB + tax + lda #E_OK + clc + rts + +nosend lda #E_NOFILE +reterr tax + pla + tay + lda #0 + sta (zta),y ; free fd - we need not lock that + txa + .byt $2c +nofile lda #E_NOFILE + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + sec + rts + +eclose ldx PCBUF+FSN_RXSTR + ldy #SCE_RERRM + lda #SC_SSTAT + jsr STRCMD + lda #SC_NUL + jsr STRCMD + ldx PCBUF+FSN_TXSTR + ldy #SCE_WERRM + lda #SC_SSTAT + jsr STRCMD + lda #SC_EOF + jmp STRCMD + .) + +&Listen .( + bcc listenopen + txa + pha + + ldx #SEM_SENDBUF + clc + jsr PSEM + + pla + sta PCBUF+FSN_PORT + + ldy #FSN_PORT+1 + lda #FS_UNLISTEN + ldx #SEND_NET + jsr SEND + + lda #E_OK + clc + rts + +listenopen + sta zth + sty zth+1 + txa + pha + + jsr taskinit + + ldx #SEM_SENDBUF + clc + jsr PSEM + + pla + sta PCBUF+FSN_PROT + + ldy #0 + lda (zth),y + tax +l0 dex + beq ende + iny + lda (zth),y + sta PCBUF+FSN_ADDR-1,y + jmp l0 + +ende tya + clc + adc #FSN_ADDR + tay + ldx #SEND_NET + lda #FS_LISTEN + jsr SEND +;.byt 2 + bcs nosend + sec + jsr XRECEIVE +;.byt 2 + lda PCBUF+FSN_RET + bne reterr + + lda PCBUF+FSN_PORT + pha + + ldx #SEM_SENDBUF + jsr VSEM + clc + pla ; listenport + tax + lda #E_OK + rts + +nosend lda #E_NOFILE +reterr pha + + ldx #SEM_SENDBUF + jsr VSEM + + pla + cmp #1 + rts + .) + +/*************************************************************************/ + +&Connect .( + sta zth + sty zth+1 + txa + pha + + jsr taskinit + + jsr getrwfd + bcc gotfd + pla + lda #E_NOFILE + sec + rts +gotfd + txa + pha + + ldx #SEM_SENDBUF + clc + jsr PSEM + + pla + pha + tax + jsr flib2osa_r + sta PCBUF+FSN_RXSTR + pla + pha + tax + jsr flib2osa_w + sta PCBUF+FSN_TXSTR + + tsx + lda $0102,x + sta PCBUF+FSN_PROT + + ldy #0 + lda (zth),y + tax +l0 dex + beq ende + iny + lda (zth),y + sta PCBUF+FSN_ADDR-1,y + jmp l0 + +ende tya + clc + adc #FSN_ADDR + tay + ldx #SEND_NET + lda #FS_CONNECT + jsr SEND +;.byt 2 + bcs nosend + sec + jsr XRECEIVE +;.byt 2 + lda PCBUF+FSN_RET + bne reterr + + ldx #SEM_SENDBUF + jsr VSEM + clc + pla + tax ; fd + pla ; was protocol + lda #E_OK + rts + +nosend lda #E_NOFILE +reterr sta zth + + ldx #SEM_SENDBUF + jsr VSEM + + pla ; fd + sta zth+1 + tax + pla ; was protocol + + jsr flib2osa_r + lda #SC_EOF + jsr STRCMD + ldx zth+1 + jsr flib2osa_w + lda #SC_NUL + jsr STRCMD + + lda zth + pha + + ldx zth+1 + jsr fclose + + pla + cmp #1 + rts + .) + + + .) + +#endif /* LIB6502_NONET */ + diff --git a/dump/oa-2.0.9/lib6502/libsem.a65 b/dump/oa-2.0.9/lib6502/libsem.a65 new file mode 100644 index 0000000..add062c --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libsem.a65 @@ -0,0 +1,56 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +Semget .( + php + jsr GETSEM + bcs gse + plp + clc + rts +gse jsr YIELD + plp + bcs Semget + sec + rts + .) + +Semfre .( + jmp FRESEM + .) + +Psem .( + bcs cs ; grr - carry just the other way round... + sec + .byt $24 +cs clc + jmp PSEM + .) + +Vsem .( + jmp VSEM + .) + + diff --git a/dump/oa-2.0.9/lib6502/libsig.a65 b/dump/oa-2.0.9/lib6502/libsig.a65 new file mode 100644 index 0000000..db85020 --- /dev/null +++ b/dump/oa-2.0.9/lib6502/libsig.a65 @@ -0,0 +1,166 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* + * This is the signal code of lib6502 on OS/A65. + * + * It needs to have the signal masks USR1-USR4 set by the + * task init code, as well as the LT_SIGADDR map being + * set to zero on task startup. + * Also the signal handler must be set to rxsig. + * All this is done in initsig + */ + + +initsig .( + ldy #LT_SIGADDR + lda #0 +l0 sta (zta),y + iny + cpy #LT_SIGADDR+NUMOFSIG*2 + bcc l0 + lda #rxsig + sec + jsr SETSIG + lda #SIG_USR1 | SIG_USR2 | SIG_USR3 | SIG_USR4 | SIG_CHLD + clc + jmp SETSIG + .) + +Signal .( + sta zth + sty zth+1 + txa + ldy #NUMOFSIG-1 +l0 cmp sigtab,y + beq ok + dey + bpl l0 + lda #E_ILLSIG + sec + rts + +ok tya + asl + clc + adc #LT_SIGADDR + php + sei + tay + lda zth + sta (zta),y + iny + lda zth+1 + sta (zta),y + plp + clc + rts + .) + +Sendsignal .( + tay + txa + pha + tya + tax + pla + sec + jmp SENDSIG + .) + +rxsig .( + pha + tya + pha + txa + pha + lda zth + pha + lda zth+1 + pha +l1 tsx + ldy #NUMOFSIG-1 +l0 lda $0105,x ; signal mask + and sigtab,y + bne doit + dey + bpl l0 +endsig + pla + sta zth+1 + pla + sta zth + pla + tax + pla + tay + pla + pla + rti + +doit + lda sigtab,y + pha ; save for signal handler + eor #$ff + and $0105,x ; clear corresponding signal bit + sta $0105,x + tya + asl + clc + adc #LT_SIGADDR + tay + lda (zta),y + sta zth + iny + ora (zta),y + beq checkchild ; l1 + lda (zta),y + sta zth+1 + pla ; signal mask + cmp #SIG_CHLD + beq dochild + jsr jmpzth + jmp l1 +checkchild + pla + cmp #SIG_CHLD + bne l1a +cc jsr CHECKCHLD + bcc cc +l1a jmp l1 + +dochild jsr CHECKCHLD + bcs l1a + ldy #0 ; high byte PID + jsr jmpzth + jmp dochild + .) + +jmpzth jmp (zth) + + ; SIG_CHLD must be the last one, it cannot be sent. +sigtab .byt SIG_USR1, SIG_USR2, SIG_USR3, SIG_USR4, SIG_CHLD + diff --git a/dump/oa-2.0.9/oldlib/loader.a65 b/dump/oa-2.0.9/oldlib/loader.a65 new file mode 100644 index 0000000..c937b6c --- /dev/null +++ b/dump/oa-2.0.9/oldlib/loader.a65 @@ -0,0 +1,438 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/************************************************************************** + * + * Loader for 6502 relocatable binary format + * + * The loader supports 16 bit o65 version 1 files without undefined + * references. Also it doesn't like pagewise relocation and 65816 + * code, because there are different/additional relocation entries. + * + * The support routines, that have to be changed are at the end of the + * file. The stuff in this file is in absolute format (well, you have to + * bootstrap from something :-) + * The support routines for the file handling are for the operating system + * OS/A65, as of version 1.3.10b. The first part of the file (wrapped in + * "#ifdef C64") shows how to use it with a C64, for example. + * + * The subroutine 'loader' is called with a file descriptor, that has a + * meaning for the support routines, in the X register. + * The file must already be open. Also binit must have been called before. + * The loader doesn't close the file. + * + * Support routines are: + * + * zalloc a = length of needed zeropage block. returns a=address + * zfree a = address of block to free + * + * fgetc x = file descriptor, returns read byte (c=0) or error (c=1) + * The error is passed through; fgetc blocks if no data + * available + * fgetb x = filedescriptor, a/y = address of block descriptor, + * i.e. a word start address and a word length of block. + * returns (c=0) or error in accu (c=1). + * + **************************************************************************/ + + +/************************************************************************** + * This part is a binding for a C64 + * to show how it works + */ + +#include "file_o65.def" + +#define E_NOMEM <-40 +#define E_FVERSION <-41 + +loader .( + .zero +p1 .word +p2 .word + + .data +tmp .byt 0 +file .byt 0 + +header .dsb HDR_LEN + +textb .byt 0 ; memory block ID +texta .word 0 ; address of block +;textl .word 0 ; address of block +textd .word 0 ; difference to assemble address + +;datab .byt 0 +dataa .word 0 +;datal .word 0 +datad .word 0 + +;bssb .byt 0 +bssa .word 0 +bssd .word 0 + +zeroa .byt 0 +zerod .word 0 + + .text + + stx file + jsr Fgetc + bcs end + sta tmp + jsr Fgetc + bcs end + tay + lda tmp + cpy #0 + bne rt + cmp #1 + beq load +rt lda #E_FVERSION ; ok, but not this version +end sec + rts + +load .( + lda #
header + sta p1+1 + ldx #p1 + lda #HDR_LEN + jsr fgetb + bcs end + ; header loaded, check magic and version + lda header+HDR_MAGIC + cmp #$6f + bne end + lda header+HDR_MAGIC+1 + cmp #"6" + bne end + lda header+HDR_MAGIC+2 + cmp #"5" + bne end + lda header+HDR_VERSION + cmp #0 + bne end + lda header+HDR_MODE+1 + and #%11110000 + bne end + ; now allocate buffers + /* TODO: check alignment! */ + lda header+HDR_TLEN + ldy header+HDR_TLEN+1 + clc + adc header+HDR_DLEN + pha + tya + adc header+HDR_DLEN+1 + tay + pla + clc + adc header+HDR_BLEN + pha + tya + adc header+HDR_BLEN+1 + tay + pla + jsr Balloc + bcc ok + jmp no_text +ok + stx textb + sta texta + sty texta+1 + clc + adc header+HDR_TLEN + sta dataa + pha + tya + adc header+HDR_TLEN+1 + sta dataa+1 + tay + pla + adc header+HDR_DLEN + sta bssa + pha + tya + adc header+HDR_DLEN+1 + sta bssa+1 + tay + pla + + sec + sbc header+HDR_BBASE + sta bssd + tya + sbc header+HDR_BBASE+1 + sta bssd+1 + + sec + lda dataa + sbc header+HDR_DBASE + sta datad + lda dataa+1 + sbc header+HDR_DBASE+1 + sta datad+1 + + sec + lda texta + sbc header+HDR_TBASE + sta textd + lda texta+1 + sbc header+HDR_TBASE+1 + sta textd+1 + + lda header+HDR_ZLEN + jsr Zalloc + bcs no_zero + + sta zeroa + sec + sbc header+HDR_ZBASE + sta zerod + lda #0 + sta zerod+1 + + jmp do_load + +no_file +no_zero + ldx textb + jsr Bfree + +close +no_text ldx file + lda #E_NUL + jsr STRCMD + sec + rts + +do_load ; load options (i.e. ignore them now) + ldx file + jsr Fgetc + bcs no_file + cmp #0 + beq load_text + tay + dey +optl jsr Fgetc + bcs no_file + dey + bne optl + beq do_load + +load_text ; load text segment + lda texta + sta p1 + lda texta+1 + sta p1+1 + ldx #p1 + lda header+HDR_TLEN + ldy header+HDR_TLEN+1 + jsr fgetb + bcs no_file + ; load data segment + lda dataa + sta p1 + lda dataa+1 + sta p1+1 + ldx #p1 + lda header+HDR_DLEN + ldy header+HDR_DLEN+1 + jsr fgetb + bcs no_file + ; check number of undefined references + ldx file + jsr Fgetc +&no_file2 bcs no_file + cmp #0 + bne no_file ; we have some -> not handled + ldx file + jsr Fgetc + bcs no_file + cmp #0 + bne no_file + ; ok, text segments loaded, now relocate + lda texta + sec + sbc #1 + sta p1 + lda texta+1 + sbc #0 + sta p1+1 + jsr trel + + lda dataa + sec + sbc #1 + sta p1 + lda dataa+1 + sbc #0 + sta p1+1 + jsr trel + + jsr close + + lda texta ; return start of text segment + ldy texta+1 + clc + rts + .) + +trel .( + ldx file + jsr Fgetc +no_file1 bcs no_file2 + cmp #0 + beq reloc_rts + cmp #255 + bne t1 + lda #254 + clc + adc p1 + sta p1 + bcc trel + inc p1+1 + jmp trel +t1 clc + adc p1 + sta p1 + bcc t1a + inc p1+1 +t1a ; p1 is the relocation address + ldx file + jsr Fgetc + bcs no_file1 + tay + and #A_MASK + sta tmp + tya + and #A_FMASK + jsr getreldiff + ldy tmp + cpy #A_ADR + bne t2 + + ldy #0 + clc + adc (p1),y + sta (p1),y + iny + txa + adc (p1),y + sta (p1),y + jmp trel +t2 + cpy #A_LOW + bne t3 + ldy #0 + clc + adc (p1),y + sta (p1),y + jmp trel +t3 + cpy #A_HIGH + bne trel + sta p2 + stx p2+1 + ldx file + jsr Fgetc + clc + adc p2 ; just get the carry bit + ldy #0 + lda p2+1 ; relocate high byte + adc (p1),y + sta (p1),y + jmp trel + +reloc_rts + clc + rts + .) + +getreldiff .( ; comparing with SEG_UNDEF would give a way + ; to get label value here for undefined refs + cmp #SEG_TEXT + bne notext + lda textd + ldx textd+1 + rts +notext cmp #SEG_DATA + bne nodata + lda datad + ldx datad+1 + rts +nodata cmp #SEG_BSS + bne nobss + lda bssd + ldx bssd+1 + rts +nobss cmp #SEG_ZERO + bne nozero + lda zerod + ldx zerod+1 +nozero rts + .) + +fgetb .( + .zero +p .word 0 + .data +l .word 0 + .text + + sta l + sty l+1 + lda 0,x + sta p + lda 1,x + sta p+1 + +loop ldx file + jsr Fgetc ; this is a simple implementation + bcs end1 + ldy #0 + sta (p),y + inc p + bne l0 + inc p+1 +l0 + lda l + bne l1 + dec l+1 +l1 dec l + + lda l + ora l+1 + bne loop + clc +end1 + rts + .) + + .) + + diff --git a/dump/oa-2.0.9/oldlib/mem.a65 b/dump/oa-2.0.9/oldlib/mem.a65 new file mode 100644 index 0000000..415a1d9 --- /dev/null +++ b/dump/oa-2.0.9/oldlib/mem.a65 @@ -0,0 +1,846 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/********************************************************************** + * New memory management for IP buffers + * exports + * binit + * balloc, bfree, btrunc, bsplit, brealloc + * getbadr, getblen + * + * The routines are _not_ threadsave! + * They have to be secured with SEM_MEM before calling them! + * + */ + +#define IPBUFFER $2000 + +#define MINBUF 8 +#define MINMASK %11111000 + +#ifndef MAXSLOT +#define MAXSLOT 32 +#endif + +#ifndef MEMINIVAL +#define MEMINIVAL 0 +#endif + +#undef DEBUGMEM +#undef DB +#define DB(a) + + .( + + .data +slotladr .dsb MAXSLOT +slothadr .dsb MAXSLOT +slotllen .dsb MAXSLOT +slothlen .dsb MAXSLOT +slotrlln .dsb MAXSLOT +slotrhln .dsb MAXSLOT +slotownr .dsb MAXSLOT +slotpid .dsb MAXSLOT + +#ifdef NOMMU +init .byt 0 ; if not MEMINIVAL then init was ok! +#endif + +flist .word 0 +slot .byt 0 + + .zero +p .word 0 +p2 .word 0 +p3 .word 0 +p4 .word 0 + +; .bss +;buf .dsb IPBUFFER + + .text + +/* init memory management */ +/* x holds hibyte of start address of memory, y length in pages */ ++binit .( +#ifdef NOMMU + lda init + cmp #MEMINIVAL + bne end +#endif + stx flist+1 + stx p+1 + lda #0 + sta flist + sta p + + tya + ldy #3 + sta (p),y + dey + lda #0 + sta (p),y + dey + sta (p),y + dey + sta (p),y + + ;lda #0 + tay +l0 sta slotladr,y + sta slothadr,y + sta slotownr,y + iny + cpy #MAXSLOT + bcc l0 + +#ifdef NOMMU + inc init +#endif +end + clc + rts + .) + +/**************************************************************************/ +/* a/y = size of buffer to be allocated -> x buffer-ID */ +&balloc .( + /* walk along freelist, and take first matching buffer + length is made a multiple of 8 (for freelist connectors */ + + pha + jsr getbslot + pla + bcc gotslot + DB("balloc: no slot!^m^j") + lda #E_NOMEM + sec + rts +gotslot + stx slot + + sta slotrlln,x + pha + tya + sta slotrhln,x + pla + + adc #MINBUF-1 + and #MINMASK + sta slotllen,x + tya + adc #0 + sta slothlen,x + + jsr GETPID + txa + ldx slot + sta slotpid,x + +/*jsr printlist*/ +#if 0 /*def DEBUGMEM*/ +DB("^m^jalloc(") +txa +jsr EHexout +lda slothlen,x +jsr EHexout +lda slotllen,x +jsr EHexout +DB("^m^jFlist=") +lda flist+1 +jsr EHexout +lda flist +jsr EHexout +jsr ECrlfout +#endif + lda #0 + sta p2 + sta p2+1 + lda flist + sta p + lda flist+1 + sta p+1 +l0 +#if 0 /*def DEBUG*/ +DB("^m^jCheck@") +lda p+1:jsr EHexout:lda p:jsr EHexout +jsr ECrlfout +#endif + ldy #2 + lda (p),y + sec + sbc slotllen,x + sta p3 + iny + lda (p),y + sbc slothlen,x + sta p3+1 + bcs found + + lda p + sta p2 + lda p+1 + sta p2+1 + ldy #1 + lda (p2),y + sta p+1 + dey + lda (p2),y + sta p + ora p+1 + bne l0 + +oops lda #E_NOMEM + sec + rts + +found + /* ok, we found a free buffer: p points to the buffer, p2 to the + previous one. p3 is the length of the free buffer minus the + needed size. If the buffer is longer than needed, create a + new free buffer, then link new buffer to freelist */ + +#if 0 /*def DEBUG*/ +DB("Found Free buffer to alloc:") +DB("p=") +lda p+1:jsr EHexout:lda p:jsr EHexout +DB("p2=") +lda p2+1:jsr EHexout:lda p2:jsr EHexout +DB("p3=") +lda p3+1:jsr EHexout:lda p3:jsr EHexout +jsr ECrlfout +#endif + + lda p /* save buffer address */ + sta slotladr,x + lda p+1 + sta slothadr,x + inc slotownr,x + + lda p3 /* check length */ + ora p3+1 + beq nocreate + + lda p /* get address of new free buffer */ + clc + adc slotllen,x + sta p4 + lda p+1 + adc slothlen,x + sta p4+1 + + ldy #0 /* copy next pointer */ + lda (p),y + sta (p4),y + iny + lda (p),y + sta (p4),y + + iny /* set new length */ + lda slotllen,x + sta (p),y + lda p3 + sta (p4),y + iny + lda slothlen,x + sta (p),y + lda p3+1 + sta (p4),y + jmp set2 +nocreate + ldy #0 + lda (p),y + sta p4 + iny + lda (p),y + sta p4+1 +set2 + lda p2 + ora p2+1 + beq freestart + + ldy #0 + lda p4 + sta (p2),y + iny + lda p4+1 + sta (p2),y + clc + bcc geta +freestart +#if 0 /*def DEBUG*/ +DB("^m^jFreestart") +lda p+1:jsr EHexout:lda p:jsr EHexout:jsr ECrlfout +#endif + lda p4 + sta flist + lda p4+1 + sta flist+1 + clc +geta +#if 0 /*def DEBUGMEM*/ +php:txa:pha +DB("^m^jallocated buffer ") +txa: jsr EHexout +lda slothadr,x: jsr EHexout: lda slotladr,x: jsr EHexout +lda slothlen,x: jsr EHexout: lda slotllen,x: jsr EHexout +jsr ECrlfout +jsr printmem +jsr printlist +pla:tax:plp +#endif + lda slotladr,x + ldy slothadr,x + rts + .) + +/**************************************************************************/ + +/* free buffer (ID=xr) */ +&bfree .( +/*clc:rts*/ +&bfree2 + cpx #MAXSLOT + bcc okfree +#if 0 + DB("bfree: illegal slot#, retadr=") + txa:pha:tsx:lda $0103,x:jsr EHexout:lda $0102,x:jsr EHexout + jsr ECrlfout:pla:tax +#endif + sec + rts +okfree lda slotownr,x + bne okf1 +#if 0 + DB("bfree: slot ") + txa:jsr EHexout:DB(" not in use, retadr=") + txa:pha:tsx:lda $0103,x:jsr EHexout:lda $0102,x:jsr EHexout + jsr ECrlfout:pla:tax +#endif + sec + rts +okf1 +/* DB("bfree(")*/ + +#if 0 /*def DEBUGMEM*/ +DB("Freeing Slot ") +txa:jsr EHexout:DB(", #ownr="):lda slotownr,x:jsr EHexout: +DB(", retadr="):txa:pha:tsx:lda $103,x:jsr EHexout:lda $102,x:jsr EHexout +pla:tax:jsr ECrlfout +#endif + + dec slotownr,x + bne end2 + + lda slothadr,x + sta p3+1 + lda slotladr,x + sta p3 + ora p3+1 + beq end2 + + ldy #2 + lda slotllen,x + sta (p3),y + iny + lda slothlen,x + sta (p3),y + + lda #0 + sta slothadr,x + sta slotladr,x + + lda flist + ora flist+1 + bne ok /* no free buffer so far? */ + + lda p3 + sta flist + lda p3+1 + sta flist+1 + ldy #0 + tya + sta (p3),y + iny + sta (p3),y +end2 clc + rts +ok + lda #0 + sta p2 + sta p2+1 + lda flist + sta p + lda flist+1 + sta p+1 + + /* we have to find the place where to put the buffer in the + ordered free list. Then we have to check if we can merge + free buffers */ +loop +#if 0 /*def DEBUGMEM*/ +DB("Check slot ") +lda p+1: jsr EHexout:lda p: jsr EHexout +DB("["): ldy #3:lda (p),y:jsr EHexout:dey:lda (p),y:jsr EHexout +DB("]->"):ldy #1:lda (p),y:jsr EHexout:dey:lda (p),y:jsr EHexout +jsr ECrlfout +#endif + + lda p3+1 + cmp p+1 + bcc found + bne next + lda p3 + cmp p + bcc found +next + lda p + sta p2 + lda p+1 + sta p2+1 + ldy #0 + lda (p2),y + sta p + iny + lda (p2),y + sta p+1 + ora p + bne loop + beq found +end + clc + rts + +found /* p2 is the buffer before the one to be freed, p the one behind. + p3 is the buffer to be inserted */ + +#if 0 /*def DEBUGMEM*/ +DB("Found buffer^m^j") +DB("p3=") +lda p3+1:jsr EHexout:lda p3:jsr EHexout:jsr ECrlfout +DB("p2=") +lda p2+1:jsr EHexout:lda p2:jsr EHexout +DB("["):ldy #3:lda (p2),y:jsr EHexout:dey:lda (p2),y:jsr EHexout +DB("]->"):ldy #1:lda (p2),y:jsr EHexout:dey:lda (p2),y:jsr EHexout +jsr ECrlfout +DB("p=") +lda p+1:jsr EHexout:lda p:jsr EHexout +DB("["):ldy #3:lda (p),y:jsr EHexout:dey:lda (p),y:jsr EHexout +DB("]->"):ldy #1:lda (p),y:jsr EHexout:dey:lda (p),y:jsr EHexout +jsr ECrlfout +#endif + lda p2 + ora p2+1 + bne fok + ; insert before the first free buffer so far + ldy #0 + lda flist + sta (p3),y + iny + lda flist+1 + sta (p3),y + lda p3 + sta flist + ldy p3+1 + sty flist+1 + jsr bmerge +#if 0 /*def DEBUGMEM*/ +jsr printmem +#endif + clc + rts +fok ; insert to list + ldy #1 + lda p+1 ;lda (p2),y + sta (p3),y + dey + lda p ;lda (p2),y + sta (p3),y + lda p3 + sta (p2),y + iny + lda p3+1 + sta (p2),y + + lda p3 + ldy p3+1 + jsr bmerge + lda p2 + ldy p2+1 + jsr bmerge +#if 0 /*def DEBUGMEM*/ +jsr printmem +#endif + clc + rts + .) + +/**************************************************************************/ +/* split buffer xr at size a/y for first part. return new buffer ID in x */ +&bsplit .( + stx slot +#if 0 /*def DEBUGMEM*/ +pha +tya +pha +DB("^m^jbsplit buffer ") +txa +jsr EHexout +pla +pha +jsr EHexout +pla +tay +pla +pha +jsr EHexout +jsr ECrlfout +pla +#endif + sta p3 + sty p3+1 +/*pha:tya:pha:DB("bsplit "):jsr printlist:jsr ECrlfout:pla:tay:pla*/ + + clc + adc #MINBUF-1 + and #MINMASK + sta p2 + bcc l0 + iny +l0 sty p2+1 + + lda slotownr,x + beq splitownr + + tya + cmp slothlen,x + bcc ok + bne oops + lda p2 + cmp slotllen,x + bcc ok + bne oops + +/*DB("Btrunc to same size!^m^j")*/ + lda p3 + sta slotrlln,x + lda p3+1 + sta slotrhln,x + sec + rts + +oops DB("bsplit: oops^m^j") + sec + rts + +splitownr + DB("bsplit: no owner!^m^j") + jmp oops + +ok lda p3 + sta slotrlln,x + lda p3+1 + sta slotrhln,x + +/*DB("slot="):lda slot:jsr EHexout:jsr ECrlfout*/ + jsr getbslot + bcs oops + + ldy slot + clc + lda slotladr,y + adc p2 + sta slotladr,x + lda slothadr,y + adc p2+1 + sta slothadr,x + sec + lda slotllen,y + sbc p2 + sta slotllen,x + lda slothlen,y + sbc p2+1 + sta slothlen,x + + lda p2 + sta slotllen,y + lda p2+1 + sta slothlen,y + + inc slotownr,x +oknull +#if 0 +DB("^m^jsplit buffer @") + jsr printlist +#ifdef DEBUGMEM + txa + jsr EHexout + lda slothadr,x + jsr EHexout + lda slotladr,x + jsr EHexout + lda slothlen,x + jsr EHexout + lda slotllen,x + jsr EHexout + jsr ECrlfout +jsr printmem +#endif +#endif + clc + rts + .) + +/**************************************************************************/ +/* truncate buffer xr to size a/y */ +&btrunc .( + jsr bsplit + bcs oops + jmp bfree2 +oops rts + .) + +/* realloc buffer xr to size a/y */ +/* produce assemble errror +&brealloc .( + .) +*/ + +/* get adress of buffer */ +&getbadr .( + cpx #MAXSLOT + bcs maxerr + lda slotownr,x + beq err + lda slotladr,x + ldy slothadr,x + clc + rts +err +#if 0 + DB("getbadr from unused slot=") + txa + jsr EHexout + DB("!^m^j") +#endif + sec + rts +maxerr DB("getbadr from illegal slot^m^j") + sec + rts + .) + +/* get length of buffer */ +&getblen .( + lda slotrlln,x + ldy slotrhln,x + clc + rts + .) + +/* this registers one more user - so one bfree is ignored */ +&incownr .( + cpx #MAXSLOT + bcs err + lda slotownr,x + beq incerr + inc slotownr,x + clc + rts +err DB("incownr: illegal buffer^m^j") + sec + rts +incerr DB("incownr: unused buffer^m^j") + sec + rts + .) + +/* get free buffer-ID slot */ +getbslot .( + ldx #0 +l0 + clc + lda slotownr,x + beq found + inx + cpx #MAXSLOT + bcc l0 +found + rts + .) + +/* check if two free buffers (i.e. a/y plus following) can be merged */ +bmerge .( + sta p + sty p+1 + ldy #2 + clc + lda (p),y + adc p + sta p3 + iny + lda (p),y + adc p+1 + sta p3+1 + ldy #0 + lda (p),y + cmp p3 + bne nomerge + iny + lda (p),y + cmp p3+1 + bne nomerge +merge + ldy #2 + clc + lda (p3),y + adc (p),y + sta (p),y + iny + lda (p3),y + adc (p),y + sta (p),y + ldy #0 + lda (p3),y + sta (p),y + iny + lda (p3),y + sta (p),y +nomerge + clc + rts + .) + +/**************************************************************************/ +#ifdef DEBUGMEM + + .data +pac .byt 0 +pxr .byt 0 +pyr .byt 0 + .text + +&printlist .( + php + sta pac + stx pxr + sty pyr + + ldx #0 +l0 lda slotownr,x + beq next + txa + jsr EHexout + lda #":" + jsr ECout + lda slotownr,x + jsr EHexout + lda #"@" + jsr ECout + lda slothadr,x + jsr EHexout + lda slotladr,x + jsr EHexout + lda #"[" + jsr ECout + lda slothlen,x + jsr EHexout + lda slotllen,x + jsr EHexout + DB("] ") + + lda slotladr,x + and #%00000111 + bne error +next + inx + cpx #MAXSLOT + bcc l0 + jsr ECrlfout + + lda pac + ldx pxr + ldy pyr + plp + rts +error brk + .) + +&printmem .( + php + sta pac + stx pxr + sty pyr + +DB("^m^jMemory Free List:^m^j") + lda flist + sta p + lda flist+1 + sta p+1 + ldx #STDERR +loop + lda p+1 +; beq ende + jsr EHexout + lda p + jsr EHexout + lda #"[" + jsr Fputc + ldy #3 + lda (p),y + jsr EHexout + dey + lda (p),y + jsr EHexout + DB("]->") + ldy #1 + lda (p),y + jsr EHexout + dey + lda (p),y + jsr EHexout + jsr ECrlfout + + ldy #1 + lda (p),y + pha + dey + lda (p),y + sta p + pla + sta p+1 + ora p + bne loop + + lda pac + ldx pxr + ldy pyr + plp + rts +ende brk + .) +#endif + + .) + + diff --git a/dump/oa-2.0.9/oldlib/stdio.a65 b/dump/oa-2.0.9/oldlib/stdio.a65 new file mode 100644 index 0000000..7fe3dde --- /dev/null +++ b/dump/oa-2.0.9/oldlib/stdio.a65 @@ -0,0 +1,589 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* if not 'relocated' for other purposes, use std addr for stdio */ +#ifndef STDIOADDR +#define STDIOADDR $e800 +#endif + ++STDLIB =STDIOADDR + +#include "kernel.i65" /* kernel calls are preprocessor defines! */ + +/* TODO: check NOMMU and OLDROM to set something like threadsave */ + +#ifdef ROM + + .( + + .zero +xr .byt 0 + .text + +getc .( +#ifdef OLDROM + stx xr + ldx #STDIN + .byt $2c +#else + php + sei + sta xr + txa + ldx xr + plp + pha + ldx #STDIN + jsr fgetc + tax + pla + php + sei + sta xr + txa + ldx xr + plp + rts +#endif +&fgetc +#ifdef OLDROM + stx xr +#endif +gc1 jsr GETC + bcc ok + cmp #E_EOF + beq ok + jsr YIELD + jmp gc1 +ok +#ifdef OLDROM + ldx xr +#endif + rts + .) + +crlfout lda #13 + jsr putc +lfout lda #10 +putc .( +#ifdef OLDROM + stx xr + pha + ldx #STDOUT + bne pc1 +#else + php ; exchange x and a - thread save + sei + sta xr + txa + ldx xr + plp ; implicit cli + pha ; save former xr first + txa + ldx #STDOUT + jsr fputc + tax ; ac to xr + pla ; get former xr from stack + php ; and exchange x and a back + sei + sta xr + txa + ldx xr + plp + rts +#endif + +&fputc pha +#ifdef OLDROM + stx xr +#endif +pc1 jsr PUTC + bcc ok + cmp #E_NUL + beq ok + jsr YIELD + pla + pha + jmp pc1 +ok +#ifdef OLDROM + ldx xr +#endif + pla + rts + .) + +serbrk .( + stx xr + lda #SC_STAT + ldx #STDIN + jsr STRCMD + ldx xr + cmp #E_SEMPTY + beq s3 + sec + rts +#ifndef OLDROM +s3 clc + rts +#endif + .) + + .zero +d1 .word 0 + .text +dezbout .( + +#ifndef OLDROM + php ; thread-save + sei +#endif +l1 tay + sec + sbc #100 + bcs l1 + lda #0 + sta d1 + tya +l2 tay + sec + sbc #10 + bcc l3 + inc d1 + bcs l2 +l3 asl d1 + asl d1 + asl d1 + asl d1 + tya + ora d1 +#ifndef OLDROM + plp +#endif +&hexout + pha + lsr + lsr + lsr + lsr + jsr nibout + pla + and #$0f +nibout clc + adc #"0" + cmp #"9"+1 + bcc nibok + adc #6 +nibok jmp putc + .) + +txtout .( +tp =d1 /*syszp+1*/ + +#ifndef OLDROM + php ; switching multitasking of is a + sei ; 'bad thing' (tm)! - but a mutex is needed +#endif + sta tp + sty tp+1 + ldy #0 +tol lda (tp),y + beq tole + jsr putc + iny + bne tol + inc tp+1 + bne tol +tole +#ifndef OLDROM + plp +#else +&s3 +#endif + clc + rts + .) + +#if 0 +#ifndef OLDROM +-syszp += 3 +#endif +#endif + +/*********************************************************************** + * Warning! The following routines (Directory stuff, assigntab) are + * _not_ thread-save! + */ + +#define PATH_DRV 0 +#define PATH_NAME (PATH_DRV+1) /* ohne abschliessendes DIRSIGN */ + + .zero +zp .word 0 +d .byt 0 +maxpath .byt 0 + .text + + .( + +&usedir sta zp + sty zp+1 + lda PCBUF+FS_OPEN_DRV + bpl ok ; Laufwerk angegeben, war nix + + ldy #PATH_DRV + lda (zp),y + sta PCBUF+FS_OPEN_DRV + + ldx #FS_OPEN_NAME + lda PCBUF,x + cmp #DIRSIGN ; Pfad absolut angegeben + beq ok ; war auch nix + +ud2 iny + lda (zp),y + bne ud2 + sty d +ud4 lda PCBUF,x + beq ud3 + inx + bne ud4 +ud3 inx + txa + clc + adc d + sta d + bcs nerr + tay +ud5 lda PCBUF,x + sta PCBUF,y + dey + dex + cpx #FS_OPEN_NAME + bcs ud5 + ldy #PATH_NAME +ud6 lda (zp),y + sta PCBUF+FS_OPEN_NAME-PATH_NAME,y + beq ud7 + iny + bne ud6 +ud7 lda #DIRSIGN + sta PCBUF+FS_OPEN_NAME-PATH_NAME,y + ldx d + clc + rts +nerr sec + rts +ok ldx #FS_OPEN_NAME +ok1 lda PCBUF,x + beq oke + inx + bne ok1 +oke inx + clc + rts + .) + + .( +#if 0 +zp =syszp +d =syszp+2 +maxpath =syszp+3 +#endif + +&chdir sta zp + sty zp+1 + stx maxpath + lda PCBUF+FS_CMD_DRV + bmi nodrive + ldy #PATH_DRV + cmp (zp),y + beq nodrive + sta (zp),y + iny + lda #0 + sta (zp),y +nodrive inc zp + bne nd1 + inc zp+1 + ldy #0 + ; Name untersuchen +nd1 ldx #FS_CMD_NAME + lda PCBUF,x + bne ndrx ; kein Name dann Pfad l�schen + sta (zp),y + clc + rts +ndrx + cmp #DIRSIGN ; Name beginnt mit DIRSIGN + bne nd2 + lda #0 ; dann Pfad l�schen + sta (zp),y + +nd2a inx +nd2 lda PCBUF,x ; weiter Name anschauen + beq ndr ; kein Name dann Ende + cmp #DIRSIGN + beq nd2a ; DIRSIGN �berlesen + cmp #"." + bne nameok ; kein '.' dann ok + inx + lda PCBUF,x ; hier mindestens ein '.' + beq ndr ; Null dann Ende + cmp #DIRSIGN ; DIRSIGN, + beq nd2a ; dann '.' ignorieren + cmp #"." ; noch'n Punkt ? + bne nerrx ; nein, dann + jsr getpos + ldy d ; Position des letzten DIRSIGNs + lda #0 + sta (zp),y ; l�schen = eine Verzeichnis-Ebene h�her + beq nd2a ; (absolut) + +nerrx dex +nameok jsr getpos ; y=L�nge des alten Pfads + sty d ; hier Verzeichnis-Name an Pfad anh�ngen +no iny + cpy maxpath + bcs nerr + lda PCBUF,x + beq nr + cmp #DIRSIGN + beq nr + sta (zp),y + inx + bne no +nr lda #0 + sta (zp),y + ldy d + lda #DIRSIGN ; alles ok, dann Nullbyte (Ende alter Pfad) mit + sta (zp),y ; DIRSIGN �berschreiben + lda PCBUF,x ; Ende des neuen Verzeichnisses + bne nd2a ; nein, dann wieder nach oben +ndr clc + rts +nerr sec + rts +getpos ldy #0 ; holt y=L�nge des alten Pfadnamens + sty d ; und d=Position des letzten DIRSIGNs +no0 lda (zp),y + beq no1 + cmp #DIRSIGN + bne no2 + sty d +no2 iny + bne no0 +no1 rts + .) + + .( +#if 0 +zp =syszp +d =syszp+2 +#endif + +&getname sta zp + sty zp+1 + lda #0 + sta PCBUF+FS_OPEN_NAME + ldy #<-1 + sty PCBUF+FS_OPEN_DRV +g1 iny + lda (zp),y + beq gr + cmp #" " + beq g1 + cmp #":" + beq g1 + cmp #34 ; " + beq g2 + iny + lda (zp),y + dey + cmp #":" + bne g2 + lda (zp),y + cmp #"A" + bcc g3 + sbc #1 +g3 and #$0f + sta PCBUF+FS_OPEN_DRV + iny + iny +g2 dey + ldx #FS_OPEN_NAME + bne g2a + +&set2name /* x=iobuf, y=pcbuf */ + sta zp + sty zp+1 + ldy #<-1 +g2a lda #" " + sta d +gn1 iny + lda (zp),y + beq gn3 + cmp #" " + beq gn1 + cmp #">" + beq gn3 + cmp #34 ; " + bne gn2 + iny + sta d +gn2 lda (zp),y + beq gn3 + cmp d + beq gn3a + sta PCBUF,x + inx + iny + bne gn2 + +gn3a iny +gn3 lda #0 + sta PCBUF,x + inx +gr rts + .) + + .( +#ifndef NOMMU + .zero +#else + .data +#endif +assigntab .dsb 10 + .text + +&assign bcc assigndrv + cpx #<-1 + bne a +iniassign + ldx #0 +ai txa + sta assigntab,x + inx + cpx #10 + bcc ai + clc + rts +assigndrv + pha + cpx #10 + bcs ae + lda assigntab,x + tax +ae pla + rts + +a cpx #10 + bcs ar + sta assigntab,x +ar rts + .) + +#include "oldlib/mem.a65" +#include "oldlib/zmem.a65" +#include "oldlib/loader.a65" + +#if * > STDIOADDR-3*24 +#echo "STDLIB to long!" +#endif + +#ifndef STDTST + .dsb STDIOADDR-*-3*24,<-1 + +#echo Putting STDIO table to +#print * + +#endif + +jmp loader + +jmp zalloc +jmp zfree + +jmp balloc +jmp bfree +jmp btrunc +jmp bsplit +jmp getbadr +jmp getblen +jmp incownr + +jmp set2name +jmp usedir +jmp chdir +jmp getname +jmp assign +jmp dezbout +jmp serbrk +jmp crlfout +jmp hexout +jmp txtout +jmp putc +jmp getc +jmp fputc +jmp fgetc + +#ifndef STDTST +#if *-STDIOADDR +#echo Fehler: STDIO address not right! +ldx ,x +#endif +#endif + + .) + +#endif + +Loader =STDLIB-72 + +Zalloc =STDLIB-69 +Zfree =STDLIB-66 + +Balloc =STDLIB-63 +Bfree =STDLIB-60 +Btrunc =STDLIB-57 +Bsplit =STDLIB-54 +Getbadr =STDLIB-51 +Getblen =STDLIB-48 +Incownr =STDLIB-45 + +Set2name =STDLIB-42 /* $e7d6 */ +Usedir =STDLIB-39 /* $e7d9 */ +Chdir =STDLIB-36 /* $e7dc */ +Getname =STDLIB-33 /* $e7df */ +Assign =STDLIB-30 /* $e7e2 */ +Dezbout =STDLIB-27 /* $e7e5 */ +Serbrk =STDLIB-24 /* $e7e8 */ +Crlfout =STDLIB-21 /* $e7eb */ +Hexout =STDLIB-18 /* $e7ee */ +Txtout =STDLIB-15 /* $e7f1 */ +Putc =STDLIB-12 /* $e7f4 */ +Getc =STDLIB-9 /* $e7f7 */ +Fputc =STDLIB-6 /* $e7fa */ +Fgetc =STDLIB-3 /* $e7fd */ + diff --git a/dump/oa-2.0.9/oldlib/zmem.a65 b/dump/oa-2.0.9/oldlib/zmem.a65 new file mode 100644 index 0000000..1c1c55e --- /dev/null +++ b/dump/oa-2.0.9/oldlib/zmem.a65 @@ -0,0 +1,157 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + .( + + .data +zmem .dsb 64 ; each four byte have an owner + .text + +/* + * yr = first available zeropage address + */ + ++zinit .( + php + sei + lda #<-1 ; all in use + tax + inx +l0 sta zmem,x + inx + cpx #64 + bcc l0 + + tya + clc + adc #3 + lsr + lsr + tay + + lda #0 ; free +l1 sta zmem,y + iny + cpy #64 + bcc l1 + + plp + clc + rts + .) + + +/* + * a = length of needed zeropage area in byte + * returns a= address of zeropage area with c=0 + * or c=1 when no area found + * + */ +&zalloc .( + clc + adc #3 + lsr + lsr + + tay + jsr GETPID + inx + txa + pha + tya + + sei + ldy #0 +l1 + pha + tax +l2 + lda zmem,y + bne notfree + dex + beq found + iny + cpy #64 + bcc l2 + pla + pla + cli + rts + +notfree iny + pla + cpy #64 + bcc l1 + pla + cli + rts + +found + pla + tax + pla + iny +l3 + dey + sta zmem,y + dex + bne l3 + + tya + asl + asl + clc + cli + rts + .) + +/* + * a = address of area to free. All consecutive zeropage addresses + * belonging to this task from a on are free'd. + */ +&zfree .( + clc + adc #3 + lsr + lsr + tay + jsr GETPID + inx + sei +l0 txa + cmp zmem,y + bne ende + lda #0 + sta zmem,y + iny + cpy #64 + bcc l0 +ende + clc + cli + rts + .) + + .) + + diff --git a/dump/oa-2.0.9/sysapps/Makefile b/dump/oa-2.0.9/sysapps/Makefile new file mode 100644 index 0000000..efeb410 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/Makefile @@ -0,0 +1,8 @@ + +# appdirs= fs init mon slipd ibmon irtx basic mcopy + +clean: + (for i in *; do\ + (if test -d $$i; then cd $$i; ${MAKE} clean; fi); \ + done) + diff --git a/dump/oa-2.0.9/sysapps/README b/dump/oa-2.0.9/sysapps/README new file mode 100644 index 0000000..9c225cc --- /dev/null +++ b/dump/oa-2.0.9/sysapps/README @@ -0,0 +1,12 @@ + +The "sysapps" directory contains system-dependend programs. These include + + - filesystem servers + + - internet servers + + - hardware dependend stuff (like irtx or ibmon) + + - some old programs that have not been ported to lib6502 or are not worth + the time doing it (if you like, port them and I move them to apps) + diff --git a/dump/oa-2.0.9/sysapps/basic/Makefile b/dump/oa-2.0.9/sysapps/basic/Makefile new file mode 100644 index 0000000..332dc1f --- /dev/null +++ b/dump/oa-2.0.9/sysapps/basic/Makefile @@ -0,0 +1,13 @@ + + +XAINPUT=../../include,../../arch,../.. +XA=xa + +basic4.o65: basic4.a65 + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -DKERNEL=61440 -R -c basic4.a65 -o basic4.o65 ;\ + if [ $$? -ne 0 ]; then rm -f basic4.o65; fi; ) + +clean: + rm -f basic4.o65 + diff --git a/dump/oa-2.0.9/sysapps/basic/basic4.a65 b/dump/oa-2.0.9/sysapps/basic/basic4.a65 new file mode 100644 index 0000000..f77f542 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/basic/basic4.a65 @@ -0,0 +1,3561 @@ +/**************************************************************************** + + This BASIC interpreter is derived from Copyrighted source! + Therefore I do not hold copyrights on it. + The Copyright is held by ??? + + That's why this is only an educational example of how to + port programs to the OS/A65 operating system. + + DO NOT ASSEMBLE OR RUN THIS PROGRAM! + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +****************************************************************************/ + + +.( +#ifdef ROM + +#ifndef BASICEXE +#define BASICEXE $80 +#endif +#ifndef BASICDEV +#define BASICDEV 0 +#endif + + .word endofbasic + .byt PK_PRG+BASICEXE + .byt 2 + .byt BASICDEV, BASICDEV + .word BASIC +#ifndef ROMTEST + .byt 8,8,9,9,$a,$a,$b,$b,$c,$c,$d,$d,$e,$e,<-1 +#else + .byt 8,$18,9,$19,$a,$1a,$b,$1b,$c,$1c,$d,$1d,$e,$1e,<-1 +#endif + .asc "basic",0,0 + +#else /* ROM */ + +#include "kdefs.i65" +#include "kernel.i65" +#include "fdefs.i65" + + ;.word $800 + *=$8000 + .word 0 + .byt PK_PRG + .byt 16 + .word 0 + .word BASIC + .byt 8,0,9,0,$a,0,$b,0,<-1 + +; *=$8000 + +#endif /* ROM */ + +/*#define SHOW*/ + +#ifndef BASICEND +#define BASICEND $4000 +#endif +#ifndef BASICSTART +#define BASICSTART $800 +#endif + +RAMEND =BASICEND +RAMANF =BASICSTART +#print RAMANF +#print RAMEND + + +#define E_OPEN 2 +#define E_TOOMANYF 1 +#define E_NOTINPUT 6 +#define E_FILEOPEN 2 +#define E_NOTOPEN 3 +#define E_NOTFND 4 + +/*#ifndef NOMMU*/ +oldsyszp =syszp +-syszp =$90 /* watch out - may not work on every ROM */ +/*#endif*/ + +#echo oabasic: +#print syszp + +status =syszp +;directfl =syszp+1 +filenr =syszp+2 +drive =syszp+3 +mode =syszp+4 +fnlen =syszp+5 +fnadr =syszp+6 ;.w +actin =syszp+8 +&actout =syszp+9 +&stream =syszp+10 +dx =syszp+11 +-syszp +=12 + +#define MAXFILE 10 +#define F_FNR 0 +#define F_STR 1 +#define F_MOD 2 +#define F_DRV 3 +#define F_SLEN 4 + + +BASIC jsr inifiles + jsr inidup + jsr lffcc + jmp le394 + + .( +anzfile =syszp +FTAB =syszp+1 +-syszp +=1+MAXFILE*F_SLEN + +&inifiles ldx #0 + stx anzfile + rts + +suchfile .( + txa + ldx anzfile +sf1 dex + bmi sfe + cmp FTAB+F_SLEN*F_FNR,x + bne sf1 +sfe rts + .) + +&lffc0 ldx filenr ; open + bne op1 + jmp notinput +op1 jsr suchfile + bne op2 + jmp fileopen +op2 ldy anzfile + cpy #MAXFILE + bcc op3 + jmp toomanyf +op3 lda filenr + sta FTAB+F_SLEN*F_FNR,y + lda mode + sta FTAB+F_SLEN*F_MOD,y + lda drive + sta FTAB+F_SLEN*F_DRV,y + + jsr xopen + bcs end + + ldy anzfile + lda stream + sta FTAB+F_SLEN*F_STR,y + inc anzfile + +end rts + +&xopen jsr GETSTR + bcc op4 + jmp nofile +op4 stx stream + stx PCBUF+FS_OPEN_STR + lda mode + cmp #FS_OPEN_DR+1 + bcs xoperr + lda #0 + sta PCBUF+FS_OPEN_PFAD + jsr copen + bcs xoperr + rts + +&copen lda drive + sta PCBUF+FS_OPEN_DRV + ldy #0 + ldx #FS_OPEN_NAME +op5 cpy fnlen + beq op5a + lda (fnadr),y + sta PCBUF,x + iny + inx + bne op5 +op5a lda #0 + sta PCBUF,x + inx + txa + tay + lda mode +&ropen ldx #SEND_FM + jsr SEND + bcs xcoperr + sec + jsr RECEIVE + cmp #1 +xcoperr rts + +xoperr ldx stream + jsr FRESTR + lda #E_OPEN + .byt $2c +&loaderr lda #E_NOTFND + .byt $2c +&nofile lda #E_NOFILE + .byt $2c +&toomanyf lda #E_TOOMANYF + .byt $2c +¬input lda #E_NOTINPUT + .byt $2c +&fileopen lda #E_FILEOPEN + .byt $2c +&filenotop lda #E_NOTOPEN + + pha + jsr lffcc + pla + cmp #1 + rts + +&lffe7 .( ;clall + lda anzfile + beq cle + lda FTAB+F_SLEN*F_FNR + jsr lffc3 + jmp lffe7 +cle clc + rts + .) + +&setfpar lda FTAB+F_SLEN*F_FNR,x + sta filenr + lda FTAB+F_SLEN*F_STR,x + sta stream + lda FTAB+F_SLEN*F_DRV,x + sta drive + lda FTAB+F_SLEN*F_MOD,x + sta mode + rts + +&lffc3 .( ;close + tax + jsr suchfile + beq clok + clc + rts +clok jsr setfpar + txa + pha + + tay + lda FTAB+F_SLEN*F_MOD,y + cmp #FS_OPEN_RD + beq clrd + cmp #FS_OPEN_DR + beq clrd + ldx FTAB+F_SLEN*F_STR,y + lda #SC_EOF + jsr STRCMD + lda FTAB+F_SLEN*F_MOD,y + cmp #FS_OPEN_RW + bne clx +clrd ldx FTAB+F_SLEN*F_STR,y + lda #SC_NUL + jsr STRCMD +clx + pla + tax + dec anzfile + cpx anzfile + beq clend + ldy anzfile + lda FTAB+F_SLEN*F_DRV,y + sta FTAB+F_SLEN*F_DRV,x + lda FTAB+F_SLEN*F_STR,y + sta FTAB+F_SLEN*F_STR,x + lda FTAB+F_SLEN*F_MOD,y + sta FTAB+F_SLEN*F_MOD,x + lda FTAB+F_SLEN*F_FNR,y + sta FTAB+F_SLEN*F_FNR,x +clend clc + rts + .) + +&lffc6 ;chkin + jsr suchfile + beq ckin + jmp filenotop +ckin jsr setfpar + lda stream + sta actin + clc + rts + +&lffc9 ;chkout + jsr suchfile + beq ckout + jmp filenotop +ckout jsr setfpar + lda stream + sta actout + clc + rts + .) + +lffe4 .( ;get + stx dx + ldx actin + cpx #STDIN + bne lcc1 + jsr GETC + ldx dx + bcc lcfe + lda #0 +lcfe rts + +&lffcf ;basin + stx dx + ldx actin +&lcc1 jsr GETC + bcc lcce + cmp #E_EOF + beq lccx + jsr YIELD + jmp lcc1 +lccx ldx dx + jmp filenotop +lcce ldx dx + clc + rts + + + .) + + .( +#define MAXDUP 5 + +intab =syszp +outab =syszp+MAXDUP +inpnt =syszp+2*MAXDUP +outpnt =syszp+2*MAXDUP+1 +-syszp +=2*MAXDUP+2 + +&inidup lda #0 + sta inpnt + sta outpnt + clc + rts + +&cldup .( + ldy inpnt +cld1 dey + bmi cld2 + lda intab,y + tax + lda #SC_NUL + jsr STRCMD + jmp cld1 +cld2 lda #0 + sta inpnt + ldy outpnt +cld3 dey + bmi cld4 + lda outab,y + tax + lda #SC_EOF + jsr STRCMD + jmp cld3 +cld4 lda #0 + sta outpnt + clc + rts + .) + +&dupout ldy outpnt + cpy #MAXDUP + bcs duperr1 +#ifdef SHOW + pha + lda #"o" + jsr SEROUT + pla + pha + jsr xHEXOUT + pla + clc + ldy outpnt +#endif + sta outab,y + sta actout + inc outpnt +duperr1 rts + +&clout ldy outpnt + beq cl2 + dec outpnt + lda outab-1,y +#ifdef SHOW + pha + lda #"c" + jsr SEROUT + pla + pha + jsr xHEXOUT + pla + clc +#endif + tax + lda #SC_EOF + jsr STRCMD + ldy outpnt + beq cl1a + lda outab-1,y + .byt $2c +cl1a lda #STDOUT + sta actout + clc + rts + +&clin ldy inpnt + beq cl2 + dec inpnt + lda intab-1,y + tax + lda #SC_NUL + jsr STRCMD + ldy inpnt + beq cl2a + lda intab-1,y + .byt $2c +cl2a lda #STDIN + sta actin + clc + rts +cl2 sec + rts + +&dupin ldy inpnt + cpy #MAXDUP + bcs duperr1 + sta intab,y + sta actin + inc inpnt + rts + +&lffcc ;clrch + ldy inpnt + dey + bmi c1 + lda inpnt,y + .byt $2c +c1 lda #STDIN + sta actin + ldy outpnt + dey + bmi c2 + lda outab,y + .byt $2c +c2 lda #STDOUT + sta actout + clc + rts + .) + +lffd2 ;bsout + stx dx + ldx actout +ld21 pha + jsr PUTC + bcc ld2e + cmp #E_NUL + beq ld2x + pla + jsr YIELD + jmp ld21 +ld2x pla + jmp filenotop +ld2e ldx dx + pla + rts + +anfadr =syszp +endadr =syszp+2 +loadfl =syszp+4 ;.w! +-syszp +=6 + +lffd5 ;load + stx anfadr + sty anfadr+1 + sta loadfl + + lda mode + sta loadfl+1 + + lda #FS_OPEN_RD + sta mode + jsr xopen + bcs ldendx + + ldx stream + jsr lcc1 + sta endadr + bcs loaderrx + ldx stream + jsr lcc1 + sta endadr+1 + bcs loaderrx + + lda loadfl+1 + beq ld51 + + lda endadr + sta anfadr + lda endadr+1 + sta anfadr+1 +ld51 + ldx stream + jsr lcc1 + bcs ldend + + ldy #0 + sta (anfadr),y + + inc anfadr + bne ld51 + inc anfadr+1 + bne ld51 +ldend + ldx stream + lda #SC_NUL + jsr STRCMD + +ldendx ldx anfadr + ldy anfadr+1 + clc + rts +loaderrx jsr ldend + jmp loaderr + +lffd8 ;save + stx endadr + sty endadr+1 + tax + lda 0,x + sta anfadr + lda 1,x + sta anfadr+1 + + lda #FS_OPEN_WR + sta mode + jsr xopen + bcs svend + + lda anfadr + ldx stream + jsr ld21 + lda anfadr+1 + ldx stream + jsr ld21 + +ld81 lda anfadr+1 + cmp endadr+1 + bcc ld82 + bne ld8e + lda anfadr + cmp endadr + bcs ld8e +ld82 + ldy #0 + lda (anfadr),y + ldx stream + jsr ld21 + + inc anfadr + bne ld81 + inc anfadr+1 + bne ld81 + +ld8e ldx stream + lda #SC_EOF + jsr STRCMD + cmp #1 +svend rts + +lffdb ;setime + clc + rts + +lffde ;getime + clc + rts + +lffe1 ;getstop + stx dx + ldx #STDIN + lda #SC_STAT + jsr STRCMD + ldx dx + cmp #E_SEMPTY + beq notpressd + jsr lffcc + lda #0 + sec + rts +notpressd lda #1 + clc + rts + + + +lfff0 ;cursor + clc + rts + +lfff3 ;getio + clc + rts + +lff90 ;sta directfl +lffb7 lda status + rts + +lff99 ;bcc set + ldx #RAMEND + rts + +lff9c ;bcc set + ldx #RAMANF + rts + +lffba sta filenr + stx drive ;device + sty mode ;secadr + rts + +lffbd sta fnlen + stx fnadr + sty fnadr+1 + rts + +/* + +lff90 =$ff90 +lff99 =$ff99 +lff9c =$ff9c +lffb7 =$ffb7 +lffba =$ffba +lffbd =$ffbd +lffc0 =$ffc0 +lffc3 =$ffc3 +lffc6 =$ffc6 +lffc9 =$ffc9 +lffcc =$ffcc +lffcf =$ffcf +lffd2 =$ffd2 +lffd5 =$ffd5 +lffd8 =$ffd8 +lffdb =$ffdb +lffde =$ffde +lffe1 =$ffe1 +lffe4 =$ffe4 +lffe7 =$ffe7 +lfff0 =$fff0 +lfff3 =$fff3 + + .word le394,le37b:.byt "CBMBASIC" + +*/ + +romanf =* + +l0003 =$03 ;.w +l0005 =$05 ;.w + +SUCHCHAR =$07 +HKFL =$08 +TABSPAL =$09 +LOADFL =$0a +DIM =$0b +DIMFL =$0c +STRINGFL =$0d +INTFL =$0e +LISTHKFL =$0f +FNFL =$10 +INPUTFL =$11 +ATNSIGN =$12 +ACTIO =$13 + +INT =$14 ;.w + +STRPTR =$16 +STRZEI =$17 ;.w +STRSTCK =$19 ; [0,+8] + +l0022 =$22 +l0023 =$23 +l0024 =$24 +l0025 =$25 + +REG =$26 ; [0,+3] + +BASANF =$2b ;.w +VARANF =$2d ;.w +ARRANF =$2f ;.w +ARREND =$31 ;.w +STRANF =$33 ;.w +l0035 =$35 ;.w +BASEND =$37 ;.w +ZEINR =$39 ;.w +PRVZEINR =$3b ;.w +NEXTSTAT =$3d ;.w +DZEINR =$3f ;.w +NEXTDATA =$41 ;.w +l0043 =$43 ;.w +VARNAME =$45 ;.w +VARADR =$47 ;.w +FORVAR =$49 ;.w +l004b =$4b ;.w + +l004d =$4d +l004e =$4e +l004f =$4f +l0050 =$50 +l0051 =$51 + +l0053 =$53 +l0054 =$54 +l0055 =$55 ;.w + +akku3 =$57 ; [0,+4] +akku4 =akku3+5 ; [0,+4] +FAC =akku4+5 ; [0,+7] +ARG =FAC+8 ; [0,+7] + +l0071 =$71 + +CHRGET =$73 +CHRGOT =$79 +BASZEI =$7a + +l0080 =$80 + +l008b =$8b + +l0100 =$100 ; [-1,+13] +stack =$100 + +#ifdef TESTC64 +l0200 =$200 ; [-5,+88] +#else +l0200 =$340 +#endif + +l0300 =$300 ;.w +l0302 =$302 ;.w +l0304 =$304 ;.w +l0306 =$306 ;.w +l0308 =$308 ;.w +l030a =$30a ;.w + +SYSAC =$030c +SYSXR =$030d +SYSYR =$030e +SYSST =$030f + +lusr =$0310 ; [0,+2] + +lmkdir lda #FS_MKDIR + .byt $2c +lrmdir lda #FS_RMDIR + .byt $2c +lscratch lda #FS_DELETE + .byt $2c +lformat lda #FS_FORMAT + sta loadfl + jsr le1d4 + lda mode + sta PCBUF+FS_CMD_PFAD + lda loadfl + sta mode + jsr copen + bcc cmdok + ldx #24 + jmp la437 +cmdok rts + +lrename jsr le257 ; filenamen holen + ldx #FS_CMD_NAME + ldy fnlen + beq syntaxer + ldy #0 +lr1 lda (fnadr),y + sta PCBUF,x + iny + inx + cpy fnlen + bcc lr1 + lda #0 + sta PCBUF,x + inx + stx loadfl + jsr CHRGOT + cmp #$a4 ; "to"-TokenCode + bne syntaxer + jsr CHRGET + jsr le257 + ldy fnlen + beq syntaxer + ldy #0 + ldx loadfl +lr2 lda (fnadr),y + sta PCBUF,x + inx + iny + cpy fnlen + bcc lr2 + lda #0 + sta PCBUF,x + inx + stx loadfl + jsr le200 + stx PCBUF+FS_CMD_DRV + lda #0 + sta PCBUF+FS_CMD_PFAD + lda #FS_RENAME + ldy loadfl + jmp ropen +syntaxer jmp syntax +illq jmp illquant + +buf =syszp +-syszp +=FS_DIR_NAME + +ldir beq syntaxer + lda #0 + jsr lffbd + jsr lad9e + bit STRINGFL + bpl drnoname + jsr lb6a3 + ldx l0022 + ldy l0022+1 + jsr lffbd + jsr le20e + jsr lad9e +drnoname bit STRINGFL + bmi syntaxer + jsr lb1b8 + ldx FAC+3 + bne illq + ldx FAC+4 + stx drive + lda #FS_OPEN_DR + sta mode + jsr xopen + bcc drnloop + rts + +IN ldx stream + jmp lcc1 + +drnloop jsr lffe1 + beq drend + ldy #0 +drl1 jsr IN + bcs drend + sta buf,y + iny + cpy #FS_DIR_NAME + bcc drl1 + + lda buf+FS_DIR_MODE + cmp #FS_DIR_MOD_NAM + bne drl2 + + lda #dnamtxt + jsr strout + jsr dirname + jmp drle + +drl2 cmp #FS_DIR_MOD_FIL + bne drl3 + jsr dnout + jsr sizdatim + jmp drle + +drl3 cmp #FS_DIR_MOD_FRE + bne drl4 + jsr sizeout + lda #bytfre + jsr strout + jmp drle + +drl4 cmp #FS_DIR_MOD_DIR + bne drle + jsr dnout + lda #ddirtxt + jsr strout + jmp drle + +drle jsr laad7 + jmp drnloop + +drend ldx stream + lda #SC_NUL + jsr STRCMD + clc + rts + +dnout jsr dirname + lda #"," + jsr lffd2 + ldx drive + lda #0 + jsr adrout + jsr DPOUT + jmp SSPOUT + +dirname ldy #0 + lda #34 +drn1 jsr lffd2 + jsr IN + bcs drlne + cmp #0 + beq drlne + iny + bne drn1 +drlne lda #34 +drn2 jsr lffd2 + lda #" " + iny + cpy #23 + bcc drn2 + rts + +sizdatim jsr sizeout + jsr DPOUT + lda PCBUF+FS_DIR_DAY + jsr DEZOUT + jsr PNTOUT + lda PCBUF+FS_DIR_MONTH + jsr DEZOUT + jsr PNTOUT + lda PCBUF+FS_DIR_YEAR + jsr DEZOUT + jsr SSPOUT + lda PCBUF+FS_DIR_HOUR + jsr DEZOUT + jsr DPOUT + lda PCBUF+FS_DIR_MIN + jmp DEZOUT + +DPOUT lda #":" + .byt $2c +SSPOUT lda #" " + .byt $2c +PNTOUT lda #"." + jmp lffd2 + +sizeout lda #buf+FS_DIR_LEN + ldx #" " + jmp ldezout + +ddirtxt .asc ":",0 +dnamtxt .asc "Diskettenname:",0 +bytfre .asc "Bytes free",0 + + + .( +da =syszp +lb =syszp+2 +lo =syszp+3 +w =syszp+4 +out =syszp+8 +cnt =syszp+9 +-syszp +=10 + +&ldezout .( + sta da + sty da+1 + stx lb + ldx #39 + +l1 ldy #3 +l1c lda dtab,x + sta w,y + dex + dey + bpl l1c + stx lo + iny + sty out + sty cnt +l2a ldy #3 +l2 lda (da),y + cmp w,y + bcc sloop + bne shift + dey + bpl l2 + bmi xsub +shift ldy #0 + ldx #4 + clc +h1 lda w,y + rol + sta w,y + iny + dex + bne h1 + bcs ende + inc cnt + bne l2a + +sloop dec cnt + bmi endx + ldy #3 + clc +s0 lda w,y + ror + sta w,y + dey + bpl s0 + +xsub ldy #3 +x0 lda (da),y + cmp w,y + bcc d0 + bne d1 + dey + bpl x0 +d1 ldy #0 + ldx #4 + sec +d1a lda (da),y + sbc w,y + sta (da),y + iny + dex + bne d1a + sec + .byt $24 +d0 clc + rol out + jmp sloop + +endx lda out + beq e3 + ldx #0 + stx lb + beq e1 +e3 bit lo + bmi e1 + lda lb + bne e2 +e1 ora #"0" +e2 jsr lffd2 + + ldx lo + bmi l1b + jmp l1 +l1b ende rts + +dtab .word 1,0 + .word 10,0 + .word 100,0 + .word 1000,0 + .word 10000,0 + .word 34464,1 + .word 16960,15 + .word 38528,152 + .word 57600,1525 + .word 51712,15258 + .) + +&DEZOUT .( +l1 tay + sec + sbc #100 + bcs l1 + lda #0 + sta da + tya +l2 tay + sec + sbc #10 + bcc l3 + inc da + bcs l2 +l3 asl da + asl da + asl da + asl da + tya + ora da +&&HEXOUT + pha + lsr + lsr + lsr + lsr + jsr NIBOUT + pla + and #$0f +NIBOUT clc + adc #"0" + cmp #"9"+1 + bcc nout + adc #6 +nout jmp lffd2 + .) + + .) + + .( +l00fb =syszp +l00fd =syszp+2 +l00c8 =syszp+4 +-syszp +=5 + +&parlist .( + bcc a1 + beq a1 + cmp #$ab + bne delerr1 +a1 jsr la96b + jsr la613 + jsr CHRGOT + beq a2 + cmp #$ab +delerr1 bne delerr + jsr CHRGET + jsr la96b + bne delerr +a2 rts +&delerr jmp syntax + .) + +&ldump .( + bne delerr + lda VARANF + ldy VARANF+1 +du1 cpy ARRANF+1 + bne du2 + cmp ARRANF +du2 bcs duvend + sta INT + sty INT+1 + jsr laad7 ; crlfout + jsr getstop + jsr dumpvar + lda INT + ldy INT+1 + clc + adc #7 + bcc du1 + iny + bne du1 + +dumpvar jsr duname + bcs dustrbin + lda INT + adc #2 + ldy INT+1 + bcc du3 + iny +du3 cpx #128 + bcs dufunk + pha + lda #" " + jsr duglout + pla + jsr lbba2 ; fliesskommavar holen +du4 jsr lbddd ; in ASC + jmp strout ; ausgeben +duvend jmp duarr +dustrbin txa + bpl dustr + lda #"%" ; integervar + jsr duglout + ldy #2 + lda (INT),y + tax + iny + lda (INT),y + tay + txa + jsr lb395 + jmp du4 +dustr lda #"$" ; stringvar + jsr duglout + jsr duhkout + ;lda #4 + ;jsr setfla + ldy #2 + lda (INT),y ; l�nge + beq dustrr + sta l00c8 + iny + lda (INT),y + sta l0022 + iny + lda (INT),y + sta l0022+1 + ldy #0 +dust1 lda (l0022),y + jsr lffd2 + iny + cpy l00c8 + bne dust1 +dustrr +duhkout lda #34 + jmp lffd2 +dufunk ldy #2 ;funktion + lda (INT),y + sta akku4+3 + iny + lda (INT),y + sta akku4+4 + iny + lda (INT),y + sec + sbc #2 + sta l0022 + iny + lda (INT),y + sbc #0 + sta l0022+1 + lda #"(" + jsr lffd2 + ldy #0 ; argument + lda (l0022),y + jsr lffd2 + iny + lda (l0022),y + beq duf1 + jsr lffd2 +duf1 lda #")" + jsr duglout + jsr dumplist + rts +duend jmp laad7 +duarr lda ARRANF ; arrayvariable + ldy ARRANF+1 +dua1 cpy ARREND+1 + bne dua2 + cmp ARREND +dua2 bcs duend + sta INT + sty INT+1 + jsr laad7 + jsr getstop + jsr duname + bcc duafk + txa + bmi duaint + lda #"$" + .byt $2c +duaint lda #"%" + .byt $2c +duafk lda #" " + jsr lffd2 + lda #"(" + jsr lffd2 + ldy #4 + lda (INT),y + sta l00fb ; Anzahl Dimensionen + clc + lda #5 + adc INT + sta l00fd + lda INT+1 + adc #0 + sta l00fd+1 + jmp dua4 +dua3 dec l00fb + beq duaadd + lda #"," + jsr lffd2 +dua4 lda l00fb + asl + tay + dey + lda (l00fd),y + sec + sbc #1 + pha + dey + lda (l00fd),y + sbc #0 + tay + pla + tax + tya + jsr adrout + jmp dua3 +duaadd lda #")" + jsr lffd2 + ldy #2 + lda (INT),y + clc + adc INT + pha + iny + lda (INT),y + adc INT+1 + tay + pla + jmp dua1 + +duname ldy #0 + lda (INT),y + tax + and #127 + jsr lffd2 + iny + lda (INT),y + tay + and #127 + beq dun1 + jsr lffd2 +dun1 tya + asl + rts + +duglout jsr lffd2 + lda #"=" + jmp lffd2 + .) + +&lfind .( + lda BASANF+1 + sta l00fd+1 + lda BASANF + sta l00fd + bne d1 + dec l00fd+1 +d1 dec l00fd + ;jsr d10 +d2 ldy #0 + lda (l00fd),y + bne d5 + iny ; zeilenende + iny + lda (l00fd),y ; hibyte verkettungsadr + beq fiend ; prgende + lda l00fd + sta akku4+3 + lda l00fd+1 + sta akku4+4 + lda l00fd ; 5 f�r anfang text addieren + clc + adc #5 + sta l00fd + bcc d4 + inc l00fd+1 +d4 jsr getstop + jmp d2 +fiend pla + pla + jmp ready +d5 cmp (BASZEI),y ; mit erstem Byte des zu suchenden Textes vergleichen + bne d8 +; lda l00fd +; sta l00fb +; lda l00fd+1 +; sta l00fb+1 +d6 iny + lda (BASZEI),y ; cpy l00c8 + beq d9 ; listen + lda (l00fd),y + beq d7 ; ende der Zeile dann nicht gefunden + cmp (BASZEI),y + beq d6 +d7; lda l00fb +; sta l00fd +; lda l00fb+1 +; sta l00fd+1 +d8 inc l00fd + bne d2 + inc l00fd+1 + bne d2 + +d9 inc akku4+3 + bne d09 + inc akku4+4 +d09 ldy #2 + lda (akku4+3),y + tax + iny + lda (akku4+3),y + jsr listline + jsr laad7 + ldy #<-1 +d13 iny + lda (l00fd),y + bne d13 + tya + clc + adc l00fd + sta l00fd + bcc d14 + inc l00fd+1 +d14 jmp d2 +/* +d10 ldy #<-1 +d11 iny + lda (BASZEI),y + bne d11 + sty l00c8 + rts */ + .) + +&ldelete .( + jsr parlist + lda INT:ora INT+1 + bne a3 + ldy #0 ; hier alles bis ende l�schen + tya + sta (akku4+3),y + iny + sta (akku4+3),y + jmp a9 +a3 lda akku4+3 + ldy akku4+4 + sta l0022 + sty l0022+1 + jsr la613 + bcc a5 + ldy #0 + lda (akku4+3),y + pha + iny + lda (akku4+3),y + sta akku4+4 + pla + sta akku4+3 +a5 lda l0022+1 + cmp akku4+4 + bcc a5a + bne a9 + lda l0022 + cmp akku4+3 + bcs a9 +a5a ldy #0 + ldx #3 +a6 lda (akku4+3),y + sta (l0022),y + cmp #0 + bne a7 + dex + beq a9 + bne a8 +a7 ldx #3 +a8 iny + bne a6 + inc l0022+1 + inc akku4+4 + jmp a6 +&a9 jsr bindbas + lda #2 + clc + adc l0022 + sta VARANF + lda l0022+1 + adc #0 + sta VARANF+1 + jmp la663 + +&&lrenew bne renewerr + ldy #1 + tya + sta (BASANF),y + jsr a9 + jmp ready + .) + +renewerr jmp syntax +&GETINT jsr frmnum + jmp getadr + +paraut .( + lda #0 + sta l00fb+1 + sta l00fd+1 + lda #10 + sta l00fb + lda #100 + sta l00fd + jsr weitzei + cmp #"," + beq paraut1 + jsr CHRGOT + jsr GETINT + sty l00fd + sta l00fd+1 + jsr weitzei + cmp #"," + beq paraut1 + jmp syntax +paraut1 jsr CHRGET + jsr weitzei + cmp #"," + beq paraut2 + jsr GETINT + sty l00fb + sta l00fb+1 +paraut2 rts + .) + + .( +rsyn lda #11 + .byt $2c +rend lda #128 + .byt $2c +rillq lda #14 + .byt $2c +rmemer lda #16 + sta l00c8 + jsr a9 + ldx l00c8 + jmp la437 + +&&lrenumber + jsr paraut + lda l00fb + ora l00fb+1 + bne r00 + jmp illquant +r00 ldy #1 + lda (BASANF),y + beq rend + jsr a9 + jsr CHRGOT + beq r0a + cmp #"," + bne rsyn + jsr CHRGET +r0a jsr parlist + lda INT + ora INT+1 + bne r01 + ldx #<-1 + ldy #<-1 + bne r02 +r01 ldx INT + ldy INT+1 +r02 stx l0022 + sty l0022+1 + jmp r03 +riq1 bcs rillq +r1 stx akku4+3 + sty akku4+4 +r03 ldy #1 + lda (akku4+3),y + beq r4 + ldy #3 + lda (akku4+3),y + cmp l0022+1 + bcc rrr + bne r4 + dey + lda (akku4+3),y + cmp l0022 + bcc rrr + bne r4 +rrr lda STRANF + sec + sbc #4 + sta STRANF + tax + lda STRANF+1 + sbc #0 + sta STRANF+1 + cmp VARANF+1 + bcc rmemer + bne r1a + cpx VARANF + bcc rmemer +r1a ldy #3 ; alte Zeilennummer speichern + lda (akku4+3),y + sta (STRANF),y + dey + lda (akku4+3),y + sta (STRANF),y + dey + lda l00fd+1 ; und neue dazu + sta (STRANF),y + tax + dey + lda l00fd + sta (STRANF),y + ldy #2 + sta (akku4+3),y + iny + txa + sta (akku4+3),y + lda l00fd ; neue Zeilennr erh�hen + clc + adc l00fb + sta l00fd + lda l00fd+1 + adc l00fb+1 + sta l00fd+1 + bcs riq1 + ldy #0 ; n�xte Zeile suchen + lda (akku4+3),y + tax + iny + lda (akku4+3),y + tay + bne r1 +r4 jsr la68e ; start Zeilennr im Text �ndern +r5 ldy #0 + lda (BASZEI),y + bne r6 + iny + lda (BASZEI),y + bne r7 + iny + lda (BASZEI),y + bne r7 + jmp rend +r7 lda BASZEI + clc + adc #5 + sta BASZEI + bcc r5 + inc BASZEI+1 + bne r5 +r6 cmp #$a7 + beq rthen +r8 cmp #$89 ; goto-Code + beq rgot + cmp #$8d ; gosub-Code + beq rgot + cmp #$cb ; go-Code + beq rgo + cmp #34 ; Hochkomma + beq rhoko +r9 inc BASZEI + bne r5 + inc BASZEI+1 + bne r5 +rhoko ldy #1 ; Text in Hochkomma �berspringen +rho1 lda (BASZEI),y + beq rho3 + cmp #34 ; Ende mit Hochkomma + beq rho2 + iny + bne rho1 +rho2 iny +rho3 tya + clc + adc BASZEI + sta BASZEI + bcc r5 + inc BASZEI+1 + bne r5 +rthen jsr CHRGET + beq r9 + bcs r8 + bcc r10 +rgo jsr CHRGET + cmp #$a4 ; to-Code + bne r5 +rgot jsr CHRGET + bcs r5 +r10 lda BASZEI + sta l00fd + lda BASZEI+1 + sta l00fd+1 + jsr GETINT + sec + lda BASZEI + sbc l00fd + sta akku3 + + ; neue Zeilennr finden + + lda STRANF + sta l0035 + lda STRANF+1 + sta l0035+1 +r11 ldy #3 + lda (l0035),y + cmp INT+1 + bne r12 + dey + lda (l0035),y + cmp INT + beq r13 +r12 lda #4 + clc + adc l0035 + sta l0035 + tax + bcc r12a + inc l0035+1 +r12a lda l0035+1 + cmp BASEND+1 + bcc r11 + bne r11a + cpx BASEND + bcc r11 +r11a lda INT+1 + ldx INT + jmp r14 +r13 dey ; ZNr in Tabelle gefunden + lda (l0035),y + pha + dey + lda (l0035),y + tax + pla +r14 jsr rfacasc ; und nach ASC wandeln + ldy #<-1 +r15 iny + lda stack,y + bne r15 + lda l00fd + sta akku4+3 + lda l00fd+1 + sta akku4+4 + tya + sec + sbc akku3 + sta akku3 + beq r16 ; Zahlen im Text gleich lang + bcc r17 ; neue < alte -> kleinere Adresse + lda VARANF + sta akku3+3 + clc + adc akku3 + sta akku3+1 + sta VARANF + lda VARANF+1 + sta akku3+4 + adc #0 + sta akku3+2 + sta VARANF+1 + + cmp STRANF+1 + bcc r18 + beq r18a +r18b jmp rmemer +r18a lda VARANF + cmp STRANF + bcs r18b +r18 jsr la3bf + jmp r16 + +r17 lda BASZEI ; neue Zahl kleiner als alte + sta akku4+3 + clc + adc akku3 + sta l00fb + lda BASZEI+1 + sta akku4+4 + sbc #0 + sta l00fb+1 +r20 ldy #0 + lda (akku4+3),y + sta (l00fb),y + inc l00fb + bne r20a + inc l00fb+1 +r20a inc akku4+3 + bne r20b + inc akku4+4 +r20b lda akku4+3 + cmp VARANF + bne r20 + lda akku4+4 + cmp VARANF+1 + bne r20 +r16 lda l00fd ; ZNr gleich lang + sta BASZEI + lda l00fd+1 + sta BASZEI+1 + ldy #0 +r21 lda stack,y + beq r22 + sta (BASZEI),y + iny + bne r21 +r22 tya + clc + adc BASZEI + sta BASZEI + bcc r23 + inc BASZEI+1 +r23 jsr CHRGOT + cmp #"," ; test auf on x goto/gosub + bne r24 + jsr CHRGET + bcs r24 + jmp r10 +r24 jmp r5 + +rfacasc sta FAC+1 + stx FAC+2 + ldx #$90 + sec + jsr lbc49 + jmp lbddf + .) + .) + +quit .( + jsr lffe7 ; clall + jsr cldup + jmp TERM + .) + + .( +&lomem .( + jsr GETINT + lda INT+1 + cmp #>RAMEND + bne lmh + lda INT + cmp #"+$80 + .asc "="+$80 + .asc "<"+$80 + .asc "SG","N"+$80 + .asc "IN","T"+$80 + .asc "AB","S"+$80 + .asc "US","R"+$80 + .asc "FR","E"+$80 + .asc "PO","S"+$80 + .asc "SQ","R"+$80 + .asc "RN","D"+$80 + .asc "LO","G"+$80 + .asc "EX","P"+$80 + .asc "CO","S"+$80 + .asc "SI","N"+$80 + .asc "TA","N"+$80 + .asc "AT","N"+$80 + .asc "PEE","K"+$80 + .asc "LE","N"+$80 + .asc "STR","$"+$80 + .asc "VA","L"+$80 + .asc "AS","C"+$80 + .asc "CHR","$"+$80 + .asc "LEFT","$"+$80 + .asc "RIGHT","$"+$80 + .asc "MID","$"+$80 + .asc "G","O"+$80,0 + +la09enew .asc "DI","R"+$80 + .asc "MKDI","R"+$80 + .asc "RMDI","R"+$80 + .asc "SCRATC","H"+$80 + .asc "RENAM","E"+$80 + .asc "HEADE","R"+$80 + + .asc "DELET","E"+$80 + .asc "RENUMBE","R"+$80 + .asc "RENE","W"+$80 + .asc "DUM","P"+$80 + .asc "FIN","D"+$80 + + .asc "HIME","M"+$80 + .asc "LOME","M"+$80 + .asc "QUI","T"+$80 + .asc "ENTE","R"+$80 + .asc "CAL","L"+$80 + .asc "SPU","T"+$80 + .asc "SGE","T"+$80 + .byt 0 + +le1 .asc "TOO MANY FILE","S"+$80 +le2 .asc "FILE OPE","N"+$80 +le3 .asc "FILE NOT OPE","N"+$80 +le4 .asc "FILE NOT FOUN","D"+$80 +le5 .asc "DEVICE NOT PRESEN","T"+$80 +le6 .asc "NOT INPUT FIL","E"+$80 +le7 .asc "NOT OUTPUT FIL","E"+$80 +le8 .asc "MISSING FILE NAM","E"+$80 +le9 .asc "ILLEGAL DEVICE NUMBE","R"+$80 +le10 .asc "NEXT WITHOUT FO","R"+$80 +le11 .asc "SYNTA","X"+$80 +le12 .asc "RETURN WITHOUT GOSU","B"+$80 +le13 .asc "OUT OF DAT","A"+$80 +le14 .asc "ILLEGAL QUANTIT","Y"+$80 +le15 .asc "OVERFLO","W"+$80 +le16 .asc "OUT OF MEMOR","Y"+$80 +le17 .asc "UNDEF'D STATEMEN","T"+$80 +le18 .asc "BAD SUBSCRIP","T"+$80 +le19 .asc "REDIM'D ARRA","Y"+$80 +le20 .asc "DIVISION BY ZER","O"+$80 +le21 .asc "ILLEGAL DIREC","T"+$80 +le22 .asc "TYPE MISMATC","H"+$80 +le23 .asc "STRING TOO LON","G"+$80 +le24 .asc "FILE DAT","A"+$80 +le25 .asc "FORMULA TOO COMPLE","X"+$80 +le26 .asc "CAN'T CONTINU","E"+$80 +le27 .asc "UNDEF'D FUNCTIO","N"+$80 +le28 .asc "VERIF","Y"+$80 +le29 .asc "LOA","D"+$80 + +la328 .word le1,le2,le3,le4,le5,le6,le7,le8,le9 + .word le10,le11,le12,le13,le14,le15,le16 + .word le17,le18,le19,le20,le21,le22 + .word le23,le24,le25,le26,le27,le28,le29 + .word lbreak + +la364 .byt 13,10,"OK",13,10,0 +lerror .byt " ERROR",0 +la371 .byt " IN ",0 +lready .byt 13,10,"READY.",13,10,0 +la381 .byt 13,10 +lbreak .byt "BREAK",0 + +la38a tsx + 104 inx :inx :inx :inx :la38f lda stack+1,x + 105 cmp #$81:bne la3b7:lda FORVAR+1:bne la3a4:lda stack+2,x + 106 sta FORVAR:lda stack+3,x:sta FORVAR+1:la3a4 cmp stack+3,x:bne la3b0 + 107 lda FORVAR:cmp stack+2,x:beq la3b7:la3b0 txa :clc + 108 adc #$12:tax :bne la38f:la3b7 rts :la3b8 jsr la408 + 109 sta ARREND:sty ARREND+1:la3bf sec :lda akku3+3:sbc akku4+3 + 110 sta l0022:tay :lda akku3+4:sbc akku4+4:tax + 111 inx :tya :beq la3f3:lda akku3+3:sec + 112 sbc l0022:sta akku3+3:bcs la3dc:dec akku3+4:sec + 113 la3dc lda akku3+1:sbc l0022:sta akku3+1:bcs la3ec:dec akku3+2 + 114 bcc la3ec:la3e8 lda (akku3+3),y:sta (akku3+1),y:la3ec dey :bne la3e8 + 115 lda (akku3+3),y:sta (akku3+1),y:la3f3 dec akku3+4:dec akku3+2:dex + 116 bne la3ec:rts :la3fb asl :adc #$3e:bcs la435 + 117 sta l0022:tsx :cpx l0022:bcc la435:rts + 118 la408 cpy STRANF+1:bcc la434:bne la412:cmp STRANF:bcc la434 + 119 la412 pha :ldx #$09:tya :la416 pha :lda akku3,x + 120 dex :bpl la416:jsr lb526:ldx #$f7:la421 pla + 121 sta FAC,x:inx :bmi la421:pla :tay + 122 pla :cpy STRANF+1:bcc la434:bne la435:cmp STRANF + 123 bcs la435:la434 rts :la435 ldx #$10:la437 jmp (l0300):la43a txa + 124 asl :tax :lda la328-2,x:sta l0022:lda la328-1,x + 125 sta l0022+1:jsr lffcc:lda #$00:sta ACTIO:jsr laad7 + 126 jsr lab45:ldy #$00:la456 lda (l0022),y:pha :and #$7f + 127 jsr basout:iny :pla :bpl la456:jsr la67a + 128 lda #lerror:la469 jsr strout:ldy ZEINR+1:iny + 129 beq ready:jsr lbdc2:ready lda #lready:jsr strout + 130 lda #$80:jsr lff90:la480 jmp (l0302) + la483 jsr linein:stx BASZEI + 131 sty BASZEI+1:exestart jsr CHRGET:;la48d: tax :beq la480:ldx #$ff + 132 stx ZEINR+1:bcc la49c:jsr la579:jmp la7e1:la49c jsr la96b + 133 jsr la579:sty DIM:jsr la613:bcc la4ed:ldy #$01 + 134 lda (akku4+3),y:sta l0023:lda VARANF:sta l0022:lda akku4+4 + 135 sta l0025:lda akku4+3:dey :sbc (akku4+3),y:clc + 136 adc VARANF:sta VARANF:sta l0024:lda VARANF+1:adc #$ff + 137 sta VARANF+1:sbc akku4+4:tax :sec :lda akku4+3 + 138 sbc VARANF:tay :bcs la4d7:inx :dec l0025 + 139 la4d7 clc :adc l0022:bcc la4df:dec l0023:clc + 140 la4df lda (l0022),y:sta (l0024),y:iny :bne la4df:inc l0023 + 141 inc l0025:dex :bne la4df:la4ed jsr la659:jsr bindbas + 142 lda l0200:beq la480:clc :lda VARANF:sta akku3+3 + 143 adc DIM:sta akku3+1:ldy VARANF+1:sty akku3+4:bcc la508 + 144 iny :la508 sty akku3+2:jsr la3b8:lda INT:ldy INT+1 + 145 sta l0200-2:sty l0200-1:lda ARREND:ldy ARREND+1:sta VARANF + 146 sty VARANF+1:ldy DIM:dey :la522 lda l0200-4,y:sta (akku4+3),y + 147 dey :bpl la522:;la52a: jsr la659:jsr bindbas:jmp la480 + 148 bindbas + lda BASANF:ldy BASANF+1:sta l0022:sty l0023:clc + 149 la53c ldy #$01:lda (l0022),y:beq la55f:ldy #$04:la544 iny + 150 lda (l0022),y:bne la544:iny :tya :adc l0022 + 151 tax :ldy #$00:sta (l0022),y:lda l0023:adc #$00 + 152 iny :sta (l0022),y:stx l0022:sta l0023:bcc la53c + 153 la55f rts + +linein .( + LDx #0 +MO1 JSR lffcf ; le112 + bcc mo1a +/* pha + lda #"E" + jsr SEROUT + pla + pha + jsr HEXOUT + pla*/ + cmp #E_NOTOPEN + bne MO1 + txa + pha + jsr clin + pla + tax + bcc MO1 + jmp TERM + +mo1a cmp #$1f + bcs MO1A + + CMP #13:BEQ MO2 + + CMP #8:BNE MO1 + cpx #0:beq MO1 + dex + jsr lffd2 + jmp MO1 + +MO1A STA l0200,x + jsr lffd2 + INx:CPx #$59 + BCC MO1 + ldx #$17:jmp la437 +/*MO2S sec:.byt $24*/ +MO2 jmp laaca + .) +/* + linein ldx #$00:la562 jsr le112:jsr lffd2:cmp #$0d:beq la576 + 154 sta l0200,x:inx :cpx #$59:bcc la562:ldx #$17 + 155 jmp la437:la576 ;lda #10:;jsr lffd2:jmp laaca +*/ + la579 jmp (l0304) + la57c +#if l0200 & $00ff + lda BASZEI + sec + sbc #l0200-1:sta BASZEI+1 +#else + dec BASZEI+1 +#endif + lda #la78b:sta l0022:sty l0023 + 211 jmp lae43:la78b lda #lb9bc:jsr lbba2:jsr CHRGOT + 212 cmp #$a9:bne la79f:jsr CHRGET:jsr frmnum:la79f jsr lbc2b + 213 jsr lae38:lda FORVAR+1:pha :lda FORVAR:pha + 214 lda #$81:pha :la7ae jsr getstop:lda BASZEI:ldy BASZEI+1 + 215 cpy #>l0200:beq la7be:sta NEXTSTAT:sty NEXTSTAT+1 + 216 la7be ldy #$00:lda (BASZEI),y:bne la807:ldy #$02:lda (BASZEI),y + 217 clc :bne la7ce:jmp la84b:la7ce iny :lda (BASZEI),y + 218 sta ZEINR:iny :lda (BASZEI),y:sta ZEINR+1:tya + 219 adc BASZEI:sta BASZEI:bcc la7e1:inc BASZEI+1:la7e1 jmp (l0308) + la7e4 jsr CHRGET:la7e7 jsr la7ed:jmp la7ae:la7ed beq la82b:la7ef sbc #$80 + 221 bcc la804 +#ifdef SHOW + pha + jsr xHEXOUT + pla +#endif + cmp #$4c ; ist neuer Befehl + bcc la7f3 ; nein dann normal + sbc #$4c-$23 ; neue adressen direkt hinter alten + jmp la7f7 + la7f3 cmp #$23:bcs la80e ; dann function-code + la7f7 +#ifdef SHOW + pha + jsr xHEXOUT + pla +#endif + asl :tay + 222 lda la00c+1,y:pha :lda la00c,y:pha :jmp CHRGET + 223 la804 jmp la9a5:la807 cmp #$3a:beq la7e1:la80b jmp syntax:la80e cmp #$4b + 224 bne la80b:jsr CHRGET:lda #$a4:jsr laeff:jmp la8a0 + lrestore la81d sec :lda BASANF:sbc #$01:ldy BASANF+1:bcs la827 + 226 dey :la827 sta NEXTDATA:sty NEXTDATA+1:la82b rts :getstop jsr lffe1 + lstop bcs la832: + lend clc :la832 bne la870:lda BASZEI:ldy BASZEI+1 + 228 ldx ZEINR+1:inx :beq la849:sta NEXTSTAT:sty NEXTSTAT+1 + 229 lda ZEINR:ldy ZEINR+1:sta PRVZEINR:sty PRVZEINR+1:la849 pla + 230 pla :la84b lda #la381:bcc la854:jmp la469 + 231 la854 jmp le386 + lcont bne la870:ldx #$1a:ldy NEXTSTAT+1:bne la862 + 232 jmp la437:la862 lda NEXTSTAT:sta BASZEI:sty BASZEI+1:lda PRVZEINR + 233 ldy PRVZEINR+1:sta ZEINR:sty ZEINR+1:la870 rts : + lrun php + 234 lda #$00:jsr lff90:plp :bne la87d:jmp la659 + 235 la87d jsr la660:jmp la897 + lgosub lda #$03:jsr la3fb:lda BASZEI+1 + 236 pha :lda BASZEI:pha :lda ZEINR+1:pha + 237 lda ZEINR:pha :lda #$8d:pha :la897 jsr CHRGOT + 238 jsr la8a0:jmp la7ae + lgoto la8a0 jsr la96b:jsr la909:sec + 239 lda ZEINR:sbc INT:lda ZEINR+1:sbc INT+1:bcs la8bc + 240 tya :sec :adc BASZEI:ldx BASZEI+1:bcc la8c0 + 241 inx :bcs la8c0:la8bc lda BASANF:ldx BASANF+1:la8c0 jsr la617 + 242 bcc la8e3:lda akku4+3:sbc #$01:sta BASZEI:lda akku4+4 + 243 sbc #$00:sta BASZEI+1:la8d1 rts + lreturn bne la8d1:lda #$ff + 244 sta FORVAR+1:jsr la38a:txs :cmp #$8d:beq la8eb + 245 ldx #$0c:.byt $2c :la8e3 ldx #$11:jmp la437:la8e8 jmp syntax + 246 la8eb pla :pla :sta ZEINR:pla :sta ZEINR+1 + 247 pla :sta BASZEI:pla :sta BASZEI+1 + ldata la8f8 jsr la906 + 248 la8fb tya :clc :adc BASZEI:sta BASZEI:bcc la905 + 249 inc BASZEI+1:la905 rts :la906 ldx #$3a:.byt $2c :la909 ldx #$00 + 250 stx SUCHCHAR:ldy #$00:sty HKFL:la911 lda HKFL:ldx SUCHCHAR + 251 sta SUCHCHAR:stx HKFL:la919 lda (BASZEI),y:beq la905:cmp HKFL + 252 beq la905:iny :cmp #$22:bne la919:beq la911 + lif jsr lad9e:jsr CHRGOT:cmp #$89:beq la937:lda #$a7 + 254 jsr laeff:la937 lda FAC:bne la940 + lrem jsr la909:beq la8fb + 255 la940 jsr CHRGOT:bcs la948:jmp la8a0:la948 jmp la7ed + lon jsr getbyt + 256 pha :cmp #$8d:beq la957:la953 cmp #$89:bne la8e8 + 257 la957 dec FAC+4:bne la95f:pla :jmp la7ef:la95f jsr CHRGET + 258 jsr la96b:cmp #$2c:beq la957:pla :la96a rts + 259 la96b ldx #$00:stx INT:stx INT+1:la971 bcs la96a:sbc #$2f + 260 sta SUCHCHAR:lda INT+1:sta l0022:cmp #$19:bcs la953 + 261 lda INT:asl :rol l0022:asl :rol l0022 + 262 adc INT:sta INT:lda l0022:adc INT+1:sta INT+1 + 263 asl INT:rol INT+1:lda INT:adc SUCHCHAR:sta INT + 264 bcc la99f:inc INT+1:la99f jsr CHRGET:jmp la971 + llet la9a5 jsr lb08b:sta FORVAR:sty FORVAR+1:lda #$b2 + 266 jsr laeff:lda INTFL:pha :lda STRINGFL:pha + 267 jsr lad9e:pla :rol :jsr lad90:bne la9d9 + 268 pla :la9c2 bpl la9d6:jsr lbc1b:jsr lb1bf:ldy #$00 + 269 lda FAC+3:sta (FORVAR),y:iny :lda FAC+4:sta (FORVAR),y + 270 rts :la9d6 jmp lbbd0:la9d9 pla :la9da ldy FORVAR+1:cpy #$bf + 271 bne laa2c:jsr lb6a6:cmp #$06:bne laa24:ldy #$00 + 272 sty FAC:sty FAC+5:la9ed sty l0071:jsr laa1d:jsr lbae2 + 273 inc l0071:ldy l0071:jsr laa1d:jsr lbc0c:tax + 274 beq laa07:inx :txa :jsr lbaed:laa07 ldy l0071 + 275 iny :cpy #$06:bne la9ed:jsr lbae2:jsr lbc9b + 276 ldx FAC+3:ldy FAC+2:lda FAC+4:jmp lffdb:laa1d lda (l0022),y + 277 jsr l0080:bcc laa27:laa24 jmp illquant:laa27 sbc #$2f:jmp lbd7e + 278 laa2c ldy #$02:lda (FAC+3),y:cmp STRANF+1:bcc laa4b:bne laa3d + 279 dey :lda (FAC+3),y:cmp STRANF:bcc laa4b:laa3d ldy FAC+4 + 280 cpy VARANF+1:bcc laa4b:bne laa52:lda FAC+3:cmp VARANF + 281 bcs laa52:laa4b lda FAC+3:ldy FAC+4:jmp laa68:laa52 ldy #$00 + 282 lda (FAC+3),y:jsr lb475:lda l0050:ldy l0051:sta ARG+6 + 283 sty ARG+7:jsr lb67a:lda #FAC:laa68 sta l0050 + 284 sty l0051:jsr lb6db:ldy #$00:lda (l0050),y:sta (FORVAR),y + 285 iny :lda (l0050),y:sta (FORVAR),y:iny :lda (l0050),y + 286 sta (FORVAR),y:rts + lprintf jsr laa86:jmp labb5 + lcmd laa86 jsr getbyt + 287 beq laa90:lda #$2c:jsr laeff:laa90 php :stx ACTIO + 288 jsr le118:plp :jmp laaa0:laa9a jsr lab21:laa9d jsr CHRGOT + lprint laaa0 beq laad7:laaa2 beq laae7:cmp #$a3:beq laaf8:cmp #$a6 + 290 clc :beq laaf8:cmp #$2c:beq laae8:cmp #$3b + 291 beq lab13:jsr lad9e:bit STRINGFL:bmi laa9a:jsr lbddd + 292 jsr lb487:jsr lab21:jsr lab3b:bne laa9d:laaca lda #$00 + 293 sta l0200,x:ldx #l0200-1:lda ACTIO:bne laae7 + 294 laad7 lda #$0d:jsr basout:;bit ACTIO:;bpl laae5:lda #$0a + 295 jsr basout:laae5 eor #$ff:laae7 rts :laae8 sec :jsr lfff0 + 296 tya :sec :laaee sbc #$0a:bcs laaee:eor #$ff + 297 adc #$01:bne lab0e:laaf8 php :sec :jsr lfff0 + 298 sty TABSPAL:jsr lb79b:cmp #$29:bne lab5f:plp + 299 bcc lab0f:txa :sbc TABSPAL:bcc lab13:lab0e tax + 300 lab0f inx :lab10 dex :bne lab19:lab13 jsr CHRGET:jmp laaa2 + 301 lab19 jsr lab3b:bne lab10:strout jsr lb487:lab21 jsr lb6a6:tax + 302 ldy #$00:inx :lab28 dex :beq laae7:lda (l0022),y + 303 jsr basout:iny :cmp #$0d:bne lab28:jsr laae5 + 304 jmp lab28:lab3b lda ACTIO:beq lab42:lda #$20:.byt $2c + 305 lab42 lda #$1d:.byt $2c :lab45 lda #$3f:basout jsr le10c:and #$ff + 306 rts :lab4d lda INPUTFL:beq lab62:bmi lab57:ldy #$ff + 307 bne lab5b:lab57 lda DZEINR:ldy DZEINR+1:lab5b sta ZEINR:sty ZEINR+1 + 308 lab5f jmp syntax:lab62 lda ACTIO:beq lab6b:ldx #$18:jmp la437 + 309 lab6b lda #lad0c:jsr strout:lda NEXTSTAT:ldy NEXTSTAT+1 + 310 sta BASZEI:sty BASZEI+1:rts + lget jsr lb3a6:cmp #$23 + 311 bne lab92:jsr CHRGET:jsr getbyt:lda #$2c:jsr laeff + 312 stx ACTIO:jsr le11e:lab92 ldx #l0200+1:lda #$00 + 313 sta l0200+1:lda #$40:jsr lac0f:ldx ACTIO:bne labb7 + 314 rts + linputf jsr getbyt:lda #$2c:jsr laeff:stx ACTIO + 315 jsr le11e:jsr labce:labb5 lda ACTIO:labb7 jsr lffcc:ldx #$00 + 316 stx ACTIO:rts + linput cmp #$22:bne labce:jsr laebd + 317 lda #$3b:jsr laeff:jsr lab21:labce jsr lb3a6:lda #$2c + 318 sta l0200-1:labd6 jsr labf9:lda ACTIO:beq labea:jsr lffb7 + 319 and #$02:beq labea:jsr labb5:jmp la8f8:labea lda l0200 + 320 bne lac0d:lda ACTIO:bne labd6:jsr la906:jmp la8fb + 321 labf9 lda ACTIO:bne lac03:jsr lab45:jsr lab3b:lac03 jmp linein + lread ldx NEXTDATA:ldy NEXTDATA+1:lda #$98:.byt $2c :lac0d lda #$00 + 323 lac0f sta INPUTFL:stx l0043:sty l0043+1:lac15 jsr lb08b:sta FORVAR + 324 sty FORVAR+1:lda BASZEI:ldy BASZEI+1:sta l004b:sty l004b+1 + 325 ldx l0043:ldy l0043+1:stx BASZEI:sty BASZEI+1:jsr CHRGOT + 326 bne lac51:bit INPUTFL:bvc lac41:jsr le124:sta l0200 + 327 ldx #l0200-1:bne lac4d:lac41 bmi lacb8:lda ACTIO + 328 bne lac4a:jsr lab45:lac4a jsr labf9:lac4d stx BASZEI:sty BASZEI+1 + 329 lac51 jsr CHRGET:bit STRINGFL:bpl lac89:bit INPUTFL:bvc lac65 + 330 inx :stx BASZEI:lda #$00:sta SUCHCHAR:beq lac71 + 331 lac65 sta SUCHCHAR:cmp #$22:beq lac72:lda #$3a:sta SUCHCHAR + 332 lda #$2c:lac71 clc :lac72 sta HKFL:lda BASZEI:ldy BASZEI+1 + 333 adc #$00:bcc lac7d:iny :lac7d jsr lb48d:jsr lb7e2 + 334 jsr la9da:jmp lac91:lac89 jsr lbcf3:lda INTFL:jsr la9c2 + 335 lac91 jsr CHRGOT:beq lac9d:cmp #$2c:beq lac9d:jmp lab4d + 336 lac9d lda BASZEI:ldy BASZEI+1:sta l0043:sty l0043+1:lda l004b + 337 ldy l004b+1:sta BASZEI:sty BASZEI+1:jsr CHRGOT:beq lacdf + 338 jsr prkomma:jmp lac15:lacb8 jsr la906:iny :tax + 339 bne lacd1:ldx #$0d:iny :lda (BASZEI),y:beq lad32 + 340 iny :lda (BASZEI),y:sta DZEINR:iny :lda (BASZEI),y + 341 iny :sta DZEINR+1:lacd1 jsr la8fb:jsr CHRGOT:tax + 342 cpx #$83:bne lacb8:jmp lac51:lacdf lda l0043:ldy l0043+1 + 343 ldx INPUTFL:bpl lacea:jmp la827:lacea ldy #$00:lda (l0043),y + 344 beq lacfb:lda ACTIO:bne lacfb:lda #lacfc + 345 jmp strout:lacfb rts + lacfc .asc "?EXTRA IGNORED",13,0 + lad0c .asc "?REDO FROM START",13,0 + lnext bne lad24:ldy #$00:beq lad27:lad24 jsr lb08b + 350 lad27 sta FORVAR:sty FORVAR+1:jsr la38a:beq lad35:ldx #$0a + 351 lad32 jmp la437:lad35 txs :txa :clc :adc #$04 + 352 pha :adc #$06:sta l0024:pla :ldy #$01 + 353 jsr lbba2:tsx :lda stack+9,x:sta FAC+5:lda FORVAR + 354 ldy FORVAR+1:jsr lb867:jsr lbbd0:ldy #$01:jsr lbc5d + 355 tsx :sec :sbc stack+9,x:beq lad78:lda stack+$f,x + 356 sta ZEINR:lda stack+$10,x:sta ZEINR+1:lda stack+$12,x:sta BASZEI + 357 lda stack+$11,x:sta BASZEI+1:lad75 jmp la7ae:lad78 txa :adc #$11 + 358 tax :txs :jsr CHRGOT:cmp #$2c:bne lad75 + 359 jsr CHRGET:jsr lad24 + frmnum jsr lad9e:lad8d clc :.byt $24 + 360 lad8f sec :lad90 bit STRINGFL:bmi lad97:bcs lad99:lad96 rts + 361 lad97 bcs lad96:lad99 ldx #$16:jmp la437 + lad9e + ldx BASZEI:bne lada4 + 362 dec BASZEI+1:lada4 dec BASZEI + ldx #$00:.byt $24 :lada9 pha + 363 txa :pha :lda #$01:jsr la3fb:jsr lae83 + 364 lda #$00:sta l004d:ladb8 jsr CHRGOT:ladbb sec :sbc #$b1 + 365 bcc ladd7:cmp #$03:bcs ladd7:cmp #$01:rol + 366 eor #$01:eor l004d:cmp l004d:bcc lae30:sta l004d + 367 jsr CHRGET:jmp ladbb + ladd7 + ldx l004d:bne lae07:bcs lae58x + 368 adc #$07:bcc lae58x:adc STRINGFL:bne lade8:jmp lb63d + 369 lade8 adc #$ff:sta l0022:asl :adc l0022:tay + 370 ladf0 pla :cmp la080,y:bcs lae5d:jsr lad8d:ladf9 pha + 371 ladfa jsr lae20:pla :ldy l004b:bpl lae19:tax + 372 beq lae5b:bne lae66:lae07 lsr STRINGFL:txa :rol + 373 ldx BASZEI:bne lae11:dec BASZEI+1:lae11 dec BASZEI:ldy #$1b + 374 sta l004d:bne ladf0:lae19 cmp la080,y:bcs lae66:bcc ladf9 + 375 lae20 lda la080+2,y:pha :lda la080+1,y:pha : + + jsr lae33 + lda l004d:jmp lada9 + lae30 jmp syntax + + lae58x jmp lae58 + + lae33 lda FAC+5:ldx la080,y + + lae38 tay :pla :sta l0022:pla:sta l0022+1 + inc l0022:bne laexx:inc l0022+1:laexx + + 378 tya :pha :lae43 jsr lbc1b:lda FAC+4 + 379 pha :lda FAC+3:pha :lda FAC+2:pha + 380 lda FAC+1:pha :lda FAC:pha :jmp (l0022) + 381 lae58 ldy #$ff:pla :lae5b beq lae80:lae5d cmp #$64:beq lae64 + 382 jsr lad8d:lae64 sty l004b:lae66 pla :lsr :sta ATNSIGN + 383 pla :sta ARG:pla :sta ARG+1:pla + 384 sta ARG+2:pla :sta ARG+3:pla :sta ARG+4 + 385 pla :sta ARG+5:eor FAC+5:sta ARG+6:lae80 lda FAC + 386 rts + + laea8 .byt $82,$49,$0f,$da,$a1 + + lae83 jmp (l030a) + lae86 lda #$00:sta STRINGFL:lae8a jsr CHRGET + bcs lae92:lae8f jmp lbcf3 + lae92 ;hier neue Functionen einbinden + jsr lb113:bcc lae9a + jmp laf28 + lae9a cmp #"$":beq dezhex + cmp #"%":beq decbin + cmp #"&":beq decoktx + cmp #$ff:bne laead:lda #laea8:jsr lbba2 + jmp CHRGET + + 390 laead cmp #$2e:beq lae8f:cmp #$ab:beq laf0dx:cmp #$aa + 391 beq lae8a:cmp #$22:bne laeccx:laebd lda BASZEI:ldy BASZEI+1 + 392 adc #$00:bcc laec6:iny :laec6 jsr lb487:jmp lb7e2 + + laf0dx jmp laf0d + laeccx jmp laecc + decoktx jmp decokt + + decbin lda #0:sta FAC+1:sta FAC+2 + ldy #1 + deb1 lda (BASZEI),y:jsr decbit:bcs hexend + lsr:rol FAC+2:rol FAC+1:bcs overfl + iny:bpl deb1:bmi hexend + + decbit sec:sbc #"0":cmp #2:rts + + dezhex ldy #1:lda #0 + sta FAC+2:sta FAC+1 + hex1 lda (BASZEI),y + jsr deznib:bcs hexend + asl FAC+2:rol FAC+1:bcs overfl + asl FAC+2:rol FAC+1:bcs overfl + asl FAC+2:rol FAC+1:bcs overfl + asl FAC+2:rol FAC+1:bcs overfl + clc + adc FAC+2 + sta FAC+2 + iny + bpl hex1 + hexend tya + clc + adc BASZEI + sta BASZEI + bcc dec2 + inc BASZEI+1 + dec2 ldx #$90:sec:jmp lbc49 + + deznib sec:sbc #"0":cmp #10:bcc dec1 + cmp #"A"-"0":bcc nend + sec:sbc #7:dec1 cmp #16:bcc nenc + eor #%00100000:cmp #16:rts + nend sec:nenc rts + + overfl jmp illquant + + decokt ldy #1:lda #0 + sta FAC+2:sta FAC+1 + okt1 lda (BASZEI),y + jsr oktnib:bcs hexend + asl FAC+2:rol FAC+1:bcs overfl + asl FAC+2:rol FAC+1:bcs overfl + asl FAC+2:rol FAC+1:bcs overfl + clc + adc FAC+2 + sta FAC+2 + iny + bpl okt1 + tya + clc + adc BASZEI + sta BASZEI + bcc okt2 + inc BASZEI+1 + okt2 ldx #$90:sec:jmp lbc49 + + oktnib sec:sbc #"0":cmp #8:rts + + 393 laecc cmp #$a8:bne laee3:ldy #$18:bne laf0f + lnot jsr lb1bf + 394 lda FAC+4:eor #$ff:tay :lda FAC+3:eor #$ff + 395 jmp lb391:laee3 cmp #$a5:bne laeea:jmp lb3f4:laeea cmp #$b4 + 396 bcc laef1:jmp lafa7:laef1 jsr laefa:jsr lad9e:laef7 lda #$29 + 397 .byt $2c :laefa lda #$28:.byt $2c :prkomma lda #$2c:laeff ldy #$00 + 398 cmp (BASZEI),y:bne syntax:jmp CHRGET:syntax ldx #$0b:jmp la437 + 399 laf0d ldy #$15:laf0f pla :pla :jmp ladfa:laf14 sec + 400 lda FAC+3:sbc #romanf:bcc laf27 + 401 lda #romend:sbc FAC+4:laf27 rts + 402 laf28 jsr lb08b:sta FAC+3:sty FAC+4:ldx VARNAME:ldy VARNAME+1 + 403 lda STRINGFL:beq laf5d:lda #$00:sta ARG+7:jsr laf14 + 404 bcc laf5c:cpx #$54:bne laf5c:cpy #$c9:bne laf5c + 405 jsr laf84:sty akku4+2:dey :sty l0071:ldy #$06 + 406 sty akku4+1:ldy #$24:jsr lbe68:jmp lb46f:laf5c rts + 407 laf5d bit INTFL:bpl laf6e:ldy #$00:lda (FAC+3),y:tax + 408 iny :lda (FAC+3),y:tay :txa :jmp lb391 + 409 laf6e jsr laf14:bcc lafa0:cpx #$54:bne laf92:cpy #$49 + 410 bne lafa0:jsr laf84:tya :ldx #$a0:jmp lbc4f + 411 laf84 jsr lffde:stx FAC+3:sty FAC+2:sta FAC+4:ldy #$00 + 412 sty FAC+1:rts :laf92 cpx #$53:bne lafa0:cpy #$54 + 413 bne lafa0:jsr lffb7:jmp lbc3c:lafa0 lda FAC+3:ldy FAC+4 + 414 jmp lbba2:lafa7 asl :pha :tax :jsr CHRGET + 415 cpx #$8f:bcc lafd1:jsr laefa:jsr lad9e:jsr prkomma + 416 jsr lad8f:pla :tax :lda FAC+4:pha + 417 lda FAC+3:pha :txa :pha :jsr getbyt + 418 pla :tay :txa :pha :jmp lafd6 + 419 lafd1 jsr laef1:pla :tay :lafd6 lda la052-$68,y:sta l0055 + 420 lda la052-$67,y:sta l0055+1:jsr l0054:jmp lad8d + lor ldy #$ff:.byt $2c + land ldy #0:sty DIM:jsr lb1bf:lda FAC+3:eor DIM + 422 sta SUCHCHAR:lda FAC+4:eor DIM:sta HKFL:jsr lbbfc + 423 jsr lb1bf:lda FAC+4:eor DIM:and HKFL:eor DIM + 424 tay :lda FAC+3:eor DIM:and SUCHCHAR:eor DIM + 425 jmp lb391 + lcmp jsr lad90:bcs lb02e:lda ARG+5:ora #$7f + 426 and ARG+1:sta ARG+1:lda #ARG:jsr lbc5b + 427 tax :jmp lb061:lb02e lda #$00:sta STRINGFL:dec l004d + 428 jsr lb6a6:sta FAC:stx FAC+1:sty FAC+2:lda ARG+3 + 429 ldy ARG+4:jsr lb6aa:stx ARG+3:sty ARG+4:tax + 430 sec :sbc FAC:beq lb056:lda #$01:bcc lb056 + 431 ldx FAC:lda #$ff:lb056 sta FAC+5:ldy #$ff:inx + 432 lb05b iny :dex :bne lb066:ldx FAC+5:lb061 bmi lb072 + 433 clc :bcc lb072:lb066 lda (ARG+3),y:cmp (FAC+1),y:beq lb05b + 434 ldx #$ff:bcs lb072:ldx #$01:lb072 inx :txa + 435 rol :and ATNSIGN:beq lb07b:lda #$ff:lb07b jmp lbc3c + 436 lb07e jsr prkomma + ldim tax :jsr lb090:jsr CHRGOT:bne lb07e + 437 rts :lb08b ldx #$00:jsr CHRGOT:lb090 stx DIMFL:lb092 sta VARNAME + 438 jsr CHRGOT:jsr lb113:bcs lb09f:lb09c jmp syntax:lb09f ldx #$00 + 439 stx STRINGFL:stx INTFL:jsr CHRGET:bcc lb0af:jsr lb113 + 440 bcc lb0ba:lb0af tax :lb0b0 jsr CHRGET:bcc lb0b0:jsr lb113 + 441 bcs lb0b0:lb0ba cmp #$24:bne lb0c4:lda #$ff:sta STRINGFL + 442 bne lb0d4:lb0c4 cmp #$25:bne lb0db:lda FNFL:bne lb09c + 443 lda #$80:sta INTFL:ora VARNAME:sta VARNAME:lb0d4 txa + 444 ora #$80:tax :jsr CHRGET:lb0db stx VARNAME+1:sec + 445 ora FNFL:sbc #$28:bne lb0e7:jmp lb1d1:lb0e7 ldy #$00 + 446 sty FNFL:lda VARANF:ldx VARANF+1:lb0ef stx akku4+4:lb0f1 sta akku4+3 + 447 cpx ARRANF+1:bne lb0fb:cmp ARRANF:beq lb11d:lb0fb lda VARNAME + 448 cmp (akku4+3),y:bne lb109:lda VARNAME+1:iny :cmp (akku4+3),y + 449 beq lb185a:dey :lb109 clc :lda akku4+3:adc #$07 + 450 bcc lb0f1:inx :bne lb0ef + + lb113 cmp #"A":bcc lb11c:cmp #"Z"+1:bcc lb1cs + cmp #"a":bcc lb11c:cmp #"z"+1:bcc lb1cs:lb11c clc:rts + lb1cs sec: rts:lb185a beq lb185 + + lb11d pla + 452 pha :cmp #lbf13 + 453 rts :lb128 lda VARNAME:ldy VARNAME+1:cmp #$54:bne lb13b + 454 cpy #$c9:beq lb123:cpy #$49:bne lb13b:lb138 jmp syntax + 455 lb13b cmp #$53:bne lb143:cpy #$54:beq lb138:lb143 lda ARRANF + 456 ldy ARRANF+1:sta akku4+3:sty akku4+4:lda ARREND:ldy ARREND+1 + 457 sta akku3+3:sty akku3+4:clc :adc #$07:bcc lb159 + 458 iny :lb159 sta akku3+1:sty akku3+2:jsr la3b8:lda akku3+1 + 459 ldy akku3+2:iny :sta ARRANF:sty ARRANF+1:ldy #$00 + 460 lda VARNAME:sta (akku4+3),y:iny :lda VARNAME+1:sta (akku4+3),y + 461 lda #$00:iny :sta (akku4+3),y:iny :sta (akku4+3),y + 462 iny :sta (akku4+3),y:iny :sta (akku4+3),y:iny + 463 sta (akku4+3),y:lb185 lda akku4+3:clc :adc #$02:ldy akku4+4 + 464 bcc lb18f:iny :lb18f sta VARADR:sty VARADR+1:rts + 465 lb194 lda DIM:asl :adc #$05:adc akku4+3:ldy akku4+4 + 466 bcc lb1a0:iny :lb1a0 sta akku3+1:sty akku3+2:rts + lb1a5 .byt $90,$80,$00,$00,$00 + lb1aa jsr lb1bf + 468 lda FAC+3:ldy FAC+4:rts :lb1b2 jsr CHRGET:jsr lad9e + 469 lb1b8 jsr lad8d:lda FAC+5:bmi lb1cc:lb1bf lda FAC:cmp #$90 + 470 bcc lb1ce:lda #lb1a5:jsr lbc5b:lb1cc bne illquant + 471 lb1ce jmp lbc9b:lb1d1 lda DIMFL:ora INTFL:pha :lda STRINGFL + 472 pha :ldy #$00:lb1db tya :pha :lda VARNAME+1 + 473 pha :lda VARNAME:pha :jsr lb1b2:pla + 474 sta VARNAME:pla :sta VARNAME+1:pla :tay + 475 tsx :lda stack+2,x:pha :lda stack+1,x:pha + 476 lda FAC+3:sta stack+2,x:lda FAC+4:sta stack+1,x:iny + 477 jsr CHRGOT:cmp #$2c:beq lb1db:sty DIM:jsr laef7 + 478 pla :sta STRINGFL:pla :sta INTFL:and #$7f + 479 sta DIMFL:ldx ARRANF:lda ARRANF+1:lb21c stx akku4+3:sta akku4+4 + 480 cmp ARREND+1:bne lb228:cpx ARREND:beq lb261:lb228 ldy #$00 + 481 lda (akku4+3),y:iny :cmp VARNAME:bne lb237:lda VARNAME+1 + 482 cmp (akku4+3),y:beq lb24d:lb237 iny :lda (akku4+3),y:clc + 483 adc akku4+3:tax :iny :lda (akku4+3),y:adc akku4+4 + 484 bcc lb21c:lb245 ldx #$12:.byt $2c :illquant ldx #$0e:lb24a jmp la437 + 485 lb24d ldx #$13:lda DIMFL:bne lb24a:jsr lb194:lda DIM + 486 ldy #$04:cmp (akku4+3),y:bne lb245:jmp lb2ea:lb261 jsr lb194 + 487 jsr la408:ldy #$00:sty l0071+1:ldx #$05:lda VARNAME + 488 sta (akku4+3),y:bpl lb274:dex :lb274 iny :lda VARNAME+1 + 489 sta (akku4+3),y:bpl lb27d:dex :dex :lb27d stx l0071 + 490 lda DIM:iny :iny :iny :sta (akku4+3),y + 491 lb286 ldx #$0b:lda #$00:bit DIMFL:bvc lb296:pla + 492 clc :adc #$01:tax :pla :adc #$00 + 493 lb296 iny :sta (akku4+3),y:iny :txa :sta (akku4+3),y + 494 jsr lb34c:stx l0071:sta l0071+1:ldy l0022:dec DIM + 495 bne lb286:adc akku3+2:bcs lb30b:sta akku3+2:tay + 496 txa :adc akku3+1:bcc lb2b9:iny :beq lb30b + 497 lb2b9 jsr la408:sta ARREND:sty ARREND+1:lda #$00:inc l0071+1 + 498 ldy l0071:beq lb2cd:lb2c8 dey :sta (akku3+1),y:bne lb2c8 + 499 lb2cd dec akku3+2:dec l0071+1:bne lb2c8:inc akku3+2:sec + 500 lda ARREND:sbc akku4+3:ldy #$02:sta (akku4+3),y:lda ARREND+1 + 501 iny :sbc akku4+4:sta (akku4+3),y:lda DIMFL:bne lb34b + 502 iny :lb2ea lda (akku4+3),y:sta DIM:lda #$00:sta l0071 + 503 lb2f2 sta l0071+1:iny :pla :tax :sta FAC+3 + 504 pla :sta FAC+4:cmp (akku4+3),y:bcc lb30e:bne lb308 + 505 iny :txa :cmp (akku4+3),y:bcc lb30f:lb308 jmp lb245 + 506 lb30b jmp la435:lb30e iny :lb30f lda l0071+1:ora l0071:clc + 507 beq lb320:jsr lb34c:txa :adc FAC+3:tax + 508 tya :ldy l0022:lb320 adc FAC+4:stx l0071:dec DIM + 509 bne lb2f2:sta l0071+1:ldx #$05:lda VARNAME:bpl lb331 + 510 dex :lb331 lda VARNAME+1:bpl lb337:dex :dex + 511 lb337 stx REG+2:lda #$00:jsr lb355:txa :adc akku3+1 + 512 sta VARADR:tya :adc akku3+2:sta VARADR+1:tay + 513 lda VARADR:lb34b rts :lb34c sty l0022:lda (akku4+3),y:sta REG+2 + 514 dey :lda (akku4+3),y:lb355 sta REG+3:lda #$10:sta akku4+1 + 515 ldx #$00:ldy #$00:lb35f txa :asl :tax + 516 tya :rol :tay :bcs lb30b:asl l0071 + 517 rol l0071+1:bcc lb378:clc :txa :adc REG+2 + 518 tax :tya :adc REG+3:tay :bcs lb30b + 519 lb378 dec akku4+1:bne lb35f:rts + lfre lda STRINGFL:beq lb384 + 520 jsr lb6a6:lb384 jsr lb526:sec :lda STRANF:sbc ARREND + 521 tay :lda STRANF+1:sbc ARREND+1:lb391 ldx #$00:stx STRINGFL + lb395 sta FAC+1:sty FAC+2:ldx #$90:jmp lbc44 + lpos sec + 523 jsr lfff0:lb3a2 lda #$00:beq lb391 + lb3a6 ldx ZEINR+1:inx + 524 bne lb34b:ldx #$15:.byt $2c :lb3ae ldx #$1b:jmp la437 + ldef jsr lb3e1:jsr lb3a6:jsr laefa:lda #$80:sta FNFL + 526 lb3c0 jsr lb08b:jsr lad8d:jsr laef7:lda #$b2:jsr laeff + 527 pha :lda VARADR+1:pha :lda VARADR:pha + 528 lda BASZEI+1:pha :lda BASZEI:pha :jsr la8f8 + 529 jmp lb44f:lb3e1 lda #$a5:jsr laeff:ora #$80:sta FNFL + 530 jsr lb092:sta l004e:sty l004f:jmp lad8d + lb3f4 jsr lb3e1 + 531 lda l004f:pha :lda l004e:pha :jsr laef1 + 532 jsr lad8d:pla :sta l004e:pla :sta l004f + 533 ldy #$02:lda (l004e),y:sta VARADR:tax :iny + 534 lda (l004e),y:beq lb3ae:sta VARADR+1:iny :lb418 lda (VARADR),y + 535 pha :dey :bpl lb418:ldy VARADR+1:jsr lbbd4 + 536 lda BASZEI+1:pha :lda BASZEI:pha :lda (l004e),y + 537 sta BASZEI:iny :lda (l004e),y:sta BASZEI+1:lda VARADR+1 + 538 pha :lda VARADR:pha :jsr frmnum:pla + 539 sta l004e:pla :sta l004f:jsr CHRGOT:beq lb449 + 540 jmp syntax:lb449 pla :sta BASZEI:pla :sta BASZEI+1 + 541 lb44f ldy #$00:pla :sta (l004e),y:pla :iny + 542 sta (l004e),y:pla :iny :sta (l004e),y:pla + 543 iny :sta (l004e),y:pla :iny :sta (l004e),y + 544 rts + lstr jsr lad8d:ldy #$00:jsr lbddf:pla + 545 pla :lb46f lda #l0100-1 +#if (l0100-1)&$ff00 + bne lb487 +#else + beq lb487 +#endif + lb475 ldx FAC+3 + 546 ldy FAC+4:stx l0050:sty l0051:lb47d jsr lb4f4:stx FAC+1 + 547 sty FAC+2:sta FAC:rts :lb487 ldx #$22:stx SUCHCHAR + 548 stx HKFL:lb48d sta ARG+6:sty ARG+7:sta FAC+1:sty FAC+2 + 549 ldy #$ff:lb497 iny :lda (ARG+6),y:beq lb4a8:cmp SUCHCHAR + 550 beq lb4a4:cmp HKFL:bne lb497:lb4a4 cmp #$22:beq lb4a9 + 551 lb4a8 clc :lb4a9 sty FAC:tya :adc ARG+6:sta l0071 + 552 ldx ARG+7:bcc lb4b5:inx :lb4b5 stx l0071+1:lda ARG+7 + 553 beq lb4bf:cmp #>l0200:bne lb4ca:lb4bf tya :jsr lb475 + 554 ldx ARG+6:ldy ARG+7:jsr lb688:lb4ca ldx STRPTR:cpx #$22 + 555 bne lb4d5:ldx #$19:lb4d2 jmp la437:lb4d5 lda FAC:sta $00,x + 556 lda FAC+1:sta $01,x:lda FAC+2:sta $02,x:ldy #$00 + 557 stx FAC+3:sty FAC+4:sty ARG+7:dey :sty STRINGFL + 558 stx STRZEI:inx :inx :inx :stx STRPTR + 559 rts :lb4f4 lsr LISTHKFL:lb4f6 pha :eor #$ff:sec + 560 adc STRANF:ldy STRANF+1:bcs lb501:dey :lb501 cpy ARREND+1 + 561 bcc lb516:bne lb50b:cmp ARREND:bcc lb516:lb50b sta STRANF + 562 sty STRANF+1:sta l0035:sty l0035+1:tax :pla + 563 rts :lb516 ldx #$10:lda LISTHKFL:bmi lb4d2:jsr lb526 + 564 lda #$80:sta LISTHKFL:pla :bne lb4f6:lb526 ldx BASEND + 565 lda BASEND+1:lb52a stx STRANF:sta STRANF+1:ldy #$00:sty l004f + 566 sty l004e:lda ARREND:ldx ARREND+1:sta akku4+3:stx akku4+4 + 567 lda #STRSTCK:sta l0022:stx l0023:lb544 cmp STRPTR + 568 beq lb54d:jsr lb5c7:beq lb544:lb54d lda #$07:sta l0053 + 569 lda VARANF:ldx VARANF+1:sta l0022:stx l0023:lb559 cpx ARRANF+1 + 570 bne lb561:cmp ARRANF:beq lb566:lb561 jsr lb5bd:beq lb559 + 571 lb566 sta akku3+1:stx akku3+2:lda #$03:sta l0053:lb56e lda akku3+1 + 572 ldx akku3+2:lb572 cpx ARREND+1:bne lb57d:cmp ARREND:bne lb57d + 573 jmp lb606:lb57d sta l0022:stx l0023:ldy #$00:lda (l0022),y + 574 tax :iny :lda (l0022),y:php :iny + 575 lda (l0022),y:adc akku3+1:sta akku3+1:iny :lda (l0022),y + 576 adc akku3+2:sta akku3+2:plp :bpl lb56e:txa + 577 bmi lb56e:iny :lda (l0022),y:ldy #$00:asl + 578 adc #$05:adc l0022:sta l0022:bcc lb5ae:inc l0023 + 579 lb5ae ldx l0023:lb5b0 cpx akku3+2:bne lb5b8:cmp akku3+1:beq lb572 + 580 lb5b8 jsr lb5c7:beq lb5b0:lb5bd lda (l0022),y:bmi lb5f6:iny + 581 lda (l0022),y:bpl lb5f6:iny :lb5c7 lda (l0022),y:beq lb5f6 + 582 iny :lda (l0022),y:tax :iny :lda (l0022),y + 583 cmp STRANF+1:bcc lb5dc:bne lb5f6:cpx STRANF:bcs lb5f6 + 584 lb5dc cmp akku4+4:bcc lb5f6:bne lb5e6:cpx akku4+3:bcc lb5f6 + 585 lb5e6 stx akku4+3:sta akku4+4:lda l0022:ldx l0023:sta l004e + 586 stx l004f:lda l0053:sta l0055:lb5f6 lda l0053:clc + 587 adc l0022:sta l0022:bcc lb601:inc l0023:lb601 ldx l0023 + 588 ldy #$00:rts :lb606 lda l004f:ora l004e:beq lb601 + 589 lda l0055:and #$04:lsr :tay :sta l0055 + 590 lda (l004e),y:adc akku4+3:sta akku3+3:lda akku4+4:adc #$00 + 591 sta akku3+4:lda STRANF:ldx STRANF+1:sta akku3+1:stx akku3+2 + 592 jsr la3bf:ldy l0055:iny :lda akku3+1:sta (l004e),y + 593 tax :inc akku3+2:lda akku3+2:iny :sta (l004e),y + 594 jmp lb52a:lb63d lda FAC+4:pha :lda FAC+3:pha + 595 jsr lae83:jsr lad8f:pla :sta ARG+6:pla + 596 sta ARG+7:ldy #$00:lda (ARG+6),y:clc :adc (FAC+3),y + 597 bcc lb65d:ldx #$17:jmp la437:lb65d jsr lb475:jsr lb67a + 598 lda l0050:ldy l0051:jsr lb6aa:jsr lb68c:lda ARG+6 + 599 ldy ARG+7:jsr lb6aa:jsr lb4ca:jmp ladb8:lb67a ldy #$00 + 600 lda (ARG+6),y:pha :iny :lda (ARG+6),y:tax + 601 iny :lda (ARG+6),y:tay :pla :lb688 stx l0022 + 602 sty l0023:lb68c tay :beq lb699:pha :lb690 dey + 603 lda (l0022),y:sta (l0035),y:tya :bne lb690:pla + 604 lb699 clc :adc l0035:sta l0035:bcc lb6a2:inc l0035+1 + 605 lb6a2 rts :lb6a3 jsr lad8f:lb6a6 lda FAC+3:ldy FAC+4:lb6aa sta l0022 + 606 sty l0023:jsr lb6db:php :ldy #$00:lda (l0022),y + 607 pha :iny :lda (l0022),y:tax :iny + 608 lda (l0022),y:tay :pla :plp :bne lb6d6 + 609 cpy STRANF+1:bne lb6d6:cpx STRANF:bne lb6d6:pha + 610 clc :adc STRANF:sta STRANF:bcc lb6d5:inc STRANF+1 + 611 lb6d5 pla :lb6d6 stx l0022:sty l0023:rts :lb6db cpy STRZEI+1 + 612 bne lb6eb:cmp STRZEI:bne lb6eb:sta STRPTR:sbc #$03 + 613 sta STRZEI:ldy #$00:lb6eb rts + lchr jsr lb7a1:txa + 614 pha :lda #$01:jsr lb47d:pla :ldy #$00 + 615 sta (FAC+1),y:pla :pla :jmp lb4ca + lleft jsr lb761 + 616 cmp (l0050),y:tya :lb706 bcc lb70c:lda (l0050),y:tax + 617 tya :lb70c pha :lb70d txa :lb70e pha :jsr lb47d + 618 lda l0050:ldy l0051:jsr lb6aa:pla :tay + 619 pla :clc :adc l0022:sta l0022:bcc lb725 + 620 inc l0023:lb725 tya :jsr lb68c:jmp lb4ca + lright jsr lb761 + 621 clc :sbc (l0050),y:eor #$ff:jmp lb706 + lmid lda #$ff + 622 sta FAC+4:jsr CHRGOT:cmp #$29:beq lb748:jsr prkomma + 623 jsr getbyt:lb748 jsr lb761:beq lb798:dex :txa + 624 pha :clc :ldx #$00:sbc (l0050),y:bcs lb70d + 625 eor #$ff:cmp FAC+4:bcc lb70e:lda FAC+4:bcs lb70e + 626 lb761 jsr laef7:pla :tay :pla :sta l0055 + 627 pla :pla :pla :tax :pla + 628 sta l0050:pla :sta l0051:lda l0055:pha + 629 tya :pha :ldy #$00:txa :rts + llen jsr lb782:jmp lb3a2:lb782 jsr lb6a3:ldx #$00:stx STRINGFL + 631 tay :rts + lasc jsr lb782:beq lb798:ldy #$00 + 632 lda (l0022),y:tay :jmp lb3a2:lb798 jmp illquant:lb79b jsr CHRGET + 633 getbyt jsr frmnum:lb7a1 jsr lb1b8:ldx FAC+3:bne lb798:ldx FAC+4 + 634 jmp CHRGOT + lval jsr lb782:bne lb7b5:jmp lb8f7:lb7b5 ldx BASZEI + 635 ldy BASZEI+1:stx l0071:sty l0071+1:ldx l0022:stx BASZEI + 636 clc :adc l0022:sta l0024:ldx l0023:stx BASZEI+1 + 637 bcc lb7cd:inx :lb7cd stx l0025:ldy #$00:lda (l0024),y + 638 pha :tya :sta (l0024),y:jsr CHRGOT:jsr lbcf3 + 639 pla :ldy #$00:sta (l0024),y:lb7e2 ldx l0071:ldy l0071+1 + 640 stx BASZEI:sty BASZEI+1:rts :lb7eb jsr frmnum:jsr getadr + 641 lb7f1 jsr prkomma:jmp getbyt:getadr lda FAC+5:bmi lb798:lda FAC + 642 cmp #$91:bcs lb798:jsr lbc9b:lda FAC+3:ldy FAC+4 + 643 sty INT:sta INT+1:rts + lpeek lda INT+1:pha + 644 lda INT:pha :jsr getadr:ldy #$00:lda (INT),y + 645 tay :pla :sta INT:pla :sta INT+1 + 646 jmp lb3a2 + lpoke jsr lb7eb:txa :ldy #$00:sta (INT),y + 647 rts + lwait jsr lb7eb:stx FORVAR:ldx #$00:jsr CHRGOT + 648 beq lb83c:jsr lb7f1:lb83c stx FORVAR+1:ldy #$00:lb840 lda (INT),y + 649 eor FORVAR+1:and FORVAR:beq lb840:lb848 rts + lb849 lda #lbf11:jmp lb867:lb850 jsr lba8c + lsub lb853 lda FAC+5:eor #$ff:sta FAC+5:eor ARG+5:sta ARG+6 + 652 lda FAC:jmp lb86a:lb862 jsr lb999:bcc lb8a3:lb867 jsr lba8c + ladd lb86a bne lb86f:jmp lbbfc:lb86f ldx ARG+7 + 654 stx l0055+1:ldx #ARG:lda ARG:lb877 tay :beq lb848 + 655 sec :sbc FAC:beq lb8a3:bcc lb893:sty FAC + 656 ldy ARG+5:sty FAC+5:eor #$ff:adc #$00:ldy #$00 + 657 sty l0055+1:ldx #FAC:bne lb897:lb893 ldy #$00:sty ARG+7 + 658 lb897 cmp #$f9:bmi lb862:tay :lda ARG+7:lsr $01,x + 659 jsr lb9b0:lb8a3 bit ARG+6:bpl lb8fe:ldy #FAC:cpx #ARG + 660 beq lb8af:ldy #ARG:lb8af sec :eor #$ff:adc l0055+1 + 661 sta ARG+7:lda $04,y:sbc $04,x:sta FAC+4:lda $03,y + 662 sbc $03,x:sta FAC+3:lda $02,y:sbc $02,x:sta FAC+2 + 663 lda $01,y:sbc $01,x:sta FAC+1:lb8d2 bcs lb8d7:jsr lb947 + 664 lb8d7 ldy #$00:tya :clc :lb8db ldx FAC+1:bne lb929 + 665 ldx FAC+2:stx FAC+1:ldx FAC+3:stx FAC+2:ldx FAC+4 + 666 stx FAC+3:ldx ARG+7:stx FAC+4:sty ARG+7:adc #$08 + 667 cmp #$20:bne lb8db:lb8f7 lda #$00:lb8f9 sta FAC:lb8fb sta FAC+5 + 668 rts :lb8fe adc l0055+1:sta ARG+7:lda FAC+4:adc ARG+4 + 669 sta FAC+4:lda FAC+3:adc ARG+3:sta FAC+3:lda FAC+2 + 670 adc ARG+2:sta FAC+2:lda FAC+1:adc ARG+1:sta FAC+1 + 671 jmp lb936:lb91d adc #$01:asl ARG+7:rol FAC+4:rol FAC+3 + 672 rol FAC+2:rol FAC+1:lb929 bpl lb91d:sec :sbc FAC + 673 bcs lb8f7:eor #$ff:adc #$01:sta FAC:lb936 bcc lb946 + 674 lb938 inc FAC:beq lb97e:ror FAC+1:ror FAC+2:ror FAC+3 + 675 ror FAC+4:ror ARG+7:lb946 rts :lb947 lda FAC+5:eor #$ff + 676 sta FAC+5:lb94d lda FAC+1:eor #$ff:sta FAC+1:lda FAC+2 + 677 eor #$ff:sta FAC+2:lda FAC+3:eor #$ff:sta FAC+3 + 678 lda FAC+4:eor #$ff:sta FAC+4:lda ARG+7:eor #$ff + 679 sta ARG+7:inc ARG+7:bne lb97d:lb96f inc FAC+4:bne lb97d + 680 inc FAC+3:bne lb97d:inc FAC+2:bne lb97d:inc FAC+1 + 681 lb97d rts :lb97e ldx #$0f:jmp la437:lb983 ldx #REG-1:lb985 ldy $03+1,x + 682 sty ARG+7:ldy $03,x:sty $03+1,x:ldy $02,x:sty $03,x + 683 ldy $01,x:sty $02,x:ldy FAC+7:sty $01,x:lb999 adc #$08 + 684 bmi lb985:beq lb985:sbc #$08:tay :lda ARG+7 + 685 bcs lb9ba:lb9a6 asl $01,x:bcc lb9ac:inc $01,x:lb9ac ror $01,x + 686 ror $01,x:lb9b0 ror $02,x:ror $03,x:ror $03+1,x:ror + 687 iny :bne lb9a6:lb9ba clc :rts + lb9bc .byt $81,$00,$00,$00,$00 + lb9c1 .byt $03 + .byt $7f,$5e,$56,$cb,$79 + .byt $80,$13,$9b,$0b,$64 + .byt $80,$76,$38,$93,$16 + .byt $82,$38,$aa,$3b,$20 + lb9d6 .byt $80,$35,$04,$f3,$34 + lb9db .byt $81,$35,$04,$f3,$34 + lb9e0 .byt $80,$80,$00,$00,$00 + lb9e5 .byt $80,$31,$72,$17,$f8 + llog lb9ea jsr lbc2b + 695 beq lb9f1:bpl lb9f4:lb9f1 jmp illquant:lb9f4 lda FAC:sbc #$7f + 696 pha :lda #$80:sta FAC:lda #lb9d6 + 697 jsr lb867:lda #lb9db:jsr lbb0f:lda #lb9bc:jsr lb850:lda #lb9c1:jsr le043 + 699 lda #lb9e0:jsr lb867:pla :jsr lbd7e + 700 lda #lb9e5:lba28 jsr lba8c + lmul bne lba30:jmp lba8b + 701 lba30 jsr lbab7:lda #$00:sta REG:sta REG+1:sta REG+2 + 702 sta REG+3:lda ARG+7:jsr lba59:lda FAC+4:jsr lba59 + 703 lda FAC+3:jsr lba59:lda FAC+2:jsr lba59:lda FAC+1 + 704 jsr lba5e:jmp lbb8f:lba59 bne lba5e:jmp lb983:lba5e lsr + 705 ora #$80:lba61 tay :bcc lba7d:clc :lda REG+3 + 706 adc ARG+4:sta REG+3:lda REG+2:adc ARG+3:sta REG+2 + 707 lda REG+1:adc ARG+2:sta REG+1:lda REG:adc ARG+1 + 708 sta REG:lba7d ror REG:ror REG+1:ror REG+2:ror REG+3 + 709 ror ARG+7:tya :lsr :bne lba61:lba8b rts + 710 lba8c sta l0022:sty l0023:ldy #$04:lda (l0022),y:sta ARG+4 + 711 dey :lda (l0022),y:sta ARG+3:dey :lda (l0022),y + 712 sta ARG+2:dey :lda (l0022),y:sta ARG+5:eor FAC+5 + 713 sta ARG+6:lda ARG+5:ora #$80:sta ARG+1:dey + 714 lda (l0022),y:sta ARG:lda FAC:rts :lbab7 lda ARG + 715 lbab9 beq lbada:clc :adc FAC:bcc lbac4:bmi lbadf + 716 clc :.byt $2c :lbac4 bpl lbada:adc #$80:sta FAC + 717 bne lbacf:jmp lb8fb:lbacf lda ARG+6:sta FAC+5:rts + 718 lbad4 lda FAC+5:eor #$ff:bmi lbadf:lbada pla :pla + 719 jmp lb8f7:lbadf jmp lb97e:lbae2 jsr lbc0c:tax :beq lbaf8 + 720 clc :adc #$02:bcs lbadf:lbaed ldx #$00:stx ARG+6 + 721 jsr lb877:inc FAC:beq lbadf:lbaf8 rts + lbaf9 .byt $84,$20,$00,$00,$00 + lbafe jsr lbc0c:lda #lbaf9:ldx #$00:lbb07 stx ARG+6:jsr lbba2:jmp lbb12 + 724 lbb0f jsr lba8c + ldiv lbb12 beq lbb8a:jsr lbc1b:lda #$00:sec + 725 sbc FAC:sta FAC:jsr lbab7:inc FAC:beq lbadf + 726 ldx #$fc:lda #$01:lbb29 ldy ARG+1:cpy FAC+1:bne lbb3f + 727 ldy ARG+2:cpy FAC+2:bne lbb3f:ldy ARG+3:cpy FAC+3 + 728 bne lbb3f:ldy ARG+4:cpy FAC+4:lbb3f php :rol + 729 bcc lbb4c:inx :sta REG+3,x:beq lbb7a:bpl lbb7e + 730 lda #$01:lbb4c plp :bcs lbb5d:lbb4f asl ARG+4:rol ARG+3 + 731 rol ARG+2:rol ARG+1:bcs lbb3f:bmi lbb29:bpl lbb3f + 732 lbb5d tay :lda ARG+4:sbc FAC+4:sta ARG+4:lda ARG+3 + 733 sbc FAC+3:sta ARG+3:lda ARG+2:sbc FAC+2:sta ARG+2 + 734 lda ARG+1:sbc FAC+1:sta ARG+1:tya :jmp lbb4f + 735 lbb7a lda #$40:bne lbb4c:lbb7e asl :asl :asl + 736 asl :asl :asl :sta ARG+7:plp + 737 jmp lbb8f:lbb8a ldx #$14:jmp la437:lbb8f lda REG:sta FAC+1 + 738 lda REG+1:sta FAC+2:lda REG+2:sta FAC+3:lda REG+3 + 739 sta FAC+4:jmp lb8d7:lbba2 sta l0022:sty l0023:ldy #$04 + 740 lda (l0022),y:sta FAC+4:dey :lda (l0022),y:sta FAC+3 + 741 dey :lda (l0022),y:sta FAC+2:dey :lda (l0022),y + 742 sta FAC+5:ora #$80:sta FAC+1:dey :lda (l0022),y + 743 sta FAC:sty ARG+7:rts :lbbc7 ldx #akku4:.byt $2c + 744 lbbca ldx #akku3:ldy #$00:beq lbbd4:lbbd0 ldx FORVAR:ldy FORVAR+1 + 745 lbbd4 jsr lbc1b:stx l0022:sty l0023:ldy #$04:lda FAC+4 + 746 sta (l0022),y:dey :lda FAC+3:sta (l0022),y:dey + 747 lda FAC+2:sta (l0022),y:dey :lda FAC+5:ora #$7f + 748 and FAC+1:sta (l0022),y:dey :lda FAC:sta (l0022),y + 749 sty ARG+7:rts :lbbfc lda ARG+5:lbbfe sta FAC+5:ldx #$05 + 750 lbc02 lda FAC+7,x:sta akku4+4,x:dex :bne lbc02:stx ARG+7 + 751 rts :lbc0c jsr lbc1b:lbc0f ldx #$06:lbc11 lda akku4+4,x:sta FAC+7,x + 752 dex :bne lbc11:stx ARG+7:lbc1a rts :lbc1b lda FAC + 753 beq lbc1a:asl ARG+7:bcc lbc1a:lbc23 jsr lb96f:bne lbc1a + 754 jmp lb938:lbc2b lda FAC:beq lbc38:lbc2f lda FAC+5:lbc31 rol + 755 lda #$ff:bcs lbc38:lda #$01:lbc38 rts + lsgn jsr lbc2b + 756 lbc3c sta FAC+1:lda #$00:sta FAC+2:ldx #$88:lbc44 lda FAC+1 + 757 eor #$ff:rol :lbc49 lda #$00:sta FAC+4:sta FAC+3 + 758 lbc4f stx FAC:sta ARG+7:sta FAC+5:jmp lb8d2: + labs lsr FAC+5 + 759 rts: lbc5b sta l0024:lbc5d sty l0025:ldy #$00:lda (l0024),y + 760 iny :tax :beq lbc2b:lda (l0024),y:eor FAC+5 + 761 bmi lbc2f:cpx FAC:bne lbc92:lda (l0024),y:ora #$80 + 762 cmp FAC+1:bne lbc92:iny :lda (l0024),y:cmp FAC+2 + 763 bne lbc92:iny :lda (l0024),y:cmp FAC+3:bne lbc92 + 764 iny :lda #$7f:cmp ARG+7:lda (l0024),y:sbc FAC+4 + 765 beq lbcba:lbc92 lda FAC+5:bcc lbc98:eor #$ff:lbc98 jmp lbc31 + 766 lbc9b lda FAC:beq lbce9:sec :sbc #$a0:bit FAC+5 + 767 bpl lbcaf:tax :lda #$ff:sta FAC+7:jsr lb94d + 768 txa :lbcaf ldx #FAC:cmp #$f9:bpl lbcbb:jsr lb999 + 769 sty FAC+7:lbcba rts :lbcbb tay :lda FAC+5:and #$80 + 770 lsr FAC+1:ora FAC+1:sta FAC+1:jsr lb9b0 + 771 sty FAC+7:rts + lint lbccc lda FAC:cmp #$a0:bcs lbcf2 + 772 jsr lbc9b:sty ARG+7:lda FAC+5:sty FAC+5:eor #$80 + 773 rol :lda #$a0:sta FAC:lda FAC+4:sta SUCHCHAR + 774 jmp lb8d2:lbce9 sta FAC+1:sta FAC+2:sta FAC+3:sta FAC+4 + 775 tay :lbcf2 rts + lbcf3 ldy #$00:ldx #$0a:lbcf7 sty akku4+1,x + 776 dex :bpl lbcf7:bcc lbd0d:cmp #$2d:bne lbd06 + 777 stx FAC+6:beq lbd0a:lbd06 cmp #$2b:bne lbd0f:lbd0a jsr CHRGET + 778 lbd0d bcc lbd6a:lbd0f cmp #$2e:beq lbd41:cmp #$45:bne lbd47 + 779 jsr CHRGET:bcc lbd33:cmp #$ab:beq lbd2e:cmp #$2d + 780 beq lbd2e:cmp #$aa:beq lbd30:cmp #$2b:beq lbd30 + 781 bne lbd35:lbd2e ror akku4+4:lbd30 jsr CHRGET:lbd33 bcc lbd91:lbd35 bit akku4+4 + 782 bpl lbd47:lda #$00:sec :sbc akku4+2:jmp lbd49 + 783 lbd41 ror akku4+3:bit akku4+3:bvc lbd0a:lbd47 lda akku4+2:lbd49 sec + 784 sbc akku4+1:sta akku4+2:beq lbd62:bpl lbd5b:lbd52 jsr lbafe + 785 inc akku4+2:bne lbd52:beq lbd62:lbd5b jsr lbae2:dec akku4+2 + 786 bne lbd5b:lbd62 lda FAC+6:bmi lbd67:rts :lbd67 jmp lbfb4 + 787 lbd6a pha :bit akku4+3:bpl lbd71:inc akku4+1:lbd71 jsr lbae2 + 788 pla :sec :sbc #$30:jsr lbd7e:jmp lbd0a + 789 lbd7e pha :jsr lbc0c:pla :jsr lbc3c:lda ARG+5 + 790 eor FAC+5:sta ARG+6:ldx FAC:jmp lb86a:lbd91 lda akku4+2 + 791 cmp #$0a:bcc lbda0:lda #$64:bit akku4+4:bmi lbdae + 792 jmp lb97e:lbda0 asl :asl :clc :adc akku4+2 + 793 asl :clc :ldy #$00:adc (BASZEI),y:sec + 794 sbc #$30:lbdae sta akku4+2:jmp lbd30 + lbdb3 .byt $9b,$3e,$bc,$1f,$fd + lbdb8 .byt $9e,$6e,$6b,$27,$fd + lbdbd .byt $9e,$6e,$6b,$28,$00 + lbdc2 lda #la371:jsr lbdda + 797 lda ZEINR+1:ldx ZEINR:adrout sta FAC+1:stx FAC+2:ldx #$90 + 798 sec :jsr lbc49:jsr lbddf:lbdda jmp strout:lbddd ldy #$01 + 799 lbddf lda #$20:bit FAC+5:bpl lbde7:lda #$2d:lbde7 sta l0100-1,y + 800 sta FAC+5:sty l0071:iny :lda #$30:ldx FAC + 801 bne lbdf8:jmp lbf04:lbdf8 lda #$00:cpx #$80:beq lbe00 + 802 bcs lbe09:lbe00 lda #lbdbd:jsr lba28:lda #$f7 + 803 lbe09 sta akku4+1:lbe0b lda #lbdb8:jsr lbc5b:beq lbe32 + 804 bpl lbe28:lbe16 lda #lbdb3:jsr lbc5b:beq lbe21 + 805 bpl lbe2f:lbe21 jsr lbae2:dec akku4+1:bne lbe16:lbe28 jsr lbafe + 806 inc akku4+1:bne lbe0b:lbe2f jsr lb849:lbe32 jsr lbc9b:ldx #$01 + 807 lda akku4+1:clc :adc #$0a:bmi lbe47:cmp #$0b + 808 bcs lbe48:adc #$ff:tax :lda #$02:lbe47 sec + 809 lbe48 sbc #$02:sta akku4+2:stx akku4+1:txa :beq lbe53 + 810 bpl lbe66:lbe53 ldy l0071:lda #$2e:iny :sta l0100-1,y + 811 txa :beq lbe64:lda #$30:iny :sta l0100-1,y + 812 lbe64 sty l0071:lbe66 ldy #$00:lbe68 ldx #$80:lbe6a lda FAC+4:clc + 813 adc lbf16+3,y:sta FAC+4:lda FAC+3:adc lbf16+2,y:sta FAC+3 + 814 lda FAC+2:adc lbf16+1,y:sta FAC+2:lda FAC+1:adc lbf16,y + 815 sta FAC+1:inx :bcs lbe8e:bpl lbe6a:bmi lbe90 + 816 lbe8e bmi lbe6a:lbe90 txa :bcc lbe97:eor #$ff:adc #$0a + 817 lbe97 adc #$2f:iny :iny :iny :iny + 818 sty VARADR:ldy l0071:iny :tax :and #$7f + 819 sta l0100-1,y:dec akku4+1:bne lbeb2:lda #$2e:iny + 820 sta l0100-1,y:lbeb2 sty l0071:ldy VARADR:txa :eor #$ff + 821 and #$80:tax :cpy #$24:beq lbec4:cpy #$3c + 822 bne lbe6a:lbec4 ldy l0071:lbec6 lda l0100-1,y:dey :cmp #$30 + 823 beq lbec6:cmp #$2e:beq lbed3:iny :lbed3 lda #$2b + 824 ldx akku4+2:beq lbf07:bpl lbee3:lda #$00:sec + 825 sbc akku4+2:tax :lda #$2d:lbee3 sta l0100+1,y:lda #$45 + 826 sta l0100,y:txa :ldx #$2f:sec :lbeef inx + 827 sbc #$0a:bcs lbeef:adc #$3a:sta l0100+3,y:txa + 828 sta l0100+2,y:lda #$00:sta l0100+4,y:beq lbf0c:lbf04 sta l0100-1,y + 829 lbf07 lda #$00:sta l0100,y:lbf0c lda #l0100:rts + lbf11 .byt $80,$00 + lbf13 .byt $00,$00,$00 + lbf16 .byt $fa,$0a,$1f,$00 + .byt $00,$98,$96,$80 + .byt $ff,$f0,$bd,$c0 + .byt $00,$01,$86,$a0 + .byt $ff,$ff,$d8,$f0 + .byt $00,$00,$03,$e8 + .byt $ff,$ff,$ff,$9c + .byt $00,$00,$00,$0a + .byt $ff,$ff,$ff,$ff + + .byt $ff,$df,$0a,$80 + .byt $00,$03,$4b,$c0 + .byt $ff,$ff,$73,$60 + .byt $00,$00,$0e,$10 + .byt $ff,$ff,$fd,$a8 + .byt $00,$00,$00,$3c + .byt $ec + +#ifdef TESTC64 + 840 tax :tax + 841 tax :tax :tax :tax :tax + 842 tax :tax :tax :tax :tax + 843 tax :tax :tax :tax :tax + 844 tax :tax :tax :tax :tax + 845 tax :tax :tax :tax :tax + 846 tax :tax :tax +#endif + + lsqr jsr lbc0c:lda #lbf11:jsr lbba2 + lpot beq lbfed:lda ARG:bne lbf84 + 848 jmp lb8f9:lbf84 ldx #$4e:ldy #$00:jsr lbbd4:lda ARG+5 + 849 bpl lbf9e:jsr lbccc:lda #$4e:ldy #$00:jsr lbc5b + 850 bne lbf9e:tya :ldy SUCHCHAR:lbf9e jsr lbbfe:tya + 851 pha :jsr lb9ea:lda #$4e:ldy #$00:jsr lba28 + 852 jsr lbfed:pla :lsr :bcc lbfbe + lneg lbfb4 lda FAC:beq lbfbe:lda FAC+5:eor #$ff:sta FAC+5 + 854 lbfbe rts + lbfbf .byt $81,$38,$aa,$3b,$29 + lbfc4 .byt $07 + .byt $71,$34,$58,$3e,$56 + .byt $74,$16,$7e,$b3,$1b + .byt $77,$2f,$ee,$e3,$85 + .byt $7a,$1d,$84,$1c,$2a + .byt $7c,$63,$59,$58,$0a + .byt $7e,$75,$fd,$e7,$c6 + .byt $80,$31,$72,$18,$10 + .byt $81,$00,$00,$00,$00 + lexp lbfed lda #lbfbf:jsr lba28:lda ARG+7:adc #$50 + 861 bcc lbffd:jsr lbc23 + lbffd +#ifdef ORIGINAL + jmp le000 + *=$e000 + le000 +#endif + sta l0055+1:jsr lbc0f + 862 lda FAC:cmp #$88:bcc le00e:le00b jsr lbad4:le00e jsr lbccc + 863 lda SUCHCHAR:clc :adc #$81:beq le00b:sec + 864 sbc #$01:pha :ldx #$05:le01e lda ARG,x:ldy FAC,x + 865 sta FAC,x:sty ARG,x:dex :bpl le01e:lda l0055+1 + 866 sta ARG+7:jsr lb853:jsr lbfb4:lda #lbfc4 + 867 jsr le059:lda #$00:sta ARG+6:pla :jsr lbab9 + 868 rts :le043 sta l0071:sty l0071+1:jsr lbbca:lda #akku3 + 869 jsr lba28:jsr le05d:lda #akku3:jmp lba28 + 870 le059 sta l0071:sty l0071+1:le05d jsr lbbc7:lda (l0071),y:sta FAC+6 + 871 ldy l0071:iny :tya :bne le06c:inc l0071+1 + 872 le06c sta l0071:ldy l0071+1:le070 jsr lba28:lda l0071:ldy l0071+1 + 873 clc :adc #$05:bcc le07d:iny :le07d sta l0071 + 874 sty l0071+1:jsr lb867:lda #akku4:dec FAC+6 + 875 bne le070:rts + le08d .byt $98,$35,$44,$7a,$00 + le092 .byt $68,$28,$b1,$46,$00 + lrnd jsr lbc2b:bmi le0d3:bne le0be:jsr lfff3:stx l0022 + 878 sty l0023:ldy #$04:lda (l0022),y:sta FAC+1:iny + 879 lda (l0022),y:sta FAC+3:ldy #$08:lda (l0022),y:sta FAC+2 + 880 iny :lda (l0022),y:sta FAC+4:jmp le0e3:le0be lda #l008b:jsr lbba2:lda #le08d:jsr lba28 + 882 lda #le092:jsr lb867:le0d3 ldx FAC+4:lda FAC+1 + 883 sta FAC+4:stx FAC+1:ldx FAC+2:lda FAC+3:sta FAC+2 + 884 stx FAC+3:le0e3 lda #$00:sta FAC+5:lda FAC:sta ARG+7 + 885 lda #$80:sta FAC:jsr lb8d7:ldx #$8b:ldy #$00 + 886 le0f6 jmp lbbd4:le0f9 cmp #$f0:bne le104:sty BASEND+1:stx BASEND + 887 jmp la663:le104 tax :bne le109:ldx #$1e:le109 jmp la437 + 888 le10c jsr lffd2:bcs le0f9:rts :/* le112 jsr lffcf:bcs le0f9 + 889 rts :*/ le118 jsr le4ad:bcs le0f9:rts :le11e jsr lffc6 + 890 bcs le0f9:rts :le124 jsr lffe4:bcs le0f9:rts + + .( + strlen =syszp + stradr =syszp+1 + -syszp +=3 + +&gets jsr GETINT + sty stradr + sta stradr+1 + jsr CHRGOT + jsr prkomma + jsr getbyt + stx strlen + jsr CHRGOT + jsr prkomma + jsr lb08b + jsr lad8f ; test auf string + sta FORVAR + sty FORVAR+1 + lda #strlen + sta FAC+3 + sty FAC+4 + jmp laa52 + .) + + puts jsr GETINT + jsr CHRGOT + jsr prkomma + jsr lad9e + jsr lb6a3 + sta akku3 + tay + beq putse + ldy #0 + puts1 lda (l0022),y + sta (INT),y + iny + cpy akku3 + bcc puts1 + putse rts + + glcp jsr CHRGOT:beq lgs + jsr prkomma; test komma:beq lgs:cmp #",":beq lgs + jsr getbyt:clc:rts + lgs sec:cln rts + + call jsr frmnum:jsr getadr + jsr glcp:bcs cl1:stx SYSAC + cl1 jsr glcp:bcs cl2:stx SYSXR + cl2 jsr glcp:bcs cl3:stx SYSYR + cl3 jsr glcp:bcs cl4:stx SYSST + cl4 jsr lcsys + lda SYSAC:jsr slcp + lda SYSXR:jsr slcp + lda SYSYR:jsr slcp + lda SYSST + + slcp sta FAC+2:lda #0:sta FAC+1 + jsr CHRGOT:beq cln + jsr prkomma:beq cln:cmp #",":beq cln + jsr lb08b:sta FORVAR:sty FORVAR+1 + lda STRINGFL:bpl typerr + ldx #$90:sec:jsr lbc49 + lda INTFL:jmp la9c2 + typerr jmp lad99 + + lsys jsr frmnum:jsr getadr + lcsys ldy #0 + ls1 lda sysadr+1,y + beq lsend + cmp INT+1 + bne lsnex + lda INT + cmp sysadr,y + beq lsok + lsnex iny + iny + iny + iny + bne ls1 + lsok lda sysadr+2,y + sta INT + lda sysadr+3,y + sta INT+1 + lsend + lda #>le147-1:pha :lda #l0200:beq le194 + 900 lda #la364:jmp strout:le194 rts + le195 jsr lffb7 + and #$bf:beq le1a1:ldx #$1d:le19e jmp la437 + le1a1 lda BASZEI+1 + cmp #>l0200:bne le1b5 + stx VARANF:sty VARANF+1 +#ifdef SHOW + lda #"x" + jsr SEROUT +#endif + jsr la660 + jsr bindbas + jsr CHRGOT +#ifdef SHOW + jsr HEXOUT + jsr CHRGOT +#endif + jmp la7e7;jmp la52a + le1b5 jsr la68e:jsr bindbas + 904 jmp la677 + lopen jsr le219:jsr lffc0:bcs le1d1:rts + lclose jsr le219:lda FORVAR:jsr lffc3:bcc le194:le1d1 jmp le0f9 + + 906 le1d4 lda #$00:jsr lffbd:ldx #$01:ldy #$00:jsr lffba + 907 jsr weitzei:jsr le257:jsr weitzei:jsr le200:ldy #$00 + 908 stx FORVAR:jsr lffba:jsr weitzei:jsr le200:txa + 909 tay :ldx FORVAR:jmp lffba:le200 jsr le20e:jmp getbyt + 910 weitzei jsr CHRGOT:bne le20d:pla :pla :le20d rts + 911 le20e jsr prkomma:le211 jsr CHRGOT:bne le20d:jmp syntax:le219 lda #$00 + 912 jsr lffbd:jsr le211:jsr getbyt:stx FORVAR:txa + 913 ldx #$01:ldy #$00:jsr lffba:jsr weitzei:jsr le200 + 914 stx FORVAR+1:ldy #$00:lda FORVAR:cpx #$03:bcc le23f + 915 dey :le23f jsr lffba:jsr weitzei:jsr le200:txa + 916 tay :ldx FORVAR+1:lda FORVAR:jsr lffba:jsr weitzei + 917 jsr le20e:le257 jsr lad9e:jsr lb6a3:ldx l0022:ldy l0023 + 918 jmp lffbd + + lcos lda #le2e0:jsr lb867 + lsin le26b jsr lbc0c + 919 lda #le2e5:ldx ARG+5:jsr lbb07:jsr lbc0c + 920 jsr lbccc:lda #$00:sta ARG+6:jsr lb853:lda #le2ea:jsr lb850:lda FAC+5:pha :bpl le29d + 922 jsr lb849:lda FAC+5:bmi le2a0:lda ATNSIGN:eor #$ff + 923 sta ATNSIGN:le29d jsr lbfb4:le2a0 lda #le2ea:jsr lb867 + 924 pla :bpl le2ad:jsr lbfb4:le2ad lda #le2ef + 925 jmp le043 + ltan jsr lbbca:lda #$00:sta ATNSIGN:jsr le26b + 926 ldx #$4e:ldy #$00:jsr le0f6:lda #akku3 + 927 jsr lbba2:lda #$00:sta FAC+5:lda ATNSIGN:jsr le2dc + 928 lda #$4e:ldy #$00:jmp lbb0f:le2dc pha :jmp le29d + le2e0 .byt $81,$49,$0f,$da,$a2 + le2e5 .byt $83,$49,$0f,$da,$a2 + le2ea .byt $7f,$00,$00,$00,$00 + le2ef .byt $05 + .byt $84,$e6,$1a,$2d,$1b + .byt $86,$28,$07,$fb,$f8 + .byt $87,$99,$68,$89,$01 + .byt $87,$23,$35,$df,$e1 + .byt $86,$a5,$5d,$e7,$28 + .byt $83,$49,$0f,$da,$a2 + latn lda FAC+5:pha:bpl le316:jsr lbfb4:le316 lda FAC + 936 pha :cmp #$81:bcc le324:lda #lb9bc + 937 jsr lbb0f:le324 lda #le33e:jsr le043:pla + 938 cmp #$81:bcc le337:lda #le2e0:jsr lb850 + 939 le337 pla :bpl le33d:jmp lbfb4:le33d rts + le33e .byt $0b + .byt $76,$b3,$83,$bd,$d3 + .byt $79,$1e,$f4,$a6,$f5 + .byt $7b,$83,$fc,$b0,$10 + .byt $7c,$0c,$1f,$67,$ca + .byt $7c,$de,$53,$cb,$c1 + .byt $7d,$14,$64,$70,$4c + .byt $7d,$b7,$ea,$51,$7a + .byt $7d,$63,$30,$88,$7e + .byt $7e,$92,$44,$99,$3a + .byt $7e,$4c,$cc,$91,$c7 + .byt $7f,$aa,$aa,$aa,$13 + .byt $81,$00,$00,$00,$00 + + le37b jsr lffcc + lda #$00:sta ACTIO:jsr la67a:cli :le386 ldx #$80 + jmp (l0300) + le38b txa :bmi le391:jmp la43a:le391 jmp ready + le394 jsr le453:jsr le3bf:jsr le422:ldx #$fb:txs + + ldy #<-1 + lexe1 iny + lda PCBUF,y + beq le386 + cmp #" " + bne lexe1 + ldx #<-1 + lexe2 iny + inx + lda PCBUF,y + sta l0200,x + bne lexe2 + lda #l0200-1 + sta BASZEI+1 + jmp exestart + + ;bne le386 + + le3a2 inc BASZEI:bne le3a8:inc BASZEI+1:le3a8 lda $ea60 + 952 cmp #$3a:bcs le3b9:cmp #$20 + 953 beq le3a2:sec :sbc #$30:sec :sbc #$d0 + 954 le3b9 rts :.byt $80 :.byt $4f :.byt $c7 :.byt $52 + 955 cli :le3bf lda #$4c:sta l0054:sta lusr:lda #illquant:sta lusr+1:sty lusr+2:lda #lb391 + 957 sta l0005:sty l0005+1:lda #lb1aa:sta l0003 + 958 sty l0003+1:ldx #$1c:le3e2 lda le3a2,x:sta CHRGET,x:dex + 959 bpl le3e2:lda #$03:sta l0053:lda #$00:sta FAC+7 + 960 sta ACTIO:sta STRZEI+1:ldx #$01:stx l0200-3:stx l0200-4 + 961 ldx #$19:stx STRPTR:sec :jsr lff9c:stx BASANF + 962 sty BASANF+1:sec :jsr lff99:stx BASEND:sty BASEND+1 + 963 stx STRANF:sty STRANF+1:ldy #$00:tya :sta (BASANF),y + 964 inc BASANF:bne le421:inc BASANF+1:le421 rts :le422 lda BASANF + 965 ldy BASANF+1:jsr la408:lda #le473:jsr strout + 966 lda BASEND:sec :sbc BASANF:tax :lda BASEND+1 + 967 sbc BASANF+1:jsr adrout:lda #le460:jsr strout + 968 jmp la644 + le447 .word le38b,la483,la57c,la71a,la7e4,lae86 + le453 ldx #$0b + le455 lda le447,x:sta l0300,x:dex :bpl le455:rts + .byt 0 + le460 .byt " BASIC BYTES FREE",13,10,0 + le473 .byt TC_FF,13," **** COMMODORE 64 BASIC V2 ****",13,10,10 + .byt " 64K RAM SYSTEM ",0 + .byt $5c + le4ad pha:jsr lffc9:tax:pla:bcc le4b6:txa:le4b6 rts + +romend =* + +#ifdef SHOW + .( +dxr =syszp +-syszp +=1 + +&SERIN stx dxr + ldx #STDIN + bne s0 +&xIN stx dxr +s0 s1 jsr GETC + bcc s1a + cmp #E_EOF + beq s1b + jsr YIELD + jmp s1 +s1b sec +s1a ldx dxr + rts + ++SEROUT stx dxr + ldx #STDOUT +o0 s2 pha + jsr PUTC + pla + bcc s2a + jsr YIELD + jmp s2 +s2a ldx dxr + cmp #0 + rts + .) + ++xHEXOUT .( + pha + lsr + lsr + lsr + lsr + jsr NIBOUT + pla + and #$0f +NIBOUT clc + adc #"0" + cmp #"9"+1 + bcc nout + adc #6 +nout jmp SEROUT + .) + ++SPOUT lda #32 + jmp SEROUT ++CRLFOUT lda #13 + jsr SEROUT + lda #10 + jmp SEROUT + + .) +#endif + +x1 =(la9a5^laf28)&$00ff +x2 =(lac15^laf28)&$00ff +x3 =(lad24^laf28)&$00ff +x4 =(lb3c0^laf28)&$00ff + +#if x1*x2*x3*x4 +#else +#echo Adresskonflikt ! +/* +#print x1 +#print x2 +#print x3 +#print x4*/ +stx,x +#endif + +#print syszp +-syszp =oldsyszp /* watch out - may not work on every ROM */ +#echo returned to +#print syszp + +endofbasic =* +.) + diff --git a/dump/oa-2.0.9/sysapps/fs/Makefile b/dump/oa-2.0.9/sysapps/fs/Makefile new file mode 100644 index 0000000..3ed6a26 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/Makefile @@ -0,0 +1,22 @@ + + +XA=xa + +all: fsibm.o65 # fsiec.o65 fsdev.o65 + +fsibm.o65: fsibm.a65 $(wildcard fsibm/*.a65) + ${XA} -R -I../.. -I../../include -LOSA2KERNEL \ + -DFSIBM_DEVICE_DRV="sysapps/fs/fsibm/drv_ramd1.a65" \ + $< -o $@ + +fsiec.o65: fsiec.a65 + ${XA} -R -I../.. -I../../include -LOSA2KERNEL $< -o $@ + +fsdev.o65: fsdev.a65 + ${XA} -R -I../.. -I../../include -LOSA2KERNEL $< -o $@ + +clean: + rm -f *.o65 + make -C fsibm clean + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsdev.a65 b/dump/oa-2.0.9/sysapps/fs/fsdev.a65 new file mode 100644 index 0000000..7ae11f6 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsdev.a65 @@ -0,0 +1,640 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + + .( +#ifdef ROM +start .word ende ; pointer to end of file in ROM +#ifdef FSDEV_AS_INIT + .byt PK_INIT+$80 ; file type = filesystem + auto-execute bit +#else + .byt PK_FS+$80 ; file type = filesystem + auto-execute bit +#endif + .word PRG ; execution start + .byt 16 ; RAM size in 256-byte blocks + .byt >$ff-ROMSTART; $ff-start ; shared mem size in 256-byte blocks + .byt 0 ; priority + .word 0 ; stdin, stdout/stderr device number + .asc "fsdev",0,0 ; command line +#else + +#include "kdefs.i65" +#include "kernel.i65" +#include "fdefs.i65" + + .word $800 + *=$800 + jmp PRG + +#endif + +#include "fsdef.i65" + +#ifndef MAXFILE +#ifndef NOMMU +#define MAXFILE 8 +#else +#define MAXFILE 4 /* must be more than ANZDRV (number of + drives), because for each drive a buffer + is reserved */ +#endif /* NOMMU */ +#endif /* MAXFILE */ + +#define BUFSIZE 128 + +#ifdef FSDEV_NOROM +#define ANZDRV 1 +#else +#define ANZDRV 2 +#endif + + .zero +fzei .word 0 +bzei .word 0 +rzei .word 0 + + .data +owntask .byt 0 +anz .byt 0 +cnt .byt 0 +cmd .byt 0 +client .byt 0 +actfil .byt 0 +dev .byt 0 +ftab .dsb F_SLEN*MAXFILE + + .bss +buf .dsb MAXFILE*BUFSIZE + + .text + +PRG .( + stx owntask + + ldx #<-1 + jsr setzei ; init setzei (actfil) + ldx #0 + stx anz +p1 jsr setzei + lda #F_FL_FRE + ldy #F_FL + sta (fzei),y + inx + cpx #MAXFILE + bcc p1 + + ; we now inherit PCBUF from the FORK call (if PK_FS) + ; clc + ; ldx #SEM_SENDBUF + ; jsr PSEM + + lda #ANZDRV ; 2 Drives + sta PCBUF+FM_REG_DRVS + lda owntask + sta PCBUF+FM_REG_ENV + lda #FM_REG + ldx #SEND_FM + ldy #2 + jsr SEND + + php + ldx #SEM_SENDBUF + jsr VSEM + plp + + bcc loopt + jmp TERM + +loopt lda anz + bne loop + sec + .byt $24 +loop clc + jsr RECEIVE + bcs l1 + jsr rxmess +l1 ldx #0 + stx cnt + stx anz +l2 jsr setzei + ldy #F_FL + lda (fzei),y + cmp #F_FL_FRE + bne l2a + jmp nextl + +l2a inc anz + ldy #F_MODE + lda (fzei),y + cmp #F_MODE_RD + bne l3 + +ol ldy #F_BYT + lda (fzei),y + ldy #F_LEN + cmp (fzei),y + beq l4 + pha + ldy #F_STR + lda (fzei),y + tax + pla + tay + lda (bzei),y + jsr PUTC + bcs l5n + ldy #F_BYT + lda (fzei),y + clc + adc #1 + sta (fzei),y + jmp ol + +l4 ldy #F_FL + lda (fzei),y + cmp #F_FL_EOF + bne l4a + ldy #F_STR + lda (fzei),y + tax + lda #SC_EOF + jsr STRCMD + jsr close + jmp nextl +l4a jsr clrbuf + jsr loadbuf + bcc l5 + ldy #F_FL + lda #F_FL_EOF + sta (fzei),y +l5 jmp nextl + +l5n cmp #E_NUL + bne l5 + ldy #F_STR + lda (fzei),y + tax + lda #SC_EOF + jsr STRCMD + jsr close + +l3 nextl + inc cnt + ldx cnt + cpx #MAXFILE + bcs endloop + jmp l2 +endloop jsr YIELD + jmp loopt + .) + +rxmess .( + stx client + cmp #FS_OPEN_DR + bne rx1 + jsr getfre + bcs rxe1a + jsr clrbuf + lda #F_FL_DIR +oprrx ldy #F_FL + sta (fzei),y + lda PCBUF+FS_OPEN_STR + ldy #F_STR + sta (fzei),y + ldy #F_MODE + lda #F_MODE_RD + sta (fzei),y + lda #<-1 + ldy #F_DEV + sta (fzei),y + lda PCBUF+FS_OPEN_DRV + ldy #F_DRV + sta (fzei),y + ldy #F_STR + lda (fzei),y + tay + jmp rxok + +#ifndef FSDEV_NOROM +oprrom jsr findrnam + bcs rxe1a + jsr getfre + bcs rxe1a + jsr clrbuf + jsr ldrombuf + lda #F_FL_EOF + jmp oprrx +#endif + +rx1 cmp #FS_OPEN_RD + bne rx2 + +#ifndef FSDEV_NOROM + lda PCBUF+FS_OPEN_DRV + beq oprdev + jmp oprrom +#endif + +oprdev lda PCBUF+FS_OPEN_STR /* Stream vom Open sichern */ + sta cnt + ldx #0 + ldy #FS_OPEN_NAME +rxw1 lda PCBUF,y /* Name vom Open in PCBUF */ + sta PCBUF,x /* fuer DC_GNUM kopieren */ + inx + iny + cmp #0 + bne rxw1 + lda #DC_GNUM /* Die Device-Nummer zu dem */ + jsr DEVCMD /* Namen holen */ +rxe1a bcs rxe1 /* Fehler dann Ende */ + stx dev /* Device-Nummer speichern */ + ldy cnt /* Stream als */ + lda #DC_PS /* Ausgabe des Devices */ + jsr DEVCMD /* registrieren */ + bcs rxe1 /* Fehler dann Ende */ + ldx dev /* Device-Nummer zur�ckholen */ + lda #DC_RX_ON /* �bertragung starten */ + jsr DEVCMD /* und los... */ + bcs rxe1 /* Fehler dann Ende */ + ldy cnt /* hier geht's normal weiter */ + jmp rxok + +rx2 cmp #FS_OPEN_OW + beq rx2a + cmp #FS_OPEN_WR + bne rx3 +rx2a +#ifndef FSDEV_NOROM + lda PCBUF+FS_OPEN_DRV + beq opwdev + jmp opwrom +#endif + +opwdev lda PCBUF+FS_OPEN_STR + sta cnt + ldx #0 + ldy #FS_OPEN_NAME +rxr1 lda PCBUF,y + sta PCBUF,x + inx + iny + cmp #0 + bne rxr1 + lda #DC_GNUM + jsr DEVCMD + bcs rxe1 + stx dev + ldy cnt + lda #DC_GS + jsr DEVCMD + bcs rxe1 + ldx dev + lda #DC_TX_ON + jsr DEVCMD + bcs rxe1 + ldy cnt + jmp rxok + +#ifndef FSDEV_NOROM +opwrom lda #E_FWPROT + .byt $2c +#endif +rx3 lda #E_NOTIMP + .byt $2c +rxok lda #E_OK + .byt $2c +rxe1 lda #E_FNOFIL + sta PCBUF+FS_X_ERR + ldx owntask + stx PCBUF+FS_X_ENV + ldy actfil + sty PCBUF+FS_X_FIL + ldy #FS_X_SLEN + ldx client + jmp SEND + .) + +loadbuf .( + ldy #F_DEV + lda (fzei),y + bpl ldr0 + jmp loadirnam + +ldr0 + clc + ldx #SEM_SENDBUF + jsr PSEM + + ldy #F_DRV + lda (fzei),y + beq lddev + + ldy #F_DEV + lda (fzei),y + jsr setrzei + bcs lde ; rzei zeigt auf verkettungszeiger + ldy #P_NAME+1 +; ldr3 iny ; deshalb hier zwei mehr +; iny +; lda (rzei),y +; bpl ldr3 ; ende der Tabelle feststellen + ldx #<-1 +ldr4 inx + iny + lda (rzei),y + sta PCBUF,x + bne ldr4 + beq ldr5 + +lddev ldy #F_DEV + lda (fzei),y + tax + lda #DC_GNAM + jsr DEVCMD + bcs lde +ldr5 ldx #0 + ldy #FS_DIR_NAME +ld1 lda PCBUF,x + sta (bzei),y + inx + iny + cmp #0 + bne ld1 + tya + + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + + ldy #F_LEN + sta (fzei),y + lda #0 + ldy #FS_DIR_LEN +ld2 sta (bzei),y + iny + cpy #FS_DIR_MODE + bcc ld2 + lda #FS_DIR_MOD_FIL + sta (bzei),y + ldy #F_DEV + lda (fzei),y + clc + adc #1 + sta (fzei),y + clc + rts + +lde + ldx #SEM_SENDBUF + jsr VSEM + ldy #0 +lde1 lda ldet,y + sta (bzei),y + iny + cpy #FS_DIR_NAME+1 + bcc lde1 + tya + ldy #F_LEN + sta (fzei),y + sec + rts + +ldet .word 0,0 + .byt 0,0,0,0,0,0,FS_DIR_MOD_FRE,0 + +loadirnam +#ifndef FSDEV_NOROM + ldy #F_DRV + lda (fzei),y + bne romnam +#endif + lda #devtxt +#ifndef FSDEV_NOROM + bne dn1 +romnam lda #romtxt +#endif +dn1 sta rzei + sty rzei+1 + ldy #0 +dn2 lda (rzei),y + sta (bzei),y + iny + cpy #FS_DIR_NAME + bcc dn2 +dn3 lda (rzei),y + sta (bzei),y + iny + cmp #0 + bne dn3 + tya + ldy #F_LEN + sta (fzei),y + lda #0 + ldy #F_DEV + sta (fzei),y + clc + rts + +#ifndef FSDEV_NOROM +romtxt .word 0,0 ; len + .byt 90,8,23 + .byt 9,33,0 + .byt FS_DIR_MOD_NAM + .asc "romdisk",0 +#endif + +devtxt .word 0,0 + .byt 90,8,23 + .byt 9,33,0 + .byt FS_DIR_MOD_NAM + .asc "devices",0 + + .) + +close lda #F_FL_FRE + ldy #F_FL + sta (fzei),y + rts + +getfre .( + ldx #ANZDRV + stx cnt +gf1 jsr setzei + ldy #F_FL + lda (fzei),y + cmp #F_FL_FRE + clc + beq gf2 + inc cnt + ldx cnt + cpx #MAXFILE + bcc gf1 +gf2 rts + .) + +clrbuf lda #0 + ldy #F_LEN + sta (fzei),y + ldy #F_BYT + sta (fzei),y + rts + +setzei .( ; setzt zeiger, x=filenr + cpx actfil + beq sz1 + stx actfil + txa + asl + asl + asl + clc + adc #ftab + adc #0 + sta fzei+1 + txa +#if 1 + lsr + pha + lda #0 + ror ; clears carry + adc #buf + sta bzei+1 +#else + clc + adc #>buf*2 + lsr + sta bzei+1 + lda #ROMSTART +ldr1 stx rzei + sta rzei+1 + ldy #1 + lda (rzei),y + dey + and (rzei),y + tax + inx + sec + beq lde ; dann Verkettungszeiger =-1 + lda cmd + clc + beq lde + dec cmd + lda (rzei),y + tax + iny + lda (rzei),y + jmp ldr1 +lde rts + .) + +#ifndef FSDEV_NOROM +findrnam .( + lda #ROMSTART +fn1 sta rzei + stx rzei+1 + ldy #1 + lda (rzei),y + dey + and (rzei),y + tay + iny + beq fns + ldy #P_NAME+1 +; fn2 iny +; iny +; lda (rzei),y +; bpl fn2 ; ende der Tabelle ? + ldx #<-1 +fn3 iny + inx + lda (rzei),y + cmp PCBUF+FS_OPEN_NAME,x + bne fnnxt + cmp #0 + bne fn3 + clc + rts +fnnxt ldy #1 + lda (rzei),y + tax + dey + lda (rzei),y + jmp fn1 +fns sec + rts + .) + +ldrombuf .( + lda #0 + tay + sta (bzei),y + iny + sta (bzei),y + iny +lr1 lda (rzei),y + sta (bzei),y + iny + cpy #P_NAME+2 + bcc lr1 +; lr2 lda (rzei),y +; sta (bzei),y +; iny +; cmp #128 ; Ende der Tabelle bei <0 +; bcs lre +; lda (rzei),y +; sta (bzei),y +; iny +; bne lr2 +lre tya + ldy #F_LEN + sta (fzei),y + rts + .) +#endif + +#undef ANZDRV +#undef BUFSIZE +#undef MAXFILE + +ende .) + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm.a65 new file mode 100644 index 0000000..e8b9753 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm.a65 @@ -0,0 +1,96 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * TODO: + * + * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! + * + * This file lacks the stream error feature of the 1.4 kernel! + * + * To use it, you have to implement the stream error feature! + * + * In fact the file is still the 1.3 file, only the ROM boot stuff + * and some error codes have been changed. To really use it, + * you have to + * - check error codes + * - implement the error feature, as well as push and pull flags + * - bugfixes + */ + + +#ifndef ROM + +/*#define NOPRG*/ +#define SHOW +#define SHOWC +/*#define BSHOW*/ +/*#define SHOWL*/ +/*#define SHOWN*/ +/*#define SHOWD*/ + +#endif /* ROM */ + .( + +#ifdef ROM + + .word ende ; pointer to end of file in ROM +#ifdef FSIBM_AS_INIT + .byt PK_INIT+$80 ; file type = filesystem + auto-execute bit +#else + .byt PK_PRG+$80 ; file type = filesystem + auto-exec bit +#endif + .word PRG + .byt 32 ; RAM size in 256-byte blocks + .byt >$ff-ROMSTART ; shared mem size from upper end + .byt 0 ; priority (0=inherit) + .byt STDNUL, FSIBM_OUTDEV ; stdin, stdout/stderr device number + .asc "fsibm",0,0 + +#else /* ROM */ + +#include "include/kdefs.i65" +#include "include/fdefs.i65" +#include "include/kernel.i65" + +&main jmp PRG + +#endif /* ROM */ + + +#include "sysapps/fs/fsibm/defs.a65" +#include "sysapps/fs/fsibm/loop.a65" +#include "sysapps/fs/fsibm/vars.a65" +#include "sysapps/fs/fsibm/cmd.a65" +#include "sysapps/fs/fsibm/util.a65" +#include "sysapps/fs/fsibm/file.a65" +#include "sysapps/fs/fsibm/cluster.a65" +#include "sysapps/fs/fsibm/drive.a65" +#include "sysapps/fs/fsibm/buffer.a65" +/* #include "sysapps/fs/fsibm/drv_wd1770.a65" */ +/* #include "sysapps/fs/fsibm/drv_ramd1.a65" */ +/* #include "sysapps/fs/fsibm/drv_ramd2.a65" */ +#include FSIBM_DEVICE_DRV + +ende .) + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/Makefile b/dump/oa-2.0.9/sysapps/fs/fsibm/Makefile new file mode 100644 index 0000000..7234373 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/Makefile @@ -0,0 +1,21 @@ + +all: drv_wd1770.o65 buffer.o65 drive.o65 + +drv_wd1770.o65: drv_wd1770.a65 + xa -R -c ../../../include/kdefs.i65 defs.a65 drv_wd1770.a65 \ + -I../../../include -DANZDRV=4 -o drv_wd1770.o65 + file65 -V drv_wd1770.o65 + +buffer.o65: buffer.a65 + xa -R -c ../../../include/kdefs.i65 defs.a65 buffer.a65 \ + -I../../../include -o buffer.o65 + file65 -V buffer.o65 + +drive.o65: drive.a65 + xa -R -c ../../../include/kdefs.i65 defs.a65 drive.a65 \ + -I../../../include -o drive.o65 + file65 -V drive.o65 + +clean: + rm -f *.o65 + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/buffer.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/buffer.a65 new file mode 100644 index 0000000..198fea9 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/buffer.a65 @@ -0,0 +1,519 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * + * FIXME: this is horribly complicated + * + * Buffer handling + * Buffer allocation is done elsewhere + * + * Exports: + * CLBUF Write buffer if dirty, set it to 0 and free it + * DWBUF Write buffer=YR back if buffer is dirty (Write Dirty) + * IDBUF Invalidate all buffers with drive=XR, without writing + * RDBUF Read sector ar2(24 bit) on drive `drive` into buffer=YR, + * saving dirty buffer if necessary + * W1BUF Flush buffer=YR to sector ar2, invalidate/free it on write error + * WABUF Write buffer=YR back (Write Always) + * W2BUF Flush buffer=YR back, and set buffer to sector ar2. + * Set buffer to dirty (no further disk activity) + * (handle FAT blocks as well) + * INBUF Set all buffers to free (Init) + * FRBUF Free buffer=YR (no disk activity) + * MDBUF Set buffer=YR to dirty (no disk activity) + * + * Imports (calls): + * setpadr XR=buffer-# => AC/XR=buffer address + * drive current drive ... + * dzei ... and current Drive Parameter Block (DPB) address + * RWSEC Drive routine for reading/writing blocks + * ar1 + * div + * + */ + + .( + .data +p .byt 0 + +abspar .dsb ABS_SLEN + +rwpar .dsb RW_SLEN + +#if B_SLEN=8 /* to much code depends on that */ +bpb .dsb B_SLEN*ANZBUF +#endif + + .zero +bzei .word 0 + .text + +&CLBUF .( + sty p + jsr DWBUF + bcc clr + cmp #E_NOTIMP + beq clr + sec + rts +clr lda p + asl + asl + asl + tay + lda #BD_FRE + sta bpb+B_DIRT,y + ldx p + jsr setpadr + sta bzei + stx bzei+1 + lda #0 + tay + ldx #BUFLEN/256 +ccl sta (bzei),y + iny + bne ccl + inc bzei+1 + dex + bne ccl + ldx p + jsr setpadr + clc + rts + .) + +&IDBUF .( ; free't alle Puffer mit Drive = xr + .data +errfl .byt 0 + .text + + ldy #0 + sty errfl +idl sty p + tya + asl + asl + asl + tay + txa + cmp bpb+B_DRV,y + bne next + lda bpb+B_DIRT,y + bmi next + beq fre + inc errfl + lda #BD_IFRE + .byt $2c +fre lda #BD_FRE + sta bpb+B_DIRT,y +next ldy p + iny + cpy #ANZBUF + bcc idl + lda errfl + bne err + lda #E_OK + .byt $2c +err lda #E_FINTERNAL + cmp #1 + rts + .) + +&RDBUF .( + sty p + cpy #ANZBUF + bcc l1 +lserr +#ifdef DEBUGFS +lda #"x":jsr SEROUT +#endif + lda #E_ILLPAR + sec + rts +l1 lda ar2 + sta abspar+ABS_SEC + lda ar2+1 + sta abspar+ABS_SEC+1 + lda ar2+2 + sta abspar+ABS_SEC+2 + lda ar2+3 + sta abspar+ABS_SEC+3 + +#if 0 /*def DEBUGFS*/ +.( +lda #"r" +jsr SEROUT +lda abspar+ABS_SEC+1 +jsr HEXOUT +lda abspar+ABS_SEC +jsr HEXOUT +.) +#endif + lda drive + sta abspar+ABS_DRV + tya + asl + asl + asl + tay + lda bpb+B_DIRT,y + bmi lsx ; falls frei sofort laden + + lda abspar+ABS_SEC + cmp bpb+B_SECTOR,y + bne lsx1 + lda abspar+ABS_SEC+1 + cmp bpb+B_SECTOR+1,y + bne lsx1 + lda abspar+ABS_SEC+2 + cmp bpb+B_SECTOR+2,y + bne lsx1 + lda abspar+ABS_SEC+3 + cmp bpb+B_SECTOR+3,y + bne lsx1 + lda abspar+ABS_DRV + cmp bpb+B_DRV,y + beq lsend ; falls alles gleich ende + +lsx1 lda bpb+B_DIRT,y + beq lsx ; falls nicht dirty laden + ldy p + jsr DWBUF ; sonst Puffer speichern + bcs lerr + lda p + asl + asl + asl + tay + +lsx lda #BD_FRE + sta bpb+B_DIRT,y + lda abspar+ABS_DRV + sta bpb+B_DRV,y + sta rwpar+RW_DRV + lda abspar+ABS_SEC+3 + sta bpb+B_SECTOR+3,y + sta rwpar+RW_SECTOR+3 + lda abspar+ABS_SEC+2 + sta bpb+B_SECTOR+2,y + sta rwpar+RW_SECTOR+2 + lda abspar+ABS_SEC+1 + sta bpb+B_SECTOR+1,y + sta rwpar+RW_SECTOR+1 + lda abspar+ABS_SEC + sta bpb+B_SECTOR,y + sta rwpar+RW_SECTOR + ;jsr sec2rw + ;bcs lserr + ldx p + jsr setpadr + sta rwpar+RW_ADR + stx rwpar+RW_ADR+1 + lda #rwpar + clc ; load + jsr RWSEC + bcs lerr + lda p + asl + asl + asl + tay + lda #BD_OK + sta bpb+B_DIRT,y + lda #E_OK +lsend clc +lerr rts + .) + +&W1BUF .( + sty p + cpy #ANZBUF + bcc l1 +lserr lda #E_ILLPAR + sec + rts +l1 + tya + asl + asl + asl + tay + lda #BD_FRE + sta bpb+B_DIRT,y + lda drive + sta bpb+B_DRV,y + sta rwpar+RW_DRV + lda ar2 + sta bpb+B_SECTOR,y + sta rwpar+RW_SECTOR + lda ar2+1 + sta bpb+B_SECTOR+1,y + sta rwpar+RW_SECTOR+1 + lda ar2+2 + sta bpb+B_SECTOR+2,y + sta rwpar+RW_SECTOR+2 + lda ar2+3 + sta bpb+B_SECTOR+3,y + sta rwpar+RW_SECTOR+3 + ;jsr sec2rw + ;bcs lserr + ldx p + jsr setpadr + sta rwpar+RW_ADR + stx rwpar+RW_ADR+1 + lda #rwpar + sec ; write + jsr RWSEC + bcs lerr + lda p + asl + asl + asl + tay + lda #BD_OK + sta bpb+B_DIRT,y + lda #E_OK + clc +lerr rts + .) + +&WABUF .( + .data +sector .word 0,0 +xfl .byt 0 + .text + + ldx #0 + sty p ; write always (auch falls nur valid) + cpy #ANZBUF + bcs serr2x + tya + asl + asl + asl + tay + lda bpb+B_DIRT,y + bmi serr1x ; falls nicht belegt dann ende + jmp l1 + +&&DWBUF ldx #0 + .byt $2c +&DxBUF ldx #1 + sty p + cpy #ANZBUF + bcs serr2x + tya + asl + asl + asl + tay + lda bpb+B_DIRT,y ; falls frei dann fehler +serr1x bpl xx + jmp serr1 +xx bne l1 + jmp serr0 ; falls valid dann nicht schreiben + +l1 stx xfl + lda #BD_FRE + sta bpb+B_DIRT,y + lda bpb+B_DRV,y ; hier ist dirty + sta rwpar+RW_DRV + ldx p + jsr setpadr + sta rwpar+RW_ADR + stx rwpar+RW_ADR+1 + lda bpb+B_SECTOR,y + sta sector + lda bpb+B_SECTOR+1,y + sta sector+1 + lda bpb+B_SECTOR+2,y + sta sector+2 + lda bpb+B_SECTOR+3,y + sta sector+3 +wrloop lda sector + sta rwpar+RW_SECTOR + lda sector+1 + sta rwpar+RW_SECTOR+1 + lda sector+2 + sta rwpar+RW_SECTOR+2 + lda sector+3 + sta rwpar+RW_SECTOR+3 + ; sta sector + ; stx sector+1 + ;jsr sec2rw + clc +serr2x bcs serr2 + sec + lda #rwpar + jsr RWSEC + bcs serr + + lda sector + ora sector+1 + ora sector+2 + ora sector+3 + beq wre + lda xfl + bne wre + + ldy #D_SPF ; zu Sektor Sekt/FAT addieren + lda (dzei),y + clc + adc sector + sta sector + iny + lda (dzei),y + adc sector+1 + sta sector+1 + tax + bcc foo1 + inc sector+2 + bne foo1 + inc sector+3 +foo1 + lda sector+2 ; compare sector with start of main dir + ora sector+3 ; if less, write again. + bne wre + + lda sector+1 + ldy #D_STD+1 ; mit Start Main-Dir vergleichen + cmp (dzei),y ; gr��er dann ende + bcc wrl + bne wre + dey + lda sector + cmp (dzei),y + bcs wre +wrl + jmp wrloop ; sonst nochmal schreiben + +wre lda p + asl + asl + asl + tay + lda #BD_OK + sta bpb+B_DIRT,y +serr0 lda #E_OK + clc + rts +serr1 lda #E_NOTIMP + .byt $2c +serr2 lda #E_ILLPAR +serr sec + rts + .) + +&W2BUF .( + sty p + lda ar2 + sta abspar+ABS_SEC + lda ar2+1 + sta abspar+ABS_SEC+1 + lda ar2+2 + sta abspar+ABS_SEC+2 + lda ar2+3 + sta abspar+ABS_SEC+3 + cpy #ANZBUF + bcs werr + tya + asl + asl + asl + tay + lda bpb+B_DIRT,y + bmi w2 ; Daten ung�ltig + beq w2 ; Daten nicht dirty + ldy p + jsr DxBUF + bcs err + +w2 lda p + asl + asl + asl + tay + lda drive + sta bpb+B_DRV,y + lda abspar+ABS_SEC+3 + sta bpb+B_SECTOR+3,y + lda abspar+ABS_SEC+2 + sta bpb+B_SECTOR+2,y + lda abspar+ABS_SEC+1 + sta bpb+B_SECTOR+1,y + lda abspar+ABS_SEC + sta bpb+B_SECTOR,y + lda #BD_DIRTY ;lda #BD_OK + sta bpb+B_DIRT,y + clc +err rts +werr lda #E_ILLPAR + sec + rts + .) + +&INBUF .( + ldy #0 +inl sty p + jsr FRBUF + ldy p + iny + cpy #ANZBUF + bcc inl + clc + rts + .) + +&FRBUF ldx #BD_FRE + .byt $2c +&MDBUF ldx #BD_DIRTY + .( + cpy #ANZBUF + bcs cerr + tya + asl + asl + asl + tay + txa + sta bpb+B_DIRT,y + rts +cerr lda #E_ILLPAR + sec + rts + .) +/* +sec2rw .( + sta rwpar+RW_TRCK + stx rwpar+RW_TRCK+1 + clc + rts + .) +*/ + .) + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/cluster.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/cluster.a65 new file mode 100644 index 0000000..59c06da --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/cluster.a65 @@ -0,0 +1,713 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * cluster handling + * + * exports: + * clrclus + * snext + * cl2sec + * gfrebyt + * gfrecl + * gnexcl + * snexcl + */ + + .( + +&clrclus .( + ldy fpuffer + jsr CLBUF + bcs cce + ldy #D_SPC+1 + lda (dzei),y + tax + dey + lda (dzei),y + ldy #F_FSEC + sta (fzei),y + iny + txa + sta (fzei),y +wl ldy #F_FSEC + sec + lda (fzei),y + sbc #1 + tax + iny + lda (fzei),y + sbc #0 + bcc cce + sta (fzei),y + dey + txa + sta (fzei),y + jsr cl2sec + bcs cce + ldy fpuffer + jsr W2BUF ; gets pars from ar2 + bcc wl +cce rts + .) + +&snext .( + ldy #F_FSEC + lda (fzei),y + clc + adc #1 + sta (fzei),y + iny + tax + sta ar1 + lda (fzei),y + adc #0 + sta (fzei),y + sta ar1+1 + + ldy #F_FCL + lda (fzei),y + iny + ora (fzei),y + bne snok + + lda ar1+1 ; bei Cluster =0 + ldy #D_SPD+1 ; nicht �ber Main-Dir lesen + cmp (dzei),y + bcc nexend + bne nexerr + txa + dey + cmp (dzei),y + bcc nexend +nexerr lda #E_NOCLUS + rts + +snok lda ar1+1 + ldy #D_SPC+1 + cmp (dzei),y + bcc nexend + bne next + dey + txa + cmp (dzei),y + bcc nexend +next jsr xclrfsec + ldy #F_FCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + jsr gnexcl + bcs nexrts + ldy #F_FCL + sta (fzei),y + iny + txa + sta (fzei),y +nexend clc +nexrts rts + .) + +&cl2sec .( /* berechnet Sektor aus fpb-Daten -> a/x */ + ldy #F_FCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + bne cd + cpx #0 + bne cd + /* hier bei Main-Directory */ + ldy #F_FSEC+1 + lda (fzei),y + tax + dey + lda (fzei),y + clc + ldy #D_STD + adc (dzei),y + pha + iny + txa + adc (dzei),y + txa + pla + sta ar2 + stx ar2+1 + ldy #0 + sty ar2+2 + sty ar2+3 + clc + rts + +cd sec /* hier bei normalen Files */ + sbc #2 + sta ar1 + txa + sbc #0 + sta ar1+1 + bcs cdok +cerr sec + lda #E_ILLCLUS + rts +cdok + lda #0 + sta ar1+2 + sta ar1+3 + ldy #D_SPC+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr mult32 + bcs cerr + + ldy #F_FSEC ; sector in cluster + adc (fzei),y + sta ar2 + iny + txa + adc (fzei),y + sta ar2+1 + bcc cdo1 + inc ar2+2 + bne cdo1 + inc ar2+3 +cdo1 + clc + ldy #D_STC ; sector of first cluster + lda (dzei),y + adc ar2 + sta ar2 + iny + lda (dzei),y + adc ar2+1 + sta ar2+1 + bcc cdo2 + inc ar2+2 + bne cdo2 + inc ar2+3 +cdo2 + lda ar2+3 ; we only handle 24 bit sector numbers + bne cerr + clc + rts + .) + + + .data +fr1 .word 0 ; cluster +fr2 .word 0 ; sektor +fr3 .word 0 ; pos im sec +fr4 .word 0 ; gesuchter Cluster +fr5 .word 0 ; Startcluster bei suchschleife +fr6 .word 0 ; Anzahl freier Cluster + .zero +fatzei .word 0 + .text + +&gfrebyt .( + lda #2 + ldx #0 + stx fr6 ; Z�hler f�r freie Cluster + stx fr6+1 + + sta fr5 ; Cluster, bis zu dem gesucht wird + stx fr5+1 + sta fr1 ; Cluster, ab dem gesucht wird + stx fr1+1 + +gfl lda fr1 + ldx fr1+1 + jsr gld ; sucht ab a/x bis fr5 + bcs end + + inc fr6 + bne gflx + inc fr6+1 + +gflx jsr incmp ; mu� erh�ht werden, um n�chsten Cluster zu testen + bne gfl ; noch nicht zuende dann weitersuchen + beq gok + +end cmp #E_FDISKFULL + beq gok + sec + rts +gok + lda fr6 + sta ar1 + lda fr6+1 + sta ar1+1 + lda #0 + sta ar1+2 + sta ar1+3 + + ldy #D_SPC+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr mult4 + ldy #D_BPS+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr mult4 + clc + rts + .) + +&gfrecl .( ; a/x =Cluster-1 ab dem gesucht wird + sta fr5 + stx fr5+1 + sta fr1 + stx fr1+1 + + bcc gld + jsr incmp + bne gld +gle lda #E_FDISKFULL + sec + rts + +&gld jsr lfat + bcs grts + + ldy #0 +gl lda (fatzei),y + sta fr4 + + jsr tstend + bcs grts + + lda (fatzei),y + sta fr4+1 + + ldy #D_BFLAG + lda (dzei),y + bne fat16 + + lda fr1 + lsr + bcc gerade + + lda fr4 + and #$f0 + ora fr4+1 + beq found + bne next + +gerade lda fr4+1 ; bei geradem Cluster gleich drei byte + and #$0f ; = 2 Cluster testen + ora fr4 + beq found + + jsr incmp + beq gle + + lda fr4+1 + and #$f0 + sta fr4 + + jsr tstend + bcs grts + + lda (fatzei),y + sta fr4+1 + ora fr4 + beq found + bne next + +fat16 lda fr4 + ora fr4+1 + beq found + +next + jsr incmp + beq gle + jsr tstend + bcs grts + bcc gl + +found lda fr1 + ldx fr1+1 + clc +grts rts + .) + +#ifdef SHOWC +clushow .( + lda fr1+1 + jsr HEXOUT + lda fr1 + jsr HEXOUT + lda #":" + jsr SEROUT + lda fr4+1 + jsr HEXOUT + lda fr4 + jsr HEXOUT + lda #"@" + jsr SEROUT + lda fatzei+1 + jsr HEXOUT + lda fatzei + jsr HEXOUT + lda #"," + jsr SEROUT + txa + jsr HEXOUT + jsr CRLFOUT + rts + .) +#endif + +incmp .( + inc fr1 + bne g1 + inc fr1+1 +g1 lda fr1+1 + ldy #D_CLUS+1 + cmp (dzei),y + bcc gok + bne g0 + dey + lda fr1 + cmp (dzei),y + bcc gok +g0 lda #0 + sta fr1+1 + lda #2 + sta fr1 +gok lda fr1 + ldx fr1+1 + cpx fr5+1 + bne glr + cmp fr5 +glr rts + .) + +&gnexcl .( + jsr lfat + bcs fcerr + + ldy #0 + lda (fatzei),y + sta fr4 + + jsr tstend + bcs fcerr + + lda (fatzei),y + sta fr4+1 + + ldy #D_BFLAG + lda (dzei),y + bne no12 + lda fr1 + lsr + bcc noshft + lda fr4+1 + lsr + ror fr4 + lsr + ror fr4 + lsr + ror fr4 + lsr + ror fr4 + sta fr4+1 +noshft lda fr4+1 + and #$0f + sta fr4+1 + and #%00001000 ; Minus-Bit + beq no12 + lda fr4+1 + ora #$f0 + sta fr4+1 +no12 ldy #D_CLUS+1 + lda fr4+1 + cmp (dzei),y + bcc test2 + bne eof + lda fr4 + dey + cmp (dzei),y + bcs eof +test2 lda fr4 + ldx fr4+1 + bne ok + cmp #2 + bcc illclus +ok clc +fcerr rts +eof lda fr4 + cmp #$ff + bne illclus + cmp fr4+1 + beq nocl +illclus lda #E_ILLCLUS + .byt $2c +nocl lda #E_NOCLUS + sec + rts + .) + +&snexcl .( ; a/x=cluster-Nr, y=zeiger auf zu setzenden Wert in ZP + pha + lda 0,y + sta fr4 + lda 1,y + sta fr4+1 + pla + jsr lfat + bcs fcerr + + ldy #D_BFLAG + lda (dzei),y + bne s1 + lda fr4+1 + and #$0f + sta fr4+1 + lda fr1 + lsr + bcc s1 + lda fr4 + asl + rol fr4+1 + asl + rol fr4+1 + asl + rol fr4+1 + asl + rol fr4+1 + sta fr4 + ldy #0 + lda (fatzei),y + and #$0f + ora fr4 + sta fr4 +s1 ldy #0 + lda fr4 + sta (fatzei),y + ldy drive + jsr MDBUF + + jsr tstend + bcs fcerr + + ldy #D_BFLAG + lda (dzei),y + bne s2 + + lda fr1 + lsr + bcs s2 + ldy #0 + lda (fatzei),y + and #$f0 + ora fr4+1 + sta fr4+1 +s2 ldy #0 + lda fr4+1 + sta (fatzei),y + ldy drive + jsr MDBUF + clc +fcerr rts + .) + +tstend .( + inc fr3 ; increment Zeiger in FAT + bne t1 + inc fr3+1 +t1 inc fatzei + bne t2 + inc fatzei+1 +t2 + lda fr3+1 + ldx fr3 + jsr xcmpfpos ; ist Ende des Puffers ? + bcc fok ; nein + + inc fr2 + bne f2 + inc fr2+1 +f2 lda fr2 + ldx fr2+1 + jsr RDFAT + bcs fcerr + ldx drive + jsr setpadr + sta fatzei + stx fatzei+1 + ldy #0 + sty fr3 + sty fr3+1 +fok ldy #0 + clc +fcerr rts + .) + +lfat .( + sta fr1 + stx fr1+1 + ldy #D_CLUS+1 + txa + cmp (dzei),y + bcc lok + bne lerr + lda fr1 + dey + cmp (dzei),y + bcc lok +lerr lda #E_ILLPAR + rts +lok ldy #D_BFLAG + lda (dzei),y + and #1 + beq fat12 + lda fr1 + asl + sta ar1 + txa + rol + jmp f1 +fat12 lda fr1 + sta fr2 + stx fr2+1 + lsr fr2+1 + ror fr2 + clc + adc fr2 + sta ar1 + txa + adc fr2+1 +f1 sta ar1+1 + lda #0 + sta ar1+2 + sta ar1+3 + ldy #D_BPS+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr div32 + bcc fx + lda #E_ILLPAR + sec + rts +fx sta fr2 ; Sektor in der FAT + stx fr2+1 + ldy ar1 ; Position im Block + sty fr3 + ldy ar1+1 + sty fr3+1 + jsr RDFAT ; l�dt FAT-Block Nr a/x + bcs fcerrx + ldx drive + jsr setpadr + clc + adc fr3 + sta fatzei + txa + adc fr3+1 + sta fatzei+1 + clc +fcerrx rts + .) + +RDFAT .( + ldy #D_STF + clc + adc (dzei),y + sta ar2 + iny + txa + adc (dzei),y + sta ar2+1 + lda #0 + sta ar2+2 + sta ar2+3 + ldy drive + jmp RDBUF + .) + +mult4 .( /* a/x * ar1(4 Byte) -> ar1 (4 Byte) */ + clc + sta ar3 + stx ar3+1 + lda #0 + sta ar2 + sta ar2+1 + sta ar2+2 + sta ar2+3 + txa + ora ar3 + beq mend +mloop + lsr ar3+1 + ror ar3 + bcc mnext + + clc + lda ar1 + adc ar2 + sta ar2 + lda ar1+1 + adc ar2+1 + sta ar2+1 + lda ar1+2 + adc ar2+2 + sta ar2+2 + lda ar1+3 + adc ar2+3 + sta ar2+3 + bcs mend + +mnext lda ar3 + ora ar3+1 + beq mend + + asl ar1 + rol ar1+1 + rol ar1+2 + rol ar1+3 + bcc mloop + +mend lda ar2 + sta ar1 + lda ar2+1 + sta ar1+1 + lda ar2+2 + sta ar1+2 + lda ar2+3 + sta ar1+3 + rts + .) + .) + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/cmd.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/cmd.a65 new file mode 100644 index 0000000..5253026 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/cmd.a65 @@ -0,0 +1,887 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * exports "rename", "rmdir", "delete", "mkdir" + * "dloop", "setfile", "xclrfzei", "sfclus" + * "findfile", "fextend", "format" + */ + + .( + .data +cluster .word 0 +pcl .word 0 + .zero +ezei .word 0 + .text + +&rename .( + jsr inidrv + bcs re + ldy #FS_CMD_NAME + lda #ATTR_CLSD|ATTR_DIR + ldx #0 + jsr findfile ; bei gefunden sind ezei,DCL/DSEC/DPOS gesetzt + bcs re + stx fname+NAME_A + iny + jsr fil2nam + + ldy #F_FCL + lda pcl + sta (fzei),y + iny + lda pcl+1 + sta (fzei),y + + ldx #<-1 + jsr findentry + bcc fexist + cmp #E_NOCLUS + bne re + + jsr d2f + jsr cl2sec + bcs re + ldy fpuffer + jsr RDBUF + bcs re + jsr xadbufpos + sta ezei + stx ezei+1 + + jsr ynam2ezei + bcs err + ldy fpuffer + jsr WABUF +re jmp xfrebuf +fexist lda #E_FILEXIST +err sec + jmp xfrebuf + .) + +&rmdir .( + jsr inidrv + bcs re + ldy #FS_CMD_NAME + lda #ATTR_DIR + ldx #0 + jsr findfile + bcs re + lda #"*" + sta fname+NAME_N + sta fname+NAME_E + lda #ATTR_DIR|ATTR_CLSD|ATTR_HID|ATTR_SYS + sta fname+NAME_A + ldx #<-1 + jsr findentry + bcc rtest + .byt $2c +notempty lda #E_FDNEMPTY + sec +re jmp xfrebuf +rloop jsr findnext + bcs rend +rtest ldy #DE_ATTR + lda (ezei),y + and #ATTR_DIR + beq notempty + ldy #DE_NAME + lda (ezei),y + cmp #"." + bne notempty + iny + lda (ezei),y + cmp #"." + bne r2 + iny +r2 lda (ezei),y + cmp #" " + bne notempty + iny + cpy #DE_ATTR + bcc r2 + bcs rloop + +rend cmp #E_NOCLUS + bne re + jsr d2f + jsr xfcl2fscl + jsr cl2sec + bcs re + ldy fpuffer + jsr RDBUF + bcs re + jsr xadbufpos + sta ezei + stx ezei+1 + jmp xdel + .) + +&delete .( + .data +xfl .byt 0 + .text + + jsr inidrv + bcs de + ldy #FS_CMD_NAME + lda #ATTR_CLSD + ldx #0 + jsr findfile + bcs de + ldx #1 + .byt $2c +&xdel ldx #0 + stx xfl +dl sec + jsr tstlocked + bcs de + ldy #DE_NAME + lda #$e5 ; null ist auf dem PC Endekennzeichen f�r dir + sta (ezei),y + ldy fpuffer + jsr MDBUF + ldy #DE_FCLUS+1 + lda (ezei),y + tax + dey + lda (ezei),y + jsr dloop + bcs endex + ldx xfl + beq ende2 + jsr d2f + jsr findnext + bcc dl + cmp #E_NOCLUS + bne de +ende2 clc +endex php + pha + ldy fpuffer + jsr WABUF + bcs dexx + ldy drive + jsr DWBUF + bcs dexx + pla + plp + jmp xfrebuf +dexx tax + pla + txa + plp +de sec + jmp xfrebuf + + .zero +xzei .word 0 + .text + +&&dloop sta cluster + stx cluster+1 + ldy #0 + sty xzei + sty xzei+1 + jsr gnexcl + bcs dend + sta pcl + stx pcl+1 + lda cluster + ldx cluster+1 + ldy #xzei + jsr snexcl + bcs de + lda pcl + ldx pcl+1 + jmp dloop +dend cmp #E_NOCLUS + bne de + lda cluster + ldx cluster+1 + ldy #xzei + jmp snexcl + .) + +&mkdir .( + jsr inidrv + bcs err + ldy #FS_CMD_NAME + lda #ATTR_DIR + jsr setfile + bcs err + jsr clrclus + bcs err + jsr cl2sec + bcs err + ldy fpuffer + jsr RDBUF + bcs err + ldx fpuffer + jsr setpadr + sta ezei + stx ezei+1 + lda #" " + ldy #1 +m1 sta fname,y + iny + cpy #NAME_A + bcc m1 + lda #"." + sta fname+NAME_N + lda #ATTR_DIR + sta fname+NAME_A + jsr xnam2ezei + ldy #DE_FCLUS + lda cluster + sta (ezei),y + iny + lda cluster+1 + sta (ezei),y + lda #"." + sta fname+NAME_N+1 + lda #DE_SLEN + clc + adc ezei + sta ezei + bcc m2 + inc ezei+1 +m2 jsr xnam2ezei + ldy #DE_FCLUS + lda pcl + sta (ezei),y + iny + lda pcl+1 + sta (ezei),y + ldy fpuffer + jsr WABUF +err jmp xfrebuf + .) + +&setfile .( ; open new file, a=attr, y=pointer to Name in PCBUF-1 + ldx #1 + jsr findfile + bcs sok + lda #E_FILEXIST +errx sec + rts +sok cmp #E_OK + bne errx + jsr d2f ; DCL,DSEC,DPOS nach FCL,FSEC,FPOS = Leerer Eintrag + jsr sfclus ; freien Cluster suchen, belegen und nach a/x bzw cluster + bcs errx + jsr cl2sec ; FCL,FSEC nach a/x=Sektor-Nummer umrechnen + bcs errx + ldy fpuffer + jsr RDBUF ; und Sektor lesen + bcs errx + jsr xadbufpos ; FPOS+Puffer-Adresse nach a/x + sta ezei + stx ezei+1 + ldy #DE_FCLUS ; Cluster speichern im Dir-Eintrag + lda cluster + sta (ezei),y + iny + lda cluster+1 + sta (ezei),y + ldy #DE_SIZE ; L�nge auf Null setzen im Dir-Eintrag + lda #0 + sta (ezei),y + iny + sta (ezei),y + iny + sta (ezei),y + iny + sta (ezei),y + jsr nam2ezei ; Name in Dir-Eintrag + bcs err + + ldy fpuffer ; Puffer speichern + jsr WABUF + bcs err + ldy drive ; f�rs Drive die FAT sichern + jsr DWBUF + bcs err + + ldy #F_FCL ; Startcluster als File-Start setzen + lda cluster + sta (fzei),y + iny + lda cluster+1 + sta (fzei),y + + jsr xfcl2fscl ; und als Startcluster des Files setzen (f�r Lock) + + jsr xclrfsp ; FSEC,FPOS l�schen + lda #0 + ldy #F_LEN ; Dateil�nge im FPB auf Null setzen + sta (fzei),y + iny + sta (fzei),y + iny + sta (fzei),y + iny + sta (fzei),y +&&xclrfzei + ldy #F_FZEI ; Set pointer for read/write to null + lda #0 + sta (fzei),y + iny + sta (fzei),y + iny + sta (fzei),y + iny + sta (fzei),y + clc +err rts + +;free ldy #DE_NAME +; lda #0 +; sta (ezei),y +; lda #E_DISKFULL +; sec +; rts + .) + +&sfclus .( +#ifdef SHOWC + lda #"+" + jsr SEROUT +#endif + lda #2 + ldx #0 + clc + jsr gfrecl ; ab Cluster 1 nach freiem Cluster suchen + bcs errx + sta cluster + stx cluster+1 + ldy #EOFCLUS + sty ezei+1 + ldy #ezei + jsr snexcl ; neuer Cluster kriegt End of File als Folgecluster + bcs errx +#ifdef SHOWC + lda cluster+1 + jsr HEXOUT + lda cluster + jsr HEXOUT + clc +#endif + lda cluster + ldx cluster+1 +errx rts + .) + + .( +namend lda #E_FILLNAM + sec + rts +&nam2ezei + ldx #1 + .byt $2c +&xnam2ezei + ldx #0 + .byt $2c +&ynam2ezei + ldx #<-1 + ldy #0 +md1 lda fname,y + sta (ezei),y + cmp #"*" + beq namend + cmp #"?" + beq namend + cmp #34 + beq namend + cmp #"." + bne md1x + txa + bne namend +md1x iny + cpy #NAME_SLEN + bcc md1 + txa + bpl cendx + clc + rts +cendx lda #0 + ldy #DE_SIZE +md2 sta (ezei),y + iny + cpy #DE_SIZE+4 + bcc md2 + + lda #0 + ldy #5 +c1 sta PCBUF,y + dey + bpl c1 + ldy #1 ; minimale Anzahl Bytes + lda #TI_GET + ldx #SEND_TIME + jsr SEND + bcs cnd ; x-reg ist noch vom Send gesetzt + sec + jsr XRECEIVE +cnd + ; Umwandlung 6 Byte in 4 Byte und dann nach (ezei),DE_TIME/DATE + + lda PCBUF+TE_SG_YEAR + sec + sbc #80 + and #%01111111 + asl + sta ar1 + lda PCBUF+TE_SG_MONTH + and #%00001000 + lsr + lsr + lsr + ora ar1 + ldy #DE_DATE+1 + sta (ezei),y + lda PCBUF+TE_SG_MONTH + and #%00000111 + asl + asl + asl + asl + asl + sta ar1 + lda PCBUF+TE_SG_DAY + and #%00011111 + ora ar1 + ldy #DE_DATE + sta (ezei),y + + lda PCBUF+TE_SG_HOUR + and #%00011111 + asl + asl + asl + sta ar1 + lda PCBUF+TE_SG_MIN + and #%00111000 + lsr + lsr + lsr + ora ar1 + ldy #DE_TIME+1 + sta (ezei),y + lda PCBUF+TE_SG_MIN + and #%00000111 + asl + asl + asl + asl + asl + sta ar1 + lda PCBUF+TE_SG_SEC + and #%00111110 + lsr + ora ar1 + ldy #DE_TIME + sta (ezei),y + +cend clc + rts + + .) + +&findfile .( + .data +xflag .byt 0 +attr .byt 0 +npos .byt 0 + .text + + sta attr ; attribut, nach dem gesucht wird + stx xflag ; x=0 lesen, x=1 leeren Eintrag suchen test file exist + sty npos ; y=position Name in PCBUF + + lda PCBUF,y + cmp #DIRSIGN ; da eh immer bei clus=0 gestartet wird, backslash + bne l1 ; am Anfang ignorieren + inc npos +l1 + jsr xclrfcl + +fl ldy npos + lda PCBUF,y + beq fnoname + jsr xfil2nam + sty npos + + ldy #F_FCL + lda (fzei),y + sta pcl ; pcl ist Startcluster des dirs + iny + lda (fzei),y + sta pcl+1 + + ldy npos + lda PCBUF,y + php + ldx xflag + lda attr + plp + beq f2 + lda #ATTR_DIR + ldx #0 +f2 sta fname+NAME_A + jsr findentry + bcs fe + ldy #DE_ATTR + lda (ezei),y + tax + ldy npos + inc npos + lda PCBUF,y + bne fl + clc +fe rts +fnoname lda #E_FNOFIL + sec + rts + .) + +findentry .( + .data +x2fl .byt 0 +x3fl .byt 0 + .text + + stx x2fl ; x<0 dann nur auf exist testen, F_Dxx nicht �ndern + stx x3fl ; x=1 ist freien Eintrag suchen, x=0 Datei finden + jsr xclrfsec +fnew jsr xclrfpos + + jsr cl2sec + bcs fe + ldy fpuffer + jsr RDBUF + bcc f0 +fe rts + +f0 ldx fpuffer + jsr setpadr + sta ezei + stx ezei+1 + +fl ldy #DE_NAME + lda (ezei),y + beq frex + cmp #$e5 + bne fl2 + jmp fre +frex lda x3fl + bmi frey + beq frey + lda x2fl + beq frez + jsr f2d +frez lda #E_OK + .byt $2c +frey lda #E_NOCLUS + jmp nexend + +fl2 lda fname+NAME_N-DE_NAME,y + cmp #"*" + beq namok + cmp #"?" + beq fl1 + cmp (ezei),y + bne next +fl1 iny + cpy #DE_EXT + bcc fl2 +namok ldy #DE_EXT +fl3 lda fname+NAME_E-DE_EXT,y + cmp #"*" + beq extok + cmp #"?" + beq fl4 + cmp (ezei),y + bne next +fl4 iny + cpy #DE_ATTR + bcc fl3 +extok ldy #DE_ATTR + lda fname+NAME_A + tax + and (ezei),y + bne found + txa + and #ATTR_CLSD + beq next + lda (ezei),y + beq found +&findnext +next lda #DE_SLEN + clc + adc ezei + sta ezei + bcc n1 + inc ezei+1 +n1 lda #DE_SLEN + jsr xadfpos + bcs nexsec + jmp fl +nexsec jsr snext ; sucht bei FCL,FSEC + bcc f0a + cmp #E_NOCLUS + bne nexend + ldx x3fl ; soll keinen leeren suchen + bmi nexend + beq nexend ; dann E_NOCLUS + ldx x2fl ; soll suchen und hat gefunden + beq nexxend ; dann OK und c=1 + jsr fextend + bcs nexend + jsr clrclus ; l�scht Cluster + bcs nexend + jsr f2d +nexxend lda #E_OK +nexend sec + rts +f0a jmp fnew + +fre lda x2fl + bmi next + beq next + jsr f2d + lda #0 + sta x2fl + beq next + +found bit x2fl + bmi fend + jsr f2d + + ldy #DE_FCLUS+1 + lda (ezei),y + tax + dey + lda (ezei),y + ldy #F_FCL + sta (fzei),y + iny + txa + sta (fzei),y + + jsr xfcl2fscl + + ldy #DE_SIZE+1 + lda (ezei),y + tax + dey + lda (ezei),y + ldy #F_LEN + sta (fzei),y + iny + txa + sta (fzei),y + ldy #DE_SIZE+3 + lda (ezei),y + tax + dey + lda (ezei),y + ldy #F_LEN+2 + sta (fzei),y + iny + txa + sta (fzei),y + + jsr xclrfzei + jsr xclrfpos +fend clc + rts + .) + +&fextend .( ; extend file when writing + ldy #F_FCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + bne f1 + cpx #0 ; im Main-Dir nicht m�glich + bne f1 + lda #E_NOCLUS + sec + rts +f1 jsr gnexcl ; n�chsten Cluster der Datei suchen + bcc fok ; + cmp #E_NOCLUS + bne ferr ; Lese- oder sonstwas-Fehler + ldy #F_FCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + sec + jsr gfrecl ; ab letztem Cluster der Datei freien Cluster suchen + bcs ferr ; nicht gefunden + sta ezei + stx ezei+1 + ldy #F_FCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #ezei + jsr snexcl ; und Folgecluster setzen + bcs ferr ; war nix + ldy #F_FCL+1 + lda ezei+1 + sta (fzei),y + dey + tax + lda ezei + sta (fzei),y + ldy #EOFCLUS + sty ezei+1 + ldy #ezei + jsr snexcl ; der neue Cluster kriegt ein End Of File als Folgecluster + bcs ferr + +fok jsr xclrfsp ; FSEC=FPOS=0 + clc + rts +ferr sec + rts + .) + +&format .( + ; ldx PCBUF+FS_CMD_DRV + ; jsr setdzei + ldx drive + jsr dchanged + lda PCBUF+FS_CMD_PFAD + ldx drive + jsr DFORMAT + bcs ferr3 + +#ifdef DEBUGFS +lda #"f":jsr SEROUT +lda drive:jsr HEXOUT +lda dzei+1:jsr HEXOUT:lda dzei:jsr HEXOUT +#endif + ldx drive + jsr GETDPB + bcs ferr3 +;jmp ferr2 + ldy drive +;.byt 2 + jsr CLBUF + bcs ferr3 + ldy #D_STC+1 + lda (dzei),y + sta ezei+1 + dey + lda (dzei),y + sta ezei + +#ifdef DEBUGFS +.( +lda #"c":jsr SEROUT +lda dzei+1:jsr HEXOUT +lda dzei:jsr HEXOUT +lda ezei+1:jsr HEXOUT +lda ezei:jsr HEXOUT +.) +#endif + +fwl sec + lda ezei + sbc #1 + sta ezei + lda ezei+1 + sbc #0 + sta ezei+1 + ora ezei + beq ffat + + lda ezei + ldx ezei+1 + sta ar2 + stx ar2+1 + lda #0 + sta ar2+2 + sta ar2+3 + ldy drive + jsr W2BUF +ferr3 bcs ferr2 + bcc fwl + +ffat lda #<-1 + sta ezei + sta ezei+1 + ldy #ezei + lda #0 + tax + jsr snexcl + bcs ferr2 + lda #1 + ldx #0 + ldy #ezei + jsr snexcl + bcs ferr2 + ldy drive + jsr CLBUF + bcs ferr2 + sta ezei + stx ezei+1 + ldy #FS_CMD_NAME +;.byt 2 + jsr fil2nam + lda #ATTR_DSK + sta fname+NAME_A + jsr nam2ezei + ldy #D_STD+1 + lda (dzei),y + tax + dey + lda (dzei),y + sta ar2 + stx ar2+1 + lda #0 + sta ar2+2 + sta ar2+3 + ldy drive + jsr W2BUF +;.byt 2 + bcs ferr2 + ldy drive + jsr DWBUF +ferr2 rts + .) + + .) + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/defs.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/defs.a65 new file mode 100644 index 0000000..50bc07f --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/defs.a65 @@ -0,0 +1,193 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* additional error codes */ + +#define E_NOCLUS E_LASTERR +#define E_ILLCLUS E_LASTERR-1 +#define E_Q E_LASTERR-2 +#define E_GT E_LASTERR-3 +#define E_RD E_LASTERR-4 +#define E_WR E_LASTERR-5 +#define E_CMD E_LASTERR-6 +#define E_FT E_LASTERR-7 + + +/*************************************************************************/ + +#define ANZFILE 4 +#define ANZDRV 2 +#define ANZBUF (ANZDRV+ANZFILE) +#define BUFLEN 512 /* 1024 */ + +/* Data-structure on the IBM-diskette */ +/* Bootsector */ + +#define BS_SERIAL 8 +#define BS_BPS 11 /* Byte per Sector */ +#define BS_SPC 13 /* Secs/Cluster */ +#define BS_RES 14 /* no of reserved blocks at disk start, incl. bootsector */ +#define BS_FAT 16 /* no of FATs */ +#define BS_DIR 17 /* number of directory entries in root directory */ +#define BS_SEC 19 /* total number of sectors */ +#define BS_MEDIA 21 /* Media-Byte */ +#define BS_SPF 22 /* Secs/FAT */ +#define BS_SPT 24 /* Secs/Track */ +#define BS_SIDE 26 /* no of Sides */ +#define BS_HID 28 /* no of Hidden Blocks */ + +#define BS_SLEN 30 + +/* Last cluster of a file in the FAT */ + +#define EOFCLUS $ffff + +/* Directory-Entry */ + +#define DE_NAME 0 +#define DE_EXT 8 +#define DE_ATTR 11 +#define DE_TIME 22 +#define DE_DATE 24 +#define DE_FCLUS 26 +#define DE_SIZE 28 +#define DE_SLEN 32 + +/* Attribut-values */ + +#define ATTR_WP 1 +#define ATTR_HID 2 +#define ATTR_SYS 4 +#define ATTR_DSK 8 +#define ATTR_DIR 16 +#define ATTR_CLSD 32 + +/* Buffer-Parameter-Block for each buffer */ + +#define B_DRV 0 /* drive */ +#define B_DIRT 1 /* dirty flag (see below) */ +#define B_SECTOR 2 /* sector (four byte) */ +#define B_SLEN 8 /* easier to compute than 6 */ + +#define BD_FRE $ff /* buffer is free */ +#define BD_IFRE $fe /* dirty buffer that has not been saved */ +#define BD_OK 0 /* buffer valid */ +#define BD_DIRTY 1 /* buffer modified */ + +/* File-Parameter-Block for each file */ + +#define F_DRV 0 /* drive */ +#define F_FL 1 /* Flag */ +#define F_DCL 2 /* Cluster of Dir-Entry */ +#define F_DSEC 4 /* Dir-Sector in Cluster */ +#define F_DPOS 6 /* Position of Dir-Entry in sector */ +#define F_FCL 8 /* Cluster of file */ +#define F_FSEC 10 /* Sektor in Cluster */ +#define F_FPOS 12 /* Position in Sektor */ +#define F_LEN 14 /* Datei-Length in Byte */ +#define F_FZEI 18 /* long-pointer in file */ +#define F_STR 22 /* OS Stream */ +#define F_FSCL 23 /* first cluster of file (used for locking) */ +#define F_DLEN 25 /* length of saved filemask */ +#define F_DOUT 26 /* state of directory read */ +#define F_DMASK 27 /* mask for reading directory */ +#define F_FT 27+11 /* OS FS_DIR_* struct to send */ + +/* 27+11+FS_DIR_NAME+13=62 ; Name plus . and Nullbyte are 13 */ +#define F_SLEN 64 + +/* file parameter block flag values */ +#define FF_FRE $ff /* file parameter block is free */ +#define FF_RD 0 /* open for reading */ +#define FF_WR 1 /* open for writing */ +#define FF_DR 2 /* reading directory */ + +/* Drive-Parameter-Block */ + +#define D_ST 0 +#define D_BFLAG 1 /* 0=12 Bit-FAT, 1=16Bit-FAT */ +#define D_BPS 2 /* Byte per Sektor */ +#define D_SPC 4 /* Sektor per Cluster */ +#define D_CLUS 6 /* Clusters on Disk+2 (2 byte) */ +#define D_FPD 8 /* FATs pro Diskette */ +#define D_SPF 10 /* Sektors per FAT */ +#define D_SPD 12 /* Sektors per Main-Dir */ +#define D_STD 14 /* Start of Main-Dir in Sekt. */ +#define D_STC 16 /* Start of first Datacluster.*/ +#define D_SPTS 18 /* (Sektoren/Track)*Seiten = sec/cyclinder */ +#define D_SPT 20 /* Sektors per Track */ +#define D_STF 22 /* Start of first FAT */ +#define D_SECS 24 /* Sektors on the disk (4 byte) */ + +#define D_SLEN 32 /* room for extensions... */ + +#define DS_INV $ff +#define DS_OK 0 + +/* + Sektor =Cluster*SPC+SektorInCluster+STC + except if Cluster=0 then + Sektor =SektorInCluster+STD + + Zylinder=Sektor/SPTS + Side=(Sektor mod SPTS)/SPT + SektorInTrack=((Sektor mod SPTS) mod SPT) +*/ + +/* Struktur fname */ + +#define NAME_N 0 +#define NAME_E 8 +#define NAME_A 11 +#define NAME_SLEN 12 + +/* Parameter for calling RWSEC */ + +#define RW_DRV 0 +#define RW_SIDE 1 +#define RW_SECTOR 2 /* 4 byte */ +/* +#define RW_TRCK 2 +#define RW_SEC 4 +*/ +#define RW_ADR 6 +#define RW_SLEN 8 + +/* Parameter for calling RWABS */ + +#define ABS_DRV 0 +#define ABS_FL 1 +#define ABS_SEC 2 +#define ABS_SLEN 6 + +/* Parameter for calling DFORMAT */ + +#define FMT_VIRG 0 +#define FMT_SIDES 1 +#define FMT_TRCKS 2 +#define FMT_HDFL 3 +#define FMT_BLEN 4 +#define FMT_SCLST 5 /* Anzahl Sektoren+1, sekt1, sekt2, sekt3... */ + + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/drive.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/drive.a65 new file mode 100644 index 0000000..893ad88 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/drive.a65 @@ -0,0 +1,288 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* handles the internal Drive parameter block tables + * + * Exports: + * bootdpb read the boot sector and fill in the DPB + */ + + .( + .zero +zei .word 0 + .text + +&boot2dpb .( + ldy #D_ST + lda (dzei),y + bne get + clc + rts +get lda #DS_INV + sta (dzei),y +#ifdef DEBUGFS +lda #"g":jsr SEROUT +lda drive:jsr HEXOUT +#endif + ldy drive + lda #0 + sta ar2 + sta ar2+1 + sta ar2+2 + sta ar2+3 + jsr RDBUF + bcc g1 + rts +g1 ldx drive + jsr setpadr + sta zei + stx zei+1 + + /* bytes per sector */ + ldy #BS_BPS+1 + lda (zei),y + tax + dey + lda (zei),y + ldy #D_BPS + sta (dzei),y + iny + txa + sta (dzei),y + + /* sectors per cluster */ + ldy #BS_SPC + lda (zei),y + ldy #D_SPC + sta (dzei),y + iny + lda #0 + sta (dzei),y + + /* reserved blocks -> start of FAT */ + ldy #BS_RES+1 + lda (zei),y + tax + dey + lda (zei),y + ldy #D_STF + sta (dzei),y + iny + txa + sta (dzei),y + + /* sectors per track */ + ldy #BS_SPT+1 + lda (zei),y + sta ar1+1 + tax + dey + lda (zei),y + sta ar1 + ldy #D_SPT + sta (dzei),y + iny + txa + sta (dzei),y + + /* sec/tr * sieds -> sectors per cylinder */ + ldy #BS_SIDE+1 + lda (zei),y + tax + dey + lda (zei),y + jsr mult + bcs gerr2 + ldy #D_SPTS + sta (dzei),y + iny + txa + sta (dzei),y + + /* total numbers of sector */ + ldy #BS_SEC+1 + lda (zei),y + tax + dey + lda (zei),y + ldy #D_SECS + sta (dzei),y + iny + txa + sta (dzei),y + +#ifdef FSIBM_SECTOR24BIT + ldy #BS_SEC+2 /* "misuse" MEDIA byte */ + lda (zei),y +#else + lda #0 +#endif + ldy #D_SECS+2 + sta (dzei),y + iny + lda #0 + sta (dzei),y + + /* number of FATs -> FAT/disk */ + ldy #BS_FAT + lda (zei),y + ldy #D_FPD + sta (dzei),y + iny + lda #0 + sta (dzei),y + + /* sec / fat */ + ldy #BS_SPF+1 + lda (zei),y + tax + dey + lda (zei),y + ldy #D_SPF + sta (dzei),y + iny + txa + sta (dzei),y + + /* number of dir entries in main dir * 32 / BPS -> sectors for dir */ + ldy #BS_DIR+1 + lda (zei),y + sta ar1+1 + dey + lda (zei),y + sta ar1 + lda #32 + ldx #0 + jsr mult + bcs gerrx + sta ar1 + stx ar1+1 + ldy #D_BPS+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr div +gerr2 bcs gerrx + ldy #D_SPD + sta (dzei),y + iny + txa + sta (dzei),y + + /* sec/fat * fat/disk + start of FAT + sec/dir -> first data cl. */ + ldy #D_SPF + lda (dzei),y + sta ar1 + iny + lda (dzei),y + sta ar1+1 + ldy #D_FPD+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr mult +gerrx bcs gerry + ldy #D_STF + adc (dzei),y + pha + iny + txa + adc (dzei),y + tax + ldy #D_STD+1 + sta (dzei),y + dey + pla + sta (dzei),y + clc + ldy #D_SPD + adc (dzei),y + pha + iny + txa + adc (dzei),y + ldy #D_STC+1 + sta (dzei),y + dey + pla + sta (dzei),y + + /* (#sectors - first sector) / sec/cluster + 2 -> #clusters */ + ldy #D_SECS+1 + lda (dzei),y + tax + dey + lda (dzei),y + ldy #D_STC + sec + sbc (dzei),y + sta ar1 + txa + iny + sbc (dzei),y + sta ar1+1 + ldy #D_SECS+2 + lda (dzei),y + sbc #0 + sta ar1+2 + iny + lda (dzei),y + sbc #0 + sta ar1+3 + + ldy #D_SPC+1 + lda (dzei),y + tax + dey + lda (dzei),y + jsr div32 +gerry bcs gerr + tay + lda ar3+2 + ora ar3+3 + bne gerr /* number of clusters must be 2 byte */ + tya + clc + adc #2 + bcc g2 + inx + beq gerr /* number of clusters must be 2 byte */ +g2 ldy #D_CLUS + sta (dzei),y + iny + txa + sta (dzei),y + + clc + rts +gerr lda #E_ILLPAR + sec + rts + .) + + .) + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/drv_ramd1.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/drv_ramd1.a65 new file mode 100644 index 0000000..029e1db --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/drv_ramd1.a65 @@ -0,0 +1,170 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* linear ramdisk driver */ + +/* + * Driver for a simple RAM disk. You write side, track and sector + * into three memory locations and the corresponding sector is + * mapped to another memory location. There is can be read or written. + * + * Exports + * + * DLOOP + * DINIT + * RWSEC + * DFORMAT + * GETDPB + * + * Imports (calls): + * + * dchanged + * + */ + +#define RAMD_DRV $e870 +#define RAMD_SECTOR $e871 /* 3 byte */ + +#define RAMD_DATA $ec00 + + .( + + .zero +zei .word 0 +zeid .word 0 + .text + +&DLOOP rts ; not needed + +INVDPB .( ; x ist Drive + txa + jsr setdzei + ldy #D_ST + lda #DS_INV + sta (dzei),y + clc + rts + .) + +&DINIT clc ; oh, what shall we do.... + ldx #0 +il stx zei + jsr INVDPB + ldx zei + inx + cpx #ANZDRV + bcc il + clc + rts + +&DFORMAT + ldx drive + jsr INVDPB + clc + rts + rts + +&GETDPB + cpx #1 + bcs illpar + jsr boot2dpb + ldy #D_ST + lda #DS_OK + sta (dzei),y + ldy #D_BFLAG + lda #0 ; 0 -> 12 bit FAT + sta (dzei),y + clc + rts +illpar lda #E_ILLPAR + sec + rts + +&RWSEC + php + sta zei + sty zei+1 + + ldy #RW_ADR + lda (zei),y + sta zeid + iny + lda (zei),y + sta zeid+1 + + ldy #RW_DRV + lda (zei),y +; bne notimp + sta RAMD_DRV + ldy #RW_SECTOR + lda (zei),y + sta RAMD_SECTOR + iny + lda (zei),y + sta RAMD_SECTOR+1 + iny + lda (zei),y + sta RAMD_SECTOR+2 + iny + lda (zei),y + bne rwerr + + plp + bcs write + +read .( + ldy #0 +rl1 lda RAMD_DATA,y + sta (zeid),y + iny + bne rl1 + inc zeid+1 +rl2 lda RAMD_DATA + $100,y + sta (zeid),y + iny + bne rl2 + clc + rts + .) + +write .( + ldy #0 +rl1 lda (zeid),y + sta RAMD_DATA,y + iny + bne rl1 + inc zeid+1 +rl2 lda (zeid),y + sta RAMD_DATA + $100,y + iny + bne rl2 + clc + rts + .) + +rwerr plp + sec + rts + .) + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/drv_ramd2.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/drv_ramd2.a65 new file mode 100644 index 0000000..de3378f --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/drv_ramd2.a65 @@ -0,0 +1,259 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* drv/track/sector driver ramdisk */ + +/* + * Driver for a simple RAM disk. You write side, track and sector + * into three memory locations and the corresponding sector is + * mapped to another memory location. There is can be read or written. + * + * Exports + * + * DLOOP + * DINIT + * RWSEC + * DFORMAT + * GETDPB + * + * Imports (calls): + * + * dchanged + * + */ + +#define RAMD_DRV $e870 +#define RAMD_SIDE $e871 +#define RAMD_TRACK $e872 +#define RAMD_SEC $e873 + +#define RAMD_DATA $ec00 + + .( + + .zero +zei .word 0 +zeid .word 0 +ddzei .word 0 + .text + +&DLOOP rts ; not needed + +#if D_SLEN=32 +setddzei /* AC=Drv-Nr */ + asl + asl + asl + asl + asl + clc + adc #dpb + sta ddzei+1 + clc + rts +#endif + +sec2rw .( + ldy #RW_DRV + lda (zei),y + jsr setddzei + + ldy #RW_TRCK+1 + lda (zei),y + sta ar1+1 + dey + lda (zei),y + sta ar1 + ora ar1+1 + bne notboot + + ;lda #0 + ldy #RW_SIDE +s2rl sta (zei),y + iny + cpy #RW_ADR + bcc s2rl + ldy #RW_SEC + lda #1 + sta (zei),y + clc + rts + +notboot ldy #D_SECS+1 + txa + cmp (ddzei),y + bcc sok + bne serr + dey + lda ar1 + cmp (ddzei),y + bcs serr +sok + ldy #D_SPTS+1 + lda (ddzei),y + tax + dey + lda (ddzei),y + jsr div + bcs serr + ldy #RW_TRCK + sta (zei),y + iny + txa + sta (zei),y + ldy #D_SPT+1 + lda (ddzei),y + tax + dey + lda (ddzei),y + jsr div + bcs serr + ldy #RW_SIDE + sta (zei),y + txa + bne serr + clc + lda ar1 + adc #1 + ldy #RW_SEC + sta (zei),y + iny + lda ar1+1 + adc #0 + sta (zei),y + rts +serr sec + rts + .) + +INVDPB .( ; x ist Drive + txa + jsr setdzei + ldy #D_ST + lda #DS_INV + sta (dzei),y + clc + rts + .) + +&DINIT clc ; oh, what shall we do.... + ldx #0 +il stx zei + jsr INVDPB + ldx zei + inx + cpx #ANZDRV + bcc il + clc + rts + +&DFORMAT + ldx drive + jsr INVDPB + clc + rts + rts + +&GETDPB + cpx #1 + bcs illpar + jsr boot2dpb + ldy #D_ST + lda #DS_OK + sta (dzei),y + ldy #D_BFLAG + lda #0 ; 0 -> 12 bit FAT + sta (dzei),y + clc + rts + +illpar lda #E_ILLPAR + sec + rts + +&RWSEC + php + sta zei + sty zei+1 + + jsr sec2rw + + ldy #RW_ADR + lda (zei),y + sta zeid + iny + lda (zei),y + sta zeid+1 + + ldy #RW_DRV + lda (zei),y + sta RAMD_DRV + ldy #RW_TRCK + lda (zei),y + sta RAMD_TRACK + ldy #RW_SIDE + lda (zei),y + sta RAMD_SIDE + ldy #RW_SEC + lda (zei),y + sta RAMD_SEC + + plp + bcs write + +read .( + ldy #0 +rl1 lda RAMD_DATA,y + sta (zeid),y + iny + bne rl1 + inc zeid+1 +rl2 lda RAMD_DATA + $100,y + sta (zeid),y + iny + bne rl2 + clc + rts + .) + +write .( + ldy #0 +rl1 lda (zeid),y + sta RAMD_DATA,y + iny + bne rl1 + inc zeid+1 +rl2 lda (zeid),y + sta RAMD_DATA + $100,y + iny + bne rl2 + clc + rts + .) + + .) + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/file.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/file.a65 new file mode 100644 index 0000000..ec0453f --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/file.a65 @@ -0,0 +1,944 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + + .( + .zero +rwzei .word 0 + .text + +&INIFPB .( + ldx #0 +i1 jsr setfzei + ldy #F_FL + lda #FF_FRE + sta (fzei),y + inx + cpx #ANZFILE + bcc i1 + clc + rts + .) + +&suchfile .( + ldx #0 +s1 jsr setfzei + ldy #F_FL + lda (fzei),y + bmi found + inx + cpx #ANZFILE + bcc s1 + lda #E_FNOFIL + ;rts +found ;ldy fpuffer + ;jsr FRBUF + rts + .) + +&IDFIL .( + stx ar1 + ldx #0 +i1 jsr setfzei + + ldy #F_DRV + lda (fzei),y + cmp ar1 + bne i2 + ldy #F_FL + lda (fzei),y + bmi i2 + cmp #FF_RD + bne i3 + jsr clsrd + jmp i2 +i3 cmp #FF_WR + bne i4 + jsr clswrx + jmp i2 +i4 cmp #FF_DR + bne i2 + jsr clsdr ; das gleiche wie bei read + +i2 ldx file + inx + cpx #ANZFILE + bcc i1 + clc + rts + .) + +&tstlocked .( +xfile =ar1 +xdrv =ar1+1 +cl =ar2 +xfl2 =ar3 + + ldx #0 ; c=0 testet ob file zum schreiben offen ist + bcc tl1 + ldx #1 ; c=1 testet ob file ueberhaupt offen ist +tl1 stx xfl2 + lda file ; neues file merken + sta xfile + + ldy #F_DRV + lda (fzei),y + sta xdrv ; drive merken + ldy #F_FSCL + lda (fzei),y + sta cl ; und startcluster + iny + lda (fzei),y + sta cl+1 +#ifdef SHOWL + lda #"t" + jsr SEROUT +#endif + ldx #0 ; start test mit file = 0 +tll stx file + cpx xfile ; ist neues file + beq next ; dann weiter + jsr setfzei ; fzei setzen +#ifdef SHOWL + lda #"x" + jsr SEROUT +#endif + ldy #F_FL + lda (fzei),y + bmi next ; file nicht offen dann weiter + ldy #F_DRV + lda xdrv + cmp (fzei),y + bne next ; drive nicht gleich dann weiter + ldy #F_FSCL + lda cl + cmp (fzei),y + bne next ; startcluster nicht gleich dann weiter + lda cl+1 + iny + cmp (fzei),y + beq fnd ; ist gleich dann gefunden +next +#ifdef SHOWL + lda #"n" + jsr SEROUT +#endif + ldx file + inx ; naechstes file testen + cpx #ANZFILE + bcc tll ; nicht zuende dann loop + ldx xfile ; zeiger fuer neues file setzen + jsr setfzei + clc ; alles ok + rts +fnd +#ifdef SHOWL + lda #"f" + jsr SEROUT + lda file + jsr HEXOUT +#endif + ldx xfl2 ; auf ueberhaupt offen testen + bne err ; ja dann error + ldy #F_FL + lda (fzei),y + cmp #FF_RD ; file ist nur zum lesen offen + beq next ; dann doch weiter +err +#ifdef SHOWL + lda #"l" + jsr SEROUT + lda #"o" + jsr SEROUT +#endif + ldx xfile + jsr setfzei + lda #E_FLOCKED + sec + rts + .) + +&inidrv .( + jsr suchfile + bcs oerr + lda PCBUF+FS_OPEN_DRV + ldy #F_DRV + sta (fzei),y + tax + jsr GETDPB +oerr rts + .) + +&openow .( + jsr inidrv + bcs oerrx + lda PCBUF+FS_OPEN_STR + ldy #F_STR + sta (fzei),y + lda #ATTR_CLSD + ldy #FS_OPEN_NAME + jsr findfile + bcc x1 + jmp openwr +x1 sec + jsr tstlocked + bcs oerrx + jsr d2f + jsr cl2sec + bcs oerrx + ldy fpuffer + jsr RDBUF + bcs oerrx + jsr xadbufpos + sta rwzei + stx rwzei+1 + ldy fpuffer + jsr MDBUF + ldy #DE_SIZE + lda #0 + sta (rwzei),y + iny + sta (rwzei),y + iny + sta (rwzei),y + iny + sta (rwzei),y + ldy #DE_FCLUS+1 + lda (rwzei),y + tax + lda #<-1 + sta (rwzei),y + dey + lda (rwzei),y + pha + lda #<-1 + sta (rwzei),y + pla + jsr dloop + bcs oerr1 +oerrx bcs oerr + jsr sfclus + bcs oerr1 + ldy #DE_FCLUS + sta (rwzei),y + ldy #F_FCL + sta (fzei),y + iny + txa + sta (fzei),y + ldy #DE_FCLUS+1 + sta (rwzei),y + jsr xfcl2fscl + jsr xclrfsp + ldy drive + jsr DWBUF +oerr1 pha + php + ldy fpuffer + jsr WABUF + bcs xo + plp + pla + bcc opw + .byt $2c +xo plp + pla +oerr sec + jmp xfrebuf + .) + +&openwr .( + jsr inidrv + bcs oerr + lda PCBUF+FS_OPEN_STR + ldy #F_STR + sta (fzei),y + lda #ATTR_CLSD + ldy #FS_OPEN_NAME + jsr setfile + bcs oerr +&opw lda #FF_WR + ldy #F_FL + sta (fzei),y + clc + rts +oerr sec + jmp xfrebuf + .) + +&opendr .( + jsr inidrv + bcs oerr + lda PCBUF+FS_OPEN_STR + ldy #F_STR + sta (fzei),y + + lda #0 + sta rwzei + ldy #FS_OPEN_NAME-1 +od1 iny + lda PCBUF,y + beq od2 + cmp #DIRSIGN + bne od1 + sty rwzei + beq od1 +od2 lda #0 + ldy rwzei + beq nonam + sta PCBUF,y + + lda #ATTR_DIR + ldy #FS_OPEN_NAME + ldx #0 + jsr findfile + bcc ok + cmp #E_FNOFIL + bne oerr +nonam jsr xclrf + jsr f2d +ok + ldy rwzei + bne a2 + ldy #FS_OPEN_NAME-1 +a2 iny + lda PCBUF,y + beq all + jsr xfil2nam + ldx #0 + ldy #F_DMASK +o1 lda fname,x + sta (fzei),y + iny + inx + cpx #NAME_A + bcc o1 + bcs weiter +all ldy #F_DMASK +a1 lda fall-F_DMASK,y + beq weiter + sta (fzei),y + iny + bne a1 +weiter + lda #0 + ldy #F_DLEN + sta (fzei),y + ldy #F_DOUT + sta (fzei),y + lda #FS_DIR_MOD_FIL + ldy #F_FT+FS_DIR_MODE + sta (fzei),y + ldy #F_FL + lda #FF_DR + sta (fzei),y + clc + rts +oerr sec + jmp xfrebuf + +fall .asc "* * ",0 + .) + +&openrd .( + jsr inidrv + bcs oerr + lda PCBUF+FS_OPEN_STR + ldy #F_STR + sta (fzei),y + lda #ATTR_CLSD + ldy #FS_OPEN_NAME + ldx #0 + jsr findfile + bcs oerr + ;clc + jsr tstlocked + bcs oerr + jsr tstsize + bcc oset + ldx PCBUF+FS_OPEN_STR + lda #SC_EOF + jsr STRCMD + rts ; E_OK bei L�nge = 0 +oset lda #FF_RD + ldy #F_FL + sta (fzei),y + clc +oerr jmp xfrebuf + .) + +&fileloop .( + .data +cnt .byt 0 +fcnt .byt 0 + .text + + ldx #0 + stx fcnt +loop stx cnt + jsr setfzei + ldy #F_FL + lda (fzei),y + bmi next + inc fcnt ; count number of open files + cmp #FF_RD + bne l1 + jsr xfread + jmp next +l1 cmp #FF_WR + bne l2 + jsr xfwrite + jmp next +l2 cmp #FF_DR + bne next + jsr fdir +next ldx cnt + inx + cpx #ANZFILE + bcc loop + lda fcnt ; und mit z-Flag �bergeben + rts + .) + +xfread .( + ldy #F_DRV + lda (fzei),y + tax + jsr GETDPB + bcs clsrd +rdloop jsr cl2sec + bcs clsrd + ldy fpuffer + jsr RDBUF + jsr xadbufpos + sta rwzei + stx rwzei+1 + +bloop ldy #F_STR + lda (fzei),y + tax + ldy #0 + lda (rwzei),y + jsr PUTC + bcc nextb + cmp #E_NUL + beq clsrd + rts +nextb ldy #F_FZEI + lda #1 + clc + adc (fzei),y + sta (fzei),y + iny + lda #0 + adc (fzei),y + sta (fzei),y + iny + lda #0 + adc (fzei),y + sta (fzei),y + iny + lda #0 + adc (fzei),y + sta (fzei),y + + jsr tstsize + bcc n1 + +&clsrd ldy fpuffer + jsr FRBUF + ldy #F_STR + lda (fzei),y + tax + lda #SC_EOF + jsr STRCMD + ldy #F_FL + lda #FF_FRE + sta (fzei),y + rts + +n1 lda #1 + jsr xadfpos ; x=lo a=hi neue pos + bcs nextsec + + inc rwzei + bne f2 + inc rwzei+1 +f2 jmp bloop + +nextsec jsr snext + bcs clsrd + jsr xclrfpos + jmp rdloop + .) + +tstsize .( + ldy #F_FZEI+3 + lda (fzei),y + ldy #F_LEN+3 + cmp (fzei),y + bcc n1 + bne clsrdx + dey + lda (fzei),y + ldy #F_FZEI+2 + cmp (fzei),y + bcc clsrdx + bne n1 + dey + lda (fzei),y + ldy #F_LEN+1 + cmp (fzei),y + bcc n1 + bne clsrdx + dey + lda (fzei),y + ldy #F_FZEI + cmp (fzei),y + bcc clsrdx + bne n1 +clsrdx sec + rts +n1 clc + rts + .) + +xfwrite .( + ldy #F_DRV + lda (fzei),y + tax + jsr GETDPB + bcs clswrx +sloop jsr xadbufpos + sta rwzei + stx rwzei+1 + +bloop ldy #F_STR + lda (fzei),y + tax + jsr GETC + bcc bytok + cmp #E_EOF + bne wrts +clswr jsr cl2sec + bcs clswrx + ldy fpuffer + jsr W1BUF + jsr d2f + jsr cl2sec + bcs clswrx + ldy fpuffer + jsr RDBUF + jsr xadbufpos + sta rwzei + stx rwzei+1 + ldy #F_LEN+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #DE_SIZE + sta (rwzei),y + iny + txa + sta (rwzei),y + ldy #F_LEN+3 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #DE_SIZE+2 + sta (rwzei),y + iny + txa + sta (rwzei),y + ldy fpuffer + jsr WABUF + ldy drive + jsr DWBUF +&clswrx ldy fpuffer + jsr FRBUF + ldy #F_FL + lda #FF_FRE + sta (fzei),y + ldy #F_STR + lda (fzei),y + tax + lda #SC_NUL + jsr STRCMD +wrts clc + rts +bytok ldy #0 ; Byte empfangen + sta (rwzei),y + + lda #1 ; Dateil�nge um eins erh�hen + clc + ldy #F_LEN + adc (fzei),y + sta (fzei),y + iny + lda #0 + adc (fzei),y + sta (fzei),y + iny + lda #0 + adc (fzei),y + sta (fzei),y + iny + lda #0 + adc (fzei),y + sta (fzei),y + lda #1 ; FPOS+=1 + jsr xadfpos + bcs nexsec ; Ende des Sektors erreicht? + + inc rwzei + bne r1 + inc rwzei+1 +r1 jmp bloop + +nexsec jsr cl2sec ; FCL,FSEC nach a/x + bcs clswry + ldy fpuffer + jsr W1BUF ; Puffer schreiben + bcs clswry + jsr xclrfpos ; FPOS l�schen + lda #1 ; FSEC +=1 + ldy #F_FSEC + clc + adc (fzei),y + sta (fzei),y + tax + iny + lda #0 + adc (fzei),y + sta (fzei),y + ldy #D_SPC+1 ; Ende des Clusters erreicht? + cmp (dzei),y + bcc r2 + bne fex + dey + txa + cmp (dzei),y + bcc r2 ; nein dann r2 +fex jsr fextend ; Datei erweitern + bcs clswry +r2 jmp sloop +clswry jmp clswr + .) + +convert .( + ldy #DE_NAME + lda (rwzei),y + beq cerr + cmp #$e5 + bne cok +cerr sec + rts + +cok ldy #DE_ATTR + lda (rwzei),y + tax + and #$10 + bne cdir + txa + and #8 + bne cnam + lda #FS_DIR_MOD_FIL + .byt $2c +cnam lda #FS_DIR_MOD_NAM + .byt $2c +cdir lda #FS_DIR_MOD_DIR + ldy #F_FT+FS_DIR_MODE + sta (fzei),y + cmp #FS_DIR_MOD_NAM + beq ok + + ldy #DE_NAME + sty ar1 + ldy #F_DMASK + sty ar2 + ldx #0 +tl ldy ar2 + lda (fzei),y + cmp #"*" + beq tnok + cmp #"?" + beq tnn + ldy ar1 + cmp (rwzei),y + bne ende1 +tnn inc ar1 + inc ar2 + inx + cpx #8 + bcc tl +tnok ldy #DE_EXT + sty ar1 + ldy #F_DMASK+8 + sty ar2 + ldx #0 +tel ldy ar2 + lda (fzei),y + cmp #"*" + beq ok + cmp #"?" + beq ten + ldy ar1 + cmp (rwzei),y + bne ende1 +ten inc ar1 + inc ar2 + inx + cpx #3 + bcc tel + bcs ok +ende1 lda #<-1 + sec + rts + +ok ldy #DE_NAME + sty ar1 + ldy #F_FT+FS_DIR_NAME + sty ar2 + ldx #0 + stx ar3 +cnl ldy ar1 + lda (rwzei),y + inc ar1 + ldy ar2 + sta (fzei),y + inc ar2 + cmp #0 + beq cnle + cmp #"." + bne cnl2 + sta ar3 +cnl2 inx + cpx #8 + bne cnl1 + lda #"." + cmp ar3 + bne cnl3 + lda #" " +cnl3 iny + sta (fzei),y + inc ar2 +cnl1 cpx #11 + bcc cnl + lda #0 + iny + sta (fzei),y +cnle iny + tya + + ldy #F_DLEN + sta (fzei),y + + ldy #DE_SIZE+1 + lda (rwzei),y + tax + dey + lda (rwzei),y + ldy #F_FT+FS_DIR_LEN + sta (fzei),y + iny + txa + sta (fzei),y + ldy #DE_SIZE+3 + lda (rwzei),y + tax + dey + lda (rwzei),y + ldy #F_FT+FS_DIR_LEN+2 + sta (fzei),y + iny + txa + sta (fzei),y + + ldy #DE_TIME + lda (rwzei),y + sta ar1 + and #%00011111 + asl + ldy #F_FT+FS_DIR_SEC + sta (fzei),y + ldy #DE_TIME+1 + lda (rwzei),y + sta ar1+1 + asl ar1 + rol + asl ar1 + rol + asl ar1 + rol + and #%00111111 + ldy #F_FT+FS_DIR_MIN + sta (fzei),y + lda ar1+1 + lsr + lsr + lsr + ldy #F_FT+FS_DIR_HOUR + sta (fzei),y + + ldy #DE_DATE + lda (rwzei),y + sta ar1 + and #%00011111 + ldy #F_FT+FS_DIR_DAY + sta (fzei),y + ldy #DE_DATE+1 + lda (rwzei),y + sta ar1+1 + asl ar1 + rol + asl ar1 + rol + asl ar1 + rol + and #%00001111 + ldy #F_FT+FS_DIR_MONTH + sta (fzei),y + lda ar1+1 + lsr + clc + adc #80 + ldy #F_FT+FS_DIR_YEAR + sta (fzei),y + +&setout lda #F_FT + ldy #F_DOUT + sta (fzei),y + clc + rts + .) + +fdir .( + ldy #F_DRV + lda (fzei),y + tax + jsr GETDPB + bcs clsdr + +bloop ldy #F_STR + lda (fzei),y + tax + ldy #F_DOUT + lda (fzei),y + beq first + ldy #F_DLEN + cmp (fzei),y + bcs nextentry + tay + lda (fzei),y + jsr PUTC + bcc nextb + cmp #E_NUL + beq clsdr + rts +nextb lda #1 + clc + ldy #F_DOUT + adc (fzei),y + sta (fzei),y + jmp bloop + +&clsdr ldy fpuffer + jsr FRBUF + ldy #F_STR + lda (fzei),y + tax + lda #SC_EOF + jsr STRCMD + ldy #F_FL + lda #FF_FRE + sta (fzei),y + rts + +nextentry ldy #F_FT+FS_DIR_MODE + lda (fzei),y + cmp #FS_DIR_MOD_FRE + beq clsdr ; dann war freebyte als letztes + lda #DE_SLEN + jsr xadfpos ; x=lo a=hi neue pos + bcc fok + + jsr snext + bcc first + cmp #E_NOCLUS + bne clsdr + beq clsdrx +first jsr xclrfpos + jsr cl2sec + bcs clsdr + ldy fpuffer + jsr RDBUF + bcs clsdr + +fok jsr xadbufpos + sta rwzei + stx rwzei+1 + jsr convert + bcc xl + cmp #0 + bne nextentry + beq clsdrx +xl jmp bloop +clsdrx +/*#ifdef SHOW + lda #"g" + jsr SEROUT +#endif*/ + jsr gfrebyt +/*#ifdef SHOW + php + pha + jsr HEXOUT + pla + plp +#endif*/ + bcs clsdr + ldy #F_FT+FS_DIR_LEN + ldx #0 +c1 lda ar1,x + sta (fzei),y + iny + inx + cpx #4 + bne c1 + ldy #F_FT+FS_DIR_MODE + lda #FS_DIR_MOD_FRE + sta (fzei),y + ldy #F_FT+FS_DIR_NAME + lda #0 + sta (fzei),y + iny + tya + ldy #F_DLEN + sta (fzei),y + jsr setout + jmp bloop + .) + .) + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/loop.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/loop.a65 new file mode 100644 index 0000000..5dbcbbe --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/loop.a65 @@ -0,0 +1,183 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + + +PRG .( + .data +owntask .byt 0 +client .byt 0 +lflag .byt 0 + .text + + stx owntask + sec + +#ifdef FSIBM_AS_INIT + clc + ldx #SEM_SENDBUF + jsr PSEM +#endif + +;.byt 2 +lda #"A":jsr SEROUT + + ldx #SEM_IBMDISK + jsr PSEM + bcs rel_term + + jsr init +;jmp pe + bcs pe + +lda #"I":jsr SEROUT + lda #ANZDRV + sta PCBUF+FM_REG_DRVS + lda owntask + sta PCBUF+FM_REG_ENV + lda #FM_REG + ldx #SEND_FM + ldy #2 + jsr SEND + bcc gloop +pe + pha + ldx #SEM_IBMDISK + jsr VSEM + pla +rel_term +lda #"T":jsr SEROUT + ldx #SEM_SENDBUF + jsr VSEM +;rts + jmp TERM + +gloop + php + ldx #SEM_SENDBUF + jsr VSEM + plp + +lda #"L":jsr SEROUT + +loop jsr YIELD + clc + jsr RECEIVE + bcs l1 +l2 jsr rxmess + +l1 jsr DLOOP + sta lflag ; Anzahl drives mit Motor on + + jsr fileloop + ora lflag ; Anzahl offener files + + bne loop ; sind noch dateien offen dann bei RECEIVE no wait + + sec + jsr RECEIVE ; ansonsten warten bis command oder open + bcs l1 + pha + stx client + jsr DLOOP ; vor ausf�hrung auf Disk-Change testen + ldx client + pla + jmp l2 + +rxmess .( + stx client + pha + ldx PCBUF+FS_OPEN_DRV + jsr setdzei + pla + jsr rxjmp + bcs err + lda #E_OK +err sta PCBUF+FS_X_ERR +#ifdef DEBUGFS + pha + lda #"E" + jsr SEROUT + pla + pha + jsr HEXOUT + jsr CRLFOUT + pla +#endif + ldx owntask + stx PCBUF+FS_X_ENV + ldy file + sty PCBUF+FS_X_FIL + ldy #FS_X_SLEN + ldx client + jmp SEND + +notimp lda #E_NOTIMP + sec + rts + +rxjmp ldy #0 +rjl cmp rcmd,y + beq rjok + iny + cpy #9 + bcc rjl + bcs notimp + +rjok tya + asl + tay + lda rtab+1,y + pha + lda rtab,y + pha + rts + +rcmd .byt FS_OPEN_RD,FS_OPEN_WR,FS_OPEN_DR,FS_OPEN_OW + .byt FS_RENAME,FS_DELETE,FS_FORMAT,FS_MKDIR,FS_RMDIR + +rtab .word openrd-1,openwr-1,opendr-1,openow-1 + .word rename-1,delete-1,format-1 + .word mkdir-1 ,rmdir-1 + .) + .) + + +init .( + jsr DINIT + bcs endini + jsr INBUF + bcs endini + ; jsr INIDPB + ; bcs endini + jsr INIFPB +endini rts + .) + +dchanged .( ; xr = Drive + ; jsr INVDPB + jsr IDBUF ; gibt auch Fehler ! + jsr IDFIL + rts + .) + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/util.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/util.a65 new file mode 100644 index 0000000..515b620 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/util.a65 @@ -0,0 +1,648 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + + +/* certain miscellanous subroutines */ + + .data +ar1 .dsb 4 ; 4 Byte for 32Bit-Operations (Mult4) +ar2 .dsb 4 +ar3 .dsb 4 + .text + + +mult .( /* a/x * ar1 -> a/x , c=1 ist overflow */ + clc + sta ar3 + stx ar3+1 + lda #0 + sta ar2 + sta ar2+1 + txa + ora ar3 + beq mend +mloop + lsr ar1+1 + ror ar1 + bcc mnext + + clc + lda ar3 + adc ar2 + sta ar2 + lda ar3+1 + adc ar2+1 + sta ar2+1 + bcs mend + +mnext lda ar1 + ora ar1+1 + beq mend + + asl ar3 + rol ar3+1 + bcc mloop + +mend lda ar2 + ldx ar2+1 + rts + .) + +mult32 .( /* a/x * ar1 -> a/x(16bit) or ar2 (32bit), c=1 is overflow */ + clc + sta ar3 + stx ar3+1 + lda #0 + sta ar3+2 + sta ar3+3 + sta ar2 + sta ar2+1 + sta ar2+2 + sta ar2+3 + txa + ora ar3 + beq mend +mloop + lsr ar1+1 + ror ar1 + bcc mnext + + clc + lda ar3 + adc ar2 + sta ar2 + lda ar3+1 + adc ar2+1 + sta ar2+1 + lda ar3+2 + adc ar2+2 + sta ar2+2 + lda ar3+3 + adc ar2+3 + sta ar2+3 + bcs mend + +mnext lda ar1 + ora ar1+1 + beq mend + + asl ar3 + rol ar3+1 + rol ar3+2 + rol ar3+3 + bcc mloop + +mend lda ar2 + ldx ar2+1 + rts + .) + +#if 1 +div32 .( /* ar1(32) / a/x -> a/x(16) or ar3(32), ar1(32) */ + sec + sta ar2 + stx ar2+1 + ora ar2+1 + beq derr + + lda #0 + sta ar2+2 + sta ar2+3 + + sta ar3 + sta ar3+1 + sta ar3+2 + sta ar3+3 + + ldx #0 +dl lda ar2+3 + cmp ar1+3 + bcc d1 + bne d2 + lda ar2+2 + cmp ar1+2 + bcc d1 + bne d2 + lda ar2+1 + cmp ar1+1 + bcc d1 + bne d2 + lda ar2 + cmp ar1 + beq ds + bcs d2 + +d1 inx + asl ar2 + rol ar2+1 + rol ar2+2 + rol ar2+3 + bcc dl +derr rts + +d2 lsr ar2+3 + ror ar2+2 + ror ar2+1 + ror ar2 + dex + bmi dend + +ds sec + lda ar1 + sbc ar2 + pha + lda ar1+1 + sbc ar2+1 + pha + lda ar1+2 + sbc ar2+2 + pha + lda ar1+3 + sbc ar2+3 + bcc d3 + + sta ar1+3 + pla + sta ar1+2 + pla + sta ar1+1 + pla + sta ar1 + jmp d3a + +d3 pla + pla + pla +d3a + rol ar3 + rol ar3+1 + rol ar3+2 + rol ar3+3 + jmp d2 + +dend lda ar3 + ldx ar3+1 + clc + rts + .) +#endif + +div .( /* ar1 / a/x -> a/x, ar1 */ + sec + sta ar2 + stx ar2+1 + ora ar2+1 + beq derr + + lda #0 + sta ar3 + sta ar3+1 + + ldx #0 +dl lda ar2+1 + cmp ar1+1 + bcc d1 + bne d2 + lda ar2 + cmp ar1 + beq ds + bcs d2 + +d1 inx + asl ar2 + rol ar2+1 + bcc dl +derr rts + +d2 lsr ar2+1 + ror ar2 + dex + bmi dend + +ds sec + lda ar1 + sbc ar2 + pha + lda ar1+1 + sbc ar2+1 + bcc d3 + + sta ar1+1 + pla + sta ar1 + .byt $24 +d3 pla + rol ar3 + rol ar3+1 + jmp d2 + +dend lda ar3 + ldx ar3+1 + clc + rts + .) + +f2d .( + ldy #F_FCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #F_DCL + sta (fzei),y + iny + txa + sta (fzei),y + + ldy #F_FSEC+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #F_DSEC + sta (fzei),y + iny + txa + sta (fzei),y + + ldy #F_FPOS+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #F_DPOS + sta (fzei),y + iny + txa + sta (fzei),y + + jsr xclrfsec + rts + .) + +d2f .( + ldy #F_DCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #F_FCL + sta (fzei),y + iny + txa + sta (fzei),y + + ldy #F_DSEC+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #F_FSEC + sta (fzei),y + iny + txa + sta (fzei),y + + ldy #F_DPOS+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #F_FPOS + sta (fzei),y + txa + iny + sta (fzei),y + clc + rts + .) + +xfil2nam .( ; PCBUF+y ist Dateiname + ldx #1 + lda PCBUF,y + cmp #"." + bne f0 + lda PCBUF+1,y + beq dir1 + cmp #DIRSIGN + beq dir1 + cmp #"." + bne f0 + lda PCBUF+2,y + beq dir2 + cmp #DIRSIGN + bne f0 +dir2 lda #"." + sta fname+NAME_N+1 + inx + iny +dir1 iny + lda #"." + sta fname+NAME_N + bne fne + +&fil2nam +f0 ldx #0 +f1 lda PCBUF,y + beq fne +#ifdef SHOWN + jsr SEROUT +#endif + jsr TOUPPER + cmp #DIRSIGN + beq fne + cmp #"." + beq fe1 + cpx #NAME_E-NAME_N + bcs f2 + sta fname+NAME_N,x + inx +f2 iny + bne f1 +fe2 lda #" " + sta fname+NAME_N,x + inx +fe1 cpx #NAME_E-NAME_N + bcc fe2 + iny +f3 lda PCBUF,y + beq fne +#ifdef SHOWN + jsr SEROUT +#endif + jsr TOUPPER + cmp #DIRSIGN + beq fne + cpx #NAME_A-NAME_N + bcs f4 + sta fname+NAME_N,x + inx +f4 iny + bne f3 +fe3 lda #" " + sta fname+NAME_N,x + inx +fne cpx #NAME_A-NAME_N + bcc fe3 +#ifdef SHOWN + jsr CRLFOUT +#endif + clc + rts + .) + + +xfrebuf php + pha + ldy fpuffer + jsr FRBUF + pla + plp + rts + +TOUPPER .( + cmp #"a" + bcc ok + cmp #"z"+1 + bcs ok + and #%11011111 +ok rts + .) + +xadfpos .( + ldy #F_FPOS + clc + adc (fzei),y + sta (fzei),y + tax + iny + lda #0 + adc (fzei),y + sta (fzei),y +&xcmpfpos + ldy #D_BPS+1 + cmp (dzei),y + bne xe + dey + txa + cmp (dzei),y +xe rts + .) + +xadbufpos ldx fpuffer + jsr setpadr + ldy #F_FPOS + clc + adc (fzei),y + pha + iny + txa + adc (fzei),y + tax + pla + rts + +xfcl2fscl ldy #F_FCL+1 + lda (fzei),y + tax + dey + lda (fzei),y + ldy #F_FSCL + sta (fzei),y + iny + txa + sta (fzei),y + rts + +xclrf jsr xclrfcl +xclrfsp jsr xclrfsec +xclrfpos ldy #F_FPOS + lda #0 + sta (fzei),y + iny + sta (fzei),y + rts + +xclrfcl ldy #F_FCL + lda #0 + sta (fzei),y + iny + sta (fzei),y + rts + +xclrfsec ldy #F_FSEC + lda #0 + sta (fzei),y + iny + sta (fzei),y + rts + +#if 1 /*def SHOW*/ + .( + .data +dxr .byt 0 +;str =sysmem+1 + .byt 0 ; ??? + .text + +&SEROUT stx dxr + ldx #STDOUT + bne o0 +/*&OUT*/ stx dxr +o0 s2 pha + jsr PUTC + pla + bcc s2a + jsr YIELD + jmp s2 +s2a ldx dxr + cmp #0 + rts + .) + +HEXOUT .( + pha + lsr + lsr + lsr + lsr + jsr NIBOUT + pla + and #$0f +NIBOUT clc + adc #"0" + cmp #"9"+1 + bcc nout + adc #6 +nout jmp SEROUT + .) + +SPOUT lda #32 + jmp SEROUT +CRLFOUT lda #13 + jsr SEROUT + lda #10 + jmp SEROUT +#endif + +/*************************************************************************/ + + .( + .data +a .byt 0 + .text + +#if F_SLEN=64 +&setfzei /* x=File-Nr (0-(ANZFILE-1)) */ + stx file + txa + clc + adc #ANZDRV + sta fpuffer + txa + asl + asl + asl + asl + asl + asl + clc + adc #fpb + sta fzei+1 + clc + rts +#endif + +#if BUFLEN=1024 +&setpadr + txa + asl + asl + clc + adc #>buffer + tax + lda #buffer + tax + lda #dpb + sta dzei+1 + clc + rts +#endif +#if D_SLEN=26 +&setdzei /* x=Drv-Nr */ + stx drive + txa + asl + sta a + asl + asl + pha + clc + adc a + sta a + pla + asl + clc + adc a + clc + adc #dpb + sta dzei+1 + clc + rts +#endif + .) + diff --git a/dump/oa-2.0.9/sysapps/fs/fsibm/vars.a65 b/dump/oa-2.0.9/sysapps/fs/fsibm/vars.a65 new file mode 100644 index 0000000..72fbfe4 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsibm/vars.a65 @@ -0,0 +1,47 @@ +/**************************************************************************** + + OS/A65 Version 2.1.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + + .bss +buffer .dsb BUFLEN*ANZBUF + + .data +fpb .dsb F_SLEN*ANZFILE + +dpb .dsb D_SLEN*ANZDRV + + .zero +fzei .word 0 +dzei .word 0 + + .data + +drive .byt 0 +file .byt 0 +fpuffer .byt 0 + +fname .dsb NAME_SLEN + + .text + + diff --git a/dump/oa-2.0.9/sysapps/fs/fsiec.a65 b/dump/oa-2.0.9/sysapps/fs/fsiec.a65 new file mode 100644 index 0000000..ffe00e9 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/fs/fsiec.a65 @@ -0,0 +1,1459 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * TODO: + * + * This file is only loosely adapted to the 1.4 code. + * In fact the push flag and the error code features have to + * be implemented. + */ + +#ifndef ROM + +#ifndef FSIEC_DEVICE +#define FSIEC_DEVICE "siec_gecko.a65" +#endif + +/*#define INVERT*/ +#define PARALLEL +/*#define NOCMD*/ +/*#define NOFS*/ +/*#define SHOW*/ /* test-define */ +#define NOLOOP +/*#define NOPRG*/ +#define STDTST + +#endif /* ROM */ + + .( +#ifdef ROM +start .word ende ; pointer to end of file in ROM +#ifdef FSIEC_AS_INIT + .byt PK_INIT+$80 ; file type = filesystem + auto-execute bit +#else + .byt PK_FS+$80 ; file type = filesystem + auto-execute bit +#endif + .word PRG ; execution start + .byt 16 ; RAM size in 256-byte blocks + .byt >$ff-ROMSTART; $ff-start ; shared mem size in 256-byte blocks + .byt 0 ; priority + .word 0 ; stdin, stdout/stderr device number + .asc "fsiec",0,0 ; command line + +#else /* ROM */ + +;#include "stdio.a65" +#include "kdefs.i65" +#include "kernel.i65" +#include "fdefs.i65" + +#ifdef NOPRG + + .word $800 + *=$800 + jmp PRG + +#else +; .word $800 + *=$800 + .word 0 + .byt PK_PRG ;PK_FS+$80 + .byt 8 + .word 0 + .word PRG + .byt <-1 + +#endif +#endif + +#include "fsdef.i65" + +#ifndef FSIEC_ANZDRV +#define FSIEC_ANZDRV 4 +#endif + +#define MAXLEN 64 + +#define MAXFILE 6 +#define BUFSIZE 128 + + +#define FT_MOD 0 +#define FT_STR 1 +#define FT_BYT 2 +#define FT_BYT2 3 +#define FT_ST 4 +#define FT_BYT3 5 +#define FT_DRV 6 +#define FT_BUF 7 +#define FT_SLEN 8 +#define FT_MOD_FRE 0 +#define FT_MOD_IN 1 +#define FT_MOD_OUT 2 +#define FT_MOD_EOF 3 +#define FT_MOD_DIR 4 +#define ANZ_FT 16 + +#if 0 + +#ifndef NOMMU +-syszp =$40 +-sysmem =$300 +-sysblk =$800 +#endif + +#echo fsiec: +#print syszp +#print sysmem +#print sysblk + +#endif + + .data +IECBUF .dsb MAXLEN + + .zero +fzei .word 0 +bzei .word 0 + + .data +owntask .byt 0 +cnt .byt 0 +cmd .byt 0 +anz .byt 0 +client .byt 0 +actfil .byt 0 +ftab .dsb F_SLEN*MAXFILE + + .bss +buf .dsb MAXFILE*BUFSIZE + + .text + +#ifdef SHOW + .data +showcnt .byt 0 + .text +#endif + +PRG .( + stx owntask + +#ifdef SHOW + lda #0 + sta showcnt +#endif + jsr IECINIT /* init interface */ + bcs fterm + +#ifndef NOLOOP + jsr iniftab + jsr iniass + jsr inipfad + jsr iniunit +#endif + ldx #<-1 + jsr setzei ; init setzei (actfil) + ldx #0 + stx anz +p1 jsr setzei + lda #F_FL_FRE + ldy #F_FL + sta (fzei),y + inx + cpx #MAXFILE + bcc p1 + +#ifndef NOFS + ; we now inherit PCBUF from FORK - if started as PK_FS, not PK_INIT + ; clc + ; ldx #SEM_SENDBUF + ; jsr PSEM + + lda #FSIEC_ANZDRV ; 2 Drives + sta PCBUF+FM_REG_DRVS + lda owntask + sta PCBUF+FM_REG_ENV + lda #FM_REG + ldx #SEND_FM + ldy #2 + jsr SEND + + php + ldx #SEM_SENDBUF + jsr VSEM + plp + + bcs fterm +#else + ; if we don't need it, we have to release it now + ldx #SEM_SENDBUF + jsr VSEM +#endif + + .( + jsr getif + ldx #20 ; nach dem Einschalten Autostart VC1541 +x0 jsr setti ; ueberspringen +x1 jsr fragti + beq x1 + dex + bne x0 + jsr freif + .) + + jmp loop +fterm + jmp TERM + + + .( +#ifdef SHOW + + .data +dx .byt 0 + .text + +&&CRLFOUT + lda #13 + jsr OUT + lda #10 +&&OUT + stx dx +/* ldx #$3c + stx $e888 + sei + ldx #$10 + stx $eff8 + ldx showcnt + sta $8000,x + inc showcnt*/ + ldx #STDOUT + jsr SOUT + ldx dx + rts +#endif + +&&SOUT pha + jsr PUTC + pla + bcc ok + jsr YIELD + jmp SOUT +ok clc + rts + .) + +#ifdef SHOW + +&HEXOUT .( + pha + lsr + lsr + lsr + lsr + jsr nib + pla + and #$0f + jsr nib + lda #0 +h1 clc + adc #251 ; prim + bne h1 + jmp YIELD +nib clc + adc #"0" + cmp #"9"+1 + bcc out + adc #"A"-("9"+1)-1 +out jmp OUT + .) + +&savdata .( + pha + tya + pha + sei + lda #$18 + sta $eff8 + ldy #0 +sd1 lda $300,y + sta $8000,y + lda $400,y + sta $8100,y + lda $500,y + sta $8200,y + lda $600,y + sta $8300,y + iny + bne sd1 + pla + tay + pla + cli + rts + .) +#endif + +/**************************************************************************/ + +loop +#ifndef NOLOOP + jsr INLOOP ; check for ATN on bus +#endif + jsr YIELD +#ifdef NOFS + jmp loop +#else + /* no loop -> RECEIVE may block */ + /* TODO: multithread! */ +#ifdef NOLOOP + lda anz ; check if we have open files + bne l1xxx ; if no then + sec ; block while trying to RECEIVE + .byt $24 +#endif +l1xxx + clc + jsr RECEIVE ; check for fs command + bcs l1 + jsr rxmess +l1 + ; check all open streams and read/write new data if needed + ldx #0 + stx anz + stx cnt +l2 jsr setzei + ldy #F_FL + lda (fzei),y + cmp #F_FL_EOF+1 + bcc l2a + jmp nextl + +l2a inc anz + ldy #F_MODE + lda (fzei),y + cmp #F_MODE_RD + bne l3 + +ol +#if 0 /*ndef OLDROM*/ + .zero +b2zei .word 0 + .text + + ldy #F_LEN + lda (fzei),y + sec + ldy #F_BYT + sbc (fzei),y + beq l4 + pha + lda (fzei),y + clc + adc bzei + sta b2zei + lda bzei+1 + adc #0 + sta b2zei+1 + + ldy #F_STR + lda (fzei),y + tax + pla + ldy #b2zei + jsr PUTB + bcs l5n + ldy #F_BYT + adc (fzei),y + sta (fzei),y + jmp ol +#else + ldy #F_BYT + lda (fzei),y + ldy #F_LEN + cmp (fzei),y + beq l4 + pha + ldy #F_STR + lda (fzei),y + tax + pla + tay + lda (bzei),y + jsr PUTC + bcs l5n + ldy #F_BYT + lda (fzei),y + clc + adc #1 + sta (fzei),y + jmp ol +#endif +l4 + ldy #F_FL + lda (fzei),y + cmp #F_FL_EOF + bne l4a + ldy #F_STR + lda (fzei),y + tax + lda #SC_EOF + jsr STRCMD + jsr close + jmp nextl +l4a jsr clrbuf + jsr loadbuf + bcc l5 + + and #%10111111 ; check status + beq eofonly +;.byt 2 + ldy #F_STR + lda (fzei),y + tax + lda #SC_SSTAT + ldy #SCE_WERRM ; unrecoverable error + jsr STRCMD +eofonly + ldy #F_FL + lda #F_FL_EOF + sta (fzei),y +l5 jmp nextl + +l5n cmp #E_NUL + bne l5 + ldy #F_STR + lda (fzei),y + tax + lda #SC_EOF + jsr STRCMD + jsr close + jmp nextl + +l3 cmp #F_MODE_WR + bne l8 +il +#if 0 /*ndef OLDROM*/ + lda #BUFSIZE + sec + ldy #F_BYT + sbc (fzei),y + beq l6 + + pha + lda (fzei),y + clc + adc bzei + sta b2zei + lda bzei+1 + adc #0 + sta b2zei+1 + + ldy #F_STR + lda (fzei),y + tax + pla + ldy #bzei + jsr GETB + bcs l7 + ldy #F_BYT + adc (fzei),y + sta (fzei),y + jmp il +#else + ldy #F_BYT + lda (fzei),y + cmp #BUFSIZE + beq l6 + pha + ldy #F_STR + lda (fzei),y + tax + pla + tay + jsr GETC + bcs l7 + sta (bzei),y + ldy #F_BYT + lda (fzei),y + clc + adc #1 + sta (fzei),y + jmp il +#endif + +l7 cmp #E_EOF + bne l8 + ldy #F_STR + lda (fzei),y + tax + lda #SC_NUL + jsr STRCMD + jsr savebuf + bcc noserr + +serr ldy #F_STR + lda (fzei),y + tax + ldy #SCE_RERRM + lda #SC_SSTAT + jsr STRCMD +noserr + jsr close + jmp nextl + +l6 jsr savebuf + bcs serr + jsr clrbuf + jmp nextl + +l8 nextl inc cnt + ldx cnt + cpx #MAXFILE + bcs endloop + jmp l2 +endloop jmp loop + .) + +/**************************************************************************/ + +savebuf .( + jsr getif + + jsr setfpar + clc + ldy #F_BYT + lda (fzei),y + beq lbe + jsr LISTEN + jsr SECLISTEN + lda #0 +lb1 tay + lda (bzei),y + jsr IECOUT + iny + bcs lbe + tya + ldy #F_BYT + cmp (fzei),y + bcc lb1 +lbe php + jsr geterr + pha + jsr UNLISTEN + jsr freif + pla + plp + rts + .) + +loadbuf .( + .data +dirtst .byt 0 + .text + jsr getif + + ldy #F_FL + lda (fzei),y + cmp #F_FL_DIR + beq loadirbuf + jsr setfpar + jsr TALK + jsr SECTALK + ldy #0 +lb1 jsr IECIN + sta (bzei),y + iny + bcs lbe + cpy #BUFSIZE + bcc lb1 + clc +lbe + php + jsr geterr + pha + tya + ldy #F_LEN + sta (fzei),y + jsr UNTALK + jsr freif + pla + plp + rts + +loadirbuf +;.byt 2 + jsr setfpar + jsr TALK + jsr SECTALK + jsr IECIN + bcs gdxx + jsr IECIN + bcs gdxx + lda #FS_DIR_MOD_FRE + ldy #FS_DIR_MODE + sta (bzei),y + ldy #FS_DIR_LEN + lda #0 + sta (bzei),y + iny + jsr IECIN + bcs gdxx + sta (bzei),y + iny + jsr IECIN + bcs gdxx + sta (bzei),y + iny + lda #0 + sta (bzei),y + ldx #6 + ldy #FS_DIR_YEAR +gd1 lda data-FS_DIR_YEAR,y + sta (bzei),y + iny + dex + bne gd1 +gd2 jsr IECIN +gdxx bcs gdxx2 + cmp #34 + beq gd2x + cmp #18 ; revers + bne gd2 + lda #FS_DIR_MOD_NAM + ldy #FS_DIR_MODE + sta (bzei),y +gd2y jsr IECIN + bcs gdxx2 + cmp #34 + bne gd2y + beq gd3a +gd2x ldy #FS_DIR_MODE + lda #FS_DIR_MOD_FIL + sta (bzei),y +gd3a ldy #FS_DIR_NAME +gd3 jsr IECIN + bcs gdxx2 + cmp #34 + beq gd4 + jsr CBM2ASC + sta (bzei),y + iny + cpy #BUFSIZE-7 + bcc gd3 + jmp gde +gd4 + lda #"," + sta (bzei),y + iny + sty dirtst +gd5 jsr IECIN +gdxx2 bcs gdx + cmp #" " + beq gd5 + cmp #0 + beq gdy2 + bne gd6 +gd6a jsr IECIN + bcs gdx +gd6 jsr CBM2ASC + sta (bzei),y + cmp #0 + beq gd6b2 + cmp #" " + beq gd6b + iny + cpy #BUFSIZE-1 + bcc gd6a + +gd6b jsr IECIN + bcs gdx + cmp #0 + bne gd6b + +gd6b2 lda #0 + sta (bzei),y + iny + tya + ldy #F_LEN + sta (fzei),y + + ldy dirtst + lda (bzei),y + cmp #"d" + bne gde + iny + lda (bzei),y + cmp #"i" + bne gde + iny + lda (bzei),y + cmp #"r" + bne gde + ldy #FS_DIR_MODE + lda (bzei),y + cmp #FS_DIR_MOD_FIL + bne gde + lda #FS_DIR_MOD_DIR + sta (bzei),y + lda dirtst + ldy #F_LEN + sta (fzei),y + tay + dey + lda #0 + sta (bzei),y + +gde ;jsr IECIN + ;bcs gdx + ;cmp #0 + ;bne gde +gdy2 clc + bcc gdy +gdx ldy #FS_DIR_NAME + lda #0 + sta (bzei),y + iny + tya + ldy #F_LEN + sta (fzei),y +gdy php +;.byt 2 + jsr geterr + pha + jsr UNTALK + jsr freif + pla + plp + rts + +data .byt 91,4,7,13,6,0 + .) + +close jsr setfpar + jsr IECLOSE + lda #F_FL_FRE + ldy #F_FL + sta (fzei),y + rts + +/**************************************************************************/ + +rxmess .( +;.byt 2 + stx client + cmp #FS_OPEN_RD + bne rx1a + lda #"r" + bne rxop +rx1a cmp #FS_OPEN_WR + bne rx1b +rx1ab lda #"w" + bne rxop +rx1b cmp #FS_OPEN_AP + beq rx1x + cmp #FS_OPEN_OW + beq rx1ab + jmp rx1 +rx1x lda #"a" +rxop sta cmd + lda PCBUF+FS_OPEN_PFAD + bne rxepfad + jsr getfre + bcs rxe1 + lda PCBUF+FS_OPEN_DRV + ldy #F_DEV + sta (fzei),y + jsr setfpar + lda cmd + jsr setfnpar + jsr IECOPEN + bcs rxe2 + jsr DISKST + bcs rxe2 + lda PCBUF+FS_OPEN_STR + ldy #F_STR + sta (fzei),y + lda #0 + ldy #F_DRV + sta (fzei),y + lda #F_FL_OK + ldy #F_FL + sta (fzei),y + jsr clrbuf + lda cmd + cmp #"r" + bne rxr1 + lda #F_MODE_RD + .byt $2c +rxr1 lda #F_MODE_WR + ldy #F_MODE + sta (fzei),y + + lda #E_OK + ldx owntask + ldy actfil + jmp endrx + +rxe2 jsr IECLOSE + lda #E_FNODRV + .byt $2c +rxepfad lda #E_FNOPATH + .byt $2c +namlenerr lda #E_FNAMLEN + .byt $2c +rxe1 lda #E_FNOFIL + .byt $2c +rxe0 lda #E_NOTIMP +endrx sta PCBUF+FS_X_ERR + ldx owntask + stx PCBUF+FS_X_ENV + sty PCBUF+FS_X_FIL + ldy #FS_X_SLEN + ldx client + jmp SEND + +rx1 cmp #FS_OPEN_DR + beq rx1aa + jmp rxcmds +rx1aa lda PCBUF+FS_OPEN_PFAD + bne rxepfad + ldx PCBUF+FS_OPEN_DRV + jsr setzei + ldy #F_FL + lda (fzei),y + cmp #F_FL_FRE + bne rxe1 + lda PCBUF+FS_OPEN_DRV + ldy #F_DEV + sta (fzei),y + jsr setfpar + lda PCBUF+FS_OPEN_STR + ldy #F_STR + sta (fzei),y + + .( + ; remove leading DIRSIGN, as all names are assumed global + lda PCBUF+FS_OPEN_NAME + cmp #DIRSIGN + bne noglobal + ldy #<-1 +l0 iny + lda PCBUF+FS_OPEN_NAME+1,y + sta PCBUF+FS_OPEN_NAME,y + bne l0 +noglobal + .) + lda PCBUF+FS_OPEN_NAME + bne xx1a + sta PCBUF+FS_OPEN_NAME+1 + lda #"*" + sta PCBUF+FS_OPEN_NAME + +xx1a lda #"$" + sta PCBUF+FS_OPEN_NAME-2 + lda #":" + cmp PCBUF+FS_OPEN_NAME+1 + bne xx1a2 + lda #" " +xx1a2 sta PCBUF+FS_OPEN_NAME-1 + + ldy #0 +xx1 lda PCBUF+FS_OPEN_NAME-2,y + beq xx2 + iny + bne xx1 +xx2 tya + ldy #>(PCBUF+FS_OPEN_NAME-2) + ldx #<(PCBUF+FS_OPEN_NAME-2) + jsr SETFNPAR + jsr IECOPEN +;.byt 2 +/*.( :bcc lll1: inc $d021: lll1 .)*/ +rxe2a bcs rxe2b + jsr DISKST +/*.( :bcc lll1: inc $d020: lll1 .)*/ + bcs rxe2a + jsr getif +#if 0 /*def NMIDEV*/ + lda #NMI_OFF + jsr CTRLNMI +#endif + jsr TALK + jsr SECTALK + jsr IECIN + jsr IECIN + jsr UNTALK + jsr freif +#if 0 /*def NMIDEV*/ + lda #NMI_ON + jsr CTRLNMI +#endif + lda #0 + ldy #F_DRV + sta (fzei),y + lda #F_FL_DIR + ldy #F_FL + sta (fzei),y + jsr clrbuf + lda #F_MODE_RD + ldy #F_MODE + sta (fzei),y + + lda #E_OK + ldx owntask + ldy actfil + jmp endrx + +rxe2b jmp rxe2 + +rxcmds +#ifdef NOCMD + jmp rxe0 +#else + pha + lda PCBUF+FS_CMD_DRV + clc + adc #8 + tax + ldy #15 + jsr SETFPAR + pla + ldx PCBUF+FS_CMD_PFAD + beq rcr0 + jmp rxepfad +rcr0 cmp #FS_RENAME + bne rxc2 + lda #"r" + sta IECBUF + + lda #":" + cmp PCBUF+FS_CMD_NAME+1 + bne rcr0a + lda #" " +rcr0a sta IECBUF+1 + + ldy #FS_CMD_NAME +rcr1 lda PCBUF,y + beq rcr2 + iny + bne rcr1 +rcr2 ldx #2 + iny +rcr3 lda PCBUF,y + beq rcr4 + sta IECBUF,x + iny + inx + cpx #MAXLEN + bcc rcr3 + jmp namlenerr +rcr4 lda #"=" + sta IECBUF,x + inx + ldy #FS_CMD_NAME +rcr5 lda PCBUF,y + sta IECBUF,x + beq rcr6 + iny + inx + cpx #MAXLEN + bcc rcr5 + jmp namlenerr +rcr6 txa + ldx #IECBUF +cmds jsr SETFNPAR + jsr IECOPEN + jsr DISKST + php + jsr IECLOSE + plp + lda #E_OK + bcc rcr7 + lda #E_NODEV +rcr7 jmp endrx + +rxc2 cmp #FS_DELETE + bne rxc3 + lda #"s" +scmds sta PCBUF+FS_CMD_NAME-2 + lda #":" + cmp PCBUF+FS_CMD_NAME+1 + bne sc1 + lda #" " +sc1 sta PCBUF+FS_CMD_NAME-1 + ldy #0 +rcd1 lda PCBUF+FS_CMD_NAME-2,y + beq rcd2 + iny + bne rcd1 +rcd2 tya + ldx #<(PCBUF+FS_CMD_NAME-2) + ldy #>(PCBUF+FS_CMD_NAME-1) + jmp cmds + +rxc3 cmp #FS_FORMAT + bne rxc4 + lda #"n" + bne scmds + +rxc4 cmp #FS_CHKDSK + bne rxc5 + lda #"v" + bne scmds + +rxc5 cmp #FS_CLOSE + bne rxc6 + ldx PCBUF+FS_CMD_FIL + cpx #MAXFILE + bcs rxc5e + jsr setzei + ldy #F_FL + lda (fzei),y + cmp #F_FL_FRE + beq rxc5e + ldy #F_MODE + lda (fzei),y + cmp #F_MODE_WR + bne rxc5a + jsr savebuf +rxc5a jsr close + lda #E_OK + .byt $2c +rxc5e lda #E_ILLPAR + jmp endrx + +rxc6 jmp rxe0 + +#endif +#endif + .) + +/**************************************************************************/ + +getbuf .( + ;ldx #0 + ;.byt $2c +&getfre + ldx #FSIEC_ANZDRV + stx cnt +gf1 jsr setzei + ldx cnt + ldy #F_FL + lda (fzei),y + cmp #F_FL_FRE + clc + beq gf2 + inc cnt + ldx cnt + cpx #MAXFILE + bcc gf1 +gf2 rts + .) + +#ifndef NOFS +setfnpar .( + + .data +div .byt 0 + .text + + pha + ldy #0 + sty div +sfn0 lda PCBUF+FS_OPEN_NAME,y + beq sfn1 +; cmp #"," +; bne sfn2 +; sta div +;sfn2 + iny + bne sfn0 +sfn1 +; lda div +; bne sfn3 +; lda #"," +; sta PCBUF+FS_OPEN_NAME,y +; iny +;#ifndef OLDHACK +; lda #"p" +;#else +; lda #"P" +;#endif +; sta PCBUF+FS_OPEN_NAME,y +; iny +sfn3 lda #"," + sta PCBUF+FS_OPEN_NAME,y + iny + pla +#ifdef OLDHACK + eor #$20 +#endif + sta PCBUF+FS_OPEN_NAME,y + iny + ldx #PCBUF+FS_OPEN_NAME + jmp SETFNPAR + .) + +setfpar ldy #F_DEV + lda (fzei),y + clc + adc #8 + tax + ldy #0 + lda actfil + cmp #FSIEC_ANZDRV + bcc sfp1 + clc + adc #2 + tay +sfp1 jmp SETFPAR + +clrbuf lda #0 + ldy #F_LEN + sta (fzei),y + ldy #F_BYT + sta (fzei),y + rts +#endif + +setzei .( ; setzt zeiger, x=filenr + cpx actfil + beq sz1 + stx actfil + txa + asl + asl + asl + clc + adc #ftab + adc #0 + sta fzei+1 + txa +#if 1 + lsr + pha + lda #0 + ror ; clears carry + adc #buf + sta bzei+1 +#else + clc + adc #>buf*2 + lsr + sta bzei+1 + lda #$a0->$40->$20 + cmp #"A" + bcc tuok + cmp #"Z"+1 + bcs tu2 + ora #$80 + bne tuok +tu2 cmp #"a" + bcc tuok + cmp #"z"+1 + bcs tu3 + sbc #$1f + bne tuok +tu3 cmp #"A"+$80 + bcc tuok + cmp #"Z"+$81 + bcs tuok + adc #$a0 +tuok rts + .) + +CBM2ASC .( ; ringtausch $a0->$20->$40->$a0 + cmp #"A" + bcc tlok + cmp #"Z"+1 + bcs tl2 + adc #$20 + bne tlok +tl2 cmp #"a" + bcc tlok + cmp #"z"+1 + bcs tl3 + adc #$60 + bne tlok +tl3 cmp #"A"+$80 + bcc tlok + cmp #"Z"+$81 + bcs tlok + and #$7f +tlok rts + .) + +/************************** IEC-Routinen **********************************/ +/* hier Blocktiefe 1 */ + + .( + .zero +namzei .word 0 + + .data +secadr .byt 0 +devadr .byt 0 +namlen .byt 0 +status .byt 0 + + .text + +#ifndef NOFS + + .( +&&SETFNPAR sta namlen + stx namzei + sty namzei+1 + rts +&&SETFPAR stx devadr + sty secadr + rts +&&IECLOSE + jsr getif +#if 0 /*def NMIDEV*/ + lda #NMI_OFF + jsr CTRLNMI +#endif + jsr LISTEN + lda secadr + and #$ef + ora #$e0 + jsr seclisten + jsr UNLISTEN + jsr freif +#if 0 /*def NMIDEV*/ + lda #NMI_ON + jsr CTRLNMI +#endif + clc + rts +&&IECOPEN + jsr getif + lda #0 + sta status + jsr LISTEN +;lda status:;sta $e000 + lda secadr + ora #$f0 + jsr seclisten +;lda status:;sta $e001 + lda status + bmi opend + lda namlen + beq nonam + ldy #0 +op1 lda (namzei),y + jsr ASC2CBM ;jsr TOUPPER +#ifdef SHOW + pha + JSR OUT + pla +#endif + jsr IECOUT + iny + cpy namlen + bne op1 +#ifdef SHOW + jsr CRLFOUT +#endif +nonam jsr UNLISTEN + +;inc $d020 + ;clc + ;rts + lda #E_OK + .byt $2c +opend lda #E_NODEV + ;sec + pha + jsr freif + pla +#if 0 /*def NMIDEV*/ + pha + lda #NMI_ON + jsr CTRLNMI + pla +#endif + cmp #1 + rts + +&&DISKST + jsr getif + lda #0 + sta status + jsr TALK + lda #$6f + jsr sectalk + jsr IECIN + cmp #"1" + beq lx1 + cmp #"0" + bne lx +lx1 lda status + bne lx + clc + .byt $24 +lx sec + php +tya +pha +ldy #0 +lxxx0 +jsr IECIN +;sta $e000,y +iny +lda status +beq lxxx0 +pla +tay + jsr UNTALK + jsr freif + plp + rts + .) +#endif + +/******************* here is the interface to the device *****************/ + +&TALK lda #$40 + .byt $2c +&LISTEN lda #$20 + ora devadr +atnout .( + pha + + lda #0 + sta status + + bit bytfl + bpl l1 + + sec + ror eoifl + jsr iecout + + lsr bytfl ; clear flags + lsr eoifl ; clear flags +l1 + pla + sta byte + jsr iec0out + cli + rts + .) + +&SECTALK + lda secadr + ora #$60 + jmp sectalk + +&SECLISTEN + lda secadr + ora #$60 + jmp seclisten + +&IECOUT .( + sei + pha + clc + bit bytfl + bmi iout + sec + ror bytfl + bne endout + +iout jsr iecout + +endout pla + sta byte + + lda status + cmp #1 + cli + rts + .) + +&geterr .( + lda status + rts + .) + +seterror .( + ora status + sta status + rts + .) + +/* + * device routines are: + * getif get interface -> PSEM(SEM_?IEC), CTRLNMI(NMI_OFF),... + * freif release interface -> VSEM(S*IEC), CTRLNMI(NMI_ON),... + * IECINIT inits the device + * iec0out sends a byte with ATN set + * sectalk send sectalk + * seclisten send seclisten + * IECIN receive byte + * iecout send byte + * UNLISTEN send unlisten + * UNTALK send untalk + */ + +/* if not defined works if object file to link */ +#ifdef FSIEC_DEVICE +#include FSIEC_DEVICE +#endif + +#undef FSIEC_DEVICE +#undef FSIEC_ANZDRV +#undef MAXLEN +#undef MAXFILE +#undef BUFSIZE + + .) + +ende .) + diff --git a/dump/oa-2.0.9/sysapps/ibmon/Makefile b/dump/oa-2.0.9/sysapps/ibmon/Makefile new file mode 100644 index 0000000..e755572 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/ibmon/Makefile @@ -0,0 +1,13 @@ + + +XAINPUT=../../include,../../arch,../.. +XA= XAINPUT=${XAINPUT} xa + +BIN=ibmon + +${BIN}.o65: ${BIN}.a65 + ${XA} -LKERNEL -R -G ${BIN}.a65 -o ${BIN}.o65; + +clean: + rm -f ${BIN}.o65 + diff --git a/dump/oa-2.0.9/sysapps/ibmon/ibmon.a65 b/dump/oa-2.0.9/sysapps/ibmon/ibmon.a65 new file mode 100644 index 0000000..848f143 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/ibmon/ibmon.a65 @@ -0,0 +1,1945 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/*************************************************************************** + * + * CS/A65 disk monitor for the WD1770 (shugart bus) floppy interface + * + */ + +#define NOPRG +/*#define SHOWD*/ + +#define MA 0 +#define MB 1 + +#include "chips/wd1770.i65" +#include "chips/via6522.i65" + +#define E_CMD <-96 +#define E_Q <-97 +#define E_GT <-98 +#define E_RD <-99 +#define E_WR <-100 +#define E_FT <-101 + + .( +#ifdef ROM + .word ende + .byt PK_PRG + .byt 16 + .word 0 + .word PRG + .byt /*8,8,9,9,$a,$a,$b,$b,$c,$c,$d,$d,*/ $e,$e,<-1 + .asc "ibmon",0,0 +#else + +#include "kdefs.i65" +#include "kernel.i65" +#include "oldlib/stdio.a65" + +#ifdef NOPRG + + .word $800 +; *=$800 + jmp PRG + +#else +; *=$800 + .word 0 + .byt PK_PRG + .byt 16 + .word 0 + .word PRG + .byt <-1 + +#endif +#endif + +#ifndef NOMMU +-sysblk =$4000 +-sysmem =$400 +-syszp =$40 +#endif + +#echo ibmon: +#print sysmem +#print syszp +#print sysblk + +/*************************************************************************/ + +#define ANZDRV 2 + +/* Parameter zum Aufruf RWSEC */ + +#define RW_DRV 0 +#define RW_SIDE 1 +#define RW_TRCK 2 +#define RW_SEC 3 +#define RW_ADR 4 +#define RW_SLEN 6 + +/* Parameter zum Aufruf von DFORMAT */ + +#define FMT_VIRG 0 +#define FMT_SIDES 1 +#define FMT_TRCKS 2 +#define FMT_HDFL 3 +#define FMT_BLEN 4 +#define FMT_SCLST 5 /* Anzahl Sektoren+1, sekt1, sekt2, sekt3... */ + +#define MEBYT ":" +#define ABPZ #16 +#define MESSAGE "-" +#define MAXLEN 64 +#define BUFLEN 8192 + +/*************************************************************************/ + +-sysblk -=BUFLEN +buffer =sysblk + +LZEI =sysmem +IOBUF =sysmem+1 +-sysmem +=MAXLEN+1 + +PRG jsr DINIT + lda #M0TXT + jsr Txtout +MXL + JSR Crlfout:LDA #MESSAGE + JSR Putc + JSR MLINEIN:bcs termmon +linex jsr CHRGOT:beq MXL:bne mx1 +MO0 jsr CHRGET:beq MXL +mx1 CMP #MESSAGE:BEQ MO0 + jsr TOUPPER + LDX #0:MO3 CMP MONBEF,X:BEQ MO4 + INX:CPX #ANZBEF:BCC MO3 + JSR ERR + JMP MXL +MOX pla + pla +termmon lda #MTTXT:jsr Txtout +#ifdef NOPRG + rts +#endif + jmp TERM + +ERR LDA #M3TXT:JSR Txtout:SEC:RTS +MO4 INC LZEI + JSR MOEX + ;bcc mo4 + ;jsr ERR +mo4 JMP MXL +MOEX TXA:ASL:TAX:LDA MONADR+1,X + PHA:LDA MONADR,X:PHA:RTS + +ANZBEF =14 +MONBEF .asc "XRWMI",MEBYT,"LSOTFCBN" +MONADR .word MOX-1,mread-1,mwrite-1,MOM-1,BI-1,MOI-1 + .word lread-1,lwrite-1 + .word MOO-1,MOT-1,MOF-1,MOC-1,BB-1,MON-1 + +M0TXT .ASC "^M^JC*^M^J" + .ASC "DMON V" + .BYT MA+"0",".",MB+"0" + .asc " (c) A.Fachat^@" +M3TXT .BYT " ","?",0 +MTTXT .asc "^M^JBye!^M^J",0 + +m0rtxt .asc "^MLese",0 +m0wtxt .asc "^MSchreibe",0 +m1txt .asc " Block: Drive ",0 +m2txt .asc ", Seite ",0 +m3txt .asc ", Track ",0 +m4txt .asc ", Sektor ",0 +fmtxt .asc "^M^JSind Sie sicher (J/N)?",0 + +/**************************************************************************/ + + .( +rwfl =sysmem +rwpar =sysmem+1 +rwp2 =sysmem+1+RW_SLEN +rwp3 =sysmem+1+2*RW_SLEN +-sysmem +=3*RW_SLEN+1 + +&mread ldx #0 + .byt $2c +&mwrite ldx #1 + .( + stx rwfl + jsr GETADR + bcs rwerr + sta rwpar+RW_DRV + jsr GETADR + bcs rwerr + sta rwpar+RW_SIDE + jsr GETADR + bcs rwerr + sta rwpar+RW_TRCK + jsr GETADR + bcs rwerr + sta rwpar+RW_SEC + lda #buffer + sta rwpar+RW_ADR+1 + jsr GETADR + bcs goon + sta rwpar+RW_ADR + stx rwpar+RW_ADR+1 +goon + jsr Crlfout + lda #rwpar + ldx rwfl + bne w + clc + .byt $24 +w sec + jsr RWSEC +rwerr rts + .) + +&lread ldx #0 + .byt $2c +&lwrite ldx #1 + .( + stx rwfl + jsr GETADR + bcs rwerrx + sta rwpar+RW_DRV + jsr GETADR + bcs rwerrx + sta rwp2+RW_SIDE + sta rwpar+RW_SIDE + jsr GETADR + bcs rwerrx + sta rwp3+RW_SIDE + jsr GETADR + bcs rwerrx + sta rwpar+RW_TRCK + sta rwp2+RW_TRCK + jsr GETADR + bcs rwerrx + sta rwp3+RW_TRCK + jsr GETADR + bcs rwerrx + sta rwpar+RW_SEC + sta rwp2+RW_SEC + jsr GETADR +rwerrx bcs rwerr + sta rwp3+RW_SEC + lda #buffer + sta rwpar+RW_ADR+1 + jsr GETADR + bcs goon + sta rwpar+RW_ADR + stx rwpar+RW_ADR+1 +goon + jsr Crlfout +loop + lda #rwpar + ldx rwfl + bne w + clc + .byt $24 +w sec + jsr RWSEC + bcs rwerr + + stx rwpar+RW_ADR + sty rwpar+RW_ADR+1 + + inc rwpar+RW_SEC + lda rwpar+RW_SEC + cmp rwp3+RW_SEC + bcc loop + lda rwp2+RW_SEC + sta rwpar+RW_SEC + + inc rwpar+RW_TRCK + lda rwpar+RW_TRCK + cmp rwp3+RW_TRCK + bcc loop + lda rwp2+RW_TRCK + sta rwpar+RW_TRCK + + inc rwpar+RW_SIDE + lda rwpar+RW_SIDE + cmp rwp3+RW_SIDE + bcs l3 + jmp loop + +l3 clc +rwerr rts + .) + +&MON .( ;format drive format + jsr GETADR + bcs moe + sta rwpar ;drv + jsr GETADR + bcs moe + sta rwpar+1 + + lda #fmtxt + jsr Txtout + jsr MLINEIN + jsr CHRGOT + + pha + jsr Putc + pla + + cmp #"j" + beq format + cmp #"J" + bne moe +format ldx rwpar + lda rwpar+1 + jsr DFORMAT + bcs moe + rts +moe jmp ERR + .) + .) + +/**************************************************************************/ + +Z1 =syszp +Z2 =syszp+2 +Z3 =syszp+4 +-syszp +=6 + +MOM .( + JSR GET12:BCS MOME:;jsr setout +/* + lda #buffer + adc Z1+1 + sta Z1+1 + + lda #buffer + adc Z2+1 + sta Z2+1 +*/ +30150 MOM1 JSR MOMZO + jsr Serbrk:bcs MOME +30160 LDA ABPZ:JSR ADCMP:BCC MOM1 +30170 MOME RTS +30180 MOMZO JSR Crlfout:LDA #MEBYT:JSR MASOUT +30220 LDY #0:beq mom2:MOM2 jsr SSPOUT:mom2 LDA (Z1),Y +30230 JSR SBYTO:INY:CPY ABPZ:BNE MOM2 + lda #":":jsr Putc +30240 LDY #0:MOM3 LDA (Z1),Y +30250 TAX:AND #127:CMP #32:BCS MOM4 +30260 LDX #".":MOM4 TXA:JSR Putc +30270 INY:CPY ABPZ:BNE MOM3 +30280 RTS + .) + +BB .( + JSR GET12:BCS MOBE:;jsr setout +MOB1 JSR MOBZO + jsr Serbrk:bcs MOBE + LDA #1:JSR ADCMP + BCC MOB1 +MOBE RTS +MOBZO JSR Crlfout:LDA #MEBYT:JSR MASOUT + LDY #0 + LDA (Z1),Y + JMP SBINBO + .) + +BI .( + JSR GETADR:bcs MOIE + sta Z1:stx Z1+1 +/* clc:adc #buffer:sta Z1+1 +*/ + jsr CHRGOT:bne MOI0 + lda #MEBYT + ldy #0 + jmp MOINL + +&MOI JSR GETADR:bcs MOIE + sta Z1:stx Z1+1 +/* clc: adc #buffer:sta Z1+1 +*/ + jsr CHRGOT + beq MOIE +MOI0 LDA #0:STA Z2 +MOI1 JSR GETADR:LDY Z2:BCS MOINL + STA (Z1),Y:INC Z2 + JMP MOI1 +MOIE RTS + +MOINL LDA #0 + STA Z2 + LDA #MEBYT + JSR INLOOP + BCC MOI1 + cmp #0 + clc + beq MOIE + pla + pla + jmp linex + .) + + .( +&MOC3 JSR GETADR:BCS MOCX + STA Z1:STX Z1+1 + JSR GETADR:BCS MOCX + STA Z2:STX Z2+1 + JSR GETADR:BCS MOCX + STA Z3:STX Z3+1:RTS + +&MOC JSR MOC3:BCS MOCE:;jsr setout:JSR Crlfout +30570 MOC2 LDY #0:LDA (Z1),Y:CMP (Z3),Y +30580 BEQ MOC1:LDA Z1:LDX Z1+1 +30590 JSR SADRO:JSR SSPOUT +30600 MOC1 LDA #1:JSR ADCMP:BCS MOCX +30610 INC Z3:BNE MOC2:INC Z3+1 +30620 JMP MOC2 +30630 MOCX RTS +30640 MOCE jmp ERR + .) + +MOF .( + ldy LZEI:lda IOBUF,y:pha:beq mofex + cmp #" ":beq mof00:inc LZEI +mof00 jsr GETADR:sta Z1:stx Z1+1:bcs mofex + jsr GETADR:sta Z2:stx Z2+1:bcs mofex + pla:cmp #" ":bne mofother + + lda #0:sta Z3 +mof0 jsr GETADR:bcs mofn + ldx Z3:sta IOBUF,x:inc Z3 + bne mof0 + +mofn ldy LZEI:lda IOBUF,y + cmp #34:bne mofnx + ldx Z3 +mofn1 iny + lda IOBUF,y + beq mofn2 + cmp #34 + beq mofn2a + sta IOBUF,x + inx + bne mofn1 +mofn2a iny +mofn2 sty LZEI + stx Z3 + bne mof0 + +mofnx lda Z3:beq mofe + + jsr Crlfout +mof1 ldy #0 +mofl lda (Z1),y + cmp IOBUF,y + bne mof2 + iny + cpy Z3:bcc mofl + lda Z1:ldx Z1+1:jsr SADRO + jsr SSPOUT +mof2 lda #1:jsr ADCMP:bcc mof1 + rts +mofex pla +&mofe jmp ERR + +mofother =*-3 + .) + +MOT .( + JSR MOC3:BCS mofe;MOCEO +30710 LDA Z3+1:CMP Z2+1:BCC MOT1 +30720 BNE MOTA:LDA Z3:CMP Z2:BCS MOTA +30730 MOT1 LDA Z3+1:CMP Z1+1 +30740 BCC MOTA:BNE MOTB +30750 LDA Z3:CMP Z1:BCS MOTB +30760 MOTA LDY #0:LDA (Z1),Y +30770 STA (Z3),Y:INC Z3:BNE MOT2 +30780 INC Z3+1:MOT2 LDA #1:JSR ADCMP +30790 BNE MOTA:RTS + +30800 MOTB LDA Z3:CLC:ADC Z2:STA Z3 +30810 LDA Z3+1:ADC Z2+1:STA Z3+1 +30820 LDA Z3:SEC:SBC Z1:STA Z3 +30830 LDA Z3+1:SBC Z1+1:STA Z3+1:jmp MOT3a +30840 MOT3 LDY #0:LDA (Z2),Y:STA (Z3),Y +30850 MOT3a LDA Z2:BNE MOT4:DEC Z2+1 +30860 MOT4 DEC Z2 +30870 LDA Z3:BNE MOT5:DEC Z3+1 +30880 MOT5 DEC Z3 +30890 JSR COMP +30895 BCC MOT3:BEQ MOT3:RTS + .) + +MOO .( + JSR GETADR:BCS MOCEO +30906 STA Z1:STX Z1+1 +30907 JSR GETADR:BCS MOCEO +30908 STA Z2:STX Z2+1 +30910 JSR GETADR:BCC MOO1 +30920 LDA #0:MOO1 STA Z3 +30930 MOO2 LDY #0:LDA Z3:STA (Z1),Y +30940 LDA #1:JSR ADCMP:BCC MOO2 +30950 RTS + .) + +/**************************************************************************/ + +SBINBO .( + STX Z3 + pha + LDA #"%" + JSR Putc + pla + LDX #8 +s2 ASL + PHA + BCC s1 + lda #"1" + .byt $2c +s1 lda #"0" + jsr Putc + pla + dex + bne s2 + ldx Z3 + rts + .) + +MOCEO jmp ERR + +GET12 .( + JSR GETADR + BCS GBDX + STA Z1:STX Z1+1 + STA Z2:STX Z2+1 + JSR GETADR + BCS GBD1 + STA Z2:STX Z2+1 +GBD1 CLC +GBDX RTS + .) + +MASOUT PHA + LDA #MESSAGE + JSR Putc + PLA + JSR Putc + LDA Z1 +/* sec + sbc #buffer + tax + pla +*/ + ldx Z1+1 + JSR SADRO + JMP SSPOUT + +SSBOUT JSR SBYTO + JMP SSPOUT + +SADRO PHA:TXA:JSR SBYTO:PLA +SBYTO PHA:LSR:LSR:LSR:LSR + JSR SNIBO:PLA:AND #$0F +SNIBO CLC:ADC #"0":CMP #"9"+1 + BCC SNO1:ADC #6:SNO1 JMP Putc + +SSPOUT LDA #" ":JMP Putc + + .( +&ADD CLC + ADC Z1 + STA Z1 + LDA #0 + ADC Z1+1 + STA Z1+1 + rts +&ADCMP jsr ADD + bcs cs +&COMP lda Z1+1 + CMP Z2+1 + bne cs + lda Z1 + cmp Z2 +cs rts + .) + + +INLOOP .( + PHA + TYA + CLC + ADC Z1 + STA Z1 + LDA #0 + ADC Z1+1 + STA Z1+1 + JSR Crlfout + PLA + JSR MASOUT + JSR MLINEIN + ldy #<-1 +il1 iny + lda IOBUF,y + beq ils + cmp #MESSAGE ; zeile gewechselt + beq ils + cmp #" " + beq il1 + sty LZEI + clc + rts +ils + sec + rts + .) + +/**************************************************************************/ + +TOUPPER .( + cmp #"a" + bcc tok + cmp #"z"+1 + bcs tok + sbc #$1f +tok rts + .) +/* +LINEFEED LDA #10:.BYT $2C +#ifndef NOSYSFKT +PNTOUT lda #".":.byt $2c +#endif +#ifndef NOMON +CROUT LDA #13:.BYT $2C +#endif +SSPOUT LDA #" ":JMP Putc +*/ + .( +div =sysmem +Z0 =sysmem+1 +-sysmem +=3 + ++CHRGET inc LZEI ++CHRGOT sty div + ldy LZEI + LDA IOBUF,Y + LDY div + CMP #" " + BEQ CHRGET + CMP #0 + RTS + ++GETADR LDY LZEI:LDA #0:STA Z0:STA Z0+1 +GA1 LDA IOBUF,Y:bne get + jmp GAE +get INY + CMP #" ":BEQ GA1 + + CMP #"%" + BEQ GETBIN + cmp #"." + beq GETDEZ1 + cmp #"$" + beq GETHEX + cmp #"&" + beq GETOKT + DEY + JMP GETHEX + +GETDEZ1 jmp GETDEZ + +GETHEX lda IOBUF,y + jsr tsthex + bcs gae +GA2 INY + ASL Z0:ROL Z0+1:ASL Z0:ROL Z0+1 + ASL Z0:ROL Z0+1:ASL Z0:ROL Z0+1 + ORA Z0:STA Z0 + LDA IOBUF,Y + jsr tsthex + bcc GA2 + jmp GAE1 + +gae jmp GAE + +gb1 SEC:SBC #"0" + CMP #2 + BCS GAE1 + iny + lsr + rol Z0:rol Z0+1 +GETBIN lda IOBUF,Y + beq GAE1 + bne gb1 + +go1 sec:sbc #"0" + cmp #8 + bcs GAE1 + iny + asl Z0:rol Z0+1 + asl Z0:rol Z0+1 + asl Z0:rol Z0+1 + ora Z0:sta Z0 +GETOKT lda IOBUF,y + beq GAE1 + bne go1 + +gd1 sec:sbc #"0" + cmp #10 + bcs GAE1 + iny + pha + asl Z0:rol Z0+1 + lda Z0:ldx Z0+1 + asl Z0:rol Z0+1 + asl Z0:rol Z0+1 + clc:adc Z0:sta Z0 + txa:adc Z0+1:sta Z0+1 + pla + clc + adc Z0 + sta Z0 + bcc GETDEZ + inc Z0+1 +GETDEZ lda IOBUF,y + beq GAE1 + bne gd1 + +GAE1 LDA Z0:LDX Z0+1 + CLC:sty LZEI + rts + +GAE SEC + lda IOBUF,y + STY LZEI + RTS + .) + +&tsthex .( + cmp #"A"-1 + bcs th1 + sbc #"0"-1 + cmp #10 + bcc thok +therr sec + rts +th1 beq therr + and #%00011111 + cmp #7 + bcs therr + adc #9 +thok clc + rts + .) + ++MLINEIN .( +#ifndef NOSH +li1 =sysmem +-sysmem +=1 +#endif + LDY #0 +MO1 + ldx #STDIN + jsr GETC + bcc mo1a + cmp #E_EOF + beq MO2S + jsr DLOOP + jsr YIELD + jmp MO1 + +mo1a cmp #$1f + bcs MO1A + + CMP #TC_CR:BEQ MO2 + + CMP #8:BNE MO1 + cpy #0:beq MO1 + dey + jsr Putc +/*#ifdef SHOW + ldx #STDERR + jsr OUT +#endif*/ + jmp MO1 + +MO1A STA IOBUF,Y + jsr Putc +/*#ifdef SHOW + ldx #STDERR + jsr OUT +#endif*/ + INY:CPY #MAXLEN + BCC MO1:bcs MO2 +MO2S sec:.byt $24 +MO2 CLC +/*#ifdef SHOW + php + lda #13 + ldx #STDERR + jsr OUT + lda #10 + jsr OUT + plp +#endif*/ + LDA #0:STA IOBUF,Y + sta LZEI + RTS + .) + +/**************************************************************************/ + .( + +#define WD1 $e8e0 +#define VIA2 $e8f0 + +#define ERRCNT 4 + +zei =syszp +zeid =syszp+2 +divers =syszp+4 +sect =syszp+5 +tr =syszp+6 +errcnt =syszp+7 +actdrv =syszp+8 +side =syszp+9 +cmd =syszp+10 +data =syszp+11 +drvst =syszp+17 ; drivestatus z.b. Step-Zeit +tracks =syszp+17+ANZDRV ; Track, auf dem jeweiliges Laufwerk steht +hd =syszp+17+2*ANZDRV ; High-Density-Flag =bit7 , 6= motor an flag + ; bit0=1 disk changed, bit1=1 double stepping +mcnt =syszp+17+3*ANZDRV ; motor-aus-z�hler +blen =syszp+17+4*ANZDRV ; Anzahl 256-Byte-Bl�cke in einem Sektor + +-syszp +=5*ANZDRV+17 + +/* + jmp DINIT + jmp exit + jmp seldrv ; a=drv + jmp desel + jmp selside ; a=side + jmp go2track ; a=track + jmp setadr ; a/y=adr + jmp read ; a=sect + jmp write ; " + jmp verify ; " + jmp DREAD ; a/y=*Struct + jmp DWRITE ; " + ;jmp DVERIFY ; " + jmp ftrack ; a=virgin, zeid=*seclist + jmp DFORMAT ; a/y=*Struct +*/ + + +rwzei =syszp +-syszp +=2 + +&&RWSEC + sta rwzei + sty rwzei+1 + php + lda #m0rtxt + bcc rw1 + lda #m0wtxt +rw1 jsr Txtout + lda #m1txt + jsr Txtout + + ldy #RW_DRV + lda (rwzei),y + jsr Dezbout + + lda #m2txt + jsr Txtout + ldy #RW_SIDE + lda (rwzei),y + jsr Dezbout + + lda #m3txt + jsr Txtout + ldy #RW_TRCK + lda (rwzei),y + jsr Dezbout + + lda #m4txt + jsr Txtout + ldy #RW_SEC + lda (rwzei),y + jsr Dezbout + + plp + lda rwzei + ldy rwzei+1 + bcs wr + jmp DREAD +wr jmp DWRITE + +DREAD ldx #1 + .byt $2c +DWRITE ldx #2 + stx cmd + .( + sei + sta zei + sty zei+1 + ldy #RW_ADR + lda (zei),y + pha + iny + lda (zei),y + tay + pla + jsr setadr + ldy #RW_DRV + lda (zei),y + jsr seldrv + bcs rx + ldy #RW_SIDE + lda (zei),y + jsr selside + ldy #RW_TRCK + lda (zei),y + jsr go2track + bcs rx + ldx actdrv + lda blen,x + tax ; Anzahl 256-Byte-Blocks (wird bei seldrv gesetzt) + ldy #RW_SEC + lda (zei),y + dec cmd + bne r2 + jmp read +r2 dec cmd + bne r3 + jmp write +r3 sec + lda #E_CMD +rx cli + rts + .) + +&DFORMAT .( +fpar =sysmem +-sysmem +=1 + + cmp #ANZFORM + bcc f1 + lda #E_ILLPAR + sec + rts +f1 sta fpar + asl + tay + lda fadr,y + sta zei + lda fadr+1,y + sta zei+1 + txa ; x= drive + pha + jsr desel + pla + sta actdrv + + jsr setdrv ; a=drive + + ldy #FMT_HDFL + lda (zei),y + ldx actdrv + sta hd,x + jsr setdens + + jsr motoron + + ldy #FMT_BLEN + lda (zei),y + sta data+5 + tax + lda POT2-1,x + ldx actdrv + sta blen,x + + jsr restore + bcs fx + + lda #0 + sta tr + lda #FMT_SCLST + clc + adc zei + pha + lda zei+1 + adc #0 + tay + pla + jsr setadr ; sektor-Liste setzen + +floop lda #0 + sta side + +sideloop jsr selside + + ldx data+5 ; Block-L�nge 0=128,1=256,2=512,3=1024 + ldy #FMT_VIRG + lda (zei),y + jsr ftrack + bcs fx + + inc side + lda side + ldy #FMT_SIDES + cmp (zei),y + bcc sideloop + + inc tr + lda tr + ldy #FMT_TRCKS + cmp (zei),y + bcs wrboot + + ldx actdrv + lda hd,x + and #2 + beq fnd + + jsr lowdens + + lda #$50 + jsr setstep + bcs fx +fnd + lda #$50 ; step-in ohne verify + jsr setstep + bcs fx + jsr highdens + jmp floop + +fx pha + jsr highdens + pla + ldx #<-1 + stx actdrv + sec + rts + +wrboot lda #0 + jsr selside + lda #0 + jsr go2track + bcs fx + lda fpar ; Format mal 32 als Zeiger f�r + asl ; Boot-Sektor-Daten + asl + asl + asl + asl + clc + adc #bootsektor + tay + pla + jsr setadr + + ldx actdrv + lda blen,x + tax + lda #1 + jsr write + ldx #<-1 + stx actdrv + rts + +ANZFORM =6 +fadr .word ssdd,dsdd,dshd3,dshd5,dshh5,dsdd40 + + ; single sided double density +ssdd .byt $e5,1,80,$01,2,10, 1,3,5,7,9,2,4,6,8 + ; double sided double density +dsdd .byt $e5,2,80,$01,2,10, 1,3,5,7,9,2,4,6,8 + ; double sided high density 3 1/2 zoll +dshd3 .byt $e5,2,80,$81,2,19, 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18 + ; double sided high density 5.25" +dshd5 .byt $e5,2,80,$81,2,16, 1,3,5,7,9,11,13,15,2,4,6,8,10,12,14 + ; double sided higher density 5.25" +dshh5 .byt $e5,2,80,$81,3,9, 1,3,5,7,2,4,6,8 + ; double sided double density 40 Tracks (360k) +dsdd40 .byt $e5,2,40,$03,2,10, 1,3,5,7,9,2,4,6,8 + +bootsektor ; single sided double density + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 2 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 112 ; DIR + .word 720 ; SECs + .byt 248 ; Media + .word 3 ; SPF + .word 9 ; SPT + .word 1 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided double density + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 2 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 112 ; DIR + .word 1440 ; SECs + .byt 249 ; Media + .word 3 ; SPF + .word 9 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided high density 3.5 zoll + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 224 ; DIR + .word 2880 ; SECs + .byt 240 ; Media + .word 9 ; SPF + .word 18 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided high density 5.25 zoll + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 224 ; DIR + .word 2400 ; SECs + .byt 249 ; Media + .word 7 ; SPF + .word 15 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided higher density 5.25 zoll (BPS=1024) + .byt $eb,$34,$90,"OS/A 1.2" + .word $400 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 128 ; DIR + .word 1280 ; SECs + .byt 255 ; Media + .word 2 ; SPF + .word 8 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + ; double sided double density 5.25 zoll 40 Tracks (360k) + .byt $eb,$34,$90,"OS/A 1.2" + .word $200 ; BPS + .byt 1 ; SPC + .word 1 ; RES + .byt 2 ; FATs + .word 112 ; DIR + .word 720 ; SECs + .byt 255 ; Media + .word 3 ; SPF + .word 9 ; SPT + .word 2 ; Side + .word 0 ; Hidden + .word 0 ; (Dummy) + .) + +&DINIT .( + lda #%00001111 + sta VIA2+VIA_DRA ; + + lda #0 + sta VIA2+VIA_DDRA ;Ertmal testen ob IC da + cmp VIA2+VIA_DDRA + bne xini + lda #%00101111 + sta VIA2+VIA_DDRA + cmp VIA2+VIA_DDRA + bne xini + + lda VIA2+VIA_ACR + and #%11011110 ;t2 timed irq, pa latch disabled + sta VIA2+VIA_ACR + lda VIA2+VIA_PCR + and #%11110000 ;pa + ora #%00001110 ;ca2 hi (side), ca1 neg edge + sta VIA2+VIA_PCR + lda #%00100011 ;ca1, ca2, t2 irq off + sta VIA2+VIA_IER + +/* lda #0 ; der Controller braucht zulange, um das Register + sta WD1+WD_TRCK ; upzudaten + cmp WD1+WD_TRCK + bne xini +*/ + ldx #0 +i1 lda #00000011 ; 6ms Step-Zeit + sta drvst,x + lda #<-1 + sta tracks,x + inx + cpx #ANZDRV + bcc i1 + sta actdrv + clc + rts +xini sec + rts + .) + +&DLOOP .( +dcnt =sysmem +-sysmem +=1 + + lda VIA2+VIA_DRA + and #%00000011 + cmp #%00000011 + beq d1 + clc + rts +d1 + lda #0 + sta dcnt + sta divers +dl jsr setdrv ; a=drive + + ldx divers + lda hd,x + and #%01000000 + beq dl1 + inc dcnt ; motor an + dec mcnt,x + bne dl1 + lda hd,x + and #%10111111 + sta hd,x + lda #%00000100 + dex + bmi dl1a + asl +dl1a ora VIA2+VIA_DRA + sta VIA2+VIA_DRA +dl1 + ldx divers + lda VIA2+VIA_DRA ; test auf Disk Change + and #%00010000 + bne dl2 + lda hd,x + and #1 + bne dl2 + lda hd,x + ora #1 + and #255-2 ; double-stepping aus + sta hd,x + lda #<-1 + sta tracks,x + ;jsr dchanged +dl2 + inc divers + lda divers + cmp #ANZDRV + bcc dl + jsr desel + + lda VIA2+VIA_DRA + and #%00001100 ; motor-bits + eor #%00001100 ; sind beide aus + bne dlx ; nein dann ende + jsr lowdens +dlx lda dcnt ; mit z-flag �bergeben + rts + .) + +&setdstep .( + lda hd,x + ora #2 + sta hd,x + rts + .) + +forcend .( + lda WD1+WD_ST + and #1 + beq fer + lda #%11010000 ; Force Interrupt + sta WD1+WD_CMD + jsr wloop +fer rts + .) + +selside .( + clc + and #1 + sta side + bne side1 + lda VIA2+VIA_PCR + ora #%00000010 + sta VIA2+VIA_PCR + rts +side1 lda #%11111101 + and VIA2+VIA_PCR + sta VIA2+VIA_PCR + rts + .) + +wloop .( + txa + ldx #13 +wl1 dex + bne wl1 + tax + rts + .) + +wcmd .( + pha + jsr wloop + pla + sta WD1+WD_CMD + lda #1 +wcl bit WD1+WD_ST + beq wcl + rts + .) + +setstep .( + ldx actdrv + and #%11111100 + ora #%00001000 ; ohne Motor-On-Time + sta divers + lda drvst,x + and #3 + ora divers + php + sei + jsr wcmd + ldx #128 +wc2 jsr setti +wc1 bit VIA2+VIA_DRA + bmi wcok + jsr fragti + beq wc1 + dex + bne wc2 + plp + lda #E_CMD + sec + .byt $2c ; plp,clc �berspringen +wcok plp + clc + ldx WD1+WD_ST + rts + .) + +setti lda #255 + sta VIA2+VIA_T2CL + sta VIA2+VIA_T2CH + rts + +fragti lda VIA2+VIA_IFR + and #%00100000 + rts + +seldrv .( + pha + ldx actdrv + bmi sd1 + lda WD1+WD_TRCK + sta tracks,x +sd1 pla + sta actdrv + + jsr setdrv ; a=drv + jsr setdens + jsr motoron + + ldx actdrv + lda tracks,x + bpl sd2 + jsr query + bcs sde +sd2 sta WD1+WD_TRCK + tay + ldx actdrv + lda hd,x + and #1 + beq sd3 + tya + eor #1 ; da track von 0-79 kann das nicht aus bereich raus + jsr go2track ; um disk-change zu l�schen + bcs sder + ldx actdrv + lda hd,x + and #%11111110 + sta hd,x +sd3 clc +sder rts +sde sta actdrv + rts + .) + +motoron .( + lda actdrv + and #1 + beq drva + lda VIA2+VIA_DRA + and #%11110111 ; Motor on + bne drvs +drva lda VIA2+VIA_DRA + and #%11111011 +drvs sta VIA2+VIA_DRA + ldx actdrv + lda hd,x + and #%01000000 + bne mok ; motor war schon an + sta mcnt,x ; motor-aus-z�hler auf null + lda hd,x + ora #%01000000 + sta hd,x +#ifdef SHOWD + lda #"m" + jsr Putc +#endif + +&mdelay + lda VIA2+VIA_DRA + and #%00001100 ; beide Motoren + eor #%00001100 ; aus ? + beq mok ; ja dann ende + +#ifdef SHOWD + lda #"M" + jsr Putc +#endif + ldx #40 +ml jsr setti +ml2 jsr YIELD + jsr fragti + beq ml2 + dex + bne ml +mok rts + .) + +setdrv .( + and #1 + beq drva + lda VIA2+VIA_DRA + and #%11111101 ; drive select + ora #%00000001 + bne drvs +drva lda VIA2+VIA_DRA + and #%11111110 + ora #%00000010 +drvs sta VIA2+VIA_DRA +&densok rts + .) + +setdens .( + ldx actdrv + lda hd,x ; high-Density-Bit + lsr ; auf Portbit schieben + lsr + eor VIA2+VIA_DRA ; vergleichen + and #%00100000 ; maskieren + beq densok ; gleich dann fertig + + lda hd,x + bpl lodens + lda VIA2+VIA_DRA + ora #%00100000 + bne denset +lodens lda VIA2+VIA_DRA + and #%11011111 +denset sta VIA2+VIA_DRA + jmp mdelay + .) + +lowdens lda VIA2+VIA_DRA + and #%11011111 + sta VIA2+VIA_DRA + rts +highdens ldx actdrv + lda hd,x + bpl lowdens + lda VIA2+VIA_DRA + ora #%00100000 + sta VIA2+VIA_DRA +#ifdef SHOWD + lda #"H" + jsr Putc +#endif + jmp mdelay + +query .( + jsr restore + bcs qx + lda #4 ; hd-count + sta divers + + lda #0 + jsr selside + +q ldx #40 ; bis 5.25" auf Drehzahl nach Density-Wechsel + lda #ERRCNT*2 + sta errcnt + .byt $2c +qloop ldx #16 ; 8*32ms=256ms <> 1 umdrehung bei 234 upm + lda #%11000000 ; Read Adress + ldy #5 + sei + jsr wcmd +q1 jsr setti + lda #%00100000 +q2 bit VIA2+VIA_IFR + bne qn + bit VIA2+VIA_DRA + bvc q2 + ldx WD1+WD_DATA + stx data,y + dey + bpl q2 + lda WD1+WD_ST + and #%00001100 + bne q3 + lda data+2 ; Sektor Length + and #3 + beq q3 ; Sektoren mit 128 Byte gehen nicht + tax + lda POT2-1,x ; dann Anzahl 256-Byte-Blocks im Sektor + ldx actdrv + sta blen,x + lda data+5 + cli + clc + rts + +qn lda WD1+WD_ST + dex + bne q1 + +q3 dec errcnt + bne qloop + cli + dec divers + beq qe + + ldx actdrv + lda hd,x + eor #%10000000 + sta hd,x + jsr setdens + + lda divers + pha + cmp #2 + bcs q4 + jsr restore +q4 pla + sta divers + jmp q + +qe lda #E_Q +qx sec + rts + +&POT2 .byt 1,2,4 + .) + +desel .( + ldx actdrv + bmi sd1 + lda WD1+WD_TRCK + sta tracks,x +sd1 lda #<-1 + sta actdrv + lda VIA2+VIA_DRA + ora #%00000011 + sta VIA2+VIA_DRA + clc + rts + .) + +go2track .( + sta tr + cmp WD1+WD_TRCK + beq gtr + + jsr lowdens + + jsr findtr + bcc gtc + + lda #$04 ; restore mit verify + jsr setstep + bcs gts + + jsr findtr + bcs gts +gtc and #%00011000 + bne gts + + jsr highdens +gtr clc + rts + +gts jsr highdens + lda #E_GT + sec + rts + .) + +findtr .( + lda tr + sta WD1+WD_DATA + + ldx actdrv + lda hd,x + and #2 + beq gnd + + lda WD1+WD_TRCK + pha + lda #$10 ; stepping ohne verify + jsr setstep + pla + sta WD1+WD_TRCK ; und das ganze nochmal mit verify + lda tr + sta WD1+WD_DATA ; das sind dann doppelt so viele steps + +gnd lda #$14 ; seek track + jmp setstep + .) + +restore .( + jsr forcend + jsr lowdens + lda #$00 ; restore + jsr setstep + pha + jsr highdens + lda #0 + sta tr + pla + rts + .) + +setadr sta zeid + sty zeid+1 + clc + rts + +read .( + sta sect + stx data +#ifdef BSHOW + lda #"R" + jsr Putc + txa + jsr HEXOUT +#endif + jsr forcend + lda #ERRCNT + sta errcnt +rdloop lda sect + sta WD1+WD_SECT + sei + ldx data ; Anzahl 256-Byte-Bl�cke + ldy #0 + lda #%10001000 + jsr wcmd + lda WD1+WD_ST +rd1 bit VIA2+VIA_DRA + bmi rde + bvc rd1 + lda WD1+WD_DATA + sta (zeid),y + iny + bne rd1 + inc zeid+1 + dex + bne rd1 + clc + ;ldx WD1+WD_ST + ;ldy errcnt + lda WD1+WD_ST + ldx zeid + ldy zeid+1 + cli + rts +rde dec errcnt + bne rdloop + lda #E_RD + sec + ldx WD1+WD_ST + cli + rts + .) + +write .( + sta sect ; ( x-reg die Anzahl 256-Byte-Bl�cke ) + stx data +#ifdef BSHOW + lda #"W" + jsr Putc + txa + jsr HEXOUT +#endif + jsr forcend + lda #ERRCNT + sta errcnt +wrloop lda sect + sta WD1+WD_SECT + sei + ldx data ; Anzahl 256-Byte-Bl�cke + ldy #0 + lda #%10101000 + jsr wcmd + lda WD1+WD_ST +rd1 bit VIA2+VIA_DRA + bmi rde + bvc rd1 + lda (zeid),y + sta WD1+WD_DATA + iny + bne rd1 + inc zeid+1 + dex + bne rd1 + clc + lda WD1+WD_ST + ldx zeid + ldy zeid+1 + cli + rts +rde dec errcnt + bne wrloop + lda #E_WR + sec + ldx WD1+WD_ST + cli + rts + .) + +ftrack .( + sta divers ; virgin + stx data+4 ; Sektor-L�nge + lda POT2-1,x + sta data ; Anzahl 256-Byte-Bl�cke + lda #ERRCNT + sta errcnt +errloop ldy #0 + lda (zeid),y + sta data+2 ; endsector + iny + sty sect + jsr forcend + sei + lda #%11110100 + jsr wcmd + lda WD1+WD_ST ; intrq loeschen + ldy #80 + ldx #$4e +f1a bit VIA2+VIA_DRA + bmi fey + bvc f1a + stx WD1+WD_DATA + dey + bne f1a +sloop lda data + sta data+1 + ldx #0 + ldy #12 +f2 bit VIA2+VIA_DRA + bmi fey + bvc f2 + stx WD1+WD_DATA + dey + bne f2 + ldx #$f5 + ldy #3 +f3 bit VIA2+VIA_DRA + bmi fey + bvc f3 + stx WD1+WD_DATA + dey + bne f3 + ldx #$fe +f4 bit VIA2+VIA_DRA +fey bmi fex + bvc f4 + stx WD1+WD_DATA + ldx tr +f5 bit VIA2+VIA_DRA + bmi fex + bvc f5 + stx WD1+WD_DATA + ldx side +f6 bit VIA2+VIA_DRA + bmi fex + bvc f6 + stx WD1+WD_DATA + ldy sect + lda (zeid),y + tax +f7 bit VIA2+VIA_DRA + bmi fex + bvc f7 + stx WD1+WD_DATA + ldx data+4 ; l�nge des Sektors +f8 bit VIA2+VIA_DRA + bmi fex + bvc f8 + stx WD1+WD_DATA + ldx #$f7 +f9 bit VIA2+VIA_DRA + bmi fex + bvc f9 + stx WD1+WD_DATA + ldy #22 + ldx #$4e +f10 bit VIA2+VIA_DRA + bmi fex + bvc f10 + stx WD1+WD_DATA + dey + bne f10 + ldy #12 + ldx #0 +f11 bit VIA2+VIA_DRA + bmi fex + bvc f11 + stx WD1+WD_DATA + dey + bne f11 + ldy #3 + ldx #$f5 +f12 bit VIA2+VIA_DRA +fex bmi fe + bvc f12 + stx WD1+WD_DATA + dey + bne f12 + ldx #$fb +f13 bit VIA2+VIA_DRA + bmi fe + bvc f13 + stx WD1+WD_DATA + ldx divers ; virgin +f15 ldy #0 +f14 bit VIA2+VIA_DRA ; 256 Byte + bmi fe + bvc f14 + stx WD1+WD_DATA + dey + bne f14 + dec data+1 + bne f15 + ldx #$f7 ; end of sektor +f16 bit VIA2+VIA_DRA + bmi fe + bvc f16 + stx WD1+WD_DATA + ldy #24 + ldx #$4e ; pause nach sektor +f20 bit VIA2+VIA_DRA + bmi fe + bvc f20 + stx WD1+WD_DATA + dey + bne f20 + inc sect + dec data+2 + beq f18a + jmp sloop +f18a ldx #$4e +f18 bit VIA2+VIA_DRA + bmi fr + bvc f18 + stx WD1+WD_DATA + jmp f18 ; absolut +fe dec errcnt + beq fee + jmp errloop +fee sec + lda #E_FT + ldx WD1+WD_ST + cli + rts +fr cli + clc + rts + .) + .) + +/*************************************************************************/ + +#print sysmem +#print syszp + +ende .) + + diff --git a/dump/oa-2.0.9/sysapps/ibmon/ibmon.doc b/dump/oa-2.0.9/sysapps/ibmon/ibmon.doc new file mode 100644 index 0000000..1613e87 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/ibmon/ibmon.doc @@ -0,0 +1,15 @@ + +******** ibmon ******** 17.7.92, A. Fachat + +Dieser Diskettenmonitor bedient den Shugart-Bus �ber den WD1770. Er liest +und schreibt Sektoren, die �ber Laufwerk, Seite, Track und Sektor +adressiert wird. Die Befehle O,F,C,M,B,I,X und T sind aus der Shell +�bernommen. Folgende Befehle sind f�r die Bedienung der Disketten da: +r drv side track sector (adresse) : einzelnen Sektor lesen +w drv side track sector (adresse) : einzelnen Sektor schreiben +l drv s0 s1 t0 t1 sc0 sc1 (adr) : mehrere Sektoren lesen +s drv s0 s1 t0 t1 sc0 sc1 (adr) : mehrere Sektoren schreiben + Bei l und s wird eine innere Schleife von [sc0,sc1[, dar�ber + eine Schleife von [t0,t1[ und dar�ber eine von [s0,s1[ durchlaufen. +n drv format : Formatiert Diskette im Format 'format' + diff --git a/dump/oa-2.0.9/sysapps/init/Makefile b/dump/oa-2.0.9/sysapps/init/Makefile new file mode 100644 index 0000000..c31dd60 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/init/Makefile @@ -0,0 +1,15 @@ + + +XA=xa + +all: init.o65 initmmu.o65 + +init.o65: init.a65 + ${XA} -I../../include -DINIT_RESTART -DROMSTART=\$8000 -DOSA2KERNEL=61440 -R init.a65 -o init.o65; + +initmmu.o65: init.a65 + ${XA} -DINIT_RESTART -DINIT_MMU -DINIT_MMU_BANK=2 -I../../include -DROMSTART=\$8000 -DOSA2KERNEL=61440 -R init.a65 -o initmmu.o65; + +clean: + rm -f init.o65 initmmu.o65 + diff --git a/dump/oa-2.0.9/sysapps/init/init.a65 b/dump/oa-2.0.9/sysapps/init/init.a65 new file mode 100644 index 0000000..8e769a5 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/init/init.a65 @@ -0,0 +1,825 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This process starts other processes from the ROM, using the normal + * ROM link chain. It starts PK_PRG and PK_FS types only. + * + * The difference between PK_INIT type (like this one) and the above + * mentioned is that PK_INIT type processes do _not_ get the SENDBUF + * with their command line, because the kernel is unable to alloc + * more than one SEM_SENDBUF during startup which can only be released + * by an already started process! + * + * You can define INIT_VERBOSE if you want init to print out + * some debugging/logging info. + * If you define INIT_OUTDEV with the device number, this device is used + * to print the info, otherwise device 0 is used. + * + * If INIT_USE_STDLIB is defined, init uses the (old) STDIO library, otherwise + * it will include its own printing routines if INIT_VERBOSE is defined. + * + * If INIT_MERGE is defined, then files can be started with their STDOUT/STDERR + * sent to the same device as the init process. + * + * If INIT_LIB6502 is defined, then PK_LIB ROM entries are supported and + * started with the lib6502 forkto call - or at least with an undocumented + * derivate... (argh, horrible code...). + */ + +/* + * In this exerimental version init also scans other 64k banks for + * for the standard ROM link chain to start in the upper half. + * It does not start PK_INIT/PK_DEV programs from other banks, though. + * The (currently _one_) other bank to scan is defined with INIT_MMU_BANK. + * + * To achieve remapping of the upper 32k, it assumes linear mapping + * in bank 0 when starting and remaps itself to $1***. + * + * This only works with the CS/A65 MMU CPU board! + */ + +#include "kernel.i65" +#include "kdefs.i65" + +#ifdef INIT_LIB6502 +#echo init uses lib6502 +#include "lib6502.i65" +#endif + +#ifndef INIT_OUTDEV +#define INIT_OUTDEV 0 +#endif + + .( + +start .word ende ; pointer to end of file in ROM + .byt PK_INIT+$80 ; file type = init task + auto-execute bit + .word PRG ; execution start + .byt 3 ; RAM size needed, in 256-byte blocks + .byt >$ff-ROMSTART ; shared mem size in 256-byte blocks + .byt 0 ; priority + .word 0 ; stdin, stdout/stderr device number (ignored) + .asc "init",0,0 ; command line + + .zero +pz .word 0 +s1 .byt 0 +s2 .byt 0 + .text + +#ifdef INIT_MMU + .data +actbank .byt 0 + .text +#endif + +#ifdef INIT_RESTART + +#ifndef INIT_MAXRESTART +#define INIT_MAXRESTART 7 +#endif + + .data +npid .byt 0 +kpid .byt 0 ; number of killed tasks + +#ifdef INIT_MMU +bank .dsb INIT_MAXRESTART ; bank where program resides +#endif + +lpa .dsb INIT_MAXRESTART ; ROM start address low +hpa .dsb INIT_MAXRESTART ; ROM start address high +pid .dsb INIT_MAXRESTART ; PID of started process +killed .dsb INIT_MAXRESTART ; this can still overflow - non-restartable + ; tasks give signals too! + .text +#endif + +PRG .( +#ifdef INIT_MMU +#ifdef ROM +#print * + lda #>* + lsr + lsr + lsr + lsr +#ifdef ROMTEST + ora #$10 +#endif + pha + ldy #1 + jsr SETBLK + pla + clc + adc #1 + ldy #2 + jsr SETBLK +&oldpc=* +#print * + *= (* & $0fff) | $1000 +&newpc=* +#print * + jmp *+3 +#endif +#endif + +#ifdef INIT_VERBOSE + ; first organize stream and set device accordingly + jsr GETSTR + bcs no_out + stx s1 + ldy s1 + ldx #INIT_OUTDEV + lda #DC_GS + jsr DEVCMD + ldx #INIT_OUTDEV + lda #DC_TX_ON + jsr DEVCMD + sec + ldx #STDOUT + lda s1 + jsr DUP +no_out + ldx #0 + jsr itout +#endif +#ifdef INIT_RESTART + lda #sigadr + sec + jsr SETSIG + + lda #SIG_CHLD + clc + jsr SETSIG + + lda #0 + sta npid + sta kpid +#endif +;.byt 2 +#ifdef INIT_MMU + lda #0 + jsr setbank +bankloop +#endif +;.byt 2 + lda #ROMSTART + sta pz+1 + +#ifdef INIT_MMU + ldx #6 + ldy #17 +magicl lda (pz),y + cmp magic,x + bne nextbank + iny + dex + bpl magicl + lda (pz),y + cmp pz + bne nextbank + iny + lda (pz),y + cmp pz+1 + bne nextbank + jmp startloop + +magic .byt "MOR2ASO" + +#endif + +startloop + ldy #0 + lda (pz),y + iny + and (pz),y + cmp #$ff + bne slx1 + +#ifdef INIT_MMU +nextbank + lda actbank + bne endloop + lda #INIT_MMU_BANK + jsr setbank + jmp bankloop +#endif + +endloop + +#ifdef INIT_RESTART + jmp restarts +#else + jmp TERM +#endif + +slx1 jsr dostart +#ifdef INIT_RESTART + bcs norestart + + ldy #P_KIND+2 + lda (pz),y + and #$40 + beq norestart + ldy npid + cpy #INIT_MAXRESTART + bcs norestart +#ifdef INIT_MMU + lda actbank + sta bank,y +#endif + lda pz + sta lpa,y + lda pz+1 + sta hpa,y + txa + sta pid,y + inc npid +#ifdef INIT_VERBOSE + ldx #9 + jsr itout +#endif +#endif +norestart + ldy #0 + lda (pz),y + tax + iny + lda (pz),y + sta pz+1 + stx pz + jmp startloop + + .) + + .( +&getserr3 + ldx s2 + lda #SC_EOF + jsr STRCMD + lda #SC_EOF + jsr STRCMD + jmp gs2 + +getserr2 + ldx s2 + lda #SC_EOF + jsr STRCMD + jsr FRESTR +gs2 +#ifdef INIT_VERBOSE + ldx #10 + jsr itout + jsr gs + sec + rts +#endif + +getserr1 +#ifdef INIT_VERBOSE + ldx #6 + jsr itout +#endif +gs + ldx s1 + jsr FRESTR +#ifdef INIT_VERBOSE + sec + rts ;jmp inext +#endif +getserr +#ifdef INIT_VERBOSE + ldx #6 + jsr itout +#endif + sec + rts + + +&getstrs jsr GETSTR + bcs getserr + stx s1 + +#ifdef INIT_MERGE +#ifdef INIT_VERBOSE + ldy #P_DEV+3 + lda (pz),y + cmp #INIT_OUTDEV + bne getnew + + ldx #STDOUT + lda #SC_REG_WR + jsr STRCMD + lda #SC_REG_WR + jsr STRCMD + stx s2 + jmp oldstr +getnew +#endif +#endif + jsr GETSTR + bcs getserr1 +getserr3a bcs getserr3 + stx s2 + lda #SC_REG_WR ; register second writer (for STDERR) + jsr STRCMD + ldy #P_DEV+3 + lda (pz),y + tax + pha + ldy s2 + lda #DC_GS + jsr DEVCMD + pla + bcs getserr2 + tax + lda #DC_TX_ON + jsr DEVCMD +oldstr + ldy #P_DEV+2 + lda (pz),y + bmi noinput + tax + pha + ldy s1 + lda #DC_PS + jsr DEVCMD + pla + bcs getserr3a + tax + lda #DC_RX_ON + jsr DEVCMD + clc + rts +noinput + lda #SC_EOF + ldx s1 + jmp STRCMD + .) + +dostart .( + jsr YIELD ; give devices time to clear state for restart + + ldy #P_KIND+2 + lda (pz),y + bpl slx2 + and #$3f + cmp #PK_PRG + beq iprg + cmp #PK_FS + beq ifs +#ifdef INIT_LIB6502 + cmp #PK_LIB + bne slx2 + jmp execlib +#endif +slx2 clc +slx2a jmp inext + +ifs + ldx #STDNUL + stx s1 + stx s2 + bne ifs1 + +iprg jsr getstrs + bcs slx2a +ifs1 + clc + ldx #SEM_SENDBUF + jsr PSEM ; alloc PCBUF - also does serializing, as + ; forked process releases it + lda s2 + sta PCBUF+FORK_STDOUT + sta PCBUF+FORK_STDERR + lda s1 + sta PCBUF+FORK_STDIN + ldy #P_PRIORITY+2 + lda (pz),y + sta PCBUF+FORK_PRIORITY + + ldy #P_RAM+2 + lda (pz),y + sta PCBUF+FORK_SIZE + iny + lda (pz),y + sta PCBUF+FORK_SHARED + + ldy #P_ADDR+2 + lda (pz),y + sta PCBUF+FORK_ADDR + iny + lda (pz),y + sta PCBUF+FORK_ADDR+1 + + ldy #P_NAME+2-1 +cmdn iny + lda (pz),y + sta PCBUF+FORK_NAME-P_NAME-2,y + bne cmdn + cmp PCBUF+FORK_NAME-P_NAME-3,y ; last byte also 0? + bne cmdn + iny + +#ifdef INIT_VERBOSE + tya + pha + ldx #1 + jsr itout + ldy #0 +ll lda PCBUF+FORK_NAME,y + beq lx + jsr putc + iny + bne ll + beq end +lx lda PCBUF+FORK_NAME-1,y + beq end + lda #" " + jsr putc + iny + bne ll +end + ldx #3 + jsr itout + pla + tay +#endif + + jsr FORK + bcc inext1 + ; on error release streams -> auto-release devices +#ifdef INIT_VERBOSE + ldx #4 + jsr itout +#endif + + ldx s1 + lda #SC_NUL + jsr STRCMD + ldx s2 + lda #SC_EOF + jsr STRCMD + lda #SC_EOF + jsr STRCMD + + sec + rts + ; jmp inext + +inext1 +#ifdef INIT_VERBOSE + txa + pha + ldx #5 + jsr itout + pla + tax + clc +#endif +inext rts + .) + +#ifdef INIT_VERBOSE + + .( + +m0 .asc "Init V1.0 booting^M^J",0 +m1 .asc "Start ",34,0 +m2=0 +m3 .asc 34,":",0 +m4 .asc " failed!^M^J",0 +m5 .asc " ok!^M^J",0 +m6 .asc "Couldn't alloc streams!^M^J",0 +#ifdef INIT_RESTART +m7 .asc "^M^JReceived sigchld from ",0 +m8 =m7-3 +m9 .asc "Prepared restart!^M^J",0 +m10 .asc "Could not set device stream!^M^J",0 +#endif + +haddr .byt >m0, >m1, >m2, >m3, >m4, >m5, >m6 +#ifdef INIT_RESTART + .byt >m7, >m8, >m9, >m10 +#endif +laddr .byt main + jsr mloop +#ifdef NOPRG + rts +#else + jmp TERM +#endif + +mainloop lda mp + pha + lda mp+1 + pha + + lda PCBUF+ITX_MSG + asl + tay + lda mainadr,y + pha + lda mainadr+1,y + tay + pla + jsr mloop + + pla + sta mp+1 + pla + sta mp + +showmenu ldy #MP_MENU + lda (mp),y + pha + iny + lda (mp),y + tay + pla + jmp Txtout + +main .word mainmenu + .word mainbef + .word maincode + .word mainloop + +mainmenu .asc TC_FF,"^J^J^J" + .asc "[1] Sony-Master^M^J" + .asc "[2] Sony-CD^M^J" + .asc "[3] Universum-TV^J^M" + .asc "^J^M[q] Ende^M^J",0 + +mainbef .asc "123",0 + +maincode .word 0,1,2 + +mainadr .word sonymaster,sonycdtab,unitv + +&mloop .( + sta mp + sty mp+1 +ml jsr showmenu +mlx jsr Getc + tax + cmp #"q" + beq end + + ldy #MP_BEF + lda (mp),y + sta bp + iny + lda (mp),y + sta bp+1 + + ldy #0 +ml1 lda (bp),y + beq ml + txa + cmp (bp),y + beq execute + iny + bne ml1 + +end clc + rts + +execute tya + asl + pha + ldy #MP_SC + lda (mp),y + sta bp + iny + lda (mp),y + sta bp+1 + pla + tay + lda (bp),y + sta PCBUF+ITX_MSG + iny + lda (bp),y + sta PCBUF+ITX_MSG+1 + ldy #MP_ADR + lda (mp),y + sta bp + iny + lda (mp),y + sta bp+1 + jsr mll + jmp mlx +mll jmp (bp) + .) + +sonycdtab .( + .word menucdtxt + .word befcdtab + .word sycdtab + .word sendsony + +menucdtxt .asc TC_FF,"^J^J^J" + .asc "[P] Play^M^J" + .asc "[U] Pause^M^J" + .asc "[I] Continue^M^J" + .asc "[Y] Display^M^J" + .asc "[S] Stop^M^J" + .asc "[R] Repeat^M^J" + .asc "[L] Shuffle^M^J" + .asc "[N] Next song^M^J" + .asc "[V] Previous song^M^J" + .asc "[1-9] Song no. 1-9^M^J" + .asc "[A-G] Song no. 10-16^M^J" + .asc "[H] >16^M^J" + .asc "[Q] Quit^M^J" + .asc 0 + +befcdtab .asc "puysrnv123456789abcdefghli",0 + +sycdtab .word SY_CD_PLAY, SY_CD_PAUSE, SY_CD_DISP + .word SY_CD_STOP, SY_CD_CLR, SY_CD_AMSV + .word SY_CD_AMSZ, SY_CD_1, SY_CD_2 + .word SY_CD_3, SY_CD_4, SY_CD_5 + .word SY_CD_6, SY_CD_7, SY_CD_8 + .word SY_CD_9, SY_CD_10, SY_CD_11 + .word SY_CD_12, SY_CD_13, SY_CD_14 + .word SY_CD_15, SY_CD_16, SY_CD_G16 + .word SY_CD_SHUFF, SY_CD_CONT + .) + +sonymaster .( + .word symamenu + .word symabef + .word symasc + .word sendsony + +symamenu .asc TC_FF,"^J^J^J" + .asc "[L] LDP on/off^M^J" + .asc "[V] VTR on/off^M^J" + .asc "[T] TV on/off^M^J" + .asc "[A] Audio on/off^M^J" + .asc "[+] Master Volume up^M^J" + .asc "[-] Master Volume down^M^J" + .asc "[M] Muting^M^J" + .asc " Signal sources:^M^J" + .asc "[1] CD^M^J" + .asc "[2] Tuner^M^J" + .asc "[3] Phono^M^J" + .asc "[4] Tape^M^J" + .asc "[5] DAT^M^J" + .asc "[6] Video 1^M^J" + .asc "[7] Video 2^M^J" + .asc "[8] Video 3^M^J" + .asc "[q] End^M^J",0 + +symabef .asc "lvta+-m12345678",0 + +symasc .word SY_MC_P_LDP,SY_MC_P_VTR,SY_MC_P_TV,SY_MC_P_AUDIO + .word SY_MC_VOLU,SY_MC_VOLD,SY_MC_MUTE + .word SY_MC_CD,SY_MC_TUNER,SY_MC_PHONO,SY_MC_TAPE,SY_MC_DAT + .word SY_MC_VIDEO1,SY_MC_VIDEO2,SY_MC_VIDEO3 + .) + +unitv .( + .word unitvmenu + .word unitvbef + .word unitvsc + .word unitvsend + +unitvmenu .asc TC_FF,"^J^J^J" + .asc "[T] TV on/off^J^M" + .asc "[V] TV/VIDEO^J^M" + .asc "[+] volume up^J^M" + .asc "[-] volume down^J^M" + .asc "[M] Muting^J^M" + .asc "[1-9] Program 1-9^J^M" + .asc "[A-C] Program 10-12^J^M" + .asc "[Q] Ende^J^M",0 + +unitvbef .asc "tv+-m123456789abc",0 + +unitvsc .word UNI_TV_POWER,UNI_TV_VIDEO,UNI_TV_VOLU,UNI_TV_VOLD + .word UNI_TV_MUTE,UNI_TV_1,UNI_TV_2,UNI_TV_3,UNI_TV_4 + .word UNI_TV_5,UNI_TV_6,UNI_TV_7,UNI_TV_8,UNI_TV_9 + .word UNI_TV_10,UNI_TV_11,UNI_TV_12 + .) + + .) + +getif .( +#ifdef SEM_T1 + clc + ldx #SEM_T1 + jsr PSEM +#endif + php + sei + lda VIA+VIA_ACR + and #%00111111 + sta VIA+VIA_ACR + + lda VIA+VIA_DDRB + ora #%10000000 + sta VIA+VIA_DDRB + + lda VIA+VIA_DRB + ora #%10000000 + sta VIA+VIA_DRB + + lda #%01000000 + sta VIA+VIA_IFR + sta VIA+VIA_IER + + plp + rts + .) + +freif .( +#ifdef SEM_T1 + ldx #SEM_T1 + jmp VSEM +#else + rts +#endif + .) + + +/**************************** irtxsony.a65 ********************************/ + + +#ifdef CLK1MHZ + +#define SY_TI_START 2500 +#define SY_TI_PAUSE 500 +#define SY_TI_0 650 +#define SY_TI_1 1250 +#define SY_TI_XPAUS 20000 + +#define UNI_TI_PULS 500 +#define UNI_TI_0 1500 +#define UNI_TI_1 3500 +#define UNI_TI_XPAUS 20000 + +#else + +#define SY_TI_START 5000 +#define SY_TI_PAUSE 1000 +#define SY_TI_0 1250 +#define SY_TI_1 2500 +#define SY_TI_XPAUS 40000 + +#define UNI_TI_PULS 1000 +#define UNI_TI_0 3000 +#define UNI_TI_1 7000 +#define UNI_TI_XPAUS 40000 + +#endif + +#define SD_BITS 0 +#define SD_REPT 1 +#define SD_START 2 +#define SD_P0 4 +#define SD_0 6 +#define SD_P1 8 +#define SD_1 10 +#define SD_XPAUS 12 + + .( + .zero +p .word 0 + .data +msgcnt .byt 0 +bitcnt .byt 0 +msg .word 0 + .text + + .( +&&sendsony + lda #sonydat + bne x1 +&&unitvsend + lda #univdat +x1 + sta p + sty p+1 + + jsr getif + + ldy #SD_REPT + lda (p),y + sta msgcnt + + sei + + lda VIA+VIA_ACR + ora #%11000000 + sta VIA+VIA_ACR + +ssml ldy #SD_START + lda (p),y + sta VIA+VIA_T1LL + iny + lda (p),y + sta VIA+VIA_T1CH ; start timer here + + lda PCBUF+ITX_MSG + sta msg + lda PCBUF+ITX_MSG+1 + sta msg+1 + + ldy #SD_BITS ; number of bits + lda (p),y + sta bitcnt + +bitloop lda msg + lsr + bcs pause1 + ldy #SD_P0 + .byt $2c +pause1 ldy #SD_P1 + jsr setsdti ; set time for next half period + jsr waitend ; wait till current half period is over + + lsr msg+1 + ror msg + bcc set0 + + ldy #SD_1 + .byt $2c +set0 ldy #SD_0 + jsr setsdti ; set time for next half period + jsr waitend + + dec bitcnt + bne bitloop + + dec msgcnt + beq msgend + + ldy #SD_XPAUS + jsr setsdti ; pause after last bit + + jsr waitend + + jsr waitend + + jmp ssml + +msgend lda VIA+VIA_ACR + and #%00111111 + sta VIA+VIA_ACR + lda #%01000000 + sta VIA+VIA_IFR + cli + jmp freif + rts + .) + +setsdti .( + lda (p),y + sta VIA+VIA_T1LL + iny + lda (p),y + sta VIA+VIA_T1LH + rts + .) + +waitend .( + lda #%01000000 + sta VIA+VIA_IFR +wl lda #%01000000 + and VIA+VIA_IFR + beq wl + rts + .) + +sonydat .byt 12 ; number of bits + .byt 5 ; number of repetitions for a single command + .word SY_TI_START ; length start bit + .word SY_TI_PAUSE ; break before 0 + .word SY_TI_0 ; 0 + .word SY_TI_PAUSE ; break before 1 + .word SY_TI_1 ; 1 + .word SY_TI_XPAUS ; break between repetitions + +univdat .byt 6 ; number of bits + .byt 4 ; number of repetitions for a single command + .word UNI_TI_PULS ; length start bit + .word UNI_TI_0 ; break before 0 + .word UNI_TI_PULS ; 0 + .word UNI_TI_1 ; break before 1 + .word UNI_TI_PULS ; 1 + .word UNI_TI_XPAUS ; break between repetitions + .) + +/**********************************************************************/ + +Getc .( + ldx #STDIN + sec + jmp fgetc + .) + +Txtout .( + .zero +p .word 0 + .text + sta p + sty p+1 + ldy #0 +l0 lda (p),y + beq end + ldx #STDOUT + sec + jsr fputc + iny + jmp l0 +end rts + .) +ende + .) + diff --git a/dump/oa-2.0.9/sysapps/magic/Makefile b/dump/oa-2.0.9/sysapps/magic/Makefile new file mode 100644 index 0000000..f5041c5 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/magic/Makefile @@ -0,0 +1,12 @@ + + +XA=xa + +all: magic.o65 + +magic.o65: magic.a65 + ${XA} -I../../include -R magic.a65 -o magic.o65; + +clean: + rm -f magic.o65 + diff --git a/dump/oa-2.0.9/sysapps/magic/magic.a65 b/dump/oa-2.0.9/sysapps/magic/magic.a65 new file mode 100644 index 0000000..cace4fd --- /dev/null +++ b/dump/oa-2.0.9/sysapps/magic/magic.a65 @@ -0,0 +1,47 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.1 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This little magic string allows init to determine whether it found + * a valid ROM link chain, and whether it is at the right position + */ + +#include "kdefs.i65" + + .( +start .word ende ; pointer to end of file in ROM + .byt PK_BIN ; file type = binary, no executable + .word 0 ; execution start + .byt 0 ; RAM size needed, in 256-byte blocks + .byt 0 ; shared mem size in 256-byte blocks + .byt 0 ; priority + .word 0 ; stdin, stdout/stderr device number + .asc "magic",0,0 ; command line + + .asc "OSA2ROM" + .word ROMSTART + +ende .) + + diff --git a/dump/oa-2.0.9/sysapps/mcopy/Makefile b/dump/oa-2.0.9/sysapps/mcopy/Makefile new file mode 100644 index 0000000..b1f0aa7 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/mcopy/Makefile @@ -0,0 +1,13 @@ + + +XAINPUT=../../include,../../arch,../.. +XA=xa + +mcopy.o65: mcopy.a65 + (XAINPUT=${XAINPUT}; export XAINPUT;\ + ${XA} -DKERNEL=61440 -R -c mcopy.a65 -o mcopy.o65 ;\ + if [ $$? -ne 0 ]; then rm -f mcopy.o65; fi; ) + +clean: + rm -f mcopy.o65 + diff --git a/dump/oa-2.0.9/sysapps/mcopy/mcopy.a65 b/dump/oa-2.0.9/sysapps/mcopy/mcopy.a65 new file mode 100644 index 0000000..f30a056 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/mcopy/mcopy.a65 @@ -0,0 +1,646 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#ifndef ROM +/*#define NOPRG*/ +#define TEST1 +#define TEST2 +#define TEST3 +#define STDTST +#endif + +#define SEROUT Putc +#define OUT Fputc +#define HEXOUT Hexout +#define TXTOUT Txtout +#define CRLFOUT Crlfout + + .( +#ifdef ROM + .word ende + .byt PK_PRG + .byt 2 + .word 0 + .word PRG + .byt /*8,8,9,9,$a,$a,$b,$b,$c,$c,$d,$d,*/ $e,$e,<-1 + .asc "mcopy",0,0 +#else + +#include "kdefs.i65" +#include "kernel.i65" +#include "fdefs.i65" + +#ifdef NOPRG + + .word $800 + *=$800 + jmp PRG + +#else + ;.word $800 + *=$800 + .word 0 + .byt PK_PRG + .byt 4 + .word 0 + .word PRG + .byt <-1 + +#endif +#endif + +#if 0 + +#ifndef NOMMU +-sysmem =$400 +-syszp =$40 +#endif + +#echo mcopy: +#print sysmem +#print syszp + +#endif + +#define MAXLINE 80 + + .data +outpfad .dsb MAXLINE +inpfad .dsb MAXLINE +inmask .dsb MAXLINE + +c .byt 0 +indrv .byt 0 +outdrv .byt 0 +dirstr .byt 0 + +direntry .dsb FS_DIR_NAME+32 + + .zero +zei .word 0 + + .text + +PRG .( + jsr CRLFOUT + + jsr ininames + bcc l1 +le jmp error +l1 +#ifdef TEST2 + lda indrv + clc + adc #"A" + jsr SEROUT + jsr CRLFOUT + lda #inpfad + jsr TXTOUT + jsr CRLFOUT + lda #inmask + jsr TXTOUT + jsr CRLFOUT + lda outdrv + clc + adc #"A" + jsr SEROUT + jsr CRLFOUT + lda #outpfad + jsr TXTOUT + jsr CRLFOUT +#endif + jsr opendir + bcs le + +ll jsr readentry + bcs le + jsr testentry + bcs ll +#ifdef TEST1 + lda #direntry+FS_DIR_NAME + jsr TXTOUT + jsr CRLFOUT +#endif + jsr copyfile + jmp ll + .) + +copyfile .( + lda indrv + sta PCBUF+FS_OPEN_DRV + ldx #0 + ldy #FS_OPEN_NAME +cp0 lda inpfad,x + beq cp1 + sta PCBUF,y + iny + inx + bne cp0 +cp1 ldx #FS_DIR_NAME +cp2 lda direntry,x + sta PCBUF,y + beq cp3 + inx + iny + bne cp2 +cp3 iny + jsr GETSTR + stx PCBUF+FS_OPEN_STR + stx c +#ifdef TEST1 + php + lda #"s" + jsr SEROUT + txa + jsr HEXOUT + plp +#endif + bcs cpe1x +cp4 lda #SC_REG_RD + jsr STRCMD + lda #FS_OPEN_RD + ldx #SEND_FM + jsr SEND + bcs cpe0x + sec + jsr RECEIVE + cmp #1 + bcs cpe0x + + lda outdrv + sta PCBUF+FS_OPEN_DRV + ldx #0 + ldy #FS_OPEN_NAME +cp5 lda outpfad,x + beq cp6 + sta PCBUF,y + iny + inx + bne cp5 +cp6 ldx #FS_DIR_NAME +cp7 lda direntry,x + sta PCBUF,y + beq cp8 + inx + iny + bne cp7 +cp8 iny + lda c +#ifdef TEST1 + pha + lda #"r" + jsr SEROUT + pla + pha + jsr HEXOUT + pla +#endif + sta PCBUF+FS_OPEN_STR + ldx #SEND_FM + lda #FS_OPEN_OW + jsr SEND +cpe0x bcs cpe0 +cpe1x bcs cpe1y + sec + jsr RECEIVE + cmp #1 + bcs cpe0 + + ldx #3 + clc + jsr error + ldx #4 + clc + jsr error + jsr CRLFOUT + +#ifdef TEST1 + lda #"t" + jsr SEROUT + lda c + jsr HEXOUT +#endif + +cp9 jsr YIELD + ldx c + lda #SC_RWANZ + jsr STRCMD + cpy #1 + bne cp9 + + ldx c + lda #SC_NUL + jsr STRCMD + clc + rts + +cpe0 ldx c + lda #SC_NUL + jsr STRCMD +cpe1 ldx c + jsr FRESTR +cpe1y sec + ldx #2 + rts + .) + +testentry .( + lda direntry+FS_DIR_MODE + cmp #FS_DIR_MOD_FIL + bne notfnd + + ldy #0 + ldx #FS_DIR_NAME + lda inmask,y + beq found +t1 lda inmask,y + beq test2point + cmp #"*" + beq nextpoint + cmp #"." + beq test2point + cmp #"?" + beq t2 + cmp direntry,x + bne notfnd +t2 lda direntry,x + beq notfnd +t3 inx + iny + bne t1 + +nextpoint iny + lda inmask,y + beq np1 + cmp #"." + bne nextpoint + iny +np1 lda direntry,x + bne np2 + lda inmask,y + beq found + bne notfnd +np2 cmp #"." + beq np3 + inx + bne np1 +np3 inx + bne t1 + +test2point + lda direntry,x + beq tp1 + cmp #"." + beq tp1 + cmp #" " + bne notfnd + inx + bne test2point +tp1 cmp inmask,y + bne notfnd + cmp #0 + beq found + bne t3 + +found clc + rts + +notfnd sec + rts + .) + +readentry .( + ldy #0 +rel ldx dirstr + jsr GETC + bcc re1 + cmp #E_EOF + beq rex + jsr YIELD + jmp rel +re1 sta direntry,y + iny + cpy #FS_DIR_NAME+1 + bcc rel +#ifdef TEST3 + jsr Putc +#endif + cmp #0 + bne rel + clc + rts +rex ldx dirstr + lda #SC_NUL + jsr STRCMD + sec + ldx #2 + rts + .) + +opendir .( + lda indrv + sta PCBUF+FS_OPEN_DRV + ldx #0 + stx PCBUF+FS_OPEN_PFAD + ldy #FS_OPEN_NAME +od1 lda inpfad,x + sta PCBUF,y + beq od2 + inx + iny + bne od1 +od2 iny + jsr GETSTR + bcs ode + stx dirstr + stx PCBUF+FS_OPEN_STR +#ifdef TEST3 + tya + pha + lda #"X" + jsr Putc + lda #PCBUF+FS_OPEN_NAME + jsr Txtout + pla + tay +#endif + lda #FS_OPEN_DR + ldx #SEND_FM + jsr SEND + bcs odes +#ifdef TEST3 + lda #"x" + jsr Putc +#endif + sec + jsr RECEIVE + cmp #1 + bcs odes + rts +odes ldx dirstr + jsr FRESTR +ode sec + ldx #1 + rts + .) + +error .( + php + txa + asl + tax + lda tadr+1,x + tay + lda tadr,x + jsr TXTOUT + plp + bcc erts + jmp TERM +erts rts + +tadr .word usage, nodir, eoc, copying, PCBUF+FS_OPEN_NAME + +usage .asc "Usage: mcopy drv:inputfiles drv:outputdir",0 +nodir .asc "Dir nicht gefunden",0 +eoc .asc "Kopie beendet",0 +copying .asc "Kopiere: ",0 + .) + +ininames .( + ldy #1 + sty indrv + sty outdrv + dey +l1 lda PCBUF,y + beq lex + iny + cmp #" " + bne l1 + sta c +l2 lda PCBUF,y + beq lex + cmp #" " + bne l3 + iny + bne l2 +l3 cmp #34 + beq l3a + tax + lda PCBUF+1,y + cmp #":" + bne l3b + txa + and #31 + sta indrv + iny + iny + ldx #0 + lda PCBUF,y + beq lex + cmp #" " + beq l6 +l3b lda PCBUF,y +l3a cmp #34 + bne l4 + sta c + iny + lda PCBUF,y +lex beq le +l4 ldx #0 +l5 sta inpfad,x + inx + iny + lda PCBUF,y + beq le + cmp c + bne l5 + cmp #34 + bne l6 + iny +l6 lda #0 + sta inpfad,x + lda #" " + sta c +l7 lda PCBUF,y + beq le + cmp #" " + bne l8 + iny + bne l7 +l8 cmp #34 + beq l8a + tax + lda PCBUF+1,y + cmp #":" + bne l8b + txa + and #31 + sta outdrv + iny + iny + ldx #0 + lda PCBUF,y + beq lx + cmp #" " + beq lx +l8b lda PCBUF,y +l8a ldx #0 + cmp #34 + bne l9 + sta c + iny + lda PCBUF,y + beq le +l9 sta outpfad,x + iny + inx + lda PCBUF,y + beq lx + cmp c + bne l9 +lx lda #0 + sta outpfad,x + + jmp x1 + +le ldx #0 + sec + rts + +x1 ldy #0 + sty c +x2 lda inpfad,y + beq xx + iny + cmp #DIRSIGN + bne x2 + sty c + beq x2 +xx ldy c + ldx #0 +x3 lda inpfad,y + sta inmask,x + beq x4 + inx + iny + bne x3 +x4 lda #0 + ldy c + sta inpfad,y + + dec indrv + dec outdrv + clc + rts + .) + +/* +TXTOUT .( + sta zei + sty zei+1 + ldy #0 +l1 lda (zei),y + beq le + jsr SEROUT + iny + bne l1 +le rts + .) + + .( + .data +dxr .byt 0 +str .byt 0 + .text + +&SEROUT stx dxr + ldx #STDOUT + bne o0 +&OUT stx dxr +o0 s2 pha + jsr PUTC + pla + bcc s2a + jsr YIELD + jmp s2 +s2a ldx dxr + cmp #0 + rts + +&SERBRK stx dxr + lda #SC_STAT + ldx #STDIN + jsr STRCMD + ldx dxr + cmp #E_SEMPTY + bne s3 + clc + rts +s3 sec + rts + + .) + +#ifdef TEST1 +HEXOUT .( + pha + lsr + lsr + lsr + lsr + jsr nibout + pla + and #$0f +nibout clc + adc #"0" + cmp #":" + bcc n1 + adc #6 +n1 jmp SEROUT + .) +#endif + +CRLFOUT LDA #13:JSR SEROUT +LINEFEED LDA #10 + JMP SEROUT +*/ + +#if 0 +#print sysmem +#print syszp +#endif + +#ifdef STDTST +#define ROM +#include "stdlib/stdio.a65" +#endif + +ende .) + + diff --git a/dump/oa-2.0.9/sysapps/mon/Makefile b/dump/oa-2.0.9/sysapps/mon/Makefile new file mode 100644 index 0000000..73773ac --- /dev/null +++ b/dump/oa-2.0.9/sysapps/mon/Makefile @@ -0,0 +1,13 @@ + + +XAINPUT=../../include,../.. +XA= XAINPUT=${XAINPUT} xa + +all: mon + +mon: mon.a65 shmon.a65 shdir.a65 + ${XA} -R -LLIB6502 -LOSA2KERNEL mon.a65 -o mon; + +clean: + rm -f mon + diff --git a/dump/oa-2.0.9/sysapps/mon/README b/dump/oa-2.0.9/sysapps/mon/README new file mode 100644 index 0000000..f426319 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/mon/README @@ -0,0 +1,6 @@ + +This directory actually contains the old shell and monitor, but with +the shell disabled. They both use the old stdlib functions for +output (which has yet to be changed, as well as the old shell code +removed when a new one is written) + diff --git a/dump/oa-2.0.9/sysapps/mon/mon.a65 b/dump/oa-2.0.9/sysapps/mon/mon.a65 new file mode 100644 index 0000000..a353824 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/mon/mon.a65 @@ -0,0 +1,1561 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/**********************************************************************/ +/* Shell-Prg */ +/* */ +/* wird aufgerufen mit : */ +/* SHORTMON = Dis-/Assembler aus */ +/* NOSYSFKT = im Monitor nix mit Files/System-Aufrufen */ +/* NOMON = kein Monitor */ +/* NOSH = keine Shell */ +/* NOMMU = sysmem/syszp werden 'durchgereicht' */ +/* ROM = wird fuer Startrom assembliert */ +/* NOPRG = wird zum laden und testen ohne PRG-Header ass. */ +/* SHORTLINE = if set, 8 bytes per line in hex dump at start */ +/* */ +/*nicht erlaubt sind : */ +/* NOMON && NOSH */ +/* NOSYSFKT && !NOSH */ +/**********************************************************************/ + +/* + * This is a monitor only - we should use NOSH anyway! + */ +/* #define NOSH */ +#undef MON_USE_STDLIB + +/* + * We have a new kernel... + */ + +#define GETBLK notimp +#define GETMEM notimp +#define GETENV notimp +#define WRITE notimp +#define FREMEM notimp +#define FREENV notimp +#define WTERM notimp + +/*************************************************************************/ + +#ifndef ROM + +/* +#define SHORTMON +/*#define NOMON*/ +/*#define NOSH*/ +/*#define NOSYSFKT*/ +#define NOPRG +/*#define STDTST*/ +/*#define SHOW*/ +*/ +#define SHORTLINE +#define NOSH + +#endif /* ROM */ + +#ifdef MON_USE_STDLIB + +#define OUT Fputc +#define IN Fgetc +#define HEXOUT Hexout +#define SEROUT Putc +#define SERIN Getc +#define SERBRK Serbrk +#define CRLFOUT Crlfout +#define TSERO Txtout +#define DEZOUT Dezbout + +#else + +#define Usedir usedir +#define Chdir mchdir +#define Getname getname +#define Set2name set2name + +#endif /* MON_USE_STDLIB */ + + .( +#ifdef ROM + +#ifndef MON_SHDEV +#define MON_SHDEV 0 +#endif +#ifndef MON_MONDEV +#define MON_MONDEV 7 +#endif +#ifndef MON_SHEXE +#define MON_SHEXE $80 +#endif +#ifndef MON_MONEXE +#define MON_MONEXE $80 +#endif + +/* + * These have both the same execution start address - works only + * with MMU + */ +start .word start2 ; pointer to end of file in ROM + .byt MON_SHEXE ; file type = prg + auto-execute bit + .word PRG1 ; execution start + .byt 16 ; RAM size in 256-byte blocks + .byt >$ff-ROMSTART; $ff-start ; shared mem size in 256-byte blocks + .byt 0 ; priority + .byt MON_SHDEV, MON_SHDEV ; stdin, stdout/stderr device number + .asc "shell",0,"b",0,"c:auto.bat",0,0 ; command line + +start2 .word PRGEND ; pointer to end of file in ROM + .byt MON_MONEXE ; file type = prg + auto-execute bit + .word PRG2 ; execution start + .byt 16 ; RAM size in 256-byte blocks + .byt >$ff-ROMSTART; $ff-start2 ; shared mem size in 256-byte blocks + .byt 0 ; priority + .byt MON_MONDEV, MON_MONDEV ; stdin, stdout/stderr device number + .asc "mon",0,0 ; command line + +#else /* ROM ------------------------------------------------------------*/ + +#include "kdefs.i65" +#include "kernel.i65" +#include "fdefs.i65" + +#define RETRTS /* return from program with RTS */ + ++main jmp as_stdproc + +#endif /* ROM */ + +/**********************************************************************/ + +#ifndef VSA +#define MAXLEN 82 +#define VSA 1 +#define VSB 3 +#define INDEPTH 8 +#endif + + .data +LZEI .byt 0 +IOBUF .dsb MAXLEN + .text + + + .( +#ifndef NOSH +MESSAGE ="#" + .data +bef .byt 0 + .text +#endif + +¬imp lda #E_NOTIMP + sec + rts + +#ifdef ROM + .data +offs .byt 0 +s1 .byt 0 + .text + +&PRG1 ldy #0 + .byt $2c +&PRG2 ldy #start2-start + lda start+2,y + and #3 + cmp #3 + bne as_stdproc +;.byt 2 + sty offs + jsr GETSTR + bcs nostr1 + stx s1 + ldx offs + lda start+8,x + pha + tax + ldy s1 + lda #DC_PS + jsr DEVCMD + pla + tax + lda #DC_RX_ON + jsr DEVCMD + sec + ldx #STDIN + lda s1 + jsr DUP + + jsr GETSTR + bcs nostr1 + stx s1 + ldx offs + lda start+9,x + tax + pha + ldy s1 + lda #DC_GS + jsr DEVCMD + pla + tax + lda #DC_TX_ON + jsr DEVCMD + sec + ldx #STDOUT + lda s1 + jsr DUP + ldx s1 + lda #SC_REG_WR + jsr STRCMD + sec + ldx #STDERR + lda s1 + jsr DUP + jmp as_initproc +nostr1 jmp xterm +#endif +&as_stdproc +/* + ; see if we can read the command line + .( + lda #PCBUF+FORK_NAME + jsr TSERO + jsr CRLFOUT + ldy #FORK_NAME+1 +l0 lda PCBUF-1,y + beq ok + iny + bne l0 +ok tya + ldy #>PCBUF + jsr TSERO + jsr CRLFOUT + .) +*/ + ; we now have to release PCBUF, which we inherited from FORK + ldx #SEM_SENDBUF + jsr VSEM + +as_initproc + + jsr initsig + + lda #TC_ECHO + jsr SEROUT ; switch terminal to full screen mode + +#ifndef NOSYSFKT + jsr inipfad +#endif +#ifndef NOSH + jsr inistdin +#endif +#ifndef NOSYSFKT + jsr inistdout +#endif +#ifndef NOSH + lda #initxt + jsr TSERO + + lda #metxt + jsr TSERO +#ifndef NOMMU + jsr copycmd + bcs p2 + bcc p1 +#else + jmp p2 +#endif + +ploop jsr checksig + lda #metxt + jsr TSERO +p2 jsr MLINEIN: +;.byt 2 + bcs sterm +p1 jsr CHRGOT + jmp px1 +px2 jsr CHRGET +px1 beq ploop + cmp #MESSAGE + beq px2 + jsr testbef + bcs pll + jsr exebef + jmp pl2 +pll +;.byt 2 + jsr loadbef +;.byt 2 +pl2 php + jsr oldoutstr + plp + bcs ple + jsr CRLFOUT + jmp ploop +ple lda #errtxt + jsr TSERO + jmp ploop + +LOGOFF pla + pla +sterm ;jsr clrpfad + jsr clrbatch +#else + jsr MONITOR +#endif +xterm +#ifdef NOPRG + RTS +#else +#ifdef RETRTS + rts +#else + jmp TERM +#endif +#endif + + +#ifndef NOSH +exebef txa + asl + tay + lda befadr+1,y + pha + lda befadr,y + pha + rts + +testbef ldx #0 + stx bef +tb1 ldy LZEI +tb0 lda beftab,x + beq tbok + eor IOBUF,y + beq tb2a + cmp #$20 + bne tb2 +tb2a inx + iny + bne tb0 +tb2 inc bef + lda bef + cmp #anzbef + bcs tbx +tb3 lda beftab,x + inx + cmp #0 + bne tb3 + beq tb1 +tbok lda IOBUF,y + beq tbok1 + cmp #" " + beq tbok1 + cmp #"/" + bne tb2 +tbok1 sty LZEI + clc + ldx bef +tbx rts + +#ifdef NOMON +anzbef =23 +#else +anzbef =24 +#endif + +#ifndef ROM + .data +#endif + +beftab .asc "DIR^@TYPE^@DEL^@FORMAT^@CHKDSK^@RENAME^@" + .asc "B^@BATCH^@" +#ifndef NOMON +&montxt .asc "MONITOR^@" +#endif + .asc "LOGOFF^@" + .asc "COPYCON^@DUP^@CD^@DEVCMD^@COPY^@" + .asc "GETSTR^@FRESTR^@SETMEM^@" + .asc "INFO^@KILL^@MKDIR^@RMDIR^@CHDIR^@" + +befadr .word DIRECTORY-1,TYPE-1,DELETE-1,FORMAT-1,CHKDSK-1 + .word RENAME-1,BATCH-1,BATCH-1 +#ifndef NOMON + .word MONITOR-1 +#endif + .word LOGOFF-1,COPYCON-1,PDUP-1,CD-1 + .word PDEVCMD-1,COPY-1,PGETSTR-1,PFRESTR-1 + .word SETMEM-1,PINFO-1,PKILL-1 + .word MKDIR-1,RMDIR-1,CD-1 + +initxt .asc "^M^JSHELL V" + .byt VSA+"0",".",VSB+"0" + .asc "^M^J(C) 1990-97 BY A.FACHAT^M^J^@" +errtxt .asc " ?^M^J^@" +metxt .asc "^M^J" + .byt MESSAGE,0 +#endif + .text + + .) +#ifndef NOMON +#include "sysapps/mon/shmon.a65" +#endif +#ifndef NOSYSFKT +#include "sysapps/mon/shdir.a65" +#endif + +#ifndef NOSH +PINFO .( + .data +cnt .byt 0 +zei .byt 0 + .text + + ldy #0 +i0 lda it,y + beq info + jsr SEROUT + iny + bne i0 + +info .( +#ifdef NOMMU + clc + ldx #SEM_SENDBUF + jsr PSEM +#endif + jsr GETINFO + ldx #0 + stx cnt + stx zei +infoloop + ldx zei + lda PCBUF+TN_PID,x + jsr HEXOUT + jsr SSPOUT + ldx zei + lda PCBUF+TN_NTHREADS,x + bne name + ldx #TNAMLEN +i1 jsr SSPOUT + dex + bne i1 + beq i2 +name ldy #0 + ldx zei +i4 lda PCBUF+TN_NAME,x + beq i3 + jsr SEROUT + iny + inx + cpy #TNAMLEN + bcc i4 +i3 cpy #TNAMLEN + bcs i2 + jsr SSPOUT + iny + bne i3 +i2 jsr SSPOUT + + ldx zei + lda PCBUF+TN_NTHREADS,x + jsr HEXOUT + jsr SSPOUT + lda PCBUF+TN_ENV,x + jsr HEXOUT + jsr SSPOUT + lda PCBUF+TN_PARENT,x + jsr HEXOUT +; asl +; asl +; tax +; ldy #4 +;i5 lda st,x +; jsr SEROUT +; inx +; dey +; bne i5 + jsr SSPOUT + ldx zei + lda PCBUF+TN_MEM,x + jsr HEXOUT + jsr SSPOUT + lda PCBUF+TN_SIGMASK,x + jsr HEXOUT + jsr SSPOUT + lda PCBUF+TN_SIGNAL+1,x + jsr HEXOUT + lda PCBUF+TN_SIGNAL,x + jsr HEXOUT + jsr SSPOUT + lda PCBUF+TN_STDIN,x + jsr HEXOUT + jsr SSPOUT + lda PCBUF+TN_STDOUT,x + jsr HEXOUT + jsr SSPOUT + lda PCBUF+TN_STDERR,x + jsr HEXOUT + jsr SSPOUT + jsr CRLFOUT + lda zei + clc + adc #TN_SLEN + sta zei + inc cnt + lda cnt + cmp #ANZ_ENV + bcs ie + jmp infoloop +ie +#ifdef NOMMU + ldx #SEM_SENDBUF + jsr VSEM +#endif + clc + rts + .) + +; st .asc "FRE ENV IBRKBRK RDY IRQ WFRXWFTXWSEMWTRM" +it .asc "^M^JPID Name" + .dsb TNAMLEN-5, 32 + .asc " Th En Pa Me Sm SigA In OutErr^M^J",0 + +&PKILL jsr GETADR + bcs pke + sta cnt + jsr GETADR + ldx cnt + jsr KILL +pke rts + .) +#endif + .( + .data +Z0 .byt 0 +Z1 .byt 0 + .text + +#ifndef NOSH +&SETMEM jsr GETADR + bcs MOP1 +#endif +#ifndef NOMON +&Setmem +#endif + cmp #0 + beq MOP1 +#if 0 + cmp #(PRG>>12)&$f ; bis maximal Programmstart umsetzen erlauben + bcs MOP1 +#endif + sta Z0 + lda #7 + sta Z1 +mop5 clc + ldx #OWNTASK + ldy Z1 + jsr SETBLK + ldx Z1 + cpx Z0 + bcc mopram + tax + jsr FREMEM + lda #$0f + bne mopset +mopram cmp #$0f + bne mopnext + jsr GETMEM + bcs mopnext + txa +mopset sec + ldx #OWNTASK + ldy Z1 + jsr SETBLK +mopnext dec Z1 + bpl mop5 + clc +MOP1 RTS + .) + +TOUPPER .( + cmp #"a" + bcc tok + cmp #"z"+1 + bcs tok + sbc #$1f +tok rts + .) + +LINEFEED LDA #10:.BYT $2C +#ifndef NOSYSFKT +PNTOUT lda #".":.byt $2c +#endif +#ifndef NOMON +CROUT LDA #13:.BYT $2C +#endif +SSPOUT LDA #" ":JMP SEROUT + + .( + .data +div .byt 0 +Z0 .word 0 + .text + +&CHRGET inc LZEI +&CHRGOT sty div + ldy LZEI + LDA IOBUF,Y + LDY div + CMP #" " + BEQ CHRGET + CMP #0 + RTS + +&GETADR LDY LZEI:LDA #0:STA Z0:STA Z0+1 +GA1 LDA IOBUF,Y:bne get + jmp GAE +get INY + CMP #" ":BEQ GA1 + + CMP #"%" + BEQ GETBIN + cmp #"." + beq GETDEZ1 + cmp #"$" + beq GETHEX + cmp #"&" + beq GETOKT + DEY + JMP GETHEX + +GETDEZ1 jmp GETDEZ + +GETHEX lda IOBUF,y + jsr tsthex + bcs gae +GA2 INY + ASL Z0:ROL Z0+1:ASL Z0:ROL Z0+1 + ASL Z0:ROL Z0+1:ASL Z0:ROL Z0+1 + ORA Z0:STA Z0 + LDA IOBUF,Y + jsr tsthex + bcc GA2 + jmp GAE1 + +gae jmp GAE + +gb1 SEC:SBC #"0" + CMP #2 + BCS GAE1 + iny + lsr + rol Z0:rol Z0+1 +GETBIN lda IOBUF,Y + beq GAE1 + bne gb1 + +go1 sec:sbc #"0" + cmp #8 + bcs GAE1 + iny + asl Z0:rol Z0+1 + asl Z0:rol Z0+1 + asl Z0:rol Z0+1 + ora Z0:sta Z0 +GETOKT lda IOBUF,y + beq GAE1 + bne go1 + +gd1 sec:sbc #"0" + cmp #10 + bcs GAE1 + iny + pha + asl Z0:rol Z0+1 + lda Z0:ldx Z0+1 + asl Z0:rol Z0+1 + asl Z0:rol Z0+1 + clc:adc Z0:sta Z0 + txa:adc Z0+1:sta Z0+1 + pla + clc + adc Z0 + sta Z0 + bcc GETDEZ + inc Z0+1 +GETDEZ lda IOBUF,y + beq GAE1 + bne gd1 + +GAE1 LDA Z0:LDX Z0+1 + CLC:sty LZEI + rts + +GAE SEC + lda IOBUF,y + STY LZEI + RTS +/* ++TSERO .( + .zero +ZEI .word 0 + .text + + STA ZEI:STY ZEI+1 + LDY #0 +TSO1 LDA (ZEI),Y:BEQ TSO2 + JSR SEROUT:INY:BNE TSO1 +TSO2 RTS + .) +*/ +&tsthex .( + cmp #"A"-1 + bcs th1 + sbc #"0"-1 + cmp #10 + bcc thok +therr sec + rts +th1 beq therr + and #%00011111 + cmp #7 + bcs therr + adc #9 +thok clc + rts + .) + +&MLINEIN .( +#ifndef NOSH + .data +li1 .byt 0 + .text + +#endif + LDY #0 +MO1 JSR SERIN + bcc mo1a +#ifndef NOSH + sty li1 + jsr clstdin + ldy li1 + bcc MO1 +#endif + bcs MO2S + +mo1a ; cmp #127 ; delete + ; beq del + cmp #$1f + bcs MO1A + + CMP #TC_CR:BEQ MO2 + + CMP #TC_BS:BNE MO1 +del ; lda #TC_BS + cpy #0:beq MO1 + dey + jsr SEROUT +/*#ifdef SHOW + ldx #STDERR + jsr OUT +#endif*/ + jmp MO1 + +MO1A STA IOBUF,Y + jsr SEROUT +/*#ifdef SHOW + ldx #STDERR + jsr OUT +#endif*/ + INY:CPY #MAXLEN + BCC MO1:bcs MO2 +MO2S sec:.byt $24 +MO2 CLC +/*#ifdef SHOW + php + lda #13 + ldx #STDERR + jsr OUT + lda #10 + jsr OUT + plp +#endif*/ + LDA #0:STA IOBUF,Y + sta LZEI + RTS + .) +#ifndef NOMMU +#ifndef NOSH +©cmd .( + ldx #<-1 + ldy #0 + lda #" " + sta LZEI +cc1 inx + lda PCBUF,x + beq cce + cmp #" " + beq cc1 + cmp #34 + bne cc2c + sta LZEI + inx +cc2c +#ifndef NOMON + lda PCBUF,x + cmp #"m" + bne cc2d + ldx #0 +cc2a lda montxt,x + sta IOBUF,x + beq cc2b + jsr SEROUT + inx + bne cc2a +#else + dex +#endif +cc2 inx +cc2d lda PCBUF,x + beq cce + cmp LZEI + bne cc2 +cc3 inx + lda PCBUF,x + beq cce + cmp #" " + beq cc3 +cc4 lda PCBUF,x + sta IOBUF,y + jsr SEROUT + iny +cc2b inx + cmp #0 + bne cc4 + lda #0 + sta LZEI + clc + rts +cce sec + rts + .) +#endif +#endif + .) +#ifndef NOSH + .( + .data +insp .byt 0 +inst .dsb INDEPTH + .text + +&inistdin .( + lda #0 + sta insp + rts + .) + +&&setin .( + jsr CHRGOT + cmp #"<" + beq s1 +s2 rts +s1 inc LZEI + jsr ropenfile + bcs s2 + txa + ; jmp opstdin + .) + +&opstdin .( /* a=neuer StdIn-Stream */ + ldx insp + cpx #INDEPTH + bcs ope + ldx #STDIN + sec + jsr DUP + ldx insp + sta inst,x + inc insp + clc +ope rts + .) + +&clstdin .( + ldx insp + sec + beq ope + dex + lda inst,x + stx insp + sec + ldx #STDIN + jsr DUP + tax + lda #SC_NUL + jsr STRCMD + clc +&ope rts + .) + +&clrbatch .( + ldx insp + beq ope + dex + lda inst,x + stx insp + tax + lda #SC_NUL + jsr STRCMD + jmp clrbatch + .) + .) +#endif + +#ifdef NOSYSFKT +setout rts +#else + .( + .data +outstr .byt 0 + .text + +&inistdout .( + lda #<-1 + sta outstr + rts + .) + +&setout .( + jsr CHRGOT + cmp #">" + beq s1 +s2 rts +s1 inc LZEI + jsr wopenfile + bcs s2 + txa + ldx #STDOUT + sec + jsr DUP + sta outstr + rts + .) + +&oldoutstr .( + lda outstr + bmi o1 + jsr CRLFOUT + lda outstr + sec + ldx #STDOUT + jsr DUP + tax + lda #SC_EOF + jsr STRCMD + lda #<-1 + sta outstr +o1 rts + .) + .) +#endif + +#ifndef NOSYSFKT +ldezout .( + + .zero +da .word 0 +lb .byt 0 +lo .byt 0 +w .word 0,0 +out .byt 0 +cnt .byt 0 + .text + + sta da + sty da+1 + stx lb + ldx #39 + +l1 ldy #3 +l1c lda dtab,x + sta w,y + dex + dey + bpl l1c + stx lo + iny + sty out + sty cnt +l2a ldy #3 +l2 lda (da),y + cmp w,y + bcc sloop + bne shift + dey + bpl l2 + bmi xsub +shift ldy #0 + ldx #4 + clc +h1 lda w,y + rol + sta w,y + iny + dex + bne h1 + bcs ende + inc cnt + bne l2a + +sloop dec cnt + bmi end + ldy #3 + clc +s0 lda w,y + ror + sta w,y + dey + bpl s0 + +xsub ldy #3 +x0 lda (da),y + cmp w,y + bcc d0 + bne d1 + dey + bpl x0 +d1 ldy #0 + ldx #4 + sec +d1a lda (da),y + sbc w,y + sta (da),y + iny + dex + bne d1a + sec + .byt $24 +d0 clc + rol out + jmp sloop + +end lda out + beq e3 + ldx #0 + stx lb + beq e1 +e3 bit lo + bmi e1 + lda lb + bne e2 +e1 ora #"0" +e2 jsr SEROUT + + ldx lo + bmi l1b + jmp l1 +l1b ende rts + +dtab .word 1,0 + .word 10,0 + .word 100,0 + .word 1000,0 + .word 10000,0 + .word 34464,1 + .word 16960,15 + .word 38528,152 + .word 57600,1525 + .word 51712,15258 + .) +#endif + +#ifndef MON_USE_STDLIB + + .( + .zero +tx .byt 0 +ty .byt 0 +zp .word 0 + .text + +&HEXOUT .( + pha + lsr + lsr + lsr + lsr + jsr nibble + pla +nibble and #$0f + clc + adc #"0" + cmp #"9"+1 + bcc nibok + adc #6 +nibok jmp SEROUT + .) + +&CRLFOUT .( + lda #13 + jsr SEROUT + lda #10 +&&SEROUT + stx tx + ldx #STDOUT + .byt $2c +&&OUT stx tx +loop pha + jsr PUTC + bcc ok + cmp #E_NUL + beq ok + jsr YIELD + pla + jmp loop +ok pla + ldx tx + rts + .) + +&SERIN .( + stx tx + ldx #STDIN + .byt $2c +&&IN stx tx +loop jsr GETC + bcc ok + cmp #E_EOF + beq ok + jsr YIELD + jmp loop +ok + ldx tx + rts + .) + +&TSERO .( + sta zp + sty zp+1 + ldy #0 +l0 lda (zp),y + beq end + jsr SEROUT + iny + bne l0 +end rts + .) + +&SERBRK .( + stx tx + sty ty + ldx #STDIN + lda #SC_ESTAT + jsr STRCMD + cmp #E_EOF + beq err + tya + and #SCE_BRK + beq ok2 + lda #SC_CSTAT + ldy #SCE_BRK + jsr STRCMD +err sec + .byt $24 +ok clc + ldy ty + ldx tx + rts + +ok2 ldx #STDOUT + lda #SC_STAT + jsr STRCMD + cmp #E_NUL + beq err + bne ok + .) + +&DEZOUT .( +l1 tay + sec + sbc #100 + bcs l1 + lda #0 + sta tx + tya +l2 tay + sec + sbc #10 + bcc l3 + inc tx + bcs l2 +l3 asl tx + asl tx + asl tx + asl tx + tya + ora tx + jmp HEXOUT + .) + +#if 1 /* ndef NOSH */ + +/* Taken directly from Stdlib */ + +/*********************************************************************** + * Warning! The following routines (Directory stuff, assigntab) are + * _not_ thread-save! + */ + +#ifndef PATH_DRV +#define PATH_DRV 0 +#define PATH_NAME (PATH_DRV+1) /* ohne abschliessendes DIRSIGN */ +#endif + + .zero +d .byt 0 +maxpath .byt 0 + .text + + .( + +&&usedir sta zp + sty zp+1 + lda PCBUF+FS_OPEN_DRV + bpl ok ; Laufwerk angegeben, war nix + + ldy #PATH_DRV + lda (zp),y + sta PCBUF+FS_OPEN_DRV + + ldx #FS_OPEN_NAME + lda PCBUF,x + cmp #DIRSIGN ; Pfad absolut angegeben + beq ok ; war auch nix + +ud2 iny + lda (zp),y + bne ud2 + sty d +ud4 lda PCBUF,x + beq ud3 + inx + bne ud4 +ud3 inx + txa + clc + adc d + sta d + bcs nerr + tay +ud5 lda PCBUF,x + sta PCBUF,y + dey + dex + cpx #FS_OPEN_NAME + bcs ud5 + ldy #PATH_NAME +ud6 lda (zp),y + sta PCBUF+FS_OPEN_NAME-PATH_NAME,y + beq ud7 + iny + bne ud6 +ud7 lda #DIRSIGN + sta PCBUF+FS_OPEN_NAME-PATH_NAME,y + ldx d + clc + rts +nerr sec + rts +ok ldx #FS_OPEN_NAME +ok1 lda PCBUF,x + beq oke + inx + bne ok1 +oke inx + clc + rts + .) + + .( +&&mchdir sta zp + sty zp+1 + stx maxpath + lda PCBUF+FS_CMD_DRV + bmi nodrive + ldy #PATH_DRV + cmp (zp),y + beq nodrive + sta (zp),y + iny + lda #0 + sta (zp),y +nodrive inc zp + bne nd1 + inc zp+1 + ldy #0 + ; Name untersuchen +nd1 ldx #FS_CMD_NAME + lda PCBUF,x + bne ndrx ; kein Name dann Pfad l�schen + sta (zp),y + clc + rts +ndrx + cmp #DIRSIGN ; Name beginnt mit DIRSIGN + bne nd2 + lda #0 ; dann Pfad l�schen + sta (zp),y + +nd2a inx +nd2 lda PCBUF,x ; weiter Name anschauen + beq ndr ; kein Name dann Ende + cmp #DIRSIGN + beq nd2a ; DIRSIGN �berlesen + cmp #"." + bne nameok ; kein '.' dann ok + inx + lda PCBUF,x ; hier mindestens ein '.' + beq ndr ; Null dann Ende + cmp #DIRSIGN ; DIRSIGN, + beq nd2a ; dann '.' ignorieren + cmp #"." ; noch'n Punkt ? + bne nerrx ; nein, dann + jsr getpos + ldy d ; Position des letzten DIRSIGNs + lda #0 + sta (zp),y ; l�schen = eine Verzeichnis-Ebene h�her + beq nd2a ; (absolut) + +nerrx dex +nameok jsr getpos ; y=L�nge des alten Pfads + sty d ; hier Verzeichnis-Name an Pfad anh�ngen +no iny + cpy maxpath + bcs nerr + lda PCBUF,x + beq nr + cmp #DIRSIGN + beq nr + sta (zp),y + inx + bne no +nr lda #0 + sta (zp),y + ldy d + lda #DIRSIGN ; alles ok, dann Nullbyte (Ende alter Pfad) mit + sta (zp),y ; DIRSIGN �berschreiben + lda PCBUF,x ; Ende des neuen Verzeichnisses + bne nd2a ; nein, dann wieder nach oben +ndr clc + rts +nerr sec + rts +getpos ldy #0 ; holt y=L�nge des alten Pfadnamens + sty d ; und d=Position des letzten DIRSIGNs +no0 lda (zp),y + beq no1 + cmp #DIRSIGN + bne no2 + sty d +no2 iny + bne no0 +no1 rts + .) + + .( + +&&getname sta zp + sty zp+1 + lda #0 + sta PCBUF+FS_OPEN_NAME + ldy #<-1 + sty PCBUF+FS_OPEN_DRV +g1 iny + lda (zp),y + beq gr + cmp #" " + beq g1 + cmp #":" + beq g1 + cmp #34 ; " + beq g2 + iny + lda (zp),y + dey + cmp #":" + bne g2 + lda (zp),y + cmp #"A" + bcc g3 + sbc #1 +g3 and #$0f + sta PCBUF+FS_OPEN_DRV + iny + iny +g2 dey + ldx #FS_OPEN_NAME + bne g2a + +&&set2name /* x=iobuf, y=pcbuf */ + sta zp + sty zp+1 + ldy #<-1 +g2a lda #" " + sta d +gn1 iny + lda (zp),y + beq gn3 + cmp #" " + beq gn1 + cmp #">" + beq gn3 + cmp #34 ; " + bne gn2 + iny + sta d +gn2 lda (zp),y + beq gn3 + cmp d + beq gn3a + sta PCBUF,x + inx + iny + bne gn2 + +gn3a iny +gn3 lda #0 + sta PCBUF,x + inx +gr rts + .) + +#endif /* NOSH */ + +/******************************************************************/ + +#undef Usedir +#undef Chdir +#undef Getname +#undef Set2name + .) +#endif + + .( + .data +pidtab .dsb 10,0 +pidn .byte 0 + .text + +&initsig .( + lda #0 + sta pidn + lda #sigaddr + sec + jsr SETSIG + lda #SIG_CHLD + clc + jsr SETSIG + rts + .) + +sigaddr .( + tya + pha + txa + pha + jsr CHECKCHLD + bcs nochld + txa + ldy pidn + sta pidtab,y + iny + cpy #10 + bcs nochld + inc pidn +nochld pla + tax + pla + tay + pla + rti + .) + +&checksig .( + ldy pidn + bne gotone + rts +gotone ; output task ID + lda #sigt + jsr TSERO + lda pidtab + jsr HEXOUT ; DEZOUT + jsr CRLFOUT + + jsr decpids + jmp checksig +sigt .asc "Got child t","erm si","gnal from task ",0 + .) + +decpids .( + ldy #0 + php + sei +l0 + lda pidtab+1,y + sta pidtab,y + iny + cpy pidn + bcc l0 + dec pidn + plp + rts + .) + +&waitpid .( + jsr YIELD + ldy pidn + beq waitpid + cmp pidtab + beq found + pha + jsr decpids + pla + jmp waitpid +found jmp decpids + .) + + .) + +PRGEND .) + diff --git a/dump/oa-2.0.9/sysapps/mon/shdir.a65 b/dump/oa-2.0.9/sysapps/mon/shdir.a65 new file mode 100644 index 0000000..068be8c --- /dev/null +++ b/dump/oa-2.0.9/sysapps/mon/shdir.a65 @@ -0,0 +1,1529 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#include "lib6502.i65" + +#ifndef flag_data +#define flag_data %00000001 +#define flag_page %00000010 +#define ANZ_DRV 26 +#endif + + .( + .data +&tpstr .byt 0 +tplen .byt 0 +&tpdrv .byt 0 +filenr .byt 0 +cmd .byt 0 + .text + +#ifndef NOSH + .data +tpenv .byt 0 +fh .dsb P_NAME+30 + .zero +fz .word 0 + .text +#endif + +&ropenfile lda #FS_OPEN_RD /* FS-Kommando Lesen */ + .byt $2c +&wopenfile lda #FS_OPEN_WR /* FS-Kommando Schreiben */ + .( + sta cmd /* speichern */ + jsr GETSTR /* Stream holen */ + bcs tpe /* und speichern */ + stx tpstr + lda cmd + jsr openf /* Datei oeffnen */ + bcc tpe /* Ok dann Ende */ + ldx tpstr /* ansonsten */ + jsr FRESTR /* Stream wieder freigeben */ + sec +tpe ldx tpstr /* Stream-Nummer als Returnwert */ + rts + +&openf +#if 1 /* def NOMMU */ + pha + clc + ldx #SEM_SENDBUF + jsr PSEM + pla + jsr xopenf + php + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + plp + rts +xopenf +#endif + sta cmd + ;jsr getdrv + ;bcs tpfa + ldy LZEI /* Parameter for xsetname */ + ;ldy #FS_OPEN_NAME + jsr xsetname /* Name aus Kommandozeile in PCBUF */ + ;sta tpdrv + ;sta PCBUF+FS_OPEN_DRV + sty LZEI + txa /* Laenge der FS_OPEN-Struktur */ + tay /* in y-Register fuer Send */ + ;sty tplen + ldx tpstr /* Stream-Nummer */ + stx PCBUF+FS_OPEN_STR /* in PCBUF */ + lda #0;jsr getpfad + sta PCBUF+FS_OPEN_PFAD /* Path not valid */ + lda cmd /* Lesen oder Schreiben */ + ldx #SEND_FM /* an File-Systems schicken */ + ;ldy tplen + jsr SEND /* Open losschicken */ + bcs tpfa /* Fehler dann Ende */ + sec /* bei Receive warten */ + jsr RECEIVE /* gets ack message */ + ldx PCBUF+FS_X_FIL /* file number (dumped) */ + stx filenr + cmp #1 /* c=1 bei Fehler */ +tpfa rts + .) + +#ifndef NOSH + +&loadbef .( + .data +cnt .byt 0 +dyr .byt 0 +stdin .byt 0 +stdout .byt 0 +stderr .byt 0 +lzei .byt 0 + .text + + lda LZEI + sta lzei + jsr getdrv + bcs pip1 + tay + jsr CHRGOT + bne pip1 + tya + jsr SETDRV + clc + rts +pip1 lda lzei + sta LZEI + + ldx #STDIN ; I/O-preset + stx stdin + lda #SC_REG_RD + jsr STRCMD + +mpipe ldx #STDOUT + stx stdout + lda #SC_REG_WR + jsr STRCMD + + ldx #STDERR + stx stderr + lda #SC_REG_WR + jsr STRCMD + + lda LZEI + sta lzei + +#if 0 /*--------------------- lib6502 ----------------------*/ + + jsr ropenfile + bcs tpe ; sofort rts + + ldx tpstr ; Datei-Startadr + jsr IN + bcs tpf0 ; SC_NUL + sta fz + ldx tpstr + jsr IN + bcs tpf0 ; SC_NUL + sta fz+1 + ora fz + beq lbtask ; null ist Task, <>0 ist Prg + + lda stdin ; bei Prg muss STDIN bleiben + cmp #STDIN + beq lb0 + jmp tpfx ; SC_NUL->tpstr, clstdxxx + +tpe jmp lbe ; clr stdio + ; rts + +lb0 .( + lda fz ; Prg + sta fh + lda fz+1 + sta fh+1 +lb1 ldx tpstr + jsr IN + bcs lb2 + ldy #0 + sta (fz),y + cmp (fz),y + bne tpf0 + inc fz + bne lb1 + inc fz+1 + bne lb1 +lb2 jsr tpf0 + jmp (fh) + .) + +tpf0 jsr lbe +tpf ldx tpstr + lda #SC_NUL + jsr STRCMD + sec + rts + +lbtask ; Task-Start + ldy #0 +lb3 ldx tpstr + jsr IN + bcs tpfxx ; =tpfx= SC_NUL+clstdxxx + sta fh,y + iny + cpy #P_NAME + bcc lb3 ; Ende Header=Start xTab + ldx tpstr + jsr IN + bcs tpfxx + sta fh,y + iny + cpy #P_NAME+30 ; Ende der Tabelle + bcs tpfxx ; ja dann zuviel + cmp #128 + bcc lb3 ; mpos nicht <0 dann weiter + + lda fh+P_KIND + and #$7f + cmp #PK_PRG ; normales Prg + beq lbprgx + cmp #PK_FS ; File-System (Streams ignorieren) + beq lbfsx + cmp #PK_DEV ; Device Special File + beq lbdevs +tpfxx jmp tpfx ; anderes dann Ende +lbprgx jmp lbprg +lbfsx jmp lbfs + +lbdevs .( + lda fh+P_ADDR + sta fz + lda fh+P_ADDR+1 + and #%00001111 + ora #%01000000 + sta fz+1 + lda fh+P_NAME+1 ; Exchange vorgegeben + bne lbd1 ; dann keinen Speicher suchen + jsr GETMEM + bcs tpfxx ; kein Speicher dann Ende + txa +lbd1 sta fh+P_NAME+1 + ldy #4 + ldx #OWNTASK + sec + jsr SETBLK + bcs tpfxx ; Speichertausch nicht moeglich dann ende + sta tpenv ; alter Block + + lda fh+P_NAME ; m(emory)pos(ition)=0 -> Stack init + bne lbdev + lda #$fe + sta $41ff ; Stack + +lbdev ldx tpstr ; Datei laden + jsr IN + bcs lbde + ldy #0 + sta (fz),y + inc fz + bne lbdev + inc fz+1 + bne lbdev +lbde + lda tpenv ; alten Block wieder in Speicherlandschaft + ldx #OWNTASK + ldy #4 + sec + jsr SETBLK +#if 1 /* def NOMMU */ + clc + ldx #SEM_SENDBUF + jsr PSEM +#endif + ; lda fh+P_NAME ; register device + ; sta PCBUF+REGDEV_MPOS + ; lda fh+P_NAME+1 + ; sta PCBUF+REGDEV_MBLK + lda fh+P_ADDR + tax ; sta PCBUF+REGDEV_ADR + lda fh+P_ADDR+1 + tay ; sta PCBUF+REGDEV_ADR+1 + lda #DC_REGDEV + jsr DEVCMD +#if 1 /* def NOMMU */ + ldx #SEM_SENDBUF + jsr VSEM +#endif + jsr tpf + clc + rts + ;ldx tpstr + ;lda #SC_NUL + ;jmp STRCMD + .) + +lbfs .( + jsr lbe ; clrstdin/out/err + lda #STDNUL + sta stdin + sta stdout + sta stderr + +&lbprg + ldy fh+P_RAM + jsr GETENV ; Environment holen + bcs tpfx ; fehler ->SC_NUL+clstdxxx + stx tpenv + + ldx #P_NAME ; Exchange-Tabelle +lbm1 lda fh,x ; zuende + bmi lbm2 ; dann weiter + tay ; mpos nach y + inx + lda fh,x + inx + stx cnt + cmp #0 ; kein Speicher + bne lbm3 ; dann weiter + sty dyr + jsr GETMEM + bcs lbex ; kein freier Speicher dann Ende + txa + ldy dyr +lbm3 ldx tpenv + sec + jsr SETBLK + bcs lbex ; Tausch nicht gegangen-> Ende + tax + jsr FREMEM + ldx cnt + jmp lbm1 +lbex + ldx tpenv + jsr FREENV +&tpfx + ldx tpstr + lda #SC_NUL + jsr STRCMD +&lbe + jsr clrstdin + jsr clrstdout + jsr clrstderr + sec + rts + +lbey ldx tpenv + jsr FREENV + jmp lbe + +lbeyt lda cmd + cmp #"|" + bne lbey + ldx stdout + lda #SC_NUL + jsr STRCMD + jmp lbey + +lbm2 lda fh+P_ADDR + sta fz + lda fh+P_ADDR+1 + sta fz+1 +lbm4 ; This loop is a bad thing. I should copy + ; a loader to the new environment and let + ; let it load from there instead of + ; putting the whole file there with WRITE... + ldx tpstr + jsr IN + bcs lbm5 ; Ende der Datei + ldx #fz + ldy tpenv + jsr WRITE ; in env schreiben + inc fz + bne lbm4 + inc fz+1 + bne lbm4 +lbm5 + ldx tpstr ; datei abschliessen + lda #SC_NUL + jsr STRCMD + +#endif /*------------------------- lib6502 ------------------------*/ + .( + jmp foobar + +lbeyt lda cmd + cmp #"|" + bne lbey + ldx stdout + lda #SC_NUL + jsr STRCMD +lbey + jsr clrstdin + jsr clrstdout + jsr clrstderr + sec + rts +foobar +;.byt 2 + jsr mdup ; stdxxx setzen -> cmd=Endezeichen + bcs lbey +;.byt 2 + lda cmd ; Endezeichen + bne la1 + inc LZEI +la1 cmp #"|" + bne la2 + jsr clrstdout + jsr GETSTR + bcs lbeyt ; FreEnv+clstdxxx+test pipe (StdIn-Stream) + stx stdout +la2 + jsr checkrom + bcs norom + jmp romok ; returns PID in x +norom + + clc + ldx #SEM_SENDBUF ; get send buffer + jsr PSEM + + lda lzei ; start des Namens + sta LZEI +; jsr getdrv ; drive ueberspringen +; ldy LZEI + ldx #FORK_NAME+1 +; jsr setname ; name in Fork-Struct +; lda lzei +; sta LZEI ; das ganze von vorne + stx lzei ; Laenge Fork-Struct +; jsr getdrv ; drive ueberspringen +;.byt 2 + ldy lzei + ldx LZEI +lbn0 lda #" " ; diesmal in command-Line + sta dyr +lbn1 lda IOBUF,x + sta PCBUF,y + beq endnam + inx + iny + cmp #" " ; space is ok + bne lbnx0 +lbnx2 lda #0 + sta PCBUF-1,y +lbnx1 lda IOBUF,x + cmp #" " + bne lbn1 + inx + bne lbnx1 + +lbnx0 + cmp #34 ; Anfuehrungszeichen + bne lbn2 + sta dyr + beq cpnamlp ; dann Name uebertragen +lbn2 cmp #">" ; I/O-Commands ueberspringen + beq skpnam + cmp #"<" + beq skpnam + cmp #"!" + beq skpnam + cmp #"|" + beq endnam0 ; ende dieses Commands + cmp #"&" + beq endnam0 +cpnamlp lda IOBUF,x ; ansonst Name uebertragen + sta PCBUF,y + beq endnam + inx + iny + cmp dyr + bne cpnamlp + beq lbnx2 ;lbn0 +skpnam dey +skp lda IOBUF,x + beq endnam + inx + cmp #" " ; space vor Namen + beq skp + cmp #">" ; extra IO vor namen + beq skp + cmp #"!" + beq skp ; ueberspringen + cmp #34 + bne s1 + sta dyr +s1 lda IOBUF,x ; Namen ueberspringen + beq endnam + inx + cmp dyr + bne s1 + beq lbn0 + +endnam0 dey +endnam stx LZEI + lda #0 + sta PCBUF,y ; command-Line abschliessen + iny + sta PCBUF,y + iny + sty tplen + + lda stdin + sta PCBUF+FORK_STDIN + lda stdout + sta PCBUF+FORK_STDOUT + lda stderr + sta PCBUF+FORK_STDERR +; lda #4 ;tpenv +; sta PCBUF+FORK_SIZE +; lda #$80 +; sta PCBUF+FORK_SHARED +; lda fh+P_ADDR +; sta PCBUF+FORK_ADDR +; lda fh+P_ADDR+1 +; sta PCBUF+FORK_ADDR+1 + + jsr GETSTR + bcc lbeyx + jmp lbey +lbeyx + stx PCBUF+FORK_NAME + txa + ldx tplen +;.byt 2 + jsr mon_forkto ; returns OS/A PID in XR + +; jsr FORK ; Task starten + +; ldx #SEM_SENDBUF +; jsr VSEM + +romok + +; jsr clrstdin + lda stdout ; if pipe then stdout has an open output + sta stdin +; jsr clrstdout +; jsr clrstderr + + txa + ldx cmd + bne nowait ; ende kein Nullbyte + + jsr waitpid + +; ldx tpenv +; jsr WTERM ; dann Wait bis Term + clc + rts +nowait cpx #"|" ; endezeichen = | + bne nopipe + jmp mpipe ; dann Pipe +nopipe clc + rts + +checkrom .( + ldx lzei + lda IOBUF,x + cmp #"r" + bne nook + inx + lda IOBUF,x + cmp #"o" + bne nook + inx + lda IOBUF,x + cmp #"m" + bne nook + inx + lda IOBUF,x + cmp #" " + beq ok +nook sec + rts +ok stx LZEI + jsr CHRGOT + + jsr ropenfile + bcs nook + clc + ldx #SEM_SENDBUF + jsr PSEM +loop + ldx tpstr + jsr IN ; get first byte + bcs ende + cmp #0 + bne ende + jsr IN + bcs ende + cmp #0 + bne ende + + jsr IN + jsr IN + sta PCBUF+FORK_ADDR + jsr IN + sta PCBUF+FORK_ADDR+1 + jsr IN + sta PCBUF+FORK_SIZE + jsr IN + sta PCBUF+FORK_SHARED + jsr IN + sta PCBUF+FORK_PRIORITY + bcs ende + + lda #SC_NUL + ldx tpstr + jsr STRCMD + + ldx stdin + stx PCBUF+FORK_STDIN + lda #SC_REG_RD + jsr STRCMD + ldx stdout + stx PCBUF+FORK_STDOUT + lda #SC_REG_WR + jsr STRCMD + ldx stderr + stx PCBUF+FORK_STDERR + lda #SC_REG_WR + jsr STRCMD + + /* TODO: copy command line as in lib6502 exec above */ + lda #0 + sta PCBUF+FORK_NAME + + ldy #FORK_NAME+1 + + jsr FORK + bcc done + + jsr lbey + sec +done + rts +ende + lda #SC_NUL + ldx tpstr + jsr STRCMD + sec + rts + .) + + .) + +&&PDUP .( + ldx #STDIN + stx stdin + lda #SC_REG_RD + jsr STRCMD + ldx #STDOUT + stx stdout + lda #SC_REG_WR + jsr STRCMD + ldx #STDERR + stx stderr + lda #SC_REG_WR + jsr STRCMD + + jsr mdup + bcs ende + + lda stdin + ldx #STDIN + sec + jsr DUP + sta stdin + + lda stdout + ldx #STDOUT + sec + jsr DUP + sta stdout + + lda stderr + ldx #STDERR + sec + jsr DUP + sta stderr + clc +ende php + jsr clrstdin + jsr clrstdout + jsr clrstderr + plp + rts + .) + +mdup .( + .data +fl .byt 0 + .text + +lio0 ldx LZEI +lio1 lda IOBUF,x + beq lioex + inx + cmp #" " + beq lio1 + cmp #"|" + beq lioex + cmp #"&" + beq lioex + cmp #">" + bne lin + sta fl + lda IOBUF,x + cmp #"!" + bne a1 + sta fl + inx +a1 stx LZEI + jsr wopenfile + bcs lex + jsr clrstdout + lda tpstr + sta stdout + lda fl + cmp #"!" + bne lio0 + jsr clrstderr + ldx tpstr + stx stderr + lda #SC_REG_WR + jsr STRCMD + jmp lio0 +lioex jmp lioe +lin cmp #"<" + bne lerr + stx LZEI + jsr ropenfile +lex bcs le + jsr clrstdin + lda tpstr + sta stdin + jmp lio0 +lerr cmp #"!" + bne lother + sta fl + lda IOBUF,x + cmp #">" + bne a2 + sta fl + inx +a2 stx LZEI + jsr wopenfile + bcs le + jsr clrstderr + lda tpstr + sta stderr + lda fl + cmp #">" + bne lio0a + jsr clrstdout + ldx tpstr + stx stdout + lda #SC_REG_WR + jsr STRCMD +lio0a jmp lio0 +lother cmp #34 ; Hochkomma + bne lname +lo1 lda IOBUF,x + beq lioe + inx + cmp #34 + bne lo1 + jmp lio1 +lname lda IOBUF,x + beq lioe + inx + cmp #" " + bne lname + jmp lio1 +lioe stx LZEI + sta cmd + clc +le rts + .) + +clrstdin .( + ldx stdin + lda #SC_NUL + jmp STRCMD + .) + +clrstdout .( + ldx stdout + lda #SC_EOF + jmp STRCMD + .) + +clrstderr .( + ldx stderr + lda #SC_EOF + jmp STRCMD + .) + +&© .( + jsr ropenfile + bcs cpe + lda #FS_OPEN_WR + jsr openf + bcc cpe + ldx tpstr + lda #SC_NUL + jsr STRCMD + sec +cpe rts + .) + .) + +©CON .( + jsr wopenfile + bcs cce + bcc cclx +ccl lda #TC_CR + ldx tpstr + jsr OUT +cclx jsr CRLFOUT + jsr MLINEIN + lda IOBUF + cmp #"@" + beq ccc + ldy #0 +ccl2 lda IOBUF,y + beq ccl + ldx tpstr + jsr OUT + iny + bne ccl2 +ccc ldx tpstr + lda #SC_EOF + jsr STRCMD +cce rts + .) + +&TYPE .( + jsr ropenfile + bcs tpe1 + jsr CRLFOUT +tl ldx tpstr + jsr IN + bcs tpft + jsr SEROUT + jmp tl +tpft ldx tpstr + lda #SC_NUL + jsr STRCMD + clc + rts + .) + +&BATCH .( + jsr ropenfile + bcs tpe1 + lda tpstr + jsr opstdin +&tpe1 rts + .) +#endif + .) + +#ifndef NOSH + +PDEVCMD .( + jsr CHRGOT + beq pde + ldy LZEI + ldx #0 + jsr setname + sty LZEI + lda #DC_GNUM + jsr DEVCMD + bcs pde + + stx tpdrv + jsr CHRGOT + ldy #0 + sty tpstr +l0 ldx LZEI +l1 lda cmdtab,y + beq l3 + sec + sbc IOBUF,x + beq l2 + cmp #<-$20 + beq l2 + inc tpstr + lda tpstr + cmp #Anzdevcmd + bcs pde +l4 iny + lda cmdtab,y + bne l4 + iny + bne l0 +l2 inx + iny + bne l1 +l3 lda IOBUF,x + beq l5 + cmp #" " + bne pde +l5 stx LZEI + jsr GETADR + tay + lda tpstr + ldx tpdrv + jsr DEVCMD +pde rts + +Anzdevcmd =12 +cmdtab .asc "IRQ^@RES^@GETSTR^@PUTSTR^@" + .asc "RXON^@TXON^@RXOFF^@TXOFF^@" + .asc "SPEED^@HANDSHAKE^@STATUS^@" + .asc "EXIT^@" + .) + +PGETSTR .( + jsr GETSTR + bcs pge + lda #"=" + jsr SEROUT + txa + jsr HEXOUT + clc +pge rts + .) + +PFRESTR .( + jsr CHRGOT + beq pfe + jsr GETADR + bcs pfe + tax + jsr FRESTR +pfe rts + .) + +FORMAT .( +#if 1 /* def NOMMU */ + clc + ldx #SEM_SENDBUF + jsr PSEM + jsr format_ + php + ldx #SEM_SENDBUF + jsr VSEM + plp + rts +format_ +#endif + ldy LZEI + lda IOBUF,y + cmp #"/" + bne f1 + iny + lda IOBUF,y + cmp #" " + beq f1 + iny + and #%00001111 + tax +f1 sty LZEI + lda #FS_FORMAT + sta dcmd + stx PCBUF+FS_CMD_PFAD + jsr getdrv + bcc f2 +fe rts +f2 ;sta tpdrv + sta PCBUF+FS_CMD_DRV + cmp #$80 + bcs fe + ldy LZEI + ldx #FS_CMD_NAME + jsr setname + jmp fx + +&MKDIR lda #FS_MKDIR + .byt $2c +&RMDIR lda #FS_RMDIR + .byt $2c +&CHKDSK lda #FS_CHKDSK + .byt $2c +&DELETE lda #FS_DELETE + + .data +dcmd .byt 0 + .text + +#if 1 /* def NOMMU */ + pha + clc + ldx #SEM_SENDBUF + jsr PSEM + pla +#endif + ldx #0 + sta dcmd + stx PCBUF+FS_CMD_PFAD +d1 ldy LZEI + jsr xsetname +#if 1 /* def NOMMU */ + jsr fx + php + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + plp + rts +#endif + +fx lda dcmd +&sxcmd pha + txa + tay + pla + ldx #SEND_FM + jsr SEND + bcs dx + sec + jsr RECEIVE +dx cmp #1 + rts + .) + +RENAME .( +#if 1 /* def NOMMU */ + clc + ldx #SEM_SENDBUF + jsr PSEM +#endif + ldy LZEI + ;ldy #FS_CMD_NAME + jsr xsetname + ;sta PCBUF+FS_CMD_DRV + jsr setname + ;ldx PCBUF+FS_CMD_DRV + lda #0;jsr getpfad + sta PCBUF+FS_CMD_PFAD + lda #FS_RENAME +#if 1 /* def NOMMU */ + jsr sxcmd + php + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + plp + rts +#else + jmp sxcmd +#endif + .) + +#endif /* NOSH */ + +DIRECTORY .( + .data +dirstr .byt 0 +dirlen .byt 0 +flag .byt 0 +count .byt 0 + .text + + lda #flag_data + sta flag + ldy LZEI + lda IOBUF,y + cmp #"/" + bne de +d0 iny + lda IOBUF,y + beq de + jsr TOUPPER + cmp #"P" + bne d1 + lda flag + ora #flag_page + sta flag + bne d0 +d1 cmp #"D" + bne d2 + lda flag + and #$ff-flag_data + sta flag + bne d0 +d2 cmp #" " + bne d0 +de sty LZEI +#if 1 /* def NOMMU */ + ; This should be reworked for not + ; blocking the send buffer all the time: +PC_BUF=IOBUF ; done... + clc + ldx #SEM_SENDBUF + jsr PSEM +#else +PC_BUF= PCBUF +#endif + + ldy LZEI + ;ldy #FS_CMD_NAME + jsr xsetname + ;sta PCBUF+FS_OPEN_DRV + sty LZEI + stx dirlen + ldx PCBUF+FS_OPEN_DRV + lda #0;jsr getpfad + sta PCBUF+FS_OPEN_PFAD + jsr GETSTR + bcs dire + stx dirstr + stx PCBUF+FS_OPEN_STR + lda #FS_OPEN_DR + ldx #SEND_FM + ldy dirlen + jsr SEND + bcs dire + sec + jsr RECEIVE +#if 0 /*ndef NOMMU*/ + cmp #1 + bcs dirf +#else + pha +#endif + jsr setout +#if 1 /*def NOMMU*/ + ldx #SEM_SENDBUF + jsr VSEM + pla + cmp #1 + bcs dirf +#endif + jsr showloop +dirf pha + ldx dirstr + jsr FRESTR + pla + cmp #1 +#if 1 /* def NOMMU */ + rts +#endif +dire +#if 1 /* def NOMMU */ + php + pha + ldx #SEM_SENDBUF + jsr VSEM + pla + plp +#endif + rts + +showloop .( + lda #0 + sta count +sloop slp ldy #0 + ldx dirstr + jsr IN + bcc slp2 + lda #0 + rts +sl1 ldx dirstr + jsr IN + bcs sle +slp2 sta PC_BUF,y + iny +#if 1 /* def NOMMU */ + cpy #MAXLEN + bcc llll0 + dey + lda #0 + sta PC_BUF,y + iny +llll1 + jsr IN + bcs sle + cmp #0 + bne llll1 +llll0 +#endif + cpy #FS_DIR_NAME + beq sl1 + bcc sl1 + cmp #0 + bne sl1 + + jsr CRLFOUT + + lda PC_BUF+FS_DIR_MODE + cmp #FS_DIR_MOD_FRE + beq sl00 + cmp #FS_DIR_MOD_NAM + bne sl0 + lda flag + and #flag_data + bne sl0 +sl00 lda flag + and #flag_data + beq slp + jmp showfre + +sle rts +sl0 ldy #FS_DIR_NAME +sl2 lda PC_BUF,y + beq sl13 + jsr SEROUT + iny + bne sl2 +sl13 lda flag + and #flag_data + beq sll +sl3a cpy #24+FS_DIR_NAME + bcs sl14 + lda #" " + jsr SEROUT + iny + bne sl3a +sl14 lda PC_BUF+FS_DIR_MODE + cmp #FS_DIR_MOD_FIL + bne sl15 + jsr showlen + jmp sll +sl15 cmp #FS_DIR_MOD_NAM + bne sl16 + lda #namtxt + jsr TSERO + jmp sll +sl16 cmp #FS_DIR_MOD_DIR + bne sll + lda #dirtxt + jsr TSERO +sll lda flag + and #flag_page + beq sllx + inc count + lda count + cmp #23 + bcc sllx + lda #0 + sta count + lda #pagetxt + jsr TSERO + jsr SERIN +sllx jmp sloop + +showfre jsr showlenx + lda #fretxt + jsr TSERO + jmp sll + +showlenx lda #PC_BUF+FS_DIR_LEN + ldx #" " + jmp ldezout + +showlen jsr showlenx +#ifdef SHORTLINE + rts +#else + jsr SSPOUT + lda PC_BUF+FS_DIR_DAY + jsr DEZOUT + jsr PNTOUT + lda PC_BUF+FS_DIR_MONTH + jsr DEZOUT + jsr PNTOUT + lda PC_BUF+FS_DIR_YEAR + jsr DEZOUT + jsr SSPOUT + lda PC_BUF+FS_DIR_HOUR + jsr DEZOUT + lda #":" + jsr SEROUT + lda PC_BUF+FS_DIR_MIN + jmp DEZOUT +#endif + +dirtxt .asc "^@" +namtxt .asc "^@" +fretxt .asc " BYTES FREE^@" +pagetxt .asc "^M^J^@" + + .) ; showloop + + .) ; DIRECTORY + + .( + .data +ekz .byt 0 +pdrv .byt 0 +pfad .byt 0 +#ifndef NOSH + .dsb MAXLEN ; path +#endif + .text + +HK =34 + +&inipfad .( + lda #0 +&&SETDRV sta pdrv + pha + lda #0 + sta pfad + pla + clc + rts + .) + +#ifndef NOSH +&CD .( + lda LZEI + clc + adc #IOBUF + tay + pla + jsr Getname + lda #pdrv + ldx #MAXLEN + jmp Chdir + +/* + jsr getdrv + ldy #0 + bcs cd00 + cmp #$80 + bcs cd1 + sta pdrv +cd1 ldx LZEI + lda #" " + sta ekz + dex +gn1 inx + lda IOBUF,x + beq gn3 + cmp #" " + beq gn1 + cmp #HK + bne gn2 + inx + sta ekz +gn2 lda IOBUF,x + beq gn3 + cmp ekz + beq gn3a + sta pfad,y + inx + iny + cpy #MAXLEN-2 + bcc gn2 + jsr cd00 + sec + rts + +gn3a inx +gn3 lda pfad-1,y + cmp #DIRSIGN + beq gnn + lda #DIRSIGN + sta pfad,y + iny +gnn lda #0 + sta pfad,y + clc + rts +cd00 sty pdrv + sty pfad + clc + rts +*/ + .) +#endif + +&tstdrv .( + sec + sbc #"A" + bcc xdrv + cmp #"Z"-"A" + bcc okdrv + sbc #$20 + bcc xdrv + cmp #"z"-"a" + bcc okdrv +xdrv lda #<-1 +okdrv rts + .) + +&getdrv .( + jsr CHRGOT + bne t1 + sec + rts +t1 jsr tstdrv + tax + ldy LZEI + iny + lda IOBUF,y + cmp #":" + bne t0a + iny + sty LZEI + txa + clc + rts +t0a lda #<-1 + clc + rts + .) + +&xsetname .( ; y=iobuf + tya + sta ekz + clc + adc #IOBUF + tay + pla + jsr Getname + tya + clc + adc ekz + sta ekz + lda #pdrv + jsr Usedir +#ifdef SHOW + lda PCBUF+FS_OPEN_DRV + jsr HEXOUT + lda #PCBUF+FS_OPEN_NAME + jsr TSERO +#endif + lda PCBUF+FS_OPEN_DRV + ldy ekz + rts +/* + cmp #$80 + bcc x1 + +x1b lda IOBUF,x + cmp #" " + bne x1a + inx + bne x1b + +x1a cmp #"/" + beq xnn + cmp #HK + bne x1c + lda IOBUF+1,x + cmp #"/" + beq xnn + +x1c stx ekz + ldx #0 + +x2 lda pfad,x + beq x3 + sta PCBUF,y + inx + iny + bne x2 + +x3 cpx #1 + bne x4 ; wenn nur "/" dann ueberlesen + dey +x4 ldx ekz +xnn lda pdrv +x1 pha + jsr setname + pla + rts +*/ + .) + +&setname .( /* y=iobuf, x=pcbuf */ + .data +xx .byt 0 + .text + + tya + sta xx + clc + adc #IOBUF + tay + pla + jsr Set2name + tya + clc + adc xx +F + tay + clc + rts + .) + .) + + diff --git a/dump/oa-2.0.9/sysapps/mon/shmon.a65 b/dump/oa-2.0.9/sysapps/mon/shmon.a65 new file mode 100644 index 0000000..aed386d --- /dev/null +++ b/dump/oa-2.0.9/sysapps/mon/shmon.a65 @@ -0,0 +1,1061 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This is the real monitor part of the program. + * Most stuff has just been taken over from the @MON program, + * which you can see by the all-capital writing. + * + */ + + .( + + .zero +Z1 .word 0 +Z2 .word 0 +Z3 .word 0 + .data +ABPZ .byt 0 + .text + +#ifndef NOSYSFKT + .zero +Z0 .word 0 + .text +#endif + +#ifndef SHORTMON + .zero +ZEI .word 0 ; MON TSERO, ASS +Z4 .word 0 ; U(D) +Z5 .word 0 ; U(D) +Z6 =ZEI ; U(D) + .data +LEN .byt 0 ; U/D/A +STBYT .byt 0 ; U/D/A +NR .byt 0 ; U/D/A +INP =Z4+1 ; A + .text +#endif + + .data +BRKPC .word 0 +BRKSR .byt 0 +BRKSP .byt 0 +BRKAC .byt 0 +BRKXR .byt 0 +BRKYR .byt 0 + .text + +MA =1 +MB =3 +MEBYT ="," +MEASS =";" +MEREG ="+" +MESSAGE =">" +IGNORESIGN ="-" + +30000 ;******************************** +30001 ;MONITOR-PROGRAMM +30002 ;******************************** +&MONITOR tsx + dex + dex + stx BRKSP +#ifndef SHORTLINE + lda #16 +#else + lda #8 +#endif + STA ABPZ + lda #M0TXT + jsr TSERO + JSR BR +MXL +#ifndef NOSYSFKT + jsr oldoutstr +#endif + JSR CRLFOUT:LDA #MESSAGE + JSR SEROUT + JSR MLINEIN:bcs termmon +linex jsr CHRGOT:beq MXL:bne mx1 +MO0 jsr CHRGET:beq MXL +mx1 CMP #MESSAGE:BEQ MO0 + jsr TOUPPER + LDX #0:MO3 CMP MONBEF,X:BEQ MO4 + INX:CPX #ANZBEF:BCC MO3 + JSR ERR + JMP MXL +MOX pla + pla +termmon +#ifndef NOSH + rts +#else +#ifdef RETRTS + rts +#else + jmp TERM +#endif +#endif +ERR LDA #M3TXT:JSR TSERO:SEC:RTS +MO4 INC LZEI + JSR MOEX + JMP MXL +MOEX TXA:ASL:TAX:LDA MONADR+1,X + PHA:LDA MONADR,X:PHA:RTS + +#ifdef SHORTMON +BA BD BGD BU jmp ERR +#endif + +#ifndef NOSYSFKT + .( +&MOY ldy LZEI + lda IOBUF,y + beq xERR + inc LZEI + ldy #0 + jsr TOUPPER +y1 cmp ybef,y + beq yok + iny + cpy #anzy + bcc y1 +xERR jmp ERR +yok tya + asl + tax + lda yadr+1,x + pha + lda yadr,x + pha + rts + +anzy =11 +ybef .asc "DMFSREPWVGC" + +yadr .word MOB-1,MOgetmem-1,MOfremem-1 + .word MOgetstr-1,MOfrestr-1 + .word MOgetenv-1,MOfork-1 + .word MOpsem-1,MOvsem-1 + .word MOgetblk-1,DIRECTORY-1 + +MOgetblk jsr GETADR:bcs xERR + tax + jsr GETBLK + jmp show + +MOB JSR GETADR:BCS xERR:STA Z1 + jsr GETADR:bcs xERR:sta Z1+1 + jsr GETADR + tay:lda Z1+1:ldx Z1 + jsr DEVCMD +show jsr mog + jmp BR + +MOgetmem jsr GETMEM + jmp show + +MOfremem jsr GETADR:bcs xERR + tax + jsr FREMEM + jmp show + +MOgetstr jsr GETSTR + jmp show + +MOfrestr jsr GETADR:bcs xERR + tax + jsr FRESTR + jmp show + +MOgetenv jsr GETADR:bcs MOCEOx + tay + jsr GETENV + jmp show + +MOfork +#ifdef NOMMU + clc + ldx #SEM_SENDBUF + jsr PSEM +#endif + jsr GETADR:bcs MOCEOx + sta PCBUF+FORK_ADDR + stx PCBUF+FORK_ADDR+1 + jsr GETADR:bcs MOCEOx + sta PCBUF+FORK_SIZE + jsr GETADR:bcs MOCEOx + sta PCBUF+FORK_SHARED + jsr GETADR:bcs MOCEOx + sta PCBUF+FORK_STDIN + jsr GETADR:bcs MOCEOx + sta PCBUF+FORK_STDOUT + jsr GETADR:bcs MOCEOx + sta PCBUF+FORK_STDERR + + lda #SP_FORK + ldy #6 + sec + ldx #SEND_SYS + jsr SEND +#ifdef NOMMU + jsr mog + ldx #SEM_SENDBUF + jsr VSEM + jmp BR ;show +#else + jmp show +#endif + +MOpsem jsr GETADR:bcs MOCEOx + tax + jsr PSEM + jmp show + +MOvsem jsr GETADR:bcs MOCEOx + tax + jsr VSEM + jmp show + +MOCEOx jmp ERR + .) +#endif + +MOM .( + JSR GET12:BCS MOME:jsr setout +30150 MOM1 JSR MOMZO + jsr SERBRK:bcs MOME +30160 LDA ABPZ:JSR ADCMP:BCC MOM1 +30170 MOME RTS +30180 MOMZO JSR CRLFOUT:LDA #MEBYT:JSR MASOUT +30220 LDY #0:beq mom2:MOM2 jsr SSPOUT:mom2 LDA (Z1),Y +30230 JSR SBYTO:INY:CPY ABPZ:BNE MOM2 + lda #":":jsr SEROUT +30240 LDY #0:MOM3 LDA (Z1),Y +30250 TAX:AND #127:CMP #32:BCS MOM4 +30260 LDX #".":MOM4 TXA:JSR SEROUT +30270 INY:CPY ABPZ:BNE MOM3 +30280 RTS + .) + +BB .( + JSR GET12:BCS MOBE:jsr setout +MOB1 JSR MOBZO + jsr SERBRK:bcs MOBE + LDA #1:JSR ADCMP + BCC MOB1 +MOBE RTS +MOBZO JSR CRLFOUT:LDA #MEBYT:JSR MASOUT + LDY #0 + LDA (Z1),Y + JMP SBINBO + .) + +MASOUT PHA + LDA #MESSAGE + JSR SEROUT + PLA + JSR SEROUT + LDA Z1 + LDX Z1+1 + JSR SADRO + JMP SSPOUT + +GET12 .( + JSR GETADR + BCS GBDX + STA Z1:STX Z1+1 + STA Z2:STX Z2+1 + JSR GETADR + BCS GBD1 + STA Z2:STX Z2+1 +GBD1 CLC +GBDX RTS + .) + +;******** R = REGISTER + +BR .( + jsr setout + LDA #R1TXT + JSR TSERO + +BR2 lda #MESSAGE + jsr SEROUT + LDA #MEREG + jsr SEROUT + LDA BRKPC:LDX BRKPC+1 + JSR SADRO + JSR SSPOUT + LDA BRKAC:JSR SSBOUT + LDA BRKXR:JSR SSBOUT + LDA BRKYR:JSR SSBOUT + LDA BRKSP:JSR SSBOUT + JSR SSPOUT + LDA BRKSR:JMP SBINBO + +;******** GR = GET REGISTER + +&BGR jsr CHRGOT:cmp #IGNORESIGN:beq gr1a + JSR GETADR:bcs bge:STA BRKPC:STX BRKPC+1:jmp gr2:gr1a inc LZEI +gr2 jsr CHRGOT:cmp #IGNORESIGN:beq gr2a + JSR GETADR:bcs bge:STA BRKAC:jmp gr3:gr2a inc LZEI +gr3 jsr CHRGOT:cmp #IGNORESIGN:beq gr3a + JSR GETADR:bcs bge:STA BRKXR:jmp gr4:gr3a inc LZEI +gr4 jsr CHRGOT:cmp #IGNORESIGN:beq gr4a + JSR GETADR:bcs bge:STA BRKYR:jmp gr5:gr4a inc LZEI +gr5 jsr CHRGOT:cmp #IGNORESIGN:beq gr5a + JSR GETADR:bcs bge:STA BRKSP:jmp gr6:gr5a inc LZEI +gr6 jsr CHRGOT:cmp #IGNORESIGN:beq bge + JSR GETADR:bcs bge:ORA #$20:STA BRKSR +bge jsr CROUT + JSR BR2 + rts;JMP MESS + .) + +#ifndef SHORTMON + +;******** D = DISASSEMBLER + +BD .( + JSR GET12:BCS BDX:jsr setout +BD1 JSR SERBRK:bcs BDX + JSR ZEID:BCC BD1 +BDX rts + +12015 &GETPAR LDY #0:LDA (Z1),Y:TAX:AND #$1F:CMP #$10:BNE BDA1 + TXA:LSR:LSR:LSR:LSR:LSR:STA NR:INY:LDA (Z1),Y:PHP +12025 LDX Z1+1:CLC:ADC Z1:BCC BDB1:INX:BDB1 CLC:ADC #2:BCC BDB1A:INX +12030 BDB1A PLP:BPL BDB2:DEX +12035 BDB2 STA Z3:STX Z3+1:LDA #2:STA LEN:LDA #6:STA STBYT:RTS +12040 BDA1 TXA:LDX #0:BD1A CMP CODTEX,X:BNE BD1B +12045 TXA:CLC:ADC #8:BD4B STA NR:LDA #1:STA LEN:RTS +12050 BD1B INX:CPX #37-8:BNE BD1A +12055 LDY #33:STY NR +12060 LDX #0:BD2B LDY #0:BD2A CMP CODTAB,X:BEQ BD2OUT +12065 INX:INY:CPY #5:BNE BD2A:INC NR:LDY NR +12070 CPY #45:BNE BD2B +12075 LDX #0:BD3B LDY #0:BD3A CMP CODLON,X:BEQ BD2OUT +12080 INX:INY:CPY #8:BNE BD3A:INC NR:LDY NR +12085 CPY #54:BNE BD3B:BEQ BD4 +12090 BD2OUT LDA STB,Y:STA STBYT:TAX:LDY #1:LDA (Z1),Y +12095 STA Z3:TXA:AND #4:BEQ BD3:INY +12100 LDA (Z1),Y:STA Z3+1:BD3 INY:STY LEN:RTS +12105 BD4 LDX #4:BD4A CMP ANDC,X:BEQ BD40:DEX:BPL BD4A:LDA #56:BNE BD4B +12110 BD40 LDA ANDT,X:STA NR:LDA ANDA,X:TAY:BNE BD2OUT +12115 &ZEID JSR CRLFOUT:&ZEID2 LDA #MEASS:JSR MASOUT:JSR GETPAR +12120 LDA NR:ASL:CLC:ADC NR:TAY:LDX #3 +12125 ZD1 LDA TEXT,Y:JSR SEROUT:INY:DEX:BNE ZD1 + JSR SSPOUT:LDY LEN:DEY:BEQ ZDEND +12130 LDA STBYT:AND #3:TAY:LDA VORSP,Y:BEQ ZD2:JSR SEROUT +12135 ZD2 LDA #"$":JSR SEROUT +12140 LDA Z3:LDX Z3+1:LSR STBYT:LSR STBYT:LSR STBYT:BCS ZD3:JSR SBYTO +12145 JMP ZD4:ZD3 JSR SADRO +12150 ZD4 LDA STBYT:BEQ ZDEND:ASL:CLC:ADC STBYT:TAY:LDX #3 +12155 ZD41 LDA NAHSP-3,Y:JSR SEROUT:INY:DEX:BNE ZD41 +12160 ZDEND LDY #10:LDA #" ":ZDE1 JSR SEROUT:DEY:BNE ZDE1 +12170 LDA LEN:jmp ADCMP + .) + +#endif + .( +&ADD CLC + ADC Z1 + STA Z1 + LDA #0 + ADC Z1+1 + STA Z1+1 + rts +&ADCMP jsr ADD + bcs cs +&COMP lda Z1+1 + CMP Z2+1 + bne cs + lda Z1 + cmp Z2 +cs rts + .) + +#ifndef SHORTMON + +;******** BGD = ASSEMBLER +BA .( + JSR GETADR:bcs BGD7 + STA Z1:STX Z1+1 + jsr CHRGOT:bne BGD2 + JMP GETEND +&BGD JSR GETADR:STA Z1:STX Z1+1 +BGDLOOP JSR CHRGOT + BNE BGD2:RTS +BGD2 LDX #0:STX NR + lda #TEXT + sta ZEI+1 +BGD3 LDX LZEI:ldy #0 +BGD4 LDA IOBUF,x:sec:sbc (ZEI),y:beq bgd5 + cmp #$20:bne BGD5 +bgd5 INX:INY + CPY #3 + BCC BGD4:BCS BGD6 +BGD5 INC NR:LDA NR:CMP #57:BCS BGD7 + lda ZEI:clc:adc #3:sta ZEI + bcc BGD3:inc ZEI+1:bne BGD3 +BGD7 JMP ERR +BGD6 CLC:LDA #3:ADC LZEI:STA LZEI + lda NR:cmp #56;"???":beq ASSE + JSR GETASC:LDA NR:CMP #8:BCS BGD8 +; BRANCHES + LDA STBYT:CMP #2:BNE BGD7:LDA Z3:SEC + SBC Z1:TAY:LDA Z3+1:SBC Z1+1:TAX + TYA:SEC:SBC #2:TAY:BCS BGDD1:DEX +BGDD1 CPX #0:BEQ BGDD2:INX:BNE BGD7 + TYA:BPL BGD7:BMI BGDD3:BGDD2 TYA:BMI BGD7 +BGDD3 LDY #1:STA (Z1),Y + LDA NR:ASL:ASL:ASL:ASL:ASL:ORA #$10 +ASSEND LDY #0:STA (Z1),Y:ASSE JSR CROUT + JSR ZEID2:JMP GETEND + +BGD8 CMP #37:BCS BGD9:LDY LEN:DEY:BNE BGD8E:TAX:LDY #0 + LDA CODTEX-8,X:JMP ASSEND +BGD8E CMP #33:BCS BGD9 +BA1E JMP ERR +ASKIP jmp ASSE + +BGD9 LDY LEN:DEY:BEQ BA1E + CMP #45:BCS BGDA + + LDY STBYT:CPY #5:BCS BGNF:SEC:SBC #33 + STA NR:ASL:ASL:ADC NR:ADC STBYT:TAX:LDA CODTAB,X +ASS1 BEQ BGNF;BA1E:STA NR + LDY LEN:DEY:BGD9A LDA Z3-1,Y:STA (Z1),Y + DEY:BNE BGD9A:LDA NR:BNE ASSEND + +BGDA CMP #54:BCS BGNF:LDY STBYT:CPY #8:BCS BGNF:SEC:SBC #45 + ASL:ASL:ASL:ADC STBYT:TAX:LDA CODLON,X:JMP ASS1 + +BGNF LDA NR:CMP #56:BEQ ASKIP ;"???" + LDX #4:BGNF1 LDA NR:CMP ANDT,X:BNE BGNF2 + LDA STBYT:CMP ANDA,X:BNE BGNF2 + LDA ANDC,X:BNE ASS1 +BGNF2 DEX:BPL BGNF1 + + ldx STBYT:lda STBX,x:beq bgnf + sta STBYT + inc LEN + lda #0:sta Z3+1 + lda NR:jmp BGD9 +bgnf + JMP ERR + +&GETAUF LDY #0:STY STBYT:INY:STY LEN:JSR CHRGOT:BEQ GAU1 + LDY #0:CMP #"#":BEQ GA2:INY:CMP #"(":BEQ GA2 + INY:bne ga2a +GA2 jsr CHRGET +ga2a TYA:LSR:ROR STBYT:LSR:ROR STBYT + CLC:.BYT $24:GAU1 SEC:RTS + +GETASC JSR GETAUF:BCC GA3:JMP GA1 +GA3 JSR GETADR:STA Z3:STX Z3+1:INC LEN + LDA Z3+1:BEQ GA4:SEC:ROR STBYT:INC LEN:BNE GETZU + +GA4 CLC:ROR STBYT + +&GETZU LDX #0:JSR CHRGOT:BEQ GA7N0:LDA STBYT + AND #96:CMP #32:BNE GA7KL:LDX #3:GA7KL STX INP + JSR CHRGOT:JMP GA7XX +GA7K1 JSR CHRGET +GA7XX BEQ GA7B:CMP #"?":BEQ GA7B + CMP #",":BNE GA7K1:INC INP + JSR CHRGET + CMP #"X":BEQ GA7B + cmp #"x":beq GA7B + cmp #"y":beq GA7K2 + CMP #"Y":BEQ GA7K2 +GAERR JMP ERR + +GA7K2 LDX INP:INX +GA7N0 STX INP +GA7B LDA STBYT:LSR INP:ROR:LSR INP:ROR:LSR INP:ROR:LSR:LSR:STA STBYT +GA1 LDX #9:LDA STBYT + cmp #%00011001:bne GAA:lda #$1d:sta STBYT +GAA CMP STB,X:BEQ GAA1:DEX:BPL GAA + BMI GAERR +GAA1 STX STBYT:ASSRT clc:RTS + +GETEND LDY #0 + LDA #MEASS + JSR INLOOP + BCS ASSRTx + JMP BGDLOOP +ASSRTx cmp #0 + beq ASSRT + pla + pla + jmp linex + .) + +;******** BU = ADRESSEN UMRECHNEN + +BU .( + JSR GETADR:STA Z1:STX Z1+1:JSR GETADR:STA Z2:STX Z2+1 + JSR GETADR:STA Z4:STX Z4+1:jsr GETADR:sta Z5:stx Z5+1 + jsr GETADR:sec:sbc Z4:sta Z6:txa:sbc Z4+1:sta Z6+1 + +BU1 JSR GETPAR:LDA LEN:CMP #3:BNE BU2 + LDX Z3+1:LDA Z3 + cpx Z4+1:BCC BU2:BNE BU3:CMP Z4:BCC BU2 +BU3 CPX Z5+1:BCC BU4:BNE BU2:CMP Z5:BCC BU4:BNE BU2 +BU4 LDY #1:CLC:ADC Z6:STA (Z1),Y:INY:TXA:ADC Z6+1:STA (Z1),Y +BU2 LDA LEN:JSR ADCMP:BCC BU1:RTS + .) + +#endif + +MOG .( + JSR GETADR:BCS ge + STA Z1:STX Z1+1 + jsr setout +#ifndef NOSH + jsr setin +#endif + lda BRKSR + pha + lda BRKAC + ldx BRKXR + ldy BRKYR + plp + jsr go +#ifndef NOSYSFKT +&mog +#endif + php + sta BRKAC + stx BRKXR + sty BRKYR + pla + sta BRKSR + tsx + stx BRKSP + cli + cld +ge rts + +go JMP (Z1) + .) + +;**** + +BI .( + JSR GETADR:bcs MOIE + sta Z1:stx Z1+1 + jsr CHRGOT:bne MOI0 + lda #MEBYT + ldy #0 + jmp MOINL + +&MOI JSR GETADR:STA Z1:STX Z1+1 + BCS MOIE + jsr CHRGOT + beq MOIE +MOI0 LDA #0:STA Z2 +MOI1 JSR GETADR:LDY Z2:BCS MOINL + STA (Z1),Y:INC Z2 + JMP MOI1 +MOIE RTS + +MOINL LDA #0 + STA Z2 + LDA #MEBYT + JSR INLOOP + BCC MOI1 + cmp #0 + clc + beq MOIE + pla + pla + jmp linex + .) + +INLOOP .( + PHA + TYA + CLC + ADC Z1 + STA Z1 + LDA #0 + ADC Z1+1 + STA Z1+1 + JSR CRLFOUT + PLA + JSR MASOUT + JSR MLINEIN + ldy #<-1 +il1 iny + lda IOBUF,y + beq ils + cmp #MESSAGE ; zeile gewechselt + beq ils + cmp #" " + beq il1 + sty LZEI + clc + rts +ils +/*#ifdef SHOW + lda #"c" + ldx #STDERR + jsr OUT +#endif*/ + sec + rts + .) + +;**** + +#ifdef NOSYSFKT +MOE MOS jmp ERR +#else +MOE .( + jsr GETADR + bcs MOER + sta Z2 + jsr GETADR + sta Z2+1 + bcs MOER +set ldx #OWNTASK + ldy Z2 + sec + jsr SETBLK + bcs MOER + jsr CHRGOT + cmp #"+" + beq some + inc Z2 + jsr GETADR + sta Z2+1 + bcc set + clc + rts +some jsr CHRGET + jsr GETADR + sta Z3 +next inc Z2 + inc Z2+1 + ldx #OWNTASK + ldy Z2 + lda Z2+1 + sec + jsr SETBLK + bcs MOER + dec Z3 + bne next + clc + rts +MOER +lda #"E":jsr SEROUT + jmp ERR + .) + +MOS .( + jsr wopenfile + bcs MOSE + stx Z0 + jsr GETADR + bcs mose + sta Z2:stx Z2+1 + jsr GETADR + bcs mose + sta Z1:stx Z1+1 + ldy #0 +mos1 lda Z2+1 + cmp Z1+1 + bcc mos1a + bne mosec + lda Z2 + cmp Z1 + bcs mosec +mos1a lda (Z2),y + ldx Z0 + jsr OUT + inc Z2 + bne mos1 + inc Z2+1 + jmp mos1 +mosec clc +mose php + ldx Z0 + lda #SC_EOF + jsr STRCMD + plp +MOSE bcc msx + jsr ERR +msx rts + .) +#endif + +&MOL .( + JSR CHRGOT + CMP #34 + BNE mol +#ifdef NOSYSFKT + jmp ERR +#else + jsr ropenfile + bcs MOLEx + stx Z0 + jsr GETADR + bcs mole + sta Z2:stx Z2+1 + ldy #0 +moll ldx Z0 + jsr IN + bcs molec + sta (Z2),y + inc Z2 + bne moll + inc Z2+1 + bne moll +molec clc +mole php + lda #":" + jsr SEROUT + lda Z2 + ldx Z2+1 + jsr SADRO + ldx Z0 + lda #SC_NUL + jsr STRCMD + plp +MOLEx bcc mlx + jsr ERR +mlx rts +#endif + +mol JSR GETADR:BCS MOLE +30410 STA Z1:STX Z1+1 +30420 JSR GETADR:BCS MOLE +30430 STA Z2:STX Z2+1:ora Z2+1:beq MOLE +30440 MOLL JSR SERIN:LDY #0:STA (Z1),Y +30450 INC Z1:BNE MOL1:INC Z1+1 +30460 MOL1 LDA Z2:BNE MOL2 +30470 DEC Z2+1:MOL2 DEC Z2:BNE MOLL +30480 LDA Z2+1:BNE MOLL +30490 MOLE RTS + .) + +30499 ;**** + .( +&MOC3 JSR GETADR:BCS MOCX + STA Z1:STX Z1+1 + JSR GETADR:BCS MOCX + STA Z2:STX Z2+1 + JSR GETADR:BCS MOCX + STA Z3:STX Z3+1:RTS + +&MOC JSR MOC3:BCS MOCE:jsr setout:JSR CRLFOUT +30570 MOC2 LDY #0:LDA (Z1),Y:CMP (Z3),Y +30580 BEQ MOC1:LDA Z1:LDX Z1+1 +30590 JSR SADRO:JSR SSPOUT +30600 MOC1 LDA #1:JSR ADCMP:BCS MOCX +30610 INC Z3:BNE MOC2:INC Z3+1 +30620 JMP MOC2 +30630 MOCX RTS +30640 MOCE jmp ERR + .) + +MOF .( + ldy LZEI:lda IOBUF,y:pha:beq mofex + cmp #" ":beq mof00:inc LZEI +mof00 jsr GETADR:sta Z1:stx Z1+1:bcs mofex + jsr GETADR:sta Z2:stx Z2+1:bcs mofex + pla:cmp #" ":bne mofother + + lda #0:sta Z3 +mof0 jsr GETADR:bcs mofn + ldx Z3:sta IOBUF,x:inc Z3 + bne mof0 + +mofn ldy LZEI:lda IOBUF,y + cmp #34:bne mofnx + ldx Z3 +mofn1 iny + lda IOBUF,y + beq mofn2 + cmp #34 + beq mofn2a + sta IOBUF,x + inx + bne mofn1 +mofn2a iny +mofn2 sty LZEI + stx Z3 + bne mof0 + +mofnx lda Z3:beq mofe + + jsr CRLFOUT +mof1 ldy #0 +mofl lda (Z1),y + cmp IOBUF,y + bne mof2 + iny + cpy Z3:bcc mofl + lda Z1:ldx Z1+1:jsr SADRO + jsr SSPOUT +mof2 lda #1:jsr ADCMP:bcc mof1 + rts +mofex pla +mofe jmp ERR + +#ifdef SHORTMON +mofother =*-3 +#else +mofother cmp #"R":beq mofr + cmp #"r":bne mofrn +mofr +18060 LDA #6:STA IOBUF+2:LDA #2:STA IOBUF+1:LDA #%11111111:STA IOBUF +18065 BNE BFA1 +mofrn cmp #"-":beq mofneg:JSR CHRGET:JSR GETAUF:BCS BFA0 +18075 LDA #0:STA IOBUF:STA IOBUF+2:JSR CHRGOT:Beq BFA0 + JSR GADR:bcs mofe:JSR GETZU:bcs BFA3 +18080 STA IOBUF+2 +18085 BFA0 LDA LEN:STA IOBUF+1 +18090 BFA1 JSR GETPAR:LDA LEN:PHA:CMP IOBUF+1:BNE BFA1N:DEC LEN:BEQ BFA1OK +18095 LDA STBYT:CMP IOBUF+2:BNE BFA1N +18100 JSR CADR:BNE BFA1N +18105 BFA1OK JSR CROUT:PLA:JSR ZEID:JMP BFA2 +18110 BFA1N PLA:JSR ADD:BCS BFA3:BFA2 JSR SERBRK:Bcs BFA3 +18115 JSR COMP:BCC BFA1:BEQ BFA1:BFA3 RTS + +mofneg jsr GETADR:sta Z3 + jsr CRLFOUT +mofn3 ldy #0:lda (Z1),y + cmp Z3 + beq mofn4 + lda Z1:ldx Z1+1:jsr SADRO + jsr SSPOUT +mofn4 lda #1:jsr ADCMP:bcc mofn3 + rts + +CADR LDY IOBUF:LDX #0:JSR CBYT:BNE CART:INX:DEC LEN:BEQ CART +1490 CBYT LDA IOBUF+3,X:EOR Z3,X +1495 STA INP:TYA:LSR:TAY:BCS CNI1:LDA INP:AND #$0F:BNE CART +1500 CNI1 TYA:LSR:TAY:BCS CA1:LDA INP:AND #$F0:CART RTS:CA1 LDA #0:RTS + +GADR ldy LZEI:INC LEN:CLC:ROR STBYT +1460 JSR GBYT:bcs GARx:STA IOBUF+4 + lda IOBUF,y:Beq CART2 + CMP #",":BEQ CART2 + CMP #")":beq CART2 +1465 CMP #"?":BEQ CART2 + INC LEN:LDA STBYT:ORA #$80:STA STBYT + jsr GBYT:.byt $24:CART2 clc:.byt $24:GARx sec:sty LZEI:rts +1470 GBYT JSR GNIB:bcs GAR:ASL:ASL:ASL:ASL:STA INP:JSR GNIB:bcs GAR + ORA INP:STA IOBUF+3:clc:RTS +1475 GNIB lda IOBUF,y:beq GAR:iny + CMP #"*":BNE GNI1:LDA #0:SEC:BCS GNI2 +1480 GNI1 JSR tsthex:bcs GAR:CLC:GNI2 ROL IOBUF:clc:RTS + +1140 JSR CHRGET:PHP:dec LZEI +1145 PLP:BEQ GAR:CLC:RTS:GAR SEC:RTS +#endif + .) + +MOT .( + JSR MOC3:BCS MOCEO +30710 LDA Z3+1:CMP Z2+1:BCC MOT1 +30720 BNE MOTA:LDA Z3:CMP Z2:BCS MOTA +30730 MOT1 LDA Z3+1:CMP Z1+1 +30740 BCC MOTA:BNE MOTB +30750 LDA Z3:CMP Z1:BCS MOTB +30760 MOTA LDY #0:LDA (Z1),Y +30770 STA (Z3),Y:INC Z3:BNE MOT2 +30780 INC Z3+1:MOT2 LDA #1:JSR ADCMP +30790 BNE MOTA:RTS + +30800 MOTB LDA Z3:CLC:ADC Z2:STA Z3 +30810 LDA Z3+1:ADC Z2+1:STA Z3+1 +30820 LDA Z3:SEC:SBC Z1:STA Z3 +30830 LDA Z3+1:SBC Z1+1:STA Z3+1:jmp MOT3a +30840 MOT3 LDY #0:LDA (Z2),Y:STA (Z3),Y +30850 MOT3a LDA Z2:BNE MOT4:DEC Z2+1 +30860 MOT4 DEC Z2 +30870 LDA Z3:BNE MOT5:DEC Z3+1 +30880 MOT5 DEC Z3 +30890 JSR COMP +30895 BCC MOT3:BEQ MOT3:RTS + .) + +30899 ;**** + +MOCEO jmp ERR + +MOO .( + JSR GETADR:BCS MOCEO +30906 STA Z1:STX Z1+1 +30907 JSR GETADR:BCS MOCEO +30908 STA Z2:STX Z2+1 +30910 JSR GETADR:BCC MOO1 +30920 LDA #0:MOO1 STA Z3 +30930 MOO2 LDY #0:LDA Z3:STA (Z1),Y +30940 LDA #1:JSR ADCMP:BCC MOO2 +30950 RTS + .) + +30999 ;**** + +MOP .( +#ifndef NOSYSFKT + jsr CHRGOT + beq MOP1 + cmp #IGNORESIGN + beq mop1 + jsr GETADR:bcs MOP1 + jsr SETDRV + jmp mop2 +mop1 inc LZEI +mop2 +#endif + jsr CHRGOT + beq MOP1 + cmp #IGNORESIGN + beq mop3 + JSR GETADR:BCS MOP1 + STA ABPZ + jmp mop4 +mop3 inc LZEI +mop4 jsr GETADR:bcs MOP1 + jsr Setmem +MOP1 rts + .) + +38999 ;******** + +SSBOUT JSR SBYTO + JMP SSPOUT + +SADRO PHA:TXA:JSR SBYTO:PLA +SBYTO PHA:LSR:LSR:LSR:LSR + JSR SNIBO:PLA:AND #$0F +SNIBO CLC:ADC #"0":CMP #"9"+1 + BCC SNO1:ADC #6:SNO1 JMP SEROUT + +SBINBO STX Z3 + pha + LDA #"%" + JSR SEROUT + pla + LDX #8 +s2 ASL + PHA + BCC s1 + lda #"1" + .byt $2c +s1 lda #"0" + jsr SEROUT + pla + dex + bne s2 + ldx Z3 + rts + +M0TXT .ASC "^M^JC*^M^J" + .ASC "MON V" + .BYT MA+"0",".",MB+"0" + .asc " (c) A.Fachat^@" +M3TXT .BYT " ","?",0 +R1TXT .ASC "^M^J PC AC XR YR SP NV1BDIZC^M^J^@" + +MONBEF .ASC "ESMGLCTOPUIFXDBRA" + .BYT MEBYT,MEREG,MEASS +#ifndef NOSYSFKT + .byt "Y" +ANZBEF =21 +#else +ANZBEF =20 +#endif + +MONADR .WORD MOE-1,MOS-1,MOM-1,MOG-1 + .WORD MOL-1,MOC-1,MOT-1,MOO-1 + .WORD MOP-1,BU-1,BI-1,MOF-1 + .WORD MOX-1,BD-1,BB-1,BR-1,BA-1 + .word MOI-1,BGR-1,BGD-1 + +#ifndef NOSYSFKT + .word MOY-1 +#endif + +59999 ;******** + +#ifndef SHORTMON + +61000 TEXT .ASC "BPLBMIBVCBVSBCCBCSBNEBEQ";0-7 +61005 .ASC "BRKCLCCLDCLICLVDEXDEYINXINY";8-16 +61010 .ASC "NOPPHAPHPPLAPLPRTIRTSSECSEDSEI";17-26 +61015 .ASC "TAXTAYTSXTXATXSTYA";27-32 +61020 .ASC "ASLLSRROLRORBITCPXCPYDECINC";33-41 +61025 .ASC "LDYSTXSTYADCANDCMPEORLDALDXORASBCSTAJSRJMP???";42-56 +61030 CODTEX .BYT $00,$18,$D8,$58 +61035 .BYT $B8,$CA,$88,$E8,$C8,$EA +61040 .BYT $48,$08,$68,$28,$40,$60 +61045 .BYT $38,$F8,$78,$AA,$A8,$BA +61050 .BYT $8A,$9A,$98,$0A,$4A,$2A,$6A +61055 CODTAB =* +61060 .BYT $00,$06,$0E,$16,$1E +61065 .BYT $00,$46,$4E,$56,$5E +61070 .BYT $00,$26,$2E,$36,$3E +61075 .BYT $00,$66,$6E,$76,$7E +61080 .BYT $00,$24,$2C,$00,$00 +61085 .BYT $E0,$E4,$EC,$00,$00 +61090 .BYT $C0,$C4,$CC,$00,$00 +61095 .BYT $00,$C6,$CE,$D6,$DE +61100 .BYT $00,$E6,$EE,$F6,$FE +61105 .BYT $A0,$A4,$AC,$B4,$BC +61110 .BYT $00,$86,$8E,$00,$00 +61115 .BYT $00,$84,$8C,$94,$00 +61120 CODLON =* +61125 .BYT $69,$65,$6D,$75,$7D,$79,$61,$71 +61130 .BYT $29,$25,$2D,$35,$3D,$39,$21,$31 +61135 .BYT $C9,$C5,$CD,$D5,$DD,$D9,$C1,$D1 +61140 .BYT $49,$45,$4D,$55,$5D,$59,$41,$51 +61145 .BYT $A9,$A5,$AD,$B5,$BD,$B9,$A1,$B1 +61150 .BYT $A2,$A6,$AE,$00,$00,$BE,$00,$00 +61155 .BYT $09,$05,$0D,$15,$1D,$19,$01,$11 +61160 .BYT $E9,$E5,$ED,$F5,$FD,$F9,$E1,$F1 +61165 .BYT $00,$85,$8D,$95,$9D,$99,$81,$91 +61170 STB .BYT $00,$02,$06,$0A,$0E,$16,$21,$29,$1D,$12 +61175 ANDC .BYT $96,$B6,$20,$4C,$6C +61180 ANDT .BYT 43,50,54,55,55 +61185 ANDA .BYT 9,9,2,2,8 + STBX .BYT 0,2,0,4,0,0,0,0,0,5 +61500 ;**** +61505 VORSP .ASC "#(":.BYT 0 +61510 NAHSP .ASC ",X ,Y ) ,X)),Y" + +#endif + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/Makefile b/dump/oa-2.0.9/sysapps/slipd/Makefile new file mode 100644 index 0000000..d22a445 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/Makefile @@ -0,0 +1,23 @@ + +CC=gcc +CFLAGS=-W -Wall -pedantic -ansi + +XAINPUT=../../include +XA=XAINPUT=${XAINPUT} xa +FILE=file65 +RELOC=reloc65 + +all: slipd + +slipd: $(wildcard *.a65) sltcp.def + # ${XA} -DKERNEL=61440 -R -bt 16384 -bz 128 -bb 8192 -bd 6144 \ + # -G main.a65 -o slipd -l slipd.lab ; + # ${XA} -R -DKERNEL=61440 -DSTDIOADDR=53248 main.a65 -o slipd -l slipd.lab ; + ${XA} -R -LOSA2KERNEL -LLIB6502 main.a65 -o slipd -l slipd.lab ; + +fstcp: fstcp.c fstcp.h + ${CC} ${CFLAGS} fstcp.c -o fstcp +clean: + rm -f slipd slipd.lab slip slip.o65 slip.lab fstcp + + diff --git a/dump/oa-2.0.9/sysapps/slipd/csaip b/dump/oa-2.0.9/sysapps/slipd/csaip new file mode 100755 index 0000000..544cb8a --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/csaip @@ -0,0 +1,31 @@ +#!/bin/sh + +device=cua2 + +pidfile=/var/run/slattach.pid +lockfile=/var/spool/uucp/LCK..$device + +if [ "$1" != "off" ]; then + if [ -f $pidfile ]; then + echo "SLIP already running!" + exit 1; + fi + slattach -l -s 9600 -p slip /dev/$device & + + echo $! > $pidfile + + sleep 1 + + ifconfig sl0 192.168.0.1 up + route add -host 192.168.0.13 sl0 + +else + if [ ! -f $pidfile ]; then + echo "SLIP not running!" + exit 1; + fi + kill -HUP `cat $pidfile` + rm -f $pidfile + rm -f $lockfile +fi; + diff --git a/dump/oa-2.0.9/sysapps/slipd/fstcp.a65 b/dump/oa-2.0.9/sysapps/slipd/fstcp.a65 new file mode 100644 index 0000000..465d1af --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/fstcp.a65 @@ -0,0 +1,935 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + .( + +#include "fstcp.h" + +#define MAXQUEUE MAXFILES + + .bss +status .dsb MAXFILES +stream .dsb MAXFILES +fscmd .dsb MAXFILES +fstask .dsb MAXFILES +fsrxb .dsb MAXFILES ; received data buffer to be transfered to stream +fslot .dsb MAXFILES ; slot when cmd slot has to be requeued + +fsqueue .dsb MAXQUEUE +fsnq .byt 0 +fsconn .byt 0 +fscnt .byt 0 + .text + +fstcp_srv + .byte FSTCP_SERVER_IP, >FSTCP_SERVER_PORT, could not register as filed + lda #<-2 + sta fsconn + + ldx #SEM_SENDBUF + clc + jsr PSEM + + lda #1 + sta PCBUF+FM_REG_DRVS + lda owntask + sta PCBUF+FM_REG_ENV + ldx #SEND_FM + lda #FM_REG + ldy #2 + jsr SEND + + php + ldx #SEM_SENDBUF + jsr VSEM + plp + + bcc ok + rts ; jmp TERM +ok + ldy #0 + lda #F_FREE +l0 sta status,y + iny + cpy #MAXFILES + bcc l0 + + lda #0 + sta fsnq + + lda #<-1 + sta fsconn + + lda #1 + sta fscnt + +openerr + clc + rts + .) + +&&&fstcp_mloop .( /* called from mainloop */ + lda fsconn /* if negative, everything is cleared up */ + bpl ok + dec fscnt /* not give too much load when retrying */ + bne ok + lda #fstcp_srv + jsr tcp_open /* reopen */ + bcs ok +DB("fstcp_mloop: fsconn->") +txa:jsr EHexout:jsr ECrlfout + + stx fsconn +ok rts + .) + +fstcp_queue .( + txa + ldy fsnq + cpy #MAXQUEUE + bcs foops /* shouldn't happen! */ + sta fsqueue,y + inc fsnq + + clc + rts +foops sec + rts + .) + +fstcp_loop .( + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_ESTAB + bne looperr + + ; jsr rxloop + jsr qloop + jsr dloop +looperr rts + .) + + .bss +task .byt 0 +cmd .byt 0 +len .word 0 +slot .byt 0 +fd .byt 0 + .text + +/**************************************************************************** + * check streams and get/put data + */ +dloop .( + ldx #<-1 + stx fd +l0 ldx fd + inx + cpx #MAXFILES + bcc l1 + rts +l1 stx fd + + lda status,x + cmp #F_CMD_REQUEUE + bne norequeue + + lda fslot,x + tax + jsr incownr + jsr tx_requeue_packet + bcs l0 + ldx fd + lda fslot,x + tax + jsr bfree + ldx fd + lda #F_CMD_SENT + sta status,x + jmp l0 + +norequeue + cmp #F_RD + bne rd1 + + ; do read check + lda stream,x + tax + lda #SC_STAT + jsr STRCMD + cmp #E_NUL + bne noend + +rdclose lda #FS_CLOSE + jsr send_msg + bcs l0a +rdc1 ldx fd + lda stream,x + tax + lda #SC_EOF + jsr STRCMD + lda #F_FREE + ldx fd + sta status,x +l0a jmp l0 +noend + cmp #E_SLWM + beq doit + cmp #E_SEMPTY + bne l0a +doit lda #FS_READ + jsr send_msg + bcs l0a ; not queued + ldx fd + lda #F_RD_SENT + sta status,x ; this is changed to F_RD_RXD when a packet was rxd + jmp l0 + +rd1 cmp #F_RD_RXD + beq rdrx + cmp #F_RD_EOF + beq rdrx + cmp #F_RD_CLOSE + beq rdclose + jmp write +rdrx + lda fsrxb,x + tax + jsr getbadr + bcc rd1a +DB("illegal block adr in dloop rd^m^j") +rd1b jmp rdclose +rd1a + sta pp + sty pp+1 +rdloop + ldy #3 + lda (pp),y + sta len+1 + dey + lda (pp),y + sta len + dey + lda (pp),y + tax + dey + lda (pp),y + clc + adc pp + sta pd + txa + adc pp+1 + sta pd+1 +datloop + lda len + ora len+1 + bne datok + + ldx fd + lda fsrxb,x + tax + jsr bfree + + ldx fd + lda status,x + cmp #F_RD_EOF + bne l00 + lda #F_RD_CLOSE + .byt $2c +l00 lda #F_RD + sta status,x + jmp l0 +datok + ldx fd + lda stream,x + tax + ldy #0 + lda (pd),y + jsr PUTC + bcc nextd1 + cmp #E_NUL + bne noclose + +DB("rxd E_NUL from stream^m^j") + ldx fd + lda fsrxb,x + tax + jsr bfree + jmp rdclose +nextd1 jmp nextd +noclose + cmp #E_SFULL + bne nextd +DB("stream full, put back=") +lda len+1:jsr EHexout:lda len:jsr EHexout:jsr ECrlfout + + ; buffer full, so put length back to block + ldy #0 + lda pd + sec + sbc pp + sta (pp),y + iny + lda pd+1 + sbc pp+1 + sta (pp),y + iny + lda len + sta (pp),y + iny + lda len+1 + sta (pp),y + jmp l0 + +nextd inc pd + bne n0 + inc pd+1 +n0 lda len + bne n1 + dec len+1 +n1 dec len + jmp datloop + +write cmp #F_WR_WAIT + beq trysend1 + cmp #F_WR_WEOF + bne nowait +trysend1 + jmp trysend +nowait + cmp #F_WR + beq l0d +l0c1 jmp l0 +l0d + ldx fd + lda stream,x + tax + lda #SC_STAT + jsr STRCMD +pha:DB("STAT gives "):pla:pha:jsr EHexout:jsr ECrlfout:pla + cmp #E_SFULL + beq sendx + cmp #E_SHWM + beq sendx + lda #SC_RWANZ + jsr STRCMD +pha:DB("RWANZ gives "):pla:pha:jsr EHexout:jsr ECrlfout:pla + cmp #0 ; number of writing tasks - last packet! + bne l0c1 +sendx + lda #TCP_DOFFSET+FSP_DATA+64 + ldy #0 + jsr balloc + bcs l0c1 + txa + ldy fd + sta fsrxb,y + lda #TCP_DOFFSET+FSP_DATA + jsr getpinfo + bcs l0c1 + + ldx fd + lda stream,x + tax + ldy #0 +wrl jsr GETC + bcs wrle + sta (pd),y + iny + cpy #64 + bcc wrl + lda #E_OK +wrle pha +tya:pha:DB("GETC gives "):tsx:lda $102,x:jsr EHexout:jsr ECrlfout:pla:tay + lda pd + sec + sbc #FSP_DATA + sta pd + bcs w1 + dec pd+1 +w1 tya + clc + adc #FSP_DATA + sta pdl + ldy #FSP_LEN + sta (pd),y + lda fd + ldy #FSP_FD + sta (pd),y + + ldx fd + lda fsrxb,x + tax + lda pdl + ldy #0 + clc + adc #TCP_DOFFSET + bcc w2 + iny +w2 jsr btrunc + + ldy #0 + lda #TCP_DOFFSET + sta (pp),y + iny + lda pdl + sta (pp),y + iny + lda #0 + sta (pp),y + + pla + cmp #E_EOF + beq wend + ldx #F_WR_WAIT + lda #FS_WRITE + bne we2 +wend ldx #F_WR_WEOF + lda #FS_EOF +we2 + ldy #FSP_CMD + sta (pd),y + txa + ldx fd + sta status,x + + ldx fd + lda fsrxb,y + tax + jsr incownr + jsr tx_queue_packet + bcs l0c + bcc l0e +trysend + ldx fd + lda fsrxb,y + tax + jsr incownr + jsr tx_requeue_packet ; queueslot + bcs l0c +l0e + ldx fd + lda fsrxb,x + tax + jsr bfree + + ldx fd + lda status,x + cmp #F_WR_WAIT + beq l0f + + lda stream,x + tax + lda #SC_NUL + jsr STRCMD + + lda #F_FREE + .byt $2c +l0f lda #F_WR + + ldy fd + sta status,y + +l0c jmp l0 + .) + +/**************************************************************************** + * process requests from filesystem interface + */ +#if 0 +rxloop .( + lda sendbuf ; test WWW server interference + bne norx + clc + jsr RECEIVE + bcc ok +norx rts +ok +#endif + +&&&fstcp_rxmess .( + stx task + sty len + sta cmd + + ldx fsconn + bpl doit +ret jmp retnofil +doit jsr settcb + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_ESTAB + bne ret + ; check for OS/A network calls + /* get free fd */ + jsr getfd + bcc noretnofil + jmp retnofil +noretnofil + sty fd + + /* interprete received request */ + + ldy #0 + lda len + clc + adc #TCP_DOFFSET + bcc l1 + iny +l1 + jsr balloc + bcs retnomem + + sta pp + sty pp+1 + stx slot + + clc + adc #TCP_DOFFSET + sta pd + tya + adc #0 + sta pd+1 + + /* save stream and prepare PCBUF for sending */ + ldy fd + lda cmd + sta fscmd,y + sta PCBUF+FS_OPEN_DRV + lda PCBUF+FS_OPEN_STR + sta stream,y + tya + sta PCBUF+FS_OPEN_PFAD + lda len + sta PCBUF+FS_OPEN_STR + + ldy #0 + lda #TCP_DOFFSET + sta (pp),y + iny + lda #0 + sta (pp),y + iny + lda len + sta (pp),y + iny + lda len+1 + sta (pp),y +/* +DB("cmd=") +lda cmd:jsr EHexout:lda #":":jsr ECout +*/ + ldy #0 +l2 lda PCBUF,y + sta (pd),y + iny + cpy len + bcc l2 + + lda slot + ldy fd + sta fslot,y + tax + jsr incownr + jsr tx_queue_packet + bcs notqueued + + ldx slot + jsr bfree + + lda #F_CMD_SENT + .byt $2c +notqueued + lda #F_CMD_REQUEUE + ldy fd + sta status,y + lda task + sta fstask,y + + lda #E_OK + clc + rts + +retnomem +DB("retnomem!^m^j") + lda #E_NOMEM + .byt $2c +retnofil + lda #E_NOFILE + sta PCBUF+FS_X_ERR + ldy #1 + ldx task + jsr SEND + rts + .) + +getfd .( + ldy #0 + clc +l0 lda status,y + beq found + iny + cpy #MAXFILES + bcc l0 +found rts + .) + +/**************************************************************************** + * check incoming packets + */ +qloop .( + lda fsnq + bne gotone + rts +gotone + /* TODO: this implementation wants each reply in exactly one packet! */ + ldx fsqueue + jsr getbadr + sta pp + sty pp+1 +/* +DB("pp=") +lda pp+1:jsr EHexout: lda pp:jsr EHexout +DB(" do=") +ldy #1: lda (pp),y: jsr EHexout +ldy #0: lda (pp),y: jsr EHexout +DB(", l=") +ldy #3: lda (pp),y: jsr EHexout +ldy #2: lda (pp),y: jsr EHexout +DB(" slot=") +lda fsqueue:jsr EHexout +jsr ECrlfout +*/ + ldy #0 + lda (pp),y + clc + adc pp + sta pd + iny + lda (pp),y + adc pp+1 + sta pd+1 + + iny + lda (pp),y + sta len + iny + lda (pp),y + sta len+1 + + /* interpret reply packet */ + ldy #FSP_FD + lda (pd),y + sta fd + tay + lda status,y + bne noillfd + +illfd DB("illegal FD^m^j") + ldx fsqueue + jsr bfree + jmp nextbuf + +noillfd + ldy #FSP_LEN + lda (pd),y + cmp len + bne illlen + lda len+1 + beq noilllen + +illlen DB("illegal len^m^j") +disc ldx fsqueue + jsr bfree + jmp nextbuf +noilllen +/* +DB("pkt type ") +ldy #FSP_CMD:lda (pd),y:jsr EHexout +DB(", fd="):lda fd:jsr EHexout +DB(", st="):ldy fd:lda status,y:jsr EHexout:jsr ECrlfout +*/ + ldy #FSP_CMD + lda (pd),y + cmp #FS_REPLY + beq reply + jmp noreply +reply + /* first (and only) data byte is reply value */ + lda len + cmp #4 + bne illlen + + ldx fd + lda status,x + cmp #F_CMD_SENT + beq noillreply +DB("reply but not CMD_SENT: st=") +lda status,x:jsr EHexout:jsr ECrlfout + jmp disc +noillreply + + ldy #FSP_DATA + lda (pd),y + sta PCBUF+FS_X_ERR + cmp #E_OK + bne l1 + ldy fd + lda fscmd,y + cmp #FS_OPEN_RD + beq rd + cmp #FS_OPEN_WR + beq wr + cmp #FS_OPEN_DR + bne l1 +rd lda #F_RD + .byt $2c +wr lda #F_WR + .byt $2c +l1 + lda #F_FREE + ldy fd + sta status,y + + ldy fd + lda fstask,y + tax + ldy #FS_X_SLEN + lda PCBUF+FS_X_ERR + jsr SEND + + ldx fsqueue + jsr bfree + jmp nextbuf + +noreply cmp #FS_WRITE + beq write + cmp #FS_EOF + bne nowrite + ldy #F_RD_EOF + .byt $2c +write ldy #F_RD_RXD + ldx fd + lda status,x + cmp #F_RD_SENT + bne illwrite + lda fsqueue + ldx fd + sta fsrxb,x + tya + sta status,x + + ldx fsqueue + jsr getbadr + sta pp + sty pp+1 + ldy #0 + lda (pp),y + clc + adc #FSP_DATA + sta (pp),y + iny + lda (pp),y + adc #0 + sta (pp),y + iny + lda (pp),y + sec + sbc #FSP_DATA + sta (pp),y + iny + lda (pp),y + sbc #0 + sta (pp),y + jmp nextbuf +illwrite + DB("illegal write ^m^j") + ldx fsqueue + jsr bfree + jmp nextbuf +nowrite + DB("packet not a reply!^m^j") + ldx fsqueue + jsr bfree + +nextbuf + ldy #1 +l0 lda fsqueue,y + dey + sta fsqueue,y + iny + iny + cpy fsnq + bcc l0 + dec fsnq + jmp qloop + + .) + +/**************************************************************************** + * process signal from tcp + */ +fstcp_signal .( +#if 0 + pha + DB("fstcp_signal: ") + pla:pha: jsr EHexout + jsr ECrlfout + pla +#endif + jsr tcp_signal + + ldx #0 + stx fd +l0 lda status,x + beq next + cmp #F_CMD_REQUEUE + bne noreq + + lda fslot,x + tax + jsr bfree + lda #F_FREE + ldx fd + sta status,x + jmp l0 +noreq + cmp #F_RD + bcc next + cmp #F_RD_RXD + beq r1 + cmp #F_RD_EOF + beq r1 + cmp #F_RD_CLOSE+1 + bcs write + bcc rdc1 + +r1 lda fsrxb,x + tax + jsr bfree + +rdc1 ldx fd + lda stream,x + tax + lda #SC_EOF + jsr STRCMD + jmp nextfree + +write cmp #F_WR + beq wrc + cmp #F_WR_WAIT + beq w1 + cmp #F_WR_WEOF + bne next +w1 + ldx fd + lda fsrxb,x + tax + jsr bfree +wrc + ldx fd + lda stream,x + tax + lda #SC_NUL + jsr STRCMD +nextfree + ldx fd + lda #F_FREE + sta status,x + +next inc fd + ldx fd + cpx #MAXFILES + bcc l0 + +q1 ldy fsnq + beq noqueue + dey + lda fsqueue,y + tax + jsr bfree + dec fsnq + jmp q1 +noqueue + lda #<-1 + sta fsconn + sta fscnt + rts + .) + +/****************************************************************************/ + +send_msg .( + sta cmd + ldy #0 + lda #TCP_DOFFSET+3 + + jsr balloc + bcs retnomem2 + + lda #TCP_DOFFSET + jsr getpinfo + bcs retnomem2 + + /* save stream and prepare PCBUF for sending */ + ldy #0 + lda cmd + sta (pd),y + iny + lda #3 + sta (pd),y + iny + lda fd + sta (pd),y + + ldy #0 + lda #TCP_DOFFSET + sta (pp),y + iny + lda #0 + sta (pp),y + iny + lda #3 + sta (pp),y + iny + lda #0 + sta (pp),y + + ldx pslot + jsr tx_queue_packet ; is checked with send_msg return +retnomem2 + rts + .) + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/fstcp.c b/dump/oa-2.0.9/sysapps/slipd/fstcp.c new file mode 100644 index 0000000..97400be --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/fstcp.c @@ -0,0 +1,358 @@ +/**************************************************************************** + + OS/A65 Version 1.3.13 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This file is a server FSTCP filesystem implementation, to be + * used with the FSTCP program on an OS/A65 computer. + * + * usage: + * fstcp [options] exported_directory + * + * options: + * -ro export read-only + */ + +#define PORT 8090 + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include + +#include "oa1fs.h" +#include "fstcp.h" + +#define min(a,b) (((a)<(b))?(a):(b)) + +typedef struct { + int state; + FILE *fp; + DIR *dp; +} File; + +File files[MAXFILES]; + +void usage(void) { + printf("Usage: fstcp [options] exported_directory hostname_to_export_to\n" + " options=\n" + " -ro export read-only\n" + ); + exit(1); +} + +void do_cmd(char *buf, int fd) { + int tfd, cmd, len; + char retbuf[200]; + char *nm; + FILE *fp; + DIR *dp; + int n; + struct dirent *de; + struct stat sbuf; + struct tm *tp; + + cmd = buf[FSP_CMD]; + tfd = buf[FSP_FD]; + len = buf[FSP_LEN]; + fp = files[tfd].fp; + dp = files[tfd].dp; + + printf("got cmd=%d, fd=%d, name=%s\n",cmd,tfd, + cmdd_name, &sbuf); + /* TODO: check return value */ + retbuf[FSP_DATA+FS_DIR_LEN] = sbuf.st_size & 255; + retbuf[FSP_DATA+FS_DIR_LEN+1] = (sbuf.st_size >> 8) & 255; + retbuf[FSP_DATA+FS_DIR_LEN+2] = (sbuf.st_size >> 16) & 255; + retbuf[FSP_DATA+FS_DIR_LEN+3] = (sbuf.st_size >> 24) & 255; + + tp = localtime(&sbuf.st_mtime); + retbuf[FSP_DATA+FS_DIR_YEAR] = tp->tm_year; + retbuf[FSP_DATA+FS_DIR_MONTH] = tp->tm_mon; + retbuf[FSP_DATA+FS_DIR_DAY] = tp->tm_mday; + retbuf[FSP_DATA+FS_DIR_HOUR] = tp->tm_hour; + retbuf[FSP_DATA+FS_DIR_MIN] = tp->tm_min; + retbuf[FSP_DATA+FS_DIR_SEC] = tp->tm_sec; + + retbuf[FSP_DATA+FS_DIR_MODE] = S_ISDIR(sbuf.st_mode) ? + FS_DIR_MOD_DIR : FS_DIR_MOD_FIL; + strncpy(retbuf+FSP_DATA+FS_DIR_NAME, de->d_name, + min(strlen(de->d_name)+1, 199-FSP_DATA-FS_DIR_NAME)); + retbuf[199]=0; + retbuf[FSP_LEN] = FSP_DATA+FS_DIR_NAME+ + strlen(retbuf+FSP_DATA+FS_DIR_NAME) + 1; + retbuf[FSP_CMD] = FS_WRITE; + } else + if(fp) { + n = fread(retbuf+FSP_DATA, 1, 64, fp); + retbuf[FSP_LEN] = n+FSP_DATA; + if(n<64) { + retbuf[FSP_CMD] = FS_EOF; + fclose(fp); + files[tfd].fp = NULL; + } else { + retbuf[FSP_CMD] = FS_WRITE; + } + } + break; + case FS_WRITE: + case FS_EOF: + if(fp) { + n = fwrite(buf+FSP_DATA, 1, len-FSP_DATA, fp); + retbuf[FSP_DATA] = 0; + if(cmd == FS_EOF) { + fclose(fp); + files[tfd].fp = NULL; + } + } + break; + case FS_CLOSE: + if(fp) fclose(fp); + if(dp) closedir(dp); + files[tfd].fp = NULL; + files[tfd].dp = NULL; + retbuf[FSP_DATA] = 0; + break; + } + + + write(fd, retbuf, retbuf[FSP_LEN]); + printf("write %02x %02x %02x %02x\n", retbuf[0], retbuf[1], + retbuf[2], retbuf[3]); +} + +int main(int argc, char *argv[]) { + int sock, err; + struct sockaddr_in serv_addr, client_addr, host_addr; + int client_addr_len; + int port=PORT; + int fd; + int i, ro=0; + char *dir, *hname; + struct hostent *he; + + i=1; + while(ih_name); + if(he->h_addrtype != AF_INET) { + fprintf(stderr, "Address type for %s not Internet!\n", hname); + exit(2); + } + + memcpy((char*)&host_addr.sin_addr.s_addr, he->h_addr_list[0], + he->h_length); + +/* host_addr.sin_addr.s_addr = ntohl(*(long*)(he->h_addr_list[0]));*/ + + printf("ok, want connection to %08x\n", host_addr.sin_addr.s_addr); + + for(i=0;i FSP_LEN) { + plen = buf[rdp+FSP_LEN]; +printf("wrp-rdp=%d, plen=%d\n",wrp-rdp,plen); + if(wrp-rdp >= plen) { + do_cmd(buf+rdp, fd); + rdp +=plen; + } else { + break; + } + } + } + exit(0); + } else { + printf("connect trial rejected!\n"); + close(fd); + } + } + + close(sock); + return 0; +} + diff --git a/dump/oa-2.0.9/sysapps/slipd/fstcp.h b/dump/oa-2.0.9/sysapps/slipd/fstcp.h new file mode 100644 index 0000000..ee82fb4 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/fstcp.h @@ -0,0 +1,59 @@ +/**************************************************************************** + + OS/A65 Version 1.3.12 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +#include "../../include/fdefs.i65" /* needed for FS_LASTCODE */ +/* + * additional FS commands to be sent between fstcp client & server + * transparent to normal FS_* codes + */ +#define FS_READ FS_LASTCODE /* pull data (FSTCP internal) */ +#define FS_WRITE FS_LASTCODE+1 /* push data (FSTCP internal) */ +#define FS_REPLY FS_LASTCODE+2 /* return value (FSTCP internal) */ +#define FS_EOF FS_LASTCODE+3 /* as FS_WRITE, but signal EOF after */ + /* last byte sent */ + + +#define MAXFILES 4 + +/* data struct exchanged with server */ +#define FSP_CMD 0 +#define FSP_LEN 1 +#define FSP_FD 2 +#define FSP_DATA 3 + +/* status values */ +#define F_FREE 0 /* must be 0 */ +#define F_CMD_SENT 1 +#define F_CMD_REQUEUE 2 /* CMD must be requeued */ + +#define F_RD 3 /* no buffer to put to stream */ +#define F_RD_SENT 4 /* FS_READ request sent */ +#define F_RD_RXD 5 /* FS_WRITE reply received */ +#define F_RD_EOF 6 /* FS_EOF reply received */ +#define F_RD_CLOSE 7 /* FS_EOF reply processed */ + +#define F_WR 8 +#define F_WR_WAIT 9 /* buffer ready but not (yet) sent */ +#define F_WR_WEOF 10 /* last buffer ready but not (yet) sent */ + diff --git a/dump/oa-2.0.9/sysapps/slipd/icmp.a65 b/dump/oa-2.0.9/sysapps/slipd/icmp.a65 new file mode 100644 index 0000000..c5d5c83 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/icmp.a65 @@ -0,0 +1,204 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * receive icmp messages and process them (icmp2). + * generate icmp error messages for traceroute (replytrace) + * generate icmp port unreachable message for all incoming udp traffic (porterr) + */ + +/* #define DEBUGICMP */ + +#ifdef DEBUGICMP +#define DBICMP(a) DB(a) +#else +#define DBICMP(a) +#endif + + .( +tmpp =p + .bss +tmpsl .byt 0 +tihl .byt 0 +msg .byt 0 + .text + +&&uporterr + ldy #0 ; port unreachable + .byt $2c +&&replytrace .( + ldy #1 ; ttl exceeded + sty msg + sta tihl + stx tmpsl + jsr getpinfo + ldy #IPH_FL + lda (pp),y + and #%00011111 + iny + ora (pp),y + bne frag + ; get reply buffer and copy original message + lda tihl + clc + adc #8 ; the reply has the orig. IP header + 8 byte data + sta tihl + clc + adc #28 + ldy #0 + jsr balloc + bcs endreply ; discard + lda #28 + jsr getpinfo + + ldx tmpsl + jsr getbadr + sta tmpp + sty tmpp+1 + + ldy #0 +t1 lda (tmpp),y + sta (pd),y + iny + cpy tihl + bcc t1 + ; copy src ip to new trg ip + lda tmpp + sec + sbc #4 + sta tmpp + bcs t2 + dec tmpp+1 +t2 + ldy #IPH_TRG +t3 + lda (tmpp),y + sta (pp),y + iny + cpy #IPH_TRG+4 + bcc t3 + + ldx tmpsl + jsr bfree + + ldx pslot + lda #20 + jsr getpinfo + + ldy #IPH_PROT + lda #1 + sta (pp),y + + ldx msg + lda typetab,x + ldy #0 ; behind IP header + sta (pd),y + iny + lda codetab,x + sta (pd),y ; ttl time exceeded in transmit + + jmp sendicmp + +frag DBICMP("tracereply fragment - no reply!^m^j") + jmp idisc +endreply + DBICMP("No buffer for tretrace^m^j") + jmp idisc + +typetab .byt 3, 11 +codetab .byt 3, 0 + .) + +&&icmp2 .( + jsr getpinfo + bcc piok + DBICMP("getpi error in icmp^m^j") + rts +piok + lda pdl + ldy pdl+1 + ldx #pd + jsr checksum3 + +#if 0 /*def DEBUGPKT*/ +php +pha +txa +pha +DB("ICMP Checksum=") +pla +tay +jsr EHexout +pla +pha +jsr EHexout +jsr ECrlfout +tya +tax +pla +plp +#endif + bcc icmpok + jmp idisc_check +icmpok + ldy #0 + lda (pd),y ; icmp type + cmp #8 ; echo message + beq echo + jmp idisc_type +echo + /* ECHO Message */ + ; modify message to echo reply message + lda #0 ; icmp echo reply + sta (pd),y + + jsr pxip ; src IP -> trg IP +&sendicmp + jsr setmyip ; my IP -> src IP + + ldy #ICMP_CSUM + jsr setdcheck + + jsr prepip + +#ifdef DEBUGPKT +ldx #srvdata + jsr tcp_open + bcs error + + jsr preprsh +&retok + lda #E_OK + .byt $2c +&error lda #E_NOFILE + sta PCBUF+FSN_RET + ldy #1 + ldx task + jmp SEND + .) + +noconn ; it's not connect -> check listen + cmp #FS_LISTEN + bne nolisten + /* TODO: check port in use */ + .( + lda PCBUF+FSN_PROT + cmp #IPV4_TCP + bne error + + lda PCBUF+FSN_ADDR + sta listenp + lda PCBUF+FSN_ADDR+1 + sta listenp+1 + + lda #listensrv + jsr tcp_listen + bcs error + stx conn + + ldy #TCB_LPORT + lda conn + sta PCBUF+FSN_PORT + sta (tcbp),y + + ldy #2 + ldx task + lda #E_OK + sta PCBUF+FSN_RET + jmp SEND + .) + +nolisten + cmp #FS_UNLISTEN + bne nounlisten + + .( ; check all connections and close + ldx PCBUF+FSN_PORT + cpx #MAXCONN + bcs error + + ldx #0 +l0 stx conn + jsr settcb + + ldy #TCB_SERVICE + lda (tcbp),y + cmp #listensrv + bne nextul + + ldy #TCB_LPORT + lda (tcbp),y + cmp PCBUF+FSN_PORT + bne nextul + +DB("kill port ") +lda conn:jsr EHexout:jsr ECrlfout + + jsr tcb_close + +nextul ldx conn + inx + cpx #MAXCONN + bcc l0 + + ldx #SEM_SENDBUF + jmp VSEM + .) + +nounlisten + cmp #FS_ACCEPT + beq doacc + jmp error +doacc + .( + ldx #0 +l0 stx conn + jsr settcb + + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_ESTAB + bne nextl + + ldy #TCB_SERVICE + lda (tcbp),y + cmp #listensrv + bne nextl + + ldy #TCB_LPORT + lda (tcbp),y + cmp PCBUF+FSN_PORT + beq found + +nextl ldx conn + inx + cpx #MAXCONN + bcc l0 + jmp error + +found jsr GETSTR + bcs nostr + stx PCBUF+FSN_RXSTR + jsr GETSTR + bcs no2str + stx PCBUF+FSN_TXSTR + lda #E_OK + sta PCBUF+FSN_RET + + ldy #TCB_SRCIP +l1 lda (tcbp),y + sta PCBUF+FSN_ADDR-TCB_SRCIP,y + iny + cpy #TCB_SRCIP+4 + bcc l1 + + ldy #TCB_SRCP +l2 lda (tcbp),y + sta PCBUF+FSN_ADDR+4 + iny + lda (tcbp),y + sta PCBUF+FSN_ADDR+5 + + jsr preprsh + + ldy #TCB_SERVICE + lda #rsh_srv + sta (tcbp),y + + ldy #FSN_ADDR+6 + lda #E_OK + ldx task + jmp SEND + +no2str ldx PCBUF+FSN_RXSTR + jsr FRESTR +nostr + jsr tcb_close + jmp error + .) + +preprsh .( + /* prepare tcb for rsh takeover */ + ldy #TCB_RTSTR + lda PCBUF+FSN_TXSTR + sta (tcbp),y + ldy #TCB_RRSTR + lda PCBUF+FSN_RXSTR + sta (tcbp),y + + ldy #TCB_RNIQ + lda #0 + sta (tcbp),y + + ldy #TCB_RTSTAT + lda #RST_RD + sta (tcbp),y + ldy #TCB_RRSTAT + lda #RSR_WR + sta (tcbp),y + ldy #TCB_RSTAT + lda #RSS_RUN + sta (tcbp),y + rts + .) + + .) + +libip_queue + sec +libip_open + rts + +libip_loop .( + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_ESTAB + bne ret + + ldy #TCB_SERVICE + lda #rsh_srv + sta (tcbp),y +ret rts + .) + +libip_signal .( + pha + DB("libip_signal^m^j") + + ldy #TCB_RTSTR + lda (tcbp),y + tax + lda #SC_NUL + jsr STRCMD + ldy #TCB_RRSTR + lda (tcbp),y + tax + lda #SC_EOF + jsr STRCMD + + pla + jmp tcp_signal + rts + .) + +/* here are the service calls that ignore everything because we wait + * for accept to be called */ + +libip_lqueue + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_ESTAB+1 + bcs doack + sec +libip_lopen +libip_lloop + rts +doack clc + rts +libip_lsignal + jmp tcp_signal + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/main.a65 b/dump/oa-2.0.9/sysapps/slipd/main.a65 new file mode 100644 index 0000000..7cc2faf --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/main.a65 @@ -0,0 +1,387 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/**********************************************************************/ +/* SLIP/TCP */ +/* Serial Line Internet Protocol Driver */ +/* */ +/* Driver connects STDIN/OUT with a serial line internet protocol */ +/* */ +/* Options: */ +/* ROM */ +/* NOPRG */ +/* */ +/**********************************************************************/ + +#define NOMMU + +#ifndef MY_IP +#define MY_IP 192,168,0,64 +/* #define MY_IP 193,197,89,64 */ +/* #define MY_IP 0,0,0,0 */ /* auto-detect */ +#endif + +#ifndef FSTCP_SERVER_IP +#define FSTCP_SERVER_IP 192,168,0,13 +#endif + +#ifndef FSTCP_SERVER_PORT +#define FSTCP_SERVER_PORT 8090 +#endif + +#define WWW_DRV 2 +#define WWW_DEFAULT "index.html" +#define WWW_PATH 0 + +#ifndef RSH_PORT +#define RSH_PORT 23 +#endif + +#ifndef RSHNAME +#define RSHNAME "f:tlogin" +#endif + +/* One of these two _must_ be defined. They don't work together! */ +#define NO_FSTCP /* if defined, do not use fstcp */ +#undef NO_WWW /* if defined, do not use internal www server */ +#define NO_TEST /* if defined no echo, discard, chargen ports */ +#undef NO_RSH /* if defined no telnet port */ +#undef NO_LIBIP /* if defined no lib6502 ip connections */ + +#define MAXOQUEUE 2 +#define INBUF 64 +#define MTU 1024 +#define MAXSLOT 24 +#define IPBUFFER 32*256 /* must be within one (4k) page for MMU! */ + +#define DEBUGMEM + +/**********************************************************************/ + +/* RECEIVE_CHECK is the RECEIVE call to get filesystem or network calls */ + +#ifndef NO_FSTCP +#define RECEIVE_CHECK +#else +#ifndef NO_LIBIP +#define RECEIVE_CHECK +#endif +#endif + +/* RSH_BIN is the rsh stuff that is also used by LIBIP */ + +#ifndef NO_RSH +#define RSH_BIN +#else +#ifndef NO_LIBIP +#define RSH_BIN +#endif +#endif + +/**********************************************************************/ + +#ifndef ROM + +/* #define DEBUG */ +/* #define DEBUGMEM*/ +/* #define DEBUGPKT*/ +/* #define DEBUGTCP*/ +/* #define DEBUGTCP2*/ +/* #define DEBUGICMP*/ +/* #define DEBUGSLIP*/ +/* #define DEBUGWWW*/ +/* #define DEBUGUDP*/ + +#if 1 +#define DB(A) .(:.data:ll1 .byt A,0:.text:php:lda #ll1:jsr ETxtout:plp:.): +#else +#define DB(a) +#endif + + +#include "kernel.i65" +#include "kdefs.i65" +#include "fdefs.i65" +#include "lib6502.i65" + +#endif /* ROM */ + +#ifndef SLIPDEV +#define SLIPDEV 0 +#endif + +/**********************************************************************/ + + .( +#ifdef ROM + + .word PRGEND + .byt PK_PRG + .word PRG + .byt 128,0,0 + .byt SLIPDEV,SLIPDEV + .byt "slipd",0,0 + +#else /* no ROM */ + ++main + jmp PRG + +#endif /* ROM */ + +/**********************************************************************/ + + .bss +owntask .byt 0 +sendbuf .byt 0 ; !=0 when WWW server reads file -> filesystem doesn't listen +www_drv .byt 0 ; disk drive from which to read for www server + + .zero +argp .word 0 + .text + +PRG .( + sta argp + sty argp+1 +;.byt 2 + ; default params + lda #WWW_DRV + sta www_drv + +#ifndef NO_RSH + ; default login name + clc + jsr setlogin +#endif + + ; if stdout == stderr, replace stderr with stdnul + ldx #STDOUT + clc + jsr DUP + sta sendbuf + ldx #STDERR + clc + jsr DUP + cmp sendbuf + bne noclose + ldx #STDERR + lda #STDNUL + sec + jsr DUP +noclose + + ; parse command line parameter + + ldy #<-1 +l0 iny + lda (argp),y ; skip filename + bne l0 + iny + lda (argp),y ; next arg or nothing? + beq endarg + + cmp #"-" + beq nextarg2 + tya + pha + clc + adc argp + pha + lda argp+1 + adc #0 + tay + pla + ldx #OPEN_WR + jsr fopen + bcs nextarg + txa + tay + ldx #STDERR + jsr stddup + bcs nextarg + jsr fclose +nextarg pla + tay +nextarg2 + +l2 iny + lda (argp),y ; skip arg + bne l2 + iny + lda (argp),y + beq endarg + + sec + sbc #"a" + and #$0f + sta www_drv + + tya + pha + clc + adc argp + pha + lda argp+1 + adc #0 + tay + pla +;.byt 2 + jsr chdir + pla + tay + +l1 iny ; skip www drive + lda (argp),y + bne l1 + iny + lda (argp),y + beq endarg + +#ifndef NO_RSH + tya + pha + clc + adc argp + pha + lda argp+1 + adc #0 + tay + pla + sec + jsr setlogin + pla + tay +#endif + +endarg + + jsr GETPID + stx owntask +/* +.byt 2 +lda #MTU:jsr balloc:stx sendbuf +.byt 2 +lda #<60:ldy #>60:jsr btrunc +.byt 2 +ldx sendbuf:jsr bfree +.byt 2 +*/ + + lda #0 + sta sendbuf + + jsr binit +DB("binit ") + + jsr oinit + bcs exit +DB("oinit ") + + jsr iinit + bcs exit +DB("iinit ") + jsr tcpinit + bcs exit +DB("tcpinit^m^j") + jsr udpinit + bcs exit +DB("udpinit^m^j") + + jmp doloop + +exit rts + +doloop + jsr mon + jsr loopin + jsr loopout + jsr tcploop +#ifndef NO_FSTCP + jsr fstcp_mloop +#endif +#ifndef NO_LIBIP + jsr libip_mloop +#endif +#ifdef RECEIVE_CHECK + jsr mloop +#endif + jsr YIELD + jmp doloop + .) + +#ifdef RECEIVE_CHECK +mloop .( + lda sendbuf + bne norx + clc + jsr RECEIVE + bcc ok +norx rts +ok +#ifndef NO_FSTCP + cmp #FS_ASSIGN + bcs nofstcp + jmp fstcp_rxmess +nofstcp +#endif +#ifndef NO_LIBIP + /* TODO: check network calls */ + jmp libip_rxmess +#endif + .) +#endif + + .data +MyIP .byt MY_IP + .text + +#include "sltcp.def" + +#include "slipi.a65" +#include "slipo.a65" + +/* protocols can share same variables */ + .( + .zero +pp .word 0 +pd .word 0 + .bss +pslot .byt 0 +phl .byt 0 +ppl .word 0 +pdl .word 0 + .text + +#include "mon.a65" +#include "icmp.a65" +#include "tcp.a65" +#include "udp.a65" +#include "putil.a65" + .) + +#include "mem.a65" /* now emulates old stdlib with lib6502 */ +#include "util.a65" + +PRGEND .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/mem.a65 b/dump/oa-2.0.9/sysapps/slipd/mem.a65 new file mode 100644 index 0000000..3f0b5dd --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/mem.a65 @@ -0,0 +1,193 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * emulates old stdlib memory routines for slipd until slipd is rewritten + * to lib6502 + * + */ + +#include "lib6502.i65" + +#define NUMBLOCKS 32 + + .( + + .bss +blk .byt 0 +owncnt .dsb NUMBLOCKS +addrl .dsb NUMBLOCKS +addrh .dsb NUMBLOCKS +lenl .dsb NUMBLOCKS +lenh .dsb NUMBLOCKS + .text + +&binit .( + ldx #0 + txa +l0 sta owncnt,x + inx + cpx #NUMBLOCKS + bcc l0 + clc + rts + .) + +&balloc .( + pha + ldx #0 +l0 lda owncnt,x + beq found + inx + cpx #NUMBLOCKS + bcc l0 + pla + rts +found + stx blk + pla + sta lenl,x + pha + tya + sta lenh,x + pla + jsr malloc + ldx blk + sta addrl,x + pha + tya + sta addrh,x + pla + bcs error + inc owncnt,x +&error rts + .) + +&bfree .( + cpx #NUMBLOCKS + bcs error + lda owncnt,x + beq freerror + clc + dec owncnt,x + bne nofree + lda addrl,x + ldy addrh,x + jsr mfree +nofree rts +freerror +DB("bfree: owncnt zero slot=") +txa:jsr EHexout:lda #" ":jsr ECout +lda addrh,x:jsr EHexout:lda addrl,x:jsr EHexout:jsr ECrlfout + sec + rts + .) + +&incownr .( + cpx #NUMBLOCKS + bcs error + inc owncnt,x + beq boom + rts +boom DB("incownr overflow^m^j") + sec + rts + .) + +&getbadr .( + cpx #NUMBLOCKS + bcs error + lda addrl,x + ldy addrh,x + clc + rts + .) + +&getblen .( + cpx #NUMBLOCKS + bcs error + lda lenl,x + ldy lenh,x + clc + rts + .) + +&btrunc .( + .zero +t .word 0 + .text + + sta t + sty t+1 + cpx #NUMBLOCKS + bcs error + sec + lda owncnt,x + beq error + txa + pha + lda addrl,x + ldy addrh,x + ldx #t + jsr realloc + pla + tax + bcs berror + lda t + sta lenl,x + lda t+1 + sta lenh,x +berror rts + .) + +#iflused printmem +&printmem .( + jsr ECrlfout + ldx #0 +l0 lda owncnt,x + beq next + txa + jsr EHexout + jsr spout + lda addrh,x + jsr EHexout + lda addrl,x + jsr EHexout + jsr spout + lda lenh,x + jsr EHexout + lda lenl,x + jsr EHexout + jsr ECrlfout +next inx + cpx #NUMBLOCKS + bcc l0 + rts + .) + +spout lda #" " + jmp ECout +#endif + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/mon.a65 b/dump/oa-2.0.9/sysapps/slipd/mon.a65 new file mode 100644 index 0000000..2c14c2d --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/mon.a65 @@ -0,0 +1,135 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * monitor internal variables and print line on change + */ + + .( + .bss +dlen .byt 0 +cnt .byt 0 +buf .dsb 256 +bufs .dsb 256 + .zero +mp .word 0 + .text + +&&mon jsr getdata + cpx dlen + beq nolen + stx dlen + jmp printit +nolen + ldx #0 +l0 lda buf,x + cmp bufs,x + bne printit + inx + cpx dlen + bcc l0 + rts + +printit + ldx #0 +l1 lda buf,x + sta bufs,x + jsr EHexout + lda #" " + jsr ECout + inx + cpx dlen + bcc l1 + jmp ECrlfout + +getdata .( + ldx #0 + txa +ll sta buf,x + inx + bne ll + + ldx #0 + + lda onslot + sta buf,x + inx +/* + ldy #0 +l2 lda onslot,y + sta buf,x + inx + iny + cpy #MAXOQUEUE+1 + bcc l2 +*/ + lda #MAXCONN + sta cnt + lda #tcb + sta mp+1 +l3 ldy #TCB_STATE + lda (mp),y + beq next + sta buf,x + inx +/* + ldy #TCB_NTXBUF + lda (mp),y + sta buf,x + inx + ldy #TCB_RETRANS + lda (mp),y + sta buf,x + inx + ldy #TCB_TXBUF + lda (mp),y + sta buf,x + inx +*/ + ldy #TCB_CONN + lda (mp),y + sta buf,x + inx +next lda mp + clc + adc #TCB_LEN + sta mp + bcc l4 + inc mp+1 +l4 dec cnt + bne l3 + +#ifldef thstate + lda thstate + sta buf,x + inx +#endif + + rts + .) + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/oa1fs.h b/dump/oa-2.0.9/sysapps/slipd/oa1fs.h new file mode 120000 index 0000000..4b3cc2c --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/oa1fs.h @@ -0,0 +1 @@ +../../include/fdefs.i65 \ No newline at end of file diff --git a/dump/oa-2.0.9/sysapps/slipd/putil.a65 b/dump/oa-2.0.9/sysapps/slipd/putil.a65 new file mode 100644 index 0000000..eca1282 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/putil.a65 @@ -0,0 +1,160 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* + * protocol utilities + */ + +/* when called with AC=ihl and XR=islot, sets pp, pd, ppl, pdl, pslot and phl */ +getpinfo .( + sta phl + stx pslot + jsr getbadr + bcs err + + sta pp + sty pp+1 + clc + adc phl + sta pd + tya + adc #0 + sta pd+1 + jsr getblen + sta ppl + sty ppl+1 + sec + sbc phl + sta pdl + tya + sbc #0 + sta pdl+1 + clc +err rts + .) + +/* moves src IP address to trg ddress in the IP header */ +pxip .( + ldy #IPH_SRC + lda (pp),y + ldy #IPH_TRG + sta (pp),y + ldy #IPH_SRC+1 + lda (pp),y + ldy #IPH_TRG+1 + sta (pp),y + ldy #IPH_SRC+2 + lda (pp),y + ldy #IPH_TRG+2 + sta (pp),y + ldy #IPH_SRC+3 + lda (pp),y + ldy #IPH_TRG+3 + sta (pp),y + rts + .) + +/* sets my own IP address as src IP in the IP header */ +setmyip .( + ldy #IPH_SRC +l0 lda MyIP-IPH_SRC,y + sta (pp),y + iny + cpy #IPH_SRC+4 + bcc l0 + rts + .) + +/* when checksum is in (pd),YR and (pd),YR+1, then compute checksum and + set it */ +setdcheck .( + .bss +tmp .byt 0 + .text + + lda #0 + sta (pd),y + iny + sta (pd),y + + sty tmp + + lda pdl + ldy pdl+1 + ldx #pd + jsr checksum3 + + ldy tmp + sta (pd),y + dey + txa + sta (pd),y + rts + .) + +/* prepares an IP header (p*) */ +prepip .( + ldy #IPH_VER + lda #$45 /* we never send options... */ + sta (pp),y + iny + lda #0 + sta (pp),y + iny + lda ppl+1 /* set packet length */ + sta (pp),y + iny + lda ppl + sta (pp),y + iny + lda #0 /* we also never fragment */ + sta (pp),y + iny + sta (pp),y + iny + sta (pp),y /* and don't set any flags */ + iny + sta (pp),y + + ldy #IPH_CSUM /* clear checksum */ + sta (pp),y + iny + sta (pp),y + + ldy #IPH_TTL /* time to live */ + lda #64 + sta (pp),y + + lda #20 ;ppl + ldy #0 ;ppl+1 + ldx #pp + jsr checksum3 + ldy #IPH_CSUM+1 + sta (pp),y + dey + txa + sta (pp),y + + rts + .) diff --git a/dump/oa-2.0.9/sysapps/slipd/rsh.a65 b/dump/oa-2.0.9/sysapps/slipd/rsh.a65 new file mode 100644 index 0000000..959b483 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/rsh.a65 @@ -0,0 +1,827 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + .( + +#define MAXQUEUE 4 + +#define MAXBUF 128 + +#define TCB_RSTAT TCB_CONN /* general state */ + +#define TCB_SAVESIG (TCB_CONN+1) + +#define TCB_RTSTAT (TCB_CONN+2) /* state stream -> net */ +#define TCB_RTSTR (TCB_CONN+3) +#define TCB_RTSLOT (TCB_CONN+4) +#define TCB_RTCNT (TCB_CONN+5) /* not each single byte is sent + immediately, but after this count + loops */ + +#define TCB_RRSTAT (TCB_CONN+6) /* state net -> stream */ +#define TCB_RRSTR (TCB_CONN+7) +#define TCB_RNIQ (TCB_CONN+8) /* number of bytes in input queue */ +#define TCB_RIQ (TCB_CONN+9) /* MAXQUEUE bytes */ + +#if TCB_RIQ+MAXQUEUE > TCB_LEN +#echo Warning: rsh tcb struct too long! +#endif + +#define RSS_FREE 0 /* must be 0 */ +#define RSS_OPEN1 1 /* content for exec thread */ +#define RSS_OPEN2 2 /* wait for exec thread to finish */ +#define RSS_RUN 3 + +#define RST_FREE 0 /* must be 0 */ +#define RST_RD 1 +#define RST_WAIT 2 +#define RST_WEOF 3 + +#define RST_CNTV 16 + +#define RSR_FREE 0 /* must be 0 */ +#define RSR_QUEUE 1 /* queue it but no stream yet */ +#define RSR_WR 2 +#define RSR_CLOSING 3 + +&&rsh_srv + .byte 0,0,0,0, 0,0, RSH_PORT, 0, SFL_MULT + .word rsh_lopen-1, rsh_queue-1, rsh_loop-1, rsh_signal-1 + +#ifndef NO_RSH +&rsh_init .( +DB("rsh_init^m^j") + lda #0 + sta thstate + lda #rsh_srv + jmp tcp_listen + .) +#endif + +rsh_lopen .( +DB("rsh_lopen^m^j") + lda #0 + ldy #TCB_RTSTAT + sta (tcbp),y + ldy #TCB_RRSTAT + sta (tcbp),y + ldy #TCB_RNIQ + sta (tcbp),y + ldy #TCB_SAVESIG + sta (tcbp),y + + jmp rsh_open ; setup async open + .) + +&&rsh_queue .( +txa:pha +DB("rsh_queue ") +pla:pha:jsr EHexout: +DB(" tcbp=") +lda tcbp+1:jsr EHexout:lda tcbp:jsr EHexout +DB(" rst=") +ldy #TCB_RRSTAT:lda (tcbp),y:jsr EHexout +DB(" tst=") +ldy #TCB_RTSTAT:lda (tcbp),y:jsr EHexout +DB("^m^j niq=") +ldy #TCB_RNIQ:lda (tcbp),y:jsr EHexout +DB(" rstr=") +ldy #TCB_RRSTR:lda (tcbp),y:jsr EHexout +DB(" tstr=") +ldy #TCB_RTSTR:lda (tcbp),y:jsr EHexout +jsr ECrlfout +pla:tax + + ldy #TCB_RRSTAT ; queue it even if task not (yet) started + lda (tcbp),y + bne ok2 + +DB("rsh_queue: discard ") +txa:jsr EHexout:jsr ECrlfout + + jsr bfree ; discard + clc + rts +ok2 + ldy #TCB_RNIQ + lda (tcbp),y + cmp #MAXQUEUE + bcs foops /* shouldn't happen! */ + ; clc + adc #TCB_RIQ + tay + txa + sta (tcbp),y + ldy #TCB_RNIQ + lda (tcbp),y + clc + adc #1 + sta (tcbp),y + +pha:DB("RNIQ=") +pla:jsr EHexout:jsr ECrlfout + + clc + rts +foops DB("rsh: iqueue overrun^m^j") + sec + rts + .) + +rsh_loop .( + ldy #TCB_RSTAT + lda (tcbp),y + beq looperr + cmp #RSS_OPEN2+1 + bcs noopen + jsr oloop /* check async open */ +noopen + jsr rxloop + jsr txloop + jsr rsh_sig_loop +looperr rts + .) + +flushfirst .( /* returns c=0: all clear, c=1: some left */ +/* +DB("flushfirst: niq=") +ldy #TCB_RNIQ:lda (tcbp),y:jsr EHexout +DB(" first=") +ldy #TCB_RIQ:lda (tcbp),y:jsr EHexout +jsr ECrlfout +*/ + ldy #TCB_RNIQ + lda (tcbp),y + beq ende + sec + sbc #1 + sta (tcbp),y + pha + + ldy #TCB_RIQ + lda (tcbp),y + tax + jsr bfree + + ldy #TCB_RIQ +l2 iny + lda (tcbp),y + dey + sta (tcbp),y + iny + cmp #TCB_RIQ+MAXQUEUE-1 + bcc l2 + + pla +ende cmp #1 + rts + .) + +checkend .( + ldy #TCB_RTSTAT + lda (tcbp),y + bne noend + ldy #TCB_RRSTAT + lda (tcbp),y + bne noend +DB("checkend: tcb_close^m^j") + jsr tcb_close + +noend rts + .) + +/**************************************************************************** + * check streams and transfer net -> stream + */ +rxloop .( + ldy #TCB_RRSTAT + lda (tcbp),y + bne streamok + ; do read check +l1 jsr flushfirst /* flushqueue */ + bcs l1 +ende rts + +streamok + cmp #RSR_QUEUE + beq ende + + ldy #TCB_RRSTR + lda (tcbp),y + tax + lda #SC_STAT + jsr STRCMD + + cmp #E_SFULL + beq ende + cmp #E_NUL + bne noend + +&rdclose +DB("rdclose^m^j") + ldy #TCB_RRSTR + lda (tcbp),y + tax + lda #SC_EOF + jsr STRCMD + + ldy #TCB_RRSTAT + lda #RSR_FREE + sta (tcbp),y + + jmp checkend + +geterr DB("getbadr illegal slot!^m^j") + jsr flushfirst +ret rts + +noend + ldy #TCB_RNIQ + lda (tcbp),y + bne ok1 + ; no packets queued + ldy #TCB_RRSTAT + lda (tcbp),y + cmp #RSR_CLOSING ; set by rsh_signal + bne ret +DB("rdclose from CLOSING^m^j") + jmp rdclose + +ok1 +DB("read block ") +ldy #TCB_RIQ:lda (tcbp),y:jsr EHexout:jsr ECrlfout + + ldy #TCB_RIQ + lda (tcbp),y + tax + jsr getbadr + bcs geterr + sta pp + sty pp+1 + +rdloop + ldy #3 + lda (pp),y + sta pdl+1 + dey + lda (pp),y + sta pdl + dey + lda (pp),y + tax + dey + lda (pp),y + clc + adc pp + sta pd + txa + adc pp+1 + sta pd+1 + + ldy #TCB_RRSTR + lda (tcbp),y + tax +datloop .( + lda pdl + ora pdl+1 + bne datok + + jmp flushfirst +datok + ldy #0 + lda (pd),y + jsr PUTC + bcc nextd + + ; error, so put length back to block + ldy #0 + lda pd + sec + sbc pp + sta (pp),y + iny + lda pd+1 + sbc pp+1 + sta (pp),y + iny + lda pdl + sta (pp),y + iny + lda pdl+1 + sta (pp),y + rts + +nextd inc pd + bne n0 + inc pd+1 +n0 lda pdl + bne n1 + dec pdl+1 +n1 dec pdl + jmp datloop + .) + + .) + +/**************************************************************************** + * check streams and transfer stream -> net + */ + +txloop .( + ldy #TCB_RTSTAT + lda (tcbp),y + bne doit + rts +doit + cmp #RST_RD + beq newpkt + + ldy #TCB_RTSLOT + lda (tcbp),y + tax + jsr incownr + jsr tx_requeue_packet + bcc okq +notyet rts +okq +DB("okq slot=") +ldy #TCB_RTSLOT:lda (tcbp),y:jsr EHexout:jsr ECrlfout + + ldy #TCB_RTSLOT + lda (tcbp),y + tax + jsr bfree + + ldy #TCB_RTSTAT + lda (tcbp),y + cmp #RST_WEOF + beq closewr + + lda #RST_RD + sta (tcbp),y + ldy #TCB_RTCNT + lda #RST_CNTV + sta (tcbp),y + jmp newpkt + +&closewr +DB("closewr^m^j") + ldy #TCB_RTSTR + lda (tcbp),y + tax + lda #SC_NUL + jsr STRCMD + + ldy #TCB_RTSTAT + lda #RST_FREE + sta (tcbp),y + jmp checkend + +newpkt + ldy #TCB_RTSTR + lda (tcbp),y + tax + lda #SC_ESTAT + jsr STRCMD + cmp #E_EOF ; means buffer is empty anyway + beq closewr + cmp #E_SEMPTY + beq notyet ; no further check / cnt dec. + cmp #E_SFULL + beq dosend + cmp #E_SHWM + beq dosend + tya + and #SCE_PUSH + beq chkcnt + ldy #SCE_PUSH ; clear push flag + lda #SC_CSTAT + jsr STRCMD /* TODO: keep number of pushed bytes if one pkt is + no enough */ + jmp dosend +chkcnt + ldy #TCB_RTCNT + lda (tcbp),y + beq dosend + sec + sbc #1 + sta (tcbp),y + jmp notyet +dosend + lda #TCP_DOFFSET+64 + jsr balloc + bcs retnomem1 + + lda #TCP_DOFFSET + jsr getpinfo + bcc piok +retnomem1 + rts +piok + +.(:bit pslot:bpl lx:.byt 2:lda pp:lx .) +DB("pp=") +lda pp+1:jsr EHexout:lda pp:jsr EHexout +DB(" pd=") +lda pd+1:jsr EHexout:lda pd:jsr EHexout +jsr ECrlfout + + /* save stream and prepare PCBUF for sending */ + ldy #TCB_RTSTR + lda (tcbp),y + tax + ldy #0 +wrl + jsr GETC + bcs nobyt + + sta (pd),y + iny + cpy #64 + bcc wrl +nobyt + tya + beq retnomem2 + pha + +.(:bit pslot:bpl lx:.byt 2:lda pp:lx .) + + ldy #0 + lda #TCP_DOFFSET + sta (pp),y + iny + pla + pha + sta (pp),y + iny + lda #0 + sta (pp),y + + pla + clc + adc #TCP_DOFFSET + ldy #0 + ldx pslot + jsr btrunc + + lda pslot + ldy #TCB_RTSLOT + sta (tcbp),y + tax + jsr incownr + jsr tx_queue_packet + bcs notqueued + ldy #TCB_RTSLOT + lda (tcbp),y + tax +DB("queue ok slot=") +txa:jsr EHexout:jsr ECrlfout + + jsr bfree + rts +notqueued +DB("notqueued slot=") +ldy #TCB_RTSLOT:lda (tcbp),y:jsr EHexout: +DB(" tcbp=") +lda tcbp+1:jsr EHexout:lda tcbp:jsr EHexout:jsr ECrlfout + + ldy #TCB_RTSTAT + lda #RST_WAIT + sta (tcbp),y +retnomem2 + rts + .) + + +/**************************************************************************** + * process signal from tcp + */ + +rsh_signal .( + ldy #TCB_SAVESIG + sta (tcbp),y +pha:DB("rsh_signal: ") +pla:jsr EHexout:jsr ECrlfout + rts + .) + +rsh_sig_loop .( + ldy #TCB_SAVESIG + lda (tcbp),y + beq nowr ; end + + tax + + ldy #TCB_RSTAT ; we wait until process has started and + lda (tcbp),y ; thread is cleaned up until we process signal + cmp #RSS_RUN + bne nowr ; end + +txa:pha:DB("sig_loop: ") +pla:pha:jsr EHexout:DB(" RRSTAT=") +ldy #TCB_RRSTAT:lda (tcbp),y:jsr EHexout:DB(" RTSTAT=") +ldy #TCB_RTSTAT:lda (tcbp),y:jsr EHexout:jsr ECrlfout +pla:tax + + + cpx #TE_SIG_FIN + bne nofin + ; fin received - process last bytes. + ldy #TCB_SAVESIG + lda #0 + sta (tcbp),y + + ldy #TCB_RRSTAT + lda (tcbp),y + beq nord + lda #RSR_CLOSING + sta (tcbp),y +nord + ldy #TCB_RTSTAT + lda (tcbp),y + beq nowr + cmp #RST_RD + beq endit + lda #RST_WEOF + sta (tcbp),y +nowr + rts +endit jmp closewr + +nofin ; do a real cleanup, as connection is lost + ldy #TCB_RTSTAT + lda (tcbp),y + beq notx + cmp #RST_WAIT + beq dofree + cmp #RST_WAIT + bne nowait +dofree ldy #TCB_RTSLOT + lda (tcbp),y + tax + jsr bfree +nowait jsr closewr +notx + ldy #TCB_RRSTAT + lda (tcbp),y + beq norx + jsr rdclose +l1 jsr flushfirst + bcs l1 +norx + ldy #TCB_SAVESIG + lda (tcbp),y + tax + lda #0 + sta (tcbp),y + txa + + jsr tcp_signal + +end rts + .) + +/**************************************************************************** + * + * forks a thread to start a new program to which to redirect I/O + */ + + .( + .data +&&&thstate .byt 0 ; must be initialized upon load +rshname .byt RSHNAME,0 + .zero +name .word 0 + .bss +stdi .byt 0,0 ; stdin file numbers +stdo .byt 0,0 ; stdout file numbers +stde .byt 0 +pid .word 0 +forkb .dsb MAXBUF +lname .dsb MAXBUF + .text + +&rsh_open .( + DB("rsh_open^m^j") + ldy #TCB_RSTAT + lda #RSS_OPEN1 + sta (tcbp),y + ldy #TCB_RRSTAT + lda #RSR_QUEUE + sta (tcbp),y +&&oloop + ldy #TCB_RSTAT + lda (tcbp),y + cmp #RSS_OPEN1 ; content for exec thread? + bne waitth + + ldx thstate + beq startit + lda #E_TRYAGAIN + sec + rts +startit + lda #lname + sta name + sty name+1 + + inc thstate + lda #threadaddr + jsr forkthread ; lib6502 + bcc forked + dec thstate +error sec + rts +forked + ldy #TCB_RSTAT + lda #RSS_OPEN2 + sta (tcbp),y + +waitth + cmp #RSS_OPEN2 + beq openw +ret clc + rts +openw + lda thstate + bpl ret + ldx #0 + stx thstate + + cmp #$80 + beq go + pha + jsr tcb_close + pla + jmp error +go + ldx stdi+1 +#echo flib2osa_w + jsr flib2osa_w + txa + ldy #TCB_RRSTR + sta (tcbp),y + lda #SC_REG_WR + jsr STRCMD ; take over to OS + ldx stdi+1 + jsr fclose ; clean up lib6502 + lda #RSR_WR + ldy #TCB_RRSTAT + sta (tcbp),y + + ldx stdo + jsr flib2osa_r + txa + ldy #TCB_RTSTR + sta (tcbp),y + lda #SC_REG_RD + jsr STRCMD + ldx stdo + jsr fclose + lda #RST_RD + ldy #TCB_RTSTAT + sta (tcbp),y + lda #RST_CNTV + ldy #TCB_RTCNT + sta (tcbp),y + + ldy #TCB_RSTAT + lda #RSS_RUN + sta (tcbp),y + clc + rts + .) /* rsh_open */ + +threadaddr .( /* this thread is started to load/forkto another process */ + lda #2 + sta thstate + + jsr pipe + bcc noina + jmp noin +noina + stx stdi + sty stdi+1 + + jsr pipe + bcs noout + stx stdo + sty stdo+1 + + ldx stdo+1 + jsr dup + bcs noerr + stx stde + + lda stdi + sta forkb+0 /* STDIN */ + lda stdo+1 + sta forkb+1 /* STDOUT */ + lda stde + sta forkb+2 /* STDERR */ + + inc thstate ; different error code + + ldy #0 +l0 lda (name),y + sta forkb+3,y + beq dof + iny + cpy #MAXBUF-3 + bcc l0 + bcs ende +dof + inc thstate ; different error code + lda #forkb + jsr forkto + bcs ende1 + + stx pid + sty pid+1 + + ldx stde + jsr fclose + ldx stdo+1 + jsr fclose + ldx stdi + jsr fclose + lda #$80 + sta thstate + jmp term + +ende1 and #$7f + sta thstate +ende + ldx stde + jsr fclose +noerr ldx stdo + jsr fclose + ldx stdo+1 + jsr fclose +noout ldx stdi + jsr fclose + ldx stdi+1 + jsr fclose +noin + lda thstate + ora #$80 + sta thstate + jmp term + .) + +&&&&setlogin .( + bcs realname + lda #rshname +realname + sta name + sty name+1 + +DB("loginprg set to ") +lda name:ldy name+1:jsr ETxtout:jsr ECrlfout + + ldy #0 +l0 lda (name),y + sta lname,y + beq end + iny + cpy #MAXBUF-1 + bcc l0 + lda #0 + sta lname,y +end rts + .) + + .) /* */ + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/slipi.a65 b/dump/oa-2.0.9/sysapps/slipd/slipi.a65 new file mode 100644 index 0000000..6b34dc9 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/slipi.a65 @@ -0,0 +1,389 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/******************** input loop ************************/ + + .( + .bss +islot .byt 0 +ist .byt 0 ; 0=send data, $80= escaped +ilen .word 0 +ihl .byt 0 + + .zero +ip .word 0 + + .bss +iend .word 0 + + .text + +&iinit .( + lda #<-1 + sta islot + clc + rts + .) + +startin .( + .bss +oopscnt .byt 0 + .text + +/*DB("startin")*/ + lda #MTU + jsr balloc + bcs oops + +&iresp stx islot + sta ip /* reset packet */ + sty ip+1 + + lda #255 + sta oopscnt + + jsr getblen + clc + adc ip + sta iend + tya + adc ip+1 + sta iend+1 +#if 0 +DB("iresp: ip=") +lda ip+1:jsr EHexout: lda ip:jsr EHexout +lda #":":jsr ECout:lda slotladr:jsr EHexout +jsr ECrlfout +#endif + lda #0 + sta ist + clc + rts + +oops .( + +#ifdef DEBUGMEM +DB("startin Oops!^m^j") +jsr printmem +#endif + + dec oopscnt + bne doret + lda #255 + sta oopscnt + jsr tcp_kill ; kill first non-listening connection +doret sec + rts + .) + + .) + +&loopin .( + bit islot + bpl running + jsr startin + bcs ende +running + +#ifdef DEBUGSLIP +ldx islot +jsr getbadr +bcc adrok2 +DB("illegal slot# at loopin^m^j") +adrok2 +#endif + + ldx #STDIN + jsr GETC + bcc gotbyt +ende rts +gotbyt + cmp #SL_END + bne nogotpacket + jmp gotpacket +nogotpacket + cmp #SL_ESC + bne noesc + sta ist + beq loopin +noesc + bit ist + bpl noescape + cmp #SL_ESC_ESC + beq isesc + cmp #SL_ESC_END + bne noescape + lda #SL_END + .byt $2c +isesc lda #SL_ESC +noescape + ldy #0 + sty ist + sta (ip),y + inc ip + bne l1 + inc ip+1 +l1 + lda ip+1 + cmp iend+1 + bcc loopin + bne discard + lda ip + cmp iend + bcc loopin +DB("input buffer overflow!^m^j") +discard + ldx islot + bpl discok +DB("discard with invalid islot!^m^j") + rts +discok + jsr getbadr + bcs boom + jmp iresp ; no inloop, because if only SL_ENDs are sent, this + ; would become an almost infinite loop +boom +DB("illegal slot# in discok^m^j") +boom1 lda #<-1 + sta islot + rts + +gotpacket + ldx islot + lda ip + sta iend + ldy ip+1 + sty iend+1 + and #1 + beq even ; fill up with nullbyte if length is odd + lda #0 + tay + sta (ip),y +even + jsr getbadr + bcc adrok +DB("illegal slot# in gotpacket^m^j") + jmp boom1 +adrok + sta ip + sty ip+1 +#if 0 +pha:tya:pha +DB("slot=") +lda islot:jsr EHexout +DB("ip=") +lda ip+1:jsr EHexout: lda ip:jsr EHexout +lda #":":jsr ECout:lda slotladr:jsr EHexout +jsr ECrlfout +pla:tay:pla +#endif + cmp iend + bne ok + cpy iend+1 + bne ok + jmp discard ; zero length packet received +ok + +#ifdef DEBUGPKT + /* so what now? */ +DB("Received Packet: ip=") +lda ip+1:jsr EHexout:lda ip:jsr EHexout: jsr ECrlfout +#if 1 + ldx #ip:lda #48:ldy #0 + jsr printpacket2 + +DB("^m^jip=") +lda ip+1:jsr EHexout:lda ip:jsr EHexout +DB("^m^jiend=") +lda iend+1:jsr EHexout:lda iend:jsr EHexout +#endif +#endif + + /* sanity checks */ + /* header length */ + ldy #IPH_LEN ; length in hi/lo format in IP header + lda (ip),y + sta ilen+1 + iny + lda (ip),y + sta ilen + +#if 0 /*def DEBUGPKT*/ +DB("^m^jiph->len=") +lda ilen+1 +jsr EHexout +lda ilen +jsr EHexout +jsr ECrlfout +#endif + clc + lda ilen + adc ip + php + cmp iend + bne discp + plp + lda ilen+1 + adc ip+1 + cmp iend+1 + beq lenok + php +discp +#if 0 +DB("discp: ip=") +lda ip+1:jsr EHexout:lda ip:jsr EHexout +DB(" ilen=") +lda ilen+1:jsr EHexout:lda ilen:jsr EHexout +DB(" iend=") +lda iend+1:jsr EHexout:lda iend:jsr EHexout +jsr ECrlfout +#endif + plp + jmp discardlen +lenok + /* header checksum */ + lda #0 + ;sta ipl+1 + ldy #IPH_VER + lda (ip),y + and #$0f + asl + asl + sta ihl + + lda ihl + ldy #0 + ldx #ip + jsr checksum3 + +#if 0 /*def DEBUGPKT*/ +php +pha +txa +pha +DB("Header Checksum=") +pla +tay +jsr EHexout +pla +pha +jsr EHexout +jsr ECrlfout +tya +tax +pla +plp +#endif + + bcs discardcs + + .( ; take our IP address from received packet */ + lda MyIP + bne checkip + ora MyIP+1 + ora MyIP+2 + ora MyIP+3 + bne checkip + + /* copy my IP address */ + ldy #IPH_TRG +l2 lda (ip),y + sta MyIP-IPH_TRG,y + iny + cpy #IPH_TRG+4 + bcc l2 +checkip .) + + /* check my IP address */ + ldy #IPH_TRG +l2 lda MyIP-IPH_TRG,y + cmp (ip),y + beq bla + jmp discardip +bla + iny + cpy #IPH_TRG+4 + bcc l2 + + ldy #IPH_TTL + lda (ip),y + bne ttlok + jsr putbuf + jmp replytrace +ttlok + + /**** so that packet is valid -> process it ****/ + /* ip has a pointer to the packet, ihl the header length */ + /* ilen has the total packet length */ + + ldy #IPH_PROT + lda (ip),y + + cmp #1 + bne noicmp + jsr putbuf + jmp icmp2 +noicmp + cmp #17 + bne noudp + jsr putbuf + jmp udprx +noudp + cmp #6 + bne notcp + jsr putbuf + jmp tcprx2 +notcp + DB("Packet discarded: unknown protocol^m^j") + jmp discard + +discardcs + DB("Packet discarded: IP Header checksum^m^j") +disc jmp discard + +discardip + DB("Packet discarded: wrong IP^m^j") + jmp discard + +discardlen + DB("Packet discarded: length mismatch^m^j") + jmp discard + + .) + +putbuf .( + ldx islot + lda ilen + ldy ilen+1 + jsr btrunc ; cut to size + + ldx islot + lda #<-1 + sta islot + lda ihl + rts + .) + + .) diff --git a/dump/oa-2.0.9/sysapps/slipd/slipo.a65 b/dump/oa-2.0.9/sysapps/slipd/slipo.a65 new file mode 100644 index 0000000..5f2dec8 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/slipo.a65 @@ -0,0 +1,218 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/******************** output loop ***********************/ + + .( + .bss +omode .byt 0 +ol .word 0 +&&onslot .byt 0 +oslot .dsb MAXOQUEUE + + .zero +op .word 0 + + .text + +&oinit .( + lda #0 + sta onslot + sta omode + clc + rts + .) + +&loopout .( + lda omode + beq iw1 + jmp inwork +iw1 + ldy onslot + bne newpacket +ende rts +newpacket + ldx oslot + jsr getbadr + bcc adrok + DB("error getting oslot adr^m^j") + jmp nextsl +adrok + sta op + sty op+1 + jsr getblen + sta ol + sty ol+1 +#if 1 /*def DEBUGTCP2 */ +DB("Sending: ") +lda oslot:jsr EHexout:lda #" ":jsr ECout +ldy #TCP_OFFSET+TH_DOFFSET+1 +lda (op),y:jsr EHexout:DB(" seq=") +ldy #TCP_OFFSET+TH_SEQ+2:lda (op),y:jsr EHexout:iny:lda (op),y:jsr EHexout +DB(" ack=") +ldy #TCP_OFFSET+TH_ACK+2:lda (op),y:jsr EHexout:iny:lda (op),y:jsr EHexout +DB(" op=") +lda op+1:jsr EHexout:lda op:jsr EHexout +jsr ECrlfout +/* ldx #op:lda ol:ldy ol+1:jsr printpacket2 */ +#endif + lda #1 + sta omode +inwork + cmp #1 + bne esc1 + lda #SL_END + ldx #STDOUT + jsr PUTC + bcs ende2 + inc omode + lda omode +esc1 + cmp #2 + bne esc2 +next ldy #0 + lda (op),y + cmp #SL_END + beq escape + cmp #SL_ESC + beq escape + ldx #STDOUT + jsr PUTC + bcs ende2 +incp + inc op + bne l0 + inc op+1 +l0 lda ol + bne l1 + dec ol+1 +l1 dec ol + + lda ol + ora ol+1 + bne next + + inc omode + lda omode +esc2 + cmp #3 + bne esc3 + lda #SL_END + ldx #STDOUT + jsr PUTC + bcs ende2 + ; free buffer slot + ldx oslot + jsr bfree +nextsl + dec onslot + ldy #0 +l2 cpy onslot + beq reset + lda oslot+1,y + sta oslot,y + iny + bne l2 + +reset lda #0 + sta omode +ende2 rts + +escape lda #4 + sta omode +esc3 + cmp #4 + bne esc4 + lda #SL_ESC + ldx #STDOUT + jsr PUTC + bcs ende2 + inc omode + lda omode +esc4 + cmp #5 + bne reset + ldy #0 + lda (op),y + cmp #SL_ESC + beq escesc + cmp #SL_END + bne wrongesc + lda #SL_ESC_END + .byt $2c +escesc lda #SL_ESC_ESC +wrongesc + ldx #STDOUT + jsr PUTC + bcs ende2 + lda #2 + sta omode + jmp incp + .) + +&queueslot .( ; queue slot XR for output + ldy onslot + cpy #MAXOQUEUE + bcc drop1 +jmp drop:drop1 + txa + sta oslot,y + inc onslot + +/*jsr getbadr:bcc lll1:DB("illegal slot in queueslot!^m^j"):lll1*/ +#ifdef DEBUGPKT + .zero +px .word 0 + .text +DB("Sent: sl=") +txa:jsr EHexout +DB(" a=") +jsr getbadr +sta px:sty px+1 +ldy #TCP_OFFSET+TH_ACK+2 +lda (px),y:jsr EHexout:iny:lda (px),y:jsr EHexout +DB(" s=") +ldy #TCP_OFFSET+TH_SEQ+2 +lda (px),y:jsr EHexout:iny:lda (px),y:jsr EHexout +DB(" f=") +ldy #TCP_OFFSET+TH_FLAG +lda (px),y:jsr EHexout +DB(" p=") +lda px+1:jsr EHexout:lda px:jsr EHexout + +jsr ECrlfout +#endif + clc + rts +drop +#ifdef DEBUGSLIP + DB("Packet dropped due to full queue^m^j") +#endif + jsr bfree + sec + rts + .) + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/sltcp.def b/dump/oa-2.0.9/sysapps/slipd/sltcp.def new file mode 100644 index 0000000..b8cc5c2 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/sltcp.def @@ -0,0 +1,167 @@ +/**************************************************************************** + + OS/A65 Version 1.3.12 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1997 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/**********************************************************************/ +/* SLIP constants */ + +#define SL_END 192 +#define SL_ESC 219 +#define SL_ESC_END 220 +#define SL_ESC_ESC 221 + +/**********************************************************************/ +/* IP structs */ + +#define IPH_VER 0 +#define IPH_SERVICE 1 +#define IPH_LEN 2 +#define IPH_ID 4 +#define IPH_FL 6 +#define IPH_TTL 8 +#define IPH_PROT 9 +#define IPH_CSUM 10 +#define IPH_SRC 12 +#define IPH_TRG 16 + +/**********************************************************************/ +/* ICMP constants */ + +#define ICMP_TYPE 0 +#define ICMP_CODE 1 +#define ICMP_CSUM 2 + + +/**********************************************************************/ +/* TCP defines */ + +#define TIMER 25 /* makes other times in ca. 1/10 Hz */ + +#define TIME_MSL 100 /* 10 seconds ? */ +#define TIME_LASTACK 200 /* 20 seconds ? */ +#define TIME_FINW2 200 /* 20 seconds ? */ +#define TIME_RETRANS 30 /* 3 seconds ? */ + +#define MAXCONN 12 + +/* TCP connection states */ +#define TCP_CLOSED 0 +#define TCP_LISTEN 1 +#define TCP_SYNRXD 2 +#define TCP_SYNTXD 3 +#define TCP_ESTAB 4 +#define TCP_FINW1 5 +#define TCP_FINW2 6 +#define TCP_CLOSEW 7 +#define TCP_LASTACK 8 +#define TCP_CLOSING 9 +#define TCP_TIMEW 10 + +/* TCP header, including pseudo header */ +#define TH_SRCIP 0 /**/ +#define TH_TRGIP 4 +#define TH_PTCL 9 +#define TH_TCPLEN 10 +#define TH_SRCP 12 /* source port */ +#define TH_TRGP 14 /* target port */ +#define TH_SEQ 16 +#define TH_ACK 20 +#define TH_DOFFSET 24 +#define TH_FLAG 25 +#define TH_WINDOW 26 +#define TH_CHECK 28 +#define TH_URGENT 30 +#define TH_OPTIONS 32 + +/* TCP pseudo header length */ +#define TPH_LEN 12 + +/* TCP flag values */ +#define THF_FIN $01 +#define THF_SYN $02 +#define THF_RST $04 +#define THF_PSH $08 +#define THF_ACK $10 +#define THF_URG $20 + +#define TCP_MAXTXB 3 /* length of retransmission buffer queue */ + +/* transmission control block */ +#define TCB_HDR 0 /* pseudo header struct (TCB_HDR must be 0) */ +#define TCB_SRCIP (TCB_HDR+TH_SRCIP) /* SRCIP - TRGP are used to */ +#define TCB_TRGIP (TCB_HDR+TH_TRGIP) /* ident connection (hi-lo!)*/ +#define TCB_SRCP (TCB_HDR+TH_SRCP) +#define TCB_TRGP (TCB_HDR+TH_TRGP) +#define TCB_RCV_NXT (TCB_HDR+TH_SEQ) /* needed to compare */ +#define TCB_SND_UNA (TCB_HDR+TH_ACK) /* ... */ +#define TCB_SND_NXT 24 /* high-low format! */ +#define TCB_MAXSEG 28 /* two byte */ +#define TCB_SERVICE 30 /* pointer to service struct */ +#define TCB_STATE 32 /* state of connection */ +#define TCB_LSTATE 33 /* last state of connection */ +#define TCB_FLAG 34 /* TCP flag to be sent */ +#define TCB_FLAG2 35 /* TCP flag already sent */ +#define TCB_MSL 36 /* two byte time count */ +#define TCB_RETRANS 38 /* two byte time count */ +#define TCB_TRIES 40 /* number of sends so far */ +#define TCB_NTXBUF 41 /* number of buffers in retranmission buffer */ +#define TCB_TXBUF 42 /* retransmission buffer length is TCB_MAXTB */ + /* connection specific stuff starts here */ +#define TCB_CONN (TCB_TXBUF+TCP_MAXTXB) + +#define TCB_LEN 64 /* actually: (41+TCP_MAXTXB+conn_stuff) but + address computation is simpler this way + (settcb) */ + +#define TCPWIN 512 /* we have a receive window of this size */ +#define TCPSEG 256 /* we send maximal TCPSEG sized segments */ + +#define TCP_OFFSET 8 /* offset from IP hdr start to TCP pseudo hdr */ + + /* where does TCP data start in IP packet? */ +#define TCP_DOFFSET (TCP_OFFSET+TH_OPTIONS) + +/* service struct */ +#define SRV_RIP 0 /* SRV_RIP must be == TCB_SRCIP */ +#define SRV_RPORT 4 +#define SRV_LPORT 6 +#define SRV_FLAG 8 /* service flags */ +#define SRV_OPEN 9 /* called when listen port opened */ +#define SRV_QUEUE 11 /* routine to queue packets for this service */ + /* routine gets packet slot in x, tcbp & srv */ +#define SRV_LOOP 13 /* loop routine */ +#define SRV_SIGNAL 15 /* signal callback; ac = signal (TE_*) */ +#define SRV_LEN 17 + +/* service flags */ +#define SFL_MULT 1 /* if set, immediately set up listening */ + /* service again on connect */ + +/* signal codes for user_signal */ +#define TE_SIG_TERM <-1 /* connection terminates (RST receveived) */ +#define TE_SIG_FIN <-2 /* FIN received */ +#define TE_SIG_RESET <-3 /* RST received in SYNRXD state */ + +/* error codes returned to the user */ +#define TE_NOCONN <-4 /* illegal connection number */ +#define TE_CLOSING <-5 /* connection already closing */ + diff --git a/dump/oa-2.0.9/sysapps/slipd/tcp.a65 b/dump/oa-2.0.9/sysapps/slipd/tcp.a65 new file mode 100644 index 0000000..fef2f25 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/tcp.a65 @@ -0,0 +1,1944 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This file is a TCP implementation for 6502 computer + * + * it exports: + * tcpinit - init TCP + * tcploop - must be called + * tcprx - gets incoming packets + * + * tcp_open - (active) open TCP connection + * tcp_listen - (passive) open TCP connection + * tcp_close - close TCP connection + * + * tcp_kill - kill random connection because we ran into + * memory problems + * + */ + +/* TODO: make the thing 32-bit-modulo save for ack and seq! */ +/* TODO: retransmission timeout increase with retransmission */ + +/* #define DEBUGTCP */ + +#ifdef DEBUGTCP +#define DBTCP(a) DB(a) +#else +#define DBTCP(a) +#endif + + .( + .zero +tcbp .word 0 +p2 .word 0 +srv =p2 ;srv =syszp+4 + + .bss +dlen .word 0 ; length tcp data received +doffset .byt 0 ; data offset from pp! +;toffset =sysmem+3 ; tcp header offset from pp! + .byt 0 ; ??? +seg_flag .byt 0 ; incoming segment flag byte +conn .byt 0 ; connection number +discd .word 0 ; data preceding valid data in segment +timer .word 0 ; timer counter + +&&tcb .dsb MAXCONN*TCB_LEN + +tmp .byt 0 +tmp2 .dsb 3 ; should be able to hold seq number + +state .byt 0 + +scnt .byt 0 ; start counter for loop + .text + +&&tcpinit .( + ldx #0 + + stx scnt + stx timer + stx timer+1 +i1 + jsr settcb + lda #TCP_CLOSED + ldy #TCB_STATE + sta (tcbp),y + inx + cpx #MAXCONN + bcc i1 + + jsr user_init + + clc + rts + .) + +&&tcploop .( + .bss +fl .byt 0 + .text + + /* I have - yet - no way to measure the time, so we do a simple loop */ + lda timer + ora timer+1 + sta fl + beq load + lda timer + bne l1 + dec timer+1 +l1 dec timer + jmp te +end rts +load lda #TIMER + sta timer+1 +te + ldx scnt + inx + cpx #MAXCONN + bcc i1c + ldx #0 +i1c stx scnt + jmp doit + +i1 inx + cpx #MAXCONN + bcc i1a + ldx #0 +i1a + cpx scnt + beq end + + ;------------- +doit + stx conn + jsr settcb + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_CLOSED + beq i1 + + ldy #TCB_LSTATE + cmp (tcbp),y + beq same + sta (tcbp),y + ; ok, state has changed since last loop + cmp #TCP_CLOSEW + bne n1 + + lda #TE_SIG_FIN + jsr signal_user +n1 +same lda fl + bne noti + + ldy #TCB_MSL+1 + lda (tcbp),y + dey + ora (tcbp),y + beq nomsl + + sec + lda (tcbp),y + sbc #1 + sta (tcbp),y + tax + iny + lda (tcbp),y + sbc #0 + sta (tcbp),y + bne nomsl + txa + bne nomsl + + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_FINW2 + beq lastack + cmp #TCP_LASTACK + beq lastack + cmp #TCP_TIMEW + bne nomsl +lastack +DBTCP("lastack^m^j") + jsr tclose + jmp noretrans +nomsl + ldy #TCB_RETRANS+1 + lda (tcbp),y + dey + ora (tcbp),y + beq noretrans + + sec + lda (tcbp),y + sbc #1 + sta (tcbp),y + tax + iny + lda (tcbp),y + sbc #0 + sta (tcbp),y + bne noretrans + txa + bne noretrans + + jsr retransmit + ; jmp noti +noretrans +noti + ldy #TCB_FLAG + lda (tcbp),y + beq noqueuedfin +;inc $d020 + jsr send_flag + bcs noqueuedfin + + ldy #TCB_FLAG + lda #0 + sta (tcbp),y + +noqueuedfin + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_ESTAB + bcc next + cmp #TCP_CLOSEW+1 + bcs next + + ldy #TCB_SERVICE + lda (tcbp),y + sta srv + iny + lda (tcbp),y + sta srv+1 + + ldy #SRV_LOOP + lda (srv),y + iny + ora (srv),y + beq next + + jsr end2 +next + ldx conn + jmp i1 + +end2 lda (srv),y + pha + dey + lda (srv),y + pha + rts + .) + +&&tcprx2 .( + + jsr getpinfo + bcc piok + DBTCP("getpi error in tcprx2^m^j") + rts +piok + jsr ip2tcp + +#if 0 /*def DEBUGTCP*/ +DB("TCP check: pd=") +lda pd+1: jsr EHexout: lda pd: jsr EHexout +DB(", pdl=") +lda pdl+1: jsr EHexout: lda pdl: jsr EHexout +DB(", pp=") +lda pp+1: jsr EHexout: lda pp: jsr EHexout +DB(", ppl=") +lda ppl+1: jsr EHexout: lda ppl: jsr EHexout +jsr ECrlfout +#endif + + lda pdl + ldy pdl+1 + ldx #pd + jsr checksum3 + +#if 0 /*def DEBUGTCP*/ +php +pha +txa +pha +DB("TCP Checksum=") +pla +tay +jsr EHexout +pla +pha +jsr EHexout +jsr ECrlfout +tya +tax +pla +plp +#endif + bcc tcpok + +tdisc_check + DB("Packet discarded: TCP checksum^m^j") +&tdisc ldx pslot + bmi illtd + jsr bfree + lda #<-1 + sta pslot + clc + rts +illtd DBTCP("tdisc with illegal slot!^m^j") + sec + rts + + +tcpok /* here we have a valid TCP packet in (pd),0-pdl. */ + +#if 1 /* def DEBUGTCP2 */ +DB("Receiving: ") +ldy #TH_DOFFSET+1 +lda (pd),y:jsr EHexout:DB(" ack=") +ldy #TH_ACK+2:lda (pd),y:jsr EHexout:iny:lda (pd),y:jsr EHexout +DB(" seq=") +ldy #TH_SEQ+2:lda (pd),y:jsr EHexout:iny:lda (pd),y:jsr EHexout +jsr ECrlfout +#endif + + lda #0 ; data to be discarded at packet beginning. + sta discd + sta discd+1 + + ldy #TH_FLAG + lda (pd),y + sta seg_flag + + ldy #TH_DOFFSET + lda (pd),y + and #$f0 + lsr + lsr + clc + adc #TPH_LEN + sta doffset ; data offset from pseudo header start + lda pdl + sec + sbc doffset + sta dlen + lda pdl+1 + sbc #0 + sta dlen+1 ; TCP data received length + + lda phl + sec + sbc #TPH_LEN + sta phl ; offset from pp to pd + clc + adc doffset + sta doffset ; offset + + bcc looktcb +datl + DB("Data offset too large^m^j") +tdisc1 jmp tdisc + +/* we now also have: phl = offset from pp to TCP pseudo header (pd) + doffset= offset from pp to TCP data start + dlen = length of TCP data received + discd = TCP data to be discarded +*/ + +looktcb +/* DB("LookTCB^m^j")*/ + + jsr findtcb + bcc found /* TODO: send reset on no connection? */ + jmp tcp_closed +found + stx conn +#ifdef DEBUGTCP2 + lda #" " + jsr ECout + txa + jsr EHexout + lda #" " + jsr ECout + lda tcbp+1 + jsr EHexout + lda tcbp + jsr EHexout + jsr ECrlfout +#endif +#ifdef DEBUGTCP + DB("rP=") + ldy #TH_SRCP + lda (pd),y + jsr EHexout + iny + lda (pd),y + jsr EHexout + DB(" tcbp=") + lda tcbp+1 + jsr EHexout + lda tcbp + jsr EHexout + DB(" s=") + ldy #TH_SEQ+2 + lda (pd),y + jsr EHexout + iny + lda (pd),y + jsr EHexout + DB(" a=") + ldy #TH_ACK+2 + lda (pd),y + jsr EHexout + iny + lda (pd),y + jsr EHexout + DB(" f=") + ldy #TH_FLAG + lda (pd),y + jsr EHexout + jsr ECrlfout +#endif + ldy #TCB_STATE + lda (tcbp),y + sta state + +#if 0 /*def DEBUGTCP*/ + pha + lda tcbp+1 + jsr EHexout + lda tcbp + jsr EHexout + lda #":" + jsr ECout + + lda state + asl + tax + lda ttab+1,x + tay + lda ttab,x + jsr ETxtout + pla + jmp noout + +ttab .word tclosed, tlisten, tsynrxd, tsyntxd, testab, tfinw1, tfinw2 + .word tclosew, tlastack, tclosing, ttimew + +tclosed .asc "Closed:^m^j",0 +tlisten .asc "Listen:^m^j",0 +tsynrxd .asc "SynRXd:^m^j",0 +tsyntxd .asc "SynTXd:^m^j",0 +testab .asc "Established:^m^j",0 +tfinw1 .asc "FinW1:^m^j",0 +tfinw2 .asc "FinW2:^m^j",0 +tclosew .asc "CloseWait:^m^j",0 +tlastack .asc "LastAck:^m^j",0 +tclosing .asc "Closing:^m^j",0 +ttimew .asc "TimeWait^m^j",0 + +noout +#endif + cmp #TCP_CLOSED + beq tcp_closed + cmp #TCP_LISTEN + bne nolisten + jmp tcp_listen2 +nolisten + cmp #TCP_SYNTXD + bne nosyntxd + jmp tcp_syntxd +nosyntxd + jmp tcp_else + .) + +tcp_closed .( + lda seg_flag + and #THF_RST + bne end + + lda seg_flag + and #THF_ACK + bne ackset + + jsr seql2ack + jsr clrseq + lda #THF_ACK + THF_RST + bne noack + +&send_rst +&listen_ack +ackset + jsr ack2seq + lda #THF_RST +noack + ldy #TH_FLAG + sta (pd),y + jmp bangbuf + +end jmp tdisc + .) + +tcp_listen2 .( + ldy #TCB_STATE + lda #TCP_CLOSED + sta (tcbp),y ; if error, release tcb + + lda seg_flag + and #THF_RST + beq norst + DB("RST while listening^m^j") + jmp tdisc +norst + lda seg_flag + and #THF_ACK + beq noack + DB("ACK while listening^m^j") + jmp listen_ack +noack + lda seg_flag + and #THF_SYN + bne listen_syn + DB("Listen but no Syn!^m^j") + jmp tdisc +listen_syn + DBTCP("Listen_syn^m^j") + jsr seqsyn + + jsr srv_open + + jsr hasdata + beq nodat + + DB("rxd syn has data!^m^j") + jsr copy_n_queue +nodat + jsr iniseq + ldy #TCB_FLAG + lda #THF_SYN + THF_ACK + sta (tcbp),y + + ldy #TCB_STATE + lda #TCP_SYNRXD + sta (tcbp),y + sta state +;inc $d020 + jmp tdisc + +; ldy #TH_FLAG +; lda #THF_SYN + THF_ACK +; sta (pd),y +; +; jsr iniseq +; jsr setseq +; jsr setack +; +; ldy #TCB_STATE +; lda #TCP_SYNRXD +; sta (tcbp),y +; sta state +; +; lda #1 +; ldx #0 +; jsr addtxnxt +; +; jmp bangbuf + .) + +tcp_else .( +; .bss +;&needack .byt 0 +; .text +; +; lda #0 +; sta needack +/* +DB("tcp_*: ip=") +lda pp+1:jsr EHexout:lda pp:jsr EHexout +DB(", qslot=") +lda pslot:jsr EHexout +DB(", sla=") +lda slotladr:jsr EHexout +jsr ECrlfout +*/ + /* first, check sequence number */ + jsr checkseq + bcc seqok + + lda seg_flag + and #THF_RST + bne disca /* discard packet */ + + DB("bad SEQ!^m^j") + + jsr setseq + jsr setack + ldy #TH_FLAG + lda #THF_ACK + sta (pd),y + jmp bangbuf + +disca DB("got RST with bad SEQ!^m^j") + jmp tdisc + +seqok /* second, check the RST bit */ + lda seg_flag + and #THF_RST + beq noreset + + DB("got RST!^m^j") + + lda state + cmp #TCP_SYNRXD + bne seq1 + + /* TODO: if from active open, then close! */ + DB("Reset rxd!^m^j") + ldy #TCB_STATE + lda #TCP_SYNRXD + sta (tcbp),y + sta state + jsr tdisc + + /* signal_user may use q* variables! */ + lda #TE_SIG_RESET + jmp signal_user + +seq1 +; cmp #TCP_LASTACK +; bcs seq2 +; +; /* flush and close everything */ +; jsr tdisc +; +; /* signal_user may use q* variables! */ +; ;lda #TE_RESET1 +; ;jmp signal_user +;DBTCP("seq1^m^j") +; jmp tclose +; +;seq2 +DBTCP("seq2^m^j") + jsr tdisc + jmp tclose + +noreset /* third, check security and precedence... */ + + /* fourth, check SYN bit */ + + lda seg_flag + and #THF_SYN + beq nosyn + ; this is an error - abort anything + + DB("got SYN!^m^j") + + /* flush everything, close */ + jsr send_rst + + ;lda #TE_RESET2 + ;jmp signal_user + jmp tclose + +nosyn /* fifth, check the ACK bit */ + lda seg_flag + and #THF_ACK + bne ackok + + DB("No Ack^m^j") + jmp tdisc +ackok + jsr checkack + sta tmp +#ifdef DEBUGTCP +DBTCP("checkack returns "): lda tmp: jsr EHexout: jsr ECrlfout +#endif + + lda state + cmp #TCP_SYNRXD + bne ack1 + + lda tmp + beq badack + cmp #3 + bcc ackok2 + +badack DB("Bad Ack in packet^m^j") + jmp send_rst +ackok2 + ldy #TCB_STATE /* everything ok -> enter estab and continue... */ + lda #TCP_ESTAB + sta (tcbp),y + sta state + + /* TODO: check queued FIN */ + +ack1 lda tmp + beq aignore + cmp #3 + bcc a0 + + /* TODO: ack ahead send_next -> send ack, return */ +#ifdef DEBUGTCP +DB("Ack ahead send_next^m^jpkt.ack=") +ldy #TH_ACK:ldx #4:x0 lda (pd),y:jsr EHexout:iny:dex:bne x0 +DB(" seq.sndnxt=") +ldy #TCB_SND_NXT: ldx #4:x1 lda (tcbp),y: jsr EHexout: iny: dex: bne x1 +jsr ECrlfout +#endif + + jmp tdisc +a0 + jsr getuna + lda tmp + pha + jsr ackxmit + pla + sta tmp +aignore + lda state + cmp #TCP_FINW1 + bcc do6a + bne ack3 + + lda tmp + cmp #2 ; exactly SND_NXT -> FIN ack'd + bne do6a + + ldy #TCB_MSL + lda #TIME_FINW2 + sta (tcbp),y + + ldy #TCB_STATE + lda #TCP_FINW2 + sta (tcbp),y + sta state + +ack3 cmp #TCP_FINW2 + bne ack4 + +do6a jmp do6 + +ack4 cmp #TCP_CLOSING + bne ack5 + + lda tmp + cmp #2 + bne atw + ldy #TCB_STATE + lda #TCP_TIMEW + sta state + sta (tcbp),y + + ldy #TCB_MSL + lda #TIME_MSL + sta (tcbp),y + +atw jmp tdisc + +ack5 cmp #TCP_LASTACK + bne ack6 + +/* DB("LAST ACK received^m^j") */ + + lda tmp + cmp #2 + bne atw + jsr tdisc + jmp tclose + +ack6 cmp #TCP_TIMEW + bne do6 + + ldy #TCB_MSL + lda #TIME_MSL + sta (tcbp),y + + ; ack retransmitted FIN + jsr setack + jsr setseq + ldy #TH_FLAG + lda #THF_ACK + sta (pd),y + jmp bangbuf + + /* sixth, check the URG bit */ +&do6 + /* seventh, process segment text */ + + lda state + cmp #TCP_ESTAB + bcc idat + cmp #TCP_FINW2+1 + bcs idat + + /* TODO: discd? */ + ldy #0 + lda doffset + sta (pp),y + tya + iny + sta (pp),y + iny + lda dlen + sta (pp),y + iny + lda dlen+1 + sta (pp),y + + jsr hasdata + beq idat + jsr copy_n_queue ; ok, we need not copy without FIN... +; inc needack + ldy #TCB_FLAG + lda (tcbp),y + ora #THF_ACK + sta (tcbp),y + +idat + /* eighth, check the FIN bit */ + + lda state + cmp #TCP_CLOSED + beq nofin + cmp #TCP_LISTEN + beq nofin + cmp #TCP_SYNTXD + beq nofin + + lda seg_flag + and #THF_FIN + beq nofin + + lda #1 + ldx #0 + jsr addrxnxt +; inc needack + + ldy #TCB_FLAG + lda (tcbp),y + ora #THF_ACK+THF_FIN + sta (tcbp),y + + ldx state + cpx #TCP_SYNRXD + beq closew + cpx #TCP_ESTAB + bne noestab + jsr flushqueue + jmp closew +noestab + cpx #TCP_FINW1 + beq closing + + cpx #TCP_FINW2 + bne nofinw2 + + lda (tcbp),y + and #255-THF_FIN + sta (tcbp),y + + ldy #TCB_STATE + lda #TCP_TIMEW + sta state + sta (tcbp),y + + ldy #TCB_MSL + lda #TIME_MSL + sta (tcbp),y + jmp nofin +nofinw2 + +; jsr setack +; jsr setseq +; ldy #TH_FLAG +; lda #THF_ACK +; sta (pd),y +; jsr bangbuf + + ldy #TCB_FLAG + lda (tcbp),y + ora #THF_ACK + sta (tcbp),y + + lda state + cmp #TCP_ESTAB+1 + bcs f1 +closew lda #TCP_CLOSEW + .byt $2c +closing lda #TCP_CLOSING + +fe ldy #TCB_STATE + sta (tcbp),y + +f1 + /* TODO: check other states */ + +nofin + ldx pslot + bmi noslot + +; lda needack +; bne needit + jmp tdisc +;needit +; jsr setack +; jsr setseq +; ldy #TH_FLAG +; lda #THF_ACK +; sta (pd),y +; jsr bangbuf ; maybe check with retransmissions... +; bcc noslot +;inc $d020 +; ldy #TCB_FLAG +; lda (tcbp),y +; ora #4 ; saved ack +; sta (tcbp),y +noslot clc + rts + .) + +tcp_syntxd .( + /*DB("SynTxd^m^j")*/ + + /* first, check ack bit */ + lda seg_flag + and #THF_ACK + beq noack + + jsr checkack + bcc noack + +badack DB("Bad Ack in packet^m^j") + jmp send_rst +noack + /* second, check rst bit */ + lda seg_flag + and #THF_RST + beq norst + + lda seg_flag + and #THF_ACK + beq rstack + + jsr tdisc + ;lda #TE_RESET3 + ;jmp signal_user +DBTCP("noack^m^j") + jmp tclose + + /* TODO: close? or define that user signal routine should do that... */ +rstack jmp tdisc + +norst + /* third, check security */ + + /* fourth, check syn bit */ + lda seg_flag + and #THF_SYN + beq nosyn + + jsr getseq ; get rcv_nxt number from packet + + lda #1 + ldx #0 + jsr addrxnxt + + lda seg_flag + and #THF_ACK + beq nosynack + + jsr getuna + + jsr ackxmit +nosynack + jsr aheadiss + bcs noiss ; SYN not yet ACK'd + + lda #TCP_ESTAB + ldy #TCB_STATE + sta (tcbp),y + sta state + +; lda #1 +; sta needack + ldy #TCB_FLAG + lda (tcbp),y + ora #THF_ACK + sta (tcbp),y + + jmp do6 + +noiss lda #TCP_SYNRXD + ldy #TCB_STATE + sta (tcbp),y + + ldy #TCB_FLAG + lda (tcbp),y + ora #THF_SYN+THF_ACK + sta (tcbp),y + + ; jmp tdisc +/* + jsr setack + jsr decseq ; dec snd_nxt back to ISS + jsr setseq + lda #1 + ldx #0 + jsr addtxnxt ; and inc for SYN + + jsr do_queue + + ldy #TH_FLAG + lda #THF_ACK+THF_SYN + jmp bangbuf +*/ + +nosyn jmp tdisc + .) + +/* check acknowledge of packets in retransmission queue */ +/* TODO: save end pointer for each packet in queue -> no calculations here */ + +ackxmit .( + +#ifdef DEBUGTCP2 +DB("ackxmit:") +.(:ldy #TCB_SND_UNA+2: x1 lda (tcbp),y: jsr EHexout: iny: cpy #TCB_SND_UNA+4:bcc x1: .) +lda #":":jsr ECout +jsr ECrlfout +#endif + ldy #TCB_NTXBUF + lda (tcbp),y + bne noend2 + clc + rts +noend2 + ldy #TCB_TXBUF + lda (tcbp),y + tax +/*pha: DB("slot:"): pla: jsr EHexout: lda #":": jsr ECout*/ + jsr getbadr + bcc adrok + DB("illegal slot# in ackxmit^m^j") + jmp freebuf +adrok + sta p2 + sty p2+1 + + ldx #3 + ldy #TH_SEQ+TCP_OFFSET+3 +l0 lda (p2),y + sta tmp,x +/*jsr EHexout*/ + dey + dex + bpl l0 + + ldy #IPH_LEN+1 + lda (p2),y + clc + adc tmp+3 + sta tmp+3 + dey + lda (p2),y + adc tmp+2 + sta tmp+2 + bcc l1 + inc tmp+1 + bne l1 + inc tmp +l1 + lda tmp+3 + sec + sbc #TCP_OFFSET+TH_OPTIONS + sta tmp+2 + bcs l2 + lda tmp+1 + bne l3 + dec tmp +l3 dec tmp+1 +l2 +#if 0 +lda #":": jsr ECout +.(:ldy #0: x1 lda tmp,y: jsr EHexout: iny: cpy #4:bcc x1: .) +jsr ECrlfout +lda #":": jsr ECout +.(:ldy #TCB_SND_UNA: x1 lda (tcbp),y: jsr EHexout: iny: cpy #TCB_SND_UNA+4:bcc x1: .) +jsr ECrlfout +#endif + ldy #TCB_SND_UNA +l4 lda (tcbp),y + cmp tmp-TCB_SND_UNA,y + bcc end ; less than packet -> end + bne freebuf ; more than packet -> ok + iny + cpy #TCB_SND_UNA+4 + bcc l4 +freebuf + ; got ack for first packet in queue +#ifdef DEBUGTCP2 +DB("freebuf :") +ldy #TCP_OFFSET+TH_SEQ+2 +lda (p2),y:jsr EHexout:iny:lda (p2),y:jsr EHexout:jsr ECrlfout +#endif + + ldy #TCB_TXBUF + lda (tcbp),y + tax + jsr bfree + + ldy #TCB_NTXBUF + lda (tcbp),y + tax + dex + txa + sta (tcbp),y + beq end ; ok, end, nothing left + + ldy #TCB_TXBUF +l5 iny + lda (tcbp),y + dey + sta (tcbp),y + iny + dex + bne l5 + + /* set retransmission counter to 1 to send the next buffer now */ + ldy #TCB_TRIES + lda #0 + sta (tcbp),y + ldy #TCB_RETRANS + lda #1 + sta (tcbp),y + iny + lda #0 + sta (tcbp),y + + jmp ackxmit + +end rts + .) + + .bss +d2len .word 0 + .text + +hasdata .( /* TODO: check with discd */ + lda dlen + ora dlen+1 + rts + .) + +bangbuf .( +#ifdef DEBUGTCP +DB("bangbuf: pp=") +lda pp+1:jsr EHexout: lda pp:jsr EHexout +DB(", pd=") +lda pd+1:jsr EHexout: lda pd:jsr EHexout +jsr ECrlfout +#endif + ; first exchange port and IP addresses + jsr tcpxp + jsr tcpxip + jsr shortpk + +/*DB("from bangbuf: ")*/ + +&mkpacket2 + +#if 0 +DB("mkpacket: pp=") +lda pp+1: jsr EHexout: lda pp: jsr EHexout +DB(", pd=") +lda pd+1: jsr EHexout: lda pd: jsr EHexout +DB(", ppl=") +lda ppl+1: jsr EHexout: lda ppl: jsr EHexout +DB(", pdl=") +lda pdl+1: jsr EHexout: lda pdl: jsr EHexout +DB(", slotladr=") +lda slotladr:jsr EHexout +jsr ECrlfout +#endif + ; this is for other packets also... + jsr preptcp + + ; make IP header from TCP pseudo header + ; (i.e. copy the IP addresses to the right location and set protocol + ; the rest is done in the IP layer + + jsr tcp2ip + bcs needmove + + jsr prepip + +#if 0 /*def DEBUGTCP*/ + DB("Send Seq: ") + ldy #TH_SEQ +x1 lda (pd),y + jsr EHexout + iny + cpy #TH_SEQ+4 + bcc x1 + DB("^m^jSend Ack: ") + ldy #TH_ACK +x2 lda (pd),y + jsr EHexout + iny + cpy #TH_ACK+4 + bcc x2 + DB("^m^jFlag= ") + ldy #TH_FLAG + lda (pd),y + jsr EHexout + jsr ECrlfout +#endif + ldx pslot + lda #<-1 + sta pslot + jmp queueslot +needmove + jsr tdisc + sec + rts + .) +/* +incuna .( + ldy #TCB_SND_UNA+3 + ldx #3 + lda (tcbp),y + clc + adc #1 + sta (tcbp),y + dey +l5 lda (tcbp),y + adc #0 + sta (tcbp),y + dey + dex + bne l5 + rts + .) +*/ +/* +setqseq .( + lda tcbp + clc + adc #8 + sta p2 + lda tcbp+1 + adc #0 + sta p2+1 + + ldy #TH_SEQ +l5 lda (p2),y + sta (qd),y + iny + cpy #TH_SEQ+4 + bcc l5 + rts + .) + +setqack .( + lda qd + clc + adc #4 + sta p2 + lda qd+1 + adc #0 + sta p2+1 + + ldy #TCB_RCV_NXT +l5 lda (tcbp),y + sta (p2),y + iny + cpy #TCB_RCV_NXT+4 + bcc l5 + rts + .) +*/ + +/* The following routine takes the packet from + * islot/ip/id/ipl/idlen/dlen/doffset/toffset + * and queues it to the user data rx queue. + * It sets ack appropriately. + * It copies the TCP header into a new packet and sets + * islot/ip/..., but dlen is zero. + */ +copy_n_queue .( + .bss +myslot .byt 0 +myhl .byt 0 +mydlen .word 0 + .zero +myp .word 0 + .text +#if 0 +DB("copy_n_queue: ip=") +lda ip+1: jsr EHexout: lda ip: jsr EHexout +DB(", request ") +lda doffset: jsr EHexout +DB(" b., dlen=") +lda dlen+1: jsr EHexout: lda dlen: jsr EHexout +DB(" , discd=") +lda discd+1: jsr EHexout: lda discd: jsr EHexout +jsr ECrlfout +#endif + lda dlen+1 ; dlen = discd ? then return ok + cmp discd+1 + bne ok + lda dlen + cmp discd + bne ok + clc + rts +ok + lda doffset + ldy #0 + jsr balloc + bcc gotbuffer + rts +gotbuffer + stx myslot + jsr getbadr + bcc adrok + DBTCP("illegal slot# in copy_n_queue^m^j") + sec + rts +adrok + sta myp + sty myp+1 + + lda phl + sta myhl +/* +DB("got buffer slot ") +lda myslot: jsr EHexout: DB(" @ address ") +lda myp+1: jsr EHexout: lda myp: jsr EHexout +jsr ECrlfout +*/ + ldy #0 +l0 lda (pp),y + sta (myp),y +/*jsr EHexout*/ + iny + cpy doffset + bne l0 + + ldy #0 + lda doffset + clc + adc discd + sta (pp),y /* save for queue routines */ + tya + adc discd+1 + iny + sta (pp),y + iny + lda dlen + sec + sbc discd + sta mydlen + sta (pp),y + iny + lda dlen+1 + sbc discd+1 + sta mydlen+1 + sta (pp),y + +/*lda #" ": jsr ECout: tya: jsr EHexout*/ +/* + lda myp + sta ip + clc + adc phl + sta id + lda myp+1 + sta ip+1 + adc #0 + sta id+1 + + lda doffset + sec + sbc phl + sta idlen + lda #0 + sta idlen+1 +*/ + lda pslot + jsr rx_queue_packet + bcs boom + + lda mydlen + ldx mydlen+1 + jsr addrxnxt +boom + lda #0 + sta mydlen + sta mydlen+1 + + ldx myslot + lda myhl + jsr getpinfo + bcc piok + DBTCP("getpi error in copy_n_queue^m^j") +piok +/* +DB("copy_n_queue returns ip=") +lda ip+1: jsr EHexout: lda ip: jsr EHexout +DB(", id=") +lda id+1: jsr EHexout: lda id: jsr EHexout +jsr ECrlfout +*/ + clc +nobuffer + rts + .) + +/* retransmit the first packet in the retransmission queue */ +&retransmit .( + ldy #TCB_NTXBUF + lda (tcbp),y + beq ende + + ldy #TCB_TXBUF + lda (tcbp),y + tax + + ldy #TCB_TRIES + lda (tcbp),y + clc + adc #1 + cmp #10 ; retransmit 6 times only ? + bcs error + + pha + jsr incownr + jsr queueslot + pla + bcs endeini + + ldy #TCB_TRIES + sta (tcbp),y +#ifdef DEBUGTCP2 +DB("retransmit seq=") +ldy #TCB_TXBUF:lda (tcbp),y:tax:jsr getbadr +.zero:foo .word 0:.text:sta foo:sty foo+1 +ldy #TCP_OFFSET+TH_SEQ+2:lda (foo),y:jsr EHexout:iny:lda (foo),y:jsr EHexout +jsr ECrlfout +#endif + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_TIMEW + bne doit + + jsr flushqueue + rts +doit + ldy #TCB_RETRANS + lda #TIME_RETRANS + sta (tcbp),y + rts + +error DBTCP("error^m^j") + jsr tclose +ende rts + +endeini + ldy #TCB_RETRANS + lda #1 + sta (tcbp),y + iny + lda #0 + sta (tcbp),y + clc + rts + + .) + +/* this routine puts outgoing packets into the retransmission queue and sends + * them. It needs tcbp, and the packet buffer number in x. It always does + * a bfree. + */ +&tx_queue_packet .( + lda #TCP_OFFSET + jsr getpinfo + bcc piok + DBTCP("getpi error in tx_queue_packet^m^j") + sec + rts +piok + ldy #0 + lda (pp),y + cmp #TCP_DOFFSET + beq ok + +move DB("TCP offset wrong!^m^j") +#ifdef DEBUGTCP + lda pslot:jsr EHexout:lda #"-":jsr ECout + lda pp+1: jsr EHexout: lda pp: jsr EHexout: lda #":": jsr ECout + ldy #0: xx lda (pp),y: jsr EHexout: iny: cpy #10: bcc xx + jsr ECrlfout +#endif +qdisc + ldx pslot + lda #<-1 + sta pslot + jsr bfree + + lda #<-1 + sec + rts + +ok + iny + lda (pp),y + sta dlen ; len + iny + lda (pp),y + sta dlen+1 + + jsr setout + jsr setseq + jsr setack + + lda dlen + ldx dlen+1 + jsr addtxnxt ; inc seq number + + jsr preptcp + jsr tcp2ip + bcs qdisc + + jsr prepip +&do_requeue + jsr do_queue ; does an incownr + bcs notqueued + + ldx pslot + lda #<-1 + sta pslot + jsr queueslot + lda #0 + clc + rts + +notqueued + ldx pslot ; we are not expected to keep a reference here + jsr bfree + + lda #0 + sec + rts + .) + +/* + * requeue a packet that has already been to tx_queue_packet, but could + * not be queued. does a bfree. + */ +&tx_requeue_packet .( + stx pslot +#ifdef DEBUGTCP2 + lda #TCP_OFFSET + jsr getpinfo +#endif + jmp do_requeue +/* + jsr do_queue + php + ldx pslot + jsr bfree + plp + rts +*/ + .) + +do_queue + .( + ldy #TCB_NTXBUF + lda (tcbp),y + cmp #TCP_MAXTXB + bcc queueok + rts +queueok + adc #1 + sta (tcbp),y + clc + adc #TCB_TXBUF-1 + tay + + lda pslot + sta (tcbp),y + tax + jsr incownr + + cpy #TCB_TXBUF ; not only block in buffer -> don't set time + bne notime + + ldy #TCB_TRIES + lda #0 + sta (tcbp),y ; no tries so far + ldy #TCB_RETRANS+1 ; send in the next loop + sta (tcbp),y + lda #1 + dey + sta (tcbp),y +notime +#ifdef DEBUGTCP2 + DB("queued seq=") + ldy #TCP_OFFSET+TH_SEQ+2 + lda (pp),y + jsr EHexout + iny + lda (pp),y + jsr EHexout + DB(" pp= ") + lda pp+1:jsr EHexout:lda pp:jsr EHexout + jsr ECrlfout +#endif + clc + rts + .) + +setout .( + ; make TCP packet from data + clc + lda #4 + adc pd + sta p2 + lda #0 + adc pd+1 + sta p2+1 + + ldy #TH_SRCIP +l0 lda (tcbp),y + sta (p2),y + iny + cpy #TH_SRCIP+4 + bcc l0 + + sec + lda pd + sbc #4 + sta p2 + lda pd+1 + sbc #0 + sta p2+1 + + ldy #TH_TRGIP +l1 lda (tcbp),y + sta (p2),y + iny + cpy #TH_TRGIP+4 + bcc l1 + + ldy #TCB_SRCP + lda (tcbp),y + tax + iny + lda (tcbp),y + ldy #TH_TRGP+1 + sta (pd),y + dey + txa + sta (pd),y + + ldy #TCB_TRGP + lda (tcbp),y + tax + iny + lda (tcbp),y + ldy #TH_SRCP+1 + sta (pd),y + dey + txa + sta (pd),y + + ldy #TH_PTCL-1 + lda #0 + sta (pd),y + iny + lda #6 + sta (pd),y + iny + iny + lda pdl + sec + sbc #TPH_LEN + sta (pd),y + + ldy #TH_DOFFSET + lda #$50 + sta (pd),y + iny + lda #THF_ACK + sta (pd),y + + rts + .) + +&send_syn + lda #THF_SYN + .byt $2c +&send_reset + lda #THF_RST +; .byt $2c +;&send_fin +; lda #THF_FIN+THF_ACK +&send_flag + .( +;inc $d020 + /* TODO: set queued FIN until everything is really ok */ + sta tmp + + lda #TH_OPTIONS+TCP_OFFSET + jsr balloc + bcc ok + DB("Couldn't alloc send_* buffer!^m^j") + sec + rts +ok ;stx qslot + lda #TCP_OFFSET + jsr getpinfo + bcc piok + DB("getpi error in send_*^m^j") + sec + rts +piok + jsr setout + jsr setack + + ldy #TH_FLAG + lda tmp + sta (pd),y + + and #THF_FIN+THF_SYN + beq nofin + + ldy #TCB_FLAG2 + and (tcbp),y + beq nodec ; already sent -> decrement seq before sending + + jsr decseq +nodec + jsr setseq ; set packet sequence number + + lda #1 + ldx #0 + jsr addtxnxt + + ldy #TCB_FLAG2 + lda (tcbp),y + ora tmp + sta (tcbp),y + + ;ldx pslot - implicit + jsr do_queue ; everthing adding to snd_nxt should be queued! + bcc nofin2 + + ldx pslot + jsr bfree + sec + rts ; return if not able to queue + +nofin jsr setseq +nofin2 jmp mkpacket2 + .) + +&tclose .( + /* ok, clean up connection specific stuff */ + lda #TE_SIG_TERM + jsr signal_user + + ldy #TCB_STATE + lda #TCP_CLOSED + sta (tcbp),y + +&&flushqueue +#ifdef DEBUGTCP2 +DB("flushqueue^m^j") +#endif + ldy #TCB_NTXBUF + lda (tcbp),y + beq end + clc + adc #TCB_TXBUF-1 + sta tmp +l1 ldy tmp + cpy #TCB_TXBUF ; -1 + bcc end + + lda (tcbp),y + tax + jsr bfree + dec tmp + jmp l1 + +end ldy #TCB_NTXBUF + lda #0 + sta (tcbp),y + rts + .) + + +settcb .( +#if (TCB_LEN - 64) +#warning TCB length not correct! +#else + lda #0 + sta tcbp+1 + txa + asl + rol tcbp+1 + asl + rol tcbp+1 + asl + rol tcbp+1 + asl + rol tcbp+1 + asl + rol tcbp+1 + asl + rol tcbp+1 + clc + adc #tcb + adc tcbp+1 + sta tcbp+1 + rts +#endif + .) + +gettcb .( + ldx #0 +l0 jsr settcb + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_CLOSED + beq l1 + inx + cpx #MAXCONN + bcc l0 + sec + rts +l1 ldy #TCB_NTXBUF + lda #0 + sta (tcbp),y + ldy #TCB_FLAG + sta (tcbp),y + iny ; TCB_FLAG2 + sta (tcbp),y + ldy #TCB_LSTATE + lda #TCP_CLOSED + sta (tcbp),y + + ; clear connection specific data + lda #0 + ldy #TCB_CONN +l2 sta (tcbp),y + iny + cpy #TCB_LEN + bcc l2 + clc + rts + .) + +&&tcp_kill .( +DB("tcp_kill^m^j") + ldx #0 +l0 stx conn + jsr settcb + ldy #TCB_STATE + lda (tcbp),y + beq next + cmp #TCP_LISTEN + beq next + txa + pha +DB("kill conn ") +txa:jsr EHexout:jsr ECrlfout + lda #TE_SIG_RESET + jsr signal_user + pla + tax +next inx + cpx #MAXCONN + bcc l0 + rts + .) + +#include "tutil.a65" +#include "tcpuser.a65" +#ifndef NO_TEST +#include "tcpsrv.a65" +#endif +#ifndef NO_FSTCP +#include "fstcp.a65" +#endif +#ifndef NO_WWW +#include "wwwsrv.a65" +#endif +#ifdef RSH_BIN /* must be before LIBIP */ +#include "rsh.a65" +#endif +#ifndef NO_LIBIP +#include "libip.a65" +#endif + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/tcpsrv.a65 b/dump/oa-2.0.9/sysapps/slipd/tcpsrv.a65 new file mode 100644 index 0000000..4a15fe8 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/tcpsrv.a65 @@ -0,0 +1,254 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * TCP services for SLIP/TCP A65 + * + */ + + .( +echo_srv + .byte 0,0,0,0, 0,0, 7,0, SFL_MULT + .word dummy_open-1, tcp_echo_queue-1, 0, tcp_signal-1 +discard_srv + .byte 0,0,0,0, 0,0, 9,0, SFL_MULT + .word dummy_open-1, tcp_disc_queue-1, 0, tcp_signal-1 +chargen_srv + .byte 0,0,0,0, 0,0, 19,0, SFL_MULT + .word dummy_open-1, tcp_disc_queue-1, tcp_chargen_loop-1, tcp_signal-1 + +&tcp_test_init + lda #echo_srv + jsr tcp_listen + lda #discard_srv + jsr tcp_listen + lda #chargen_srv + jsr tcp_listen +&dummy_open + rts + .) + +&tcp_chargen_loop .( + .bss +cnt .byt 0 + .text + + ldy #TCB_NTXBUF + lda (tcbp),y + bne end + + lda #TCP_DOFFSET+64 + jsr balloc + bcc gotblock +end rts +gotblock + stx tmp + sta pp + sty pp+1 + + ldy #TCP_DOFFSET +l0 lda cnt + sta (pp),y + inc cnt + lda cnt + cmp #$20 + bcc set + cmp #126 + bcc ok +set lda #$20 + sta cnt +ok iny + cpy #TCP_DOFFSET+64 + bcc l0 + + ldy #0 + lda #TCP_DOFFSET + sta (pp),y + iny + lda #64 + sta (pp),y + iny + lda #0 + sta (pp),y + + ldx tmp + jmp tx_queue_packet + .) + +&tcp_echo_queue .( + jmp tx_queue_packet +#if 0 + .zero +zp .word 0 +z2 .word 0 + .bss +slot .byt 0 + .text + + stx slot + jsr getbadr + sta zp + sty zp+1 + + ldy #0 + lda (zp),y + clc + adc zp + sta z2 + iny + lda (zp),y + adc zp+1 + sta z2+1 + iny + lda (zp),y + tax + iny + lda (zp),y + sta zp+1 + stx zp + +#ifdef DEBUGTCP +DB("Data: pos=") +lda z2+1: jsr EHexout: lda z2: jsr EHexout +DB(" len= ") +lda zp+1: jsr EHexout: lda zp: jsr EHexout +jsr ECrlfout + +dloop ldy #0 + lda (z2),y + jsr EHexout + lda #" " + jsr ECout + + inc z2 + bne l0 + inc z2+1 +l0 lda zp + bne l1 + dec zp+1 +l1 dec zp + lda zp + ora zp+1 + bne dloop + + jsr ECrlfout + +DB("rx_queue_packet: return slot ") +lda slot: jsr EHexout: lda " ": jsr ECout +ldx slot: jsr getbadr: pha: tya: jsr EHexout: pla: jsr EHexout: +lda #"[": jsr ECout +ldx slot: jsr getblen: pha: tya: jsr EHexout: pla: jsr EHexout: +DB("]") +/*jsr printmem*/ +#endif + + ldx slot + jsr bfree + clc + rts +#endif + .) + +/***************************************************************************/ + +&tcp_disc_queue .( + jmp bfree +#if 0 + .zero +zp .word 0 +z2 .word 0 + .bss +slot .byt 0 + .text + + stx slot + jsr getbadr + sta zp + sty zp+1 + + ldy #0 + lda (zp),y + clc + adc zp + sta z2 + iny + lda (zp),y + adc zp+1 + sta z2+1 + iny + lda (zp),y + tax + iny + lda (zp),y + sta zp+1 + stx zp + +#ifdef DEBUGTCP +DB("Data: pos=") +lda z2+1: jsr EHexout: lda z2: jsr EHexout +DB(" len= ") +lda zp+1: jsr EHexout: lda zp: jsr EHexout +jsr ECrlfout + +dloop ldy #0 + lda (z2),y + jsr EHexout + lda #" " + jsr ECout + + inc z2 + bne l0 + inc z2+1 +l0 lda zp + bne l1 + dec zp+1 +l1 dec zp + lda zp + ora zp+1 + bne dloop + + jsr ECrlfout + +DB("rx_queue_packet: return slot ") +lda slot: jsr EHexout: lda " ": jsr ECout +ldx slot: jsr getbadr: pha: tya: jsr EHexout: pla: jsr EHexout: +lda #"[": jsr ECout +ldx slot: jsr getblen: pha: tya: jsr EHexout: pla: jsr EHexout: +DB("]") +/*jsr printmem*/ +#endif + + ldx slot + jsr bfree + clc + rts +#endif + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/tcpuser.a65 b/dump/oa-2.0.9/sysapps/slipd/tcpuser.a65 new file mode 100644 index 0000000..f92dfbc --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/tcpuser.a65 @@ -0,0 +1,428 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/*************************************************************************** + * Here are the user routines (open, close etc) + */ + + .bss +tcbno .byt 0 + .text + + ; server struct: + ; remote_ip, remote_port, local_port, flag, queue_packet + +&user_init .( +#ifndef NO_TEST + jsr tcp_test_init +#endif +#ifndef NO_FSTCP + jsr fstcp_init +#endif +#ifndef NO_WWW + jsr wwwsrv_init +#endif +#ifndef NO_RSH + jsr rsh_init +#endif +#ifndef NO_LIBIP + jsr libip_init +#endif + rts + .) + +srv_open .( + ldy #TCB_SERVICE + lda (tcbp),y + sta srv + iny + lda (tcbp),y + sta srv+1 + + ldy #SRV_OPEN+1 + lda (srv),y + pha + dey + lda (srv),y + pha + rts + .) + +rx_queue_packet .( + tax + + ldy #TCB_SERVICE + lda (tcbp),y + sta srv + iny + lda (tcbp),y + sta srv+1 + + ldy #SRV_QUEUE+1 + lda (srv),y + pha + dey + lda (srv),y + pha + + rts + .) + +&tcp_abort .( + jsr settcb + bcs notcb + + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_LISTEN + beq del + cmp #TCP_SYNTXD + beq del + + cmp #TCP_CLOSING + bcs ok + jsr send_reset +del + jsr tclose + clc + rts +notcb lda #TE_NOCONN + .byt $2c +closing lda #TE_CLOSING + sec + rts +ok clc + rts + .) + +&tcp_close .( + jsr settcb + bcc tcbok + jmp notcb +tcbok +&&tcb_close +#ifdef DEBUGTCP2 +DB("tcp_close tcbp=") +lda tcbp+1:jsr EHexout:lda tcbp:jsr EHexout: +/*DB(" sig=") +pla:pha:jsr EHexout:*/ +DB(" st=") +ldy #TCB_STATE:lda (tcbp),y:jsr EHexout +jsr ECrlfout +#endif + + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_LISTEN + beq del + cmp #TCP_SYNTXD + beq del + + cmp #TCP_SYNRXD + beq c1b + cmp #TCP_ESTAB + bne c2 +c1b +; ldy #TCB_NTXBUF +; lda (tcbp),y +; beq c1a + ldy #TCB_FLAG + lda (tcbp),y ; queued fin ! + ora #THF_FIN+THF_ACK + sta (tcbp),y +; clc +; rts +; +;c1a jsr send_fin +; bcs c1b + ldy #TCB_STATE + lda #TCP_FINW1 + sta (tcbp),y + + clc + rts + +c2 cmp #TCP_CLOSEW + bne closing +; jsr send_fin ; should always be able to queue -> no check + ldy #TCB_FLAG + lda (tcbp),y + ora #THF_ACK+THF_FIN + sta (tcbp),y + + ldy #TCB_STATE + lda #TCP_CLOSING + sta (tcbp),y + clc + rts +del + jsr tclose + clc + rts +notcb lda #TE_NOCONN + .byt $2c +closing lda #TE_CLOSING + sec + rts + .) + +&tcp_signal .( + +#ifdef DEBUGTCP +pha +DB("tcp_signal tcbp=") +lda tcbp+1:jsr EHexout:lda tcbp:jsr EHexout: +DB(" sig=") +pla:pha:jsr EHexout: +DB(" st=") +ldy #TCB_STATE:lda (tcbp),y:jsr EHexout +jsr ECrlfout +pla +#endif + + cmp #TE_SIG_FIN + bne nofin +;c1b +; ldy #TCB_NTXBUF +; lda (tcbp),y +; beq c1a + ldy #TCB_FLAG + lda (tcbp),y ; queued fin ! + ora #THF_FIN+THF_ACK + sta (tcbp),y +; clc +; rts +; +;c1a jsr send_fin +; bcs c1b + ldy #TCB_STATE + lda #TCP_LASTACK + sta (tcbp),y + + ldy #TCB_MSL + lda #TIME_LASTACK + sta (tcbp),y + + clc + rts +nofin + cmp #TE_SIG_RESET + bne norst + jmp tclose +norst + rts + .) + +&tcp_listen .( + sta srv + sty srv+1 + jsr gettcb + bcs notcb + stx conn + + ldy #TCB_SERVICE + lda srv + sta (tcbp),y + iny + lda srv+1 + sta (tcbp),y + + ldy #SRV_LPORT + lda (srv),y + tax + iny + lda (srv),y + ldy #TCB_TRGP + sta (tcbp),y + iny + txa + sta (tcbp),y + + ldy #TCB_STATE + lda #TCP_LISTEN + sta (tcbp),y + + ldx conn + clc + ;rts +notcb rts + .) + +&tcp_open .( + sta srv + sty srv+1 + jsr gettcb + bcs notcb + stx conn + + ldy #TCB_SERVICE + lda srv + sta (tcbp),y + iny + lda srv+1 + sta (tcbp),y + + ldy #SRV_RIP +l0 lda (srv),y + sta (tcbp),y + iny + cpy #SRV_RIP+4 + bcc l0 + + ldy #TCB_TRGIP +l1 lda MyIP-TCB_TRGIP,y + sta (tcbp),y + iny + cpy #TCB_TRGIP+4 + bcc l1 + + ldy #SRV_RPORT + lda (srv),y + tax + iny + lda (srv),y + ldy #TCB_SRCP+1 + sta (tcbp),y + dey + txa + sta (tcbp),y + + lda conn + pha + jsr getlport + + ldy #TCB_TRGP+1 + sta (tcbp),y + dey + txa + sta (tcbp),y + + pla + sta conn + + jsr iniseq + + ldy #TCB_STATE + lda #TCP_SYNTXD + sta (tcbp),y + + jsr send_syn ; should always be able to queue -> no check (TODO) + + ldx conn + clc +notcb rts + .) + + /* gets a new local port between 1024 and 4096 (checks if in use!) */ +getlport .( +/*DB("getlport:")*/ + lda tcbp + pha + lda tcbp+1 + pha + + lda lport+1 + cmp #>1024 + bcc setp +incp + inc lport + bne l0 + inc lport+1 +l0 + lda lport+1 + cmp #>4096 + bcc l2 +setp lda #<1024 + sta lport + lda #>1024 + sta lport+1 +l2 + ldx #0 +l1 stx conn + jsr settcb + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_CLOSED + beq next + + ldy #TCB_TRGP + lda (tcbp),y + cmp lport+1 + bne next + iny + lda (tcbp),y + cmp lport + beq incp +next ldx conn + inx + cpx #MAXCONN + bcc l1 + + pla + sta tcbp+1 + pla + sta tcbp + +/*lda lport+1:jsr EHexout:lda lport:jsr EHexout:jsr ECrlfout*/ + + lda lport + ldx lport+1 + rts + + .data +lport .word 0 + .text + .) + +signal_user .( + .data +sig .byt 0 + .text + + tax + ldy #TCB_SERVICE + lda (tcbp),y + sta srv + iny + lda (tcbp),y + sta srv+1 + + ldy #SRV_SIGNAL + lda (srv),y + iny + ora (srv),y + beq nosig + lda (srv),y + pha + dey + lda (srv),y + pha + txa +nosig + rts + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/tutil.a65 b/dump/oa-2.0.9/sysapps/slipd/tutil.a65 new file mode 100644 index 0000000..c92c0ec --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/tutil.a65 @@ -0,0 +1,724 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + +/* + * TCP utilities + */ + + .( + + .bss +phdr .dsb TPH_LEN + .text + +/* make IP header to TCP header */ +&&ip2tcp .( + lda #0 + sta phdr+TH_PTCL-1 + ldy #IPH_PROT + lda (pp),y + sta phdr+TH_PTCL + ldy #IPH_SRC +c1 lda (pp),y + sta phdr-IPH_SRC,y /* TH_SRCIP == 0 */ + iny + cpy #IPH_TRG+4 + bne c1 + ldy #TH_TCPLEN + lda pdl+1 + sta phdr,y + lda pdl + sta phdr+1,y + + lda pd + sec + sbc #TPH_LEN + sta pd + lda pd+1 + sbc #0 + sta pd+1 + + lda pdl + clc + adc #TPH_LEN + sta pdl + lda pdl+1 + adc #0 + sta pdl+1 + + ldy #0 +c2 lda phdr,y + sta (pd),y + iny + cpy #TPH_LEN + bne c2 +#if 0 +lda ppl:ldy ppl+1:ldx #pp +jsr printpacket2 +#endif + rts + .) + +/* make IP header from TCP pseudo header + * (i.e. copy the IP addresses to the right location and set protocol + * the rest is done in the IP layer */ +&&tcp2ip .( + lda phl + cmp #TCP_OFFSET + beq nomove +move DB("packet start mismatch!^m^j") +.byt 2:lda pp +#if 0 + DB("ip=") + lda qp+1: jsr EHexout: lda qp: jsr EHexout + DB(", pd=") + lda pd+1: jsr EHexout: lda pd: jsr EHexout +#endif + sec + rts +nomove +/* + lda ql + sec + sbc #TPH_LEN + sta qlen+1 +*/ +#if 0 +DB("nomove: qp=") +lda pp+1:jsr EHexout: lda pp:jsr EHexout +DB(", qlen=") +lda ppl+1:jsr EHexout: lda ppl:jsr EHexout +DB(", qd=") +lda pd+1:jsr EHexout: lda pd:jsr EHexout +DB(", ql=") +lda pdl+1:jsr EHexout: lda pdl:jsr EHexout:jsr ECrlfout +#endif + lda pd + clc + adc #4 + sta p2 + lda pd+1 + adc #0 + sta p2+1 + + ldy #TH_TRGIP+3 +l3 lda (pd),y + tax + lda (p2),y + sta (pd),y + txa + sta (p2),y + dey + cpy # next full search loop + +nextl dex + bpl inuse ; inuse -> nextl listen search loop + + DB("No Connection!^m^j") + sec + rts + +t1 jsr settcb + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_LISTEN+1 + bcc next +search + ldy #TH_SRCP /* TCB_HDR must be 0! */ +tl lda (pd),y + cmp (tcbp),y + bne next + iny + cpy #TH_TRGP+2 + bcc tl + + ldy #TH_SRCIP +tm lda (pd),y + cmp (tcbp),y + bne next + iny + cpy #TH_TRGIP+4 + bcc tm +ok clc + rts + +inuse jsr settcb /* TODO: make listen not occupy a full TCB */ + ldy #TCB_STATE + lda (tcbp),y + cmp #TCP_LISTEN + bne nextl /* full search */ + + ldy #TH_TRGP +iu2 lda (pd),y + cmp (tcbp),y + bne nextl + iny + cpy #TH_TRGP+2 + bcc iu2 + ; ok, we found one. now copy IP addresses and remote port + + ldy #TCB_SERVICE /* check if multiple listens */ + lda (tcbp),y + sta srv + iny + lda (tcbp),y + sta srv+1 + ldy #SRV_FLAG + lda (srv),y + and #SFL_MULT + beq nodup + /* yes, then dup tcb */ + lda tcbp + sta srv + lda tcbp+1 + sta srv+1 + stx conn + jsr gettcb + bcc iu4 + ldx conn + jmp nextl +iu4 + ldy #0 +iu3 lda (srv),y + sta (tcbp),y + iny + cpy #TCB_LEN + bcc iu3 +nodup + ldy #TH_SRCIP +li1 lda (pd),y + sta (tcbp),y + iny + cpy #TH_TRGP+2 + bcc li1 + jmp ok + .) + +&checkseq .( /* check sequence number */ +tmpu =phdr + + ldy #TH_SEQ /* we don't handle disordered packets - ignore them */ +seql lda (pd),y + cmp (tcbp),y + bcc lesscheck + bne seqmm1 +next iny + cpy #TH_SEQ+4 + bcc seql + clc /* pkt.seq == tcb.rcvnxt */ + rts +lesscheck + ldy #TH_SEQ+3 + lda (pd),y + clc + adc dlen + sta tmpu+3 + dey + lda (pd),y + adc dlen+1 + sta tmpu+2 + dey + lda (pd),y + adc #0 + sta tmpu+1 + dey + lda (pd),y + adc #0 + sta tmpu + + ldy #TCB_RCV_NXT +seqt lda tmpu-TCB_RCV_NXT,y + cmp (tcbp),y + bcc seqmm1 + bne setdiscd + iny + cpy #TCB_RCV_NXT+4 + bcc seqt + bcs setdiscd + +seqmm1 +#ifdef DEBUGTCP + DB("Sequence mismatch^m^j") +#endif + sec /* pkt.seq+dlen <= tcb.rcvnxt < pkt.seq */ + rts + +setdiscd + ldx #4 + ldy #TCB_RCV_NXT+3 + sec +s1 lda (tcbp),y + sbc (pd),y + sta tmpu-TCB_RCV_NXT,y + dey + dex + bne s1 + + lda tmpu + ora tmpu+1 + bne seqmm1 + /* discd = tcb.rcvnxt - pkt.seq */ + lda tmpu+2 + sta discd+1 + lda tmpu+3 + sta discd + clc + rts + .) + + .) + +seql2ack .( /* pkt.seq + dlen -> pkt.ack */ + clc + ldy #TH_SEQ+3 + lda (pd),y + adc dlen + ldy #TH_ACK+3 + sta (pd),y + ldy #TH_SEQ+2 + lda (pd),y + adc dlen+1 + ldy #TH_ACK+2 + sta (pd),y + ldy #TH_SEQ+1 + lda (pd),y + adc #0 + ldy #TH_ACK+1 + sta (pd),y + ldy #TH_SEQ + lda (pd),y + adc #0 + ldy #TH_ACK + sta (pd),y + rts + .) + +ack2seq .( /* pkt.ack -> pkt.seq */ + ldy #TH_ACK + lda (pd),y + ldy #TH_SEQ + sta (pd),y + ldy #TH_ACK+1 + lda (pd),y + ldy #TH_SEQ+1 + sta (pd),y + ldy #TH_ACK+2 + lda (pd),y + ldy #TH_SEQ+2 + sta (pd),y + ldy #TH_ACK+3 + lda (pd),y + ldy #TH_SEQ+3 + sta (pd),y + rts + .) + +clrseq .( /* 0 -> pkt.seq */ + lda #0 + ldy #TH_SEQ +l0 sta (pd),y + iny + cpy #TH_SEQ+4 + bcc l0 + rts + .) + +tcpxip .( /* pkt.srcip <-> pkt.trgip */ + lda pd + clc + adc #TH_TRGIP - TH_SRCIP + sta p2 + lda pd+1 + adc #0 + sta p2+1 + + ldy #TH_SRCIP +l2 lda (pd),y + tax + lda (p2),y + sta (pd),y + txa + sta (p2),y + iny + cpy #TH_SRCIP+4 + bcc l2 + rts + .) + +tcpxp .( + lda pd + clc + adc #TH_TRGP - TH_SRCP + sta p2 + lda pd+1 + adc #0 + sta p2+1 + + ldy #TH_SRCP +l1 lda (pd),y + tax + lda (p2),y + sta (pd),y + txa + sta (p2),y + iny + cpy #TH_SRCP+2 + bcc l1 + rts + .) + +shortpk .( /* shorten packet to minimum reply */ + lda #$50 + ldy #TH_DOFFSET /* data offset */ + sta (pd),y + lsr + lsr + ldy #TH_TCPLEN+1 /* TCPLEN in byte */ + sta (pd),y + clc + adc #TPH_LEN + sta pdl /* plus pseudo header length is tcp len */ + dey + lda #0 + sta (pd),y + adc #0 + sta pdl+1 + + lda pdl + clc + adc phl /* plus pp->pd offset is packet length */ + sta ppl + lda pdl+1 + adc #0 + sta ppl+1 + + tay + lda ppl + ldx pslot + jmp btrunc /* and shorten */ + .) + +preptcp .( + ldy #TH_TCPLEN+1 + lda pdl + sec + sbc #TPH_LEN + sta (pd),y + dey + lda pdl+1 + sbc #0 + sta (pd),y + + ldy #TH_WINDOW + lda #>TCPWIN + sta (pd),y + iny + lda # tcb.rcvnxt */ + ldy #TH_SEQ+3 + clc + lda (pd),y + adc #1 + sta (pd),y + sta (tcbp),y + dey + lda (pd),y + adc #0 + sta (pd),y + sta (tcbp),y + dey + lda (pd),y + adc #0 + sta (pd),y + sta (tcbp),y + dey + lda (pd),y + adc #0 + sta (pd),y + sta (tcbp),y + rts + .) + +iniseq .( /* rand() -> tcb.sndnxt,tcb.snduna */ + ldy #TCB_SND_NXT + lda $dc07 + sta (tcbp),y + iny + lda $dc06 + sta (tcbp),y + iny + lda $dd07 + sta (tcbp),y + iny + lda $dd06 + sta (tcbp),y + + lda #4 + clc + adc tcbp + sta p2 + lda #0 + adc tcbp+1 + sta p2+1 + + ldy #TCB_SND_UNA +l0 lda (p2),y + sta (tcbp),y + iny + cpy #TCB_SND_UNA+4 + bcc l0 + clc + rts + .) + +setseq .( /* tcp.sndnxt -> pkt.seq */ + lda tcbp + clc + adc #8 + sta p2 + lda tcbp+1 + adc #0 + sta p2+1 + + ldy #TH_SEQ +l5 lda (p2),y + sta (pd),y + iny + cpy #TH_SEQ+4 + bcc l5 + rts + .) + +setack .( /* tcb.rcvnxt -> pkt.ack */ + lda pd + clc + adc #4 + sta p2 + lda pd+1 + adc #0 + sta p2+1 + + ldy #TCB_RCV_NXT +l5 lda (tcbp),y + sta (p2),y + iny + cpy #TCB_RCV_NXT+4 + bcc l5 + rts + .) + +getuna .( /* pkt.ack -> tcb.snduna */ + ldy #TH_ACK +a1 lda (pd),y + sta (tcbp),y + iny + cpy #TH_ACK+4 + bcc a1 + rts + .) + +getseq .( /* pkt.seq -> tcb.rcvnxt */ + ldy #TCB_RCV_NXT +l0 lda (pd),y + sta (tcbp),y + iny + cpy #TCB_RCV_NXT+4 + bcc l0 + rts + .) + +&decseq .( /* tcb.sndnxt-- */ + ldx #3 + ldy #TCB_SND_NXT+3 + sec + lda (tcbp),y + sbc #1 + sta (tcbp),y +l0 dey + lda (tcbp),y + sbc #0 + sta (tcbp),y + dex + bne l0 + rts + .) + + /* add a/x to tx_nxt */ +addtxnxt .( + ldy #TCB_SND_NXT+3 + clc + adc (tcbp),y + sta (tcbp),y + dey + txa + adc (tcbp),y + sta (tcbp),y + dey + ldx #2 +l5 lda (tcbp),y + adc #0 + sta (tcbp),y + dey + dex + bne l5 + rts + .) + + /* add a/x to rx_nxt */ +addrxnxt .( + ldy #TCB_RCV_NXT+3 + clc + adc (tcbp),y + sta (tcbp),y + dey + txa + adc (tcbp),y + sta (tcbp),y + dey + ldx #2 +l5 lda (tcbp),y + adc #0 + sta (tcbp),y + dey + dex + bne l5 + rts + .) + +checkack .( /* TODO: check for below ISS */ + /* first check with SND_UNA - if less then ignore */ + ldy #TH_ACK +l1 lda (pd),y + cmp (tcbp),y + bcc badack0 + bne l1a + iny + cpy #TH_ACK+4 + bcc l1 +l1a + lda tcbp + clc + adc #4 + sta p2 + lda tcbp+1 + adc #0 + sta p2+1 + + /* now check with SND_NXT - if greater then error */ + ldy #TH_ACK +l2 lda (p2),y + cmp (pd),y + bcc badack1 + bne okack1 + iny + cpy #TH_ACK+4 + bcc l2 + + /* now check for equality with SND_NXT */ + ldy #TH_ACK+3 +l3 lda (p2),y + cmp (pd),y + bne okack1 + dey + cpy #TH_ACK + bcs l3 + lda #2 ; exactly SND_NXT + .byt $2c +okack1 lda #1 ; not exactly SND_NXT + clc + rts +badack0 lda #0 ; old acknowledge + .byt $2c +badack1 lda #3 ; ack ahead + sec + rts + .) + +aheadiss .( /* TODO: actually save ISS. this assumes we don't send data + before we are in TCP_ESTAB! */ + lda #4 + clc + adc tcbp + sta p2 + lda #0 + adc tcbp+1 + sta p2+1 + + ldy #TH_ACK +l0 lda (pd),y + cmp (p2),y + bne bad + iny + cpy #TH_ACK+4 + bcc l0 + clc + rts +bad sec + rts + .) + +&&exports .( /* exchange udp ports _before_ ip2tcp */ + lda pd + clc + adc #2 + sta p2 + lda pd+1 + adc #0 + sta p2+1 + ldy #0 +l0 lda (pd),y + tax + lda (p2),y + sta (pd),y + txa + sta (p2),y + iny + cpy #0+2 + bcc l0 + rts + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/udp.a65 b/dump/oa-2.0.9/sysapps/slipd/udp.a65 new file mode 100644 index 0000000..233072a --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/udp.a65 @@ -0,0 +1,140 @@ + +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * This file is a TCP implementation for 6502 computer + * + * it exports: + * udpinit - init TCP + * udprx - gets incoming packets + * + */ + +/* #define DEBUGUDP */ + +#ifdef DEBUGUDP +#define DBUDP(a) DB(a) +#else +#define DBUDP(a) +#endif + + .( + +&&udpinit .( + clc + rts + .) + + +&&udprx .( + + jsr getpinfo + bcc piok + DBUDP("getpi error in udprx^m^j") + rts +piok + ldy #6 + lda (pd),y + iny + ora (pd),y + beq udpok ; no check + +#if 0 + jsr ip2tcp + +#if 0 /*def DEBUGTCP*/ +DB("TCP check: pd=") +lda pd+1: jsr EHexout: lda pd: jsr EHexout +DB(", pdl=") +lda pdl+1: jsr EHexout: lda pdl: jsr EHexout +DB(", pp=") +lda pp+1: jsr EHexout: lda pp: jsr EHexout +DB(", ppl=") +lda ppl+1: jsr EHexout: lda ppl: jsr EHexout +jsr ECrlfout +#endif + + lda pdl + ldy pdl+1 + ldx #pd + jsr checksum3 + + php + lda #8 + sta phl + jsr tcp2ip + plp + +#if 0 /*def DEBUGTCP*/ +php +pha +txa +pha +DB("TCP Checksum=") +pla +tay +jsr EHexout +pla +pha +jsr EHexout +jsr ECrlfout +tya +tax +pla +plp +#endif + bcc udpok +#endif + +tdisc_check + DB("Packet discarded: UDP checksum^m^j") +&tdisc ldx pslot + bmi illtd + jsr bfree + lda #<-1 + sta pslot + clc + rts +illtd DBUDP("tdisc with illegal slot!^m^j") + sec + rts + + +udpok /* here we have a valid UDP packet in (pd),0-pdl. */ +/* +DB("tcpok pp=") +lda pp+1:jsr EHexout:lda pp:jsr EHexout +jsr ECrlfout +*/ + DBUDP("UDP port unreachable packet!^m^j") + + ; jsr exports + + lda phl + ldx pslot + jmp uporterr + .) + + .) + diff --git a/dump/oa-2.0.9/sysapps/slipd/util.a65 b/dump/oa-2.0.9/sysapps/slipd/util.a65 new file mode 100644 index 0000000..a9070b1 --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/util.a65 @@ -0,0 +1,283 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + +/* + * exports checksum3, printpacket2, ECout, ETxtout, EHexout, EClfout + * + * Must be at the end of the code, because of #iflused constructs + */ + + .( + .bss +tmp .byt 0,0,0 +len .word 0 + .zero +&p .word 0 + .text + + /* computes IP header checksum and returns it in a/x */ + /* packet length in a/y, x = zeropage address of pkt address pointer */ +&checksum3 .( + + sec + sbc #1 + sta len + tya + sbc #0 + sta len+1 + bcs uf + rts +uf + lda 0,x + sta p + lda 1,x + sta p+1 + +#if 0 /* def DEBUGPKT */ +DB("Check: ") +lda p+1:jsr EHexout: lda p: jsr EHexout:lda #" ": jsr ECout +lda len+1:jsr EHexout: lda len: jsr EHexout +#endif + lda #0 + sta tmp + sta tmp+1 + sta tmp+2 + ldy #0 +loop + iny + lda tmp + clc + adc (p),y + sta tmp + lda tmp+1 + dey + adc (p),y + sta tmp+1 + bcc l0 + inc tmp+2 +l0 + iny + iny + bne l1 + inc p+1 +l1 + lda len + sec + sbc #2 + sta len + bcs l1a + lda len+1 + sbc #0 + sta len+1 + bcc loope ; underflow (even size) -> end +l1a lda len + ora len+1 + bne loop + +l1b lda (p),y + clc + adc tmp+1 + sta tmp+1 + bcc loope + inc tmp+2 +loope + lda tmp + clc + adc tmp+2 + pha + lda tmp+1 + adc #0 + eor #$ff + tax + pla + eor #$ff +#if 0 /* def DEBUGPKT */ + php + pha + DB(" -> ") + txa + jsr EHexout + pla + pha + jsr EHexout + jsr ECrlfout + pla + plp +#endif + bne err + cpx #0 + bne err + clc + rts +err sec + rts + .) + + +#iflused printpacket2 + +&printpacket2 .( + sta len + sty len+1 + cmp #64 + bcs limit + tya + beq nolimit +limit lda #48 + sta len + lda #0 + sta len+1 +nolimit + lda 0,x + sta p + lda 1,x + sta p+1 + + ldy #0 +l0 + lda (p),y + jsr EHexout + lda #" " + jsr ECout + iny + cpy len + beq lend + tya + and #7 + bne l0 + jsr ECrlfout + jmp l0 +lend + DB("^m^jHeader Checksum=") + lda #0 + sta tmp+1 + ldy #IPH_VER + lda (p),y + and #$0f + asl + asl + sta tmp + lda tmp + ldy tmp+1 + ldx #p + jsr checksum3 + pha + txa + jsr EHexout + pla + jsr EHexout + + jsr ECrlfout + clc + rts + .) +#endif + .) + +/**********************************************************************/ +/* Output on STDERR */ + + .( + .bss +XR .byt 0 + .text + +#iflused ECout +&ECout .( + stx XR + ldx #STDERR + sec + jsr fputc + ldx XR + rts + .) +#endif + +#iflused ECrlfout +&ECrlfout .( + stx XR + ldx #STDERR + lda #13 + sec + jsr fputc + lda #10 + sec + jsr fputc + ldx XR + rts + .) +#endif + +#iflused EHexout +&EHexout .( + stx XR + pha + lsr + lsr + lsr + lsr + jsr nibout + pla + and #$0f +nibout ldx #STDERR + clc + adc #"0" + cmp #"9"+1 + bcc nibok + adc #6 +nibok sec + jsr fputc + ldx XR + rts + .) +#endif + +#iflused ETxtout +&ETxtout + .( + .zero +tp .word + .text + + sta tp + sty tp+1 + stx XR + ldx #STDERR + ldy #0 +tol lda (tp),y + beq tole + sec + jsr fputc + iny + bne tol + inc tp+1 + bne tol +tole + ldx XR + clc + rts + .) +#endif + .) + + diff --git a/dump/oa-2.0.9/sysapps/slipd/wwwsrv.a65 b/dump/oa-2.0.9/sysapps/slipd/wwwsrv.a65 new file mode 100644 index 0000000..f40f20d --- /dev/null +++ b/dump/oa-2.0.9/sysapps/slipd/wwwsrv.a65 @@ -0,0 +1,949 @@ +/**************************************************************************** + + OS/A65 Version 2.0.0 + Multitasking Operating System for 6502 Computers + + Copyright (C) 1989-1998 Andre Fachat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +****************************************************************************/ + + .( + +#define TCB_WS TCB_CONN +#define TCB_WSLOT (TCB_CONN+1) +#define TCB_WSTR (TCB_CONN+2) +#define TCB_WTASK (TCB_CONN+3) +#define TCB_WCNT (TCB_CONN+4) +#define TCB_WPREFIX (TCB_CONN+5) + +#define WS_FREE 0 +#define WS_RXD 1 /* filename received */ +#define WS_FSENT 2 /* filename sent to filesystem */ +#define WS_WR 3 /* get data and send it */ +#define WS_WR_WAIT 4 /* send prepared data block */ +#define WS_WR_WEOF 5 /* send last data block */ +#define WS_CLOSING 6 /* closing */ +#define WS_CLOSED 7 /* closed */ + +#define WE_ILLFORMED 1 /* illformed request */ +#define WE_TRYAGAIN 2 /* temporary resource shortage */ +#define WE_NOTFOUND 3 /* file not found */ + +www_srv .byte 0,0,0,0, 0,0, 80,0, SFL_MULT + .word wwwsrv_open-1, wwwsrv_queue-1, wwwsrv_loop-1, wwwsrv_signal-1 + + .zero +zp .word 0 + .text + +&wwwsrv_init .( + lda #www_srv + jmp tcp_listen + .) + +wwwsrv_open + rts + +wwwsrv_queue .( + stx pslot + jsr getbadr + sta pp + sty pp+1 + +#ifdef DEBUGWWW +DB("wwwsrv_queue: tcbp=") +lda tcbp+1:jsr EHexout:lda tcbp:jsr EHexout:jsr ECrlfout +#endif + + ldy #TCB_WS + lda (tcbp),y + cmp #WS_FREE + beq noclose + jmp close +noclose + ldy #TCB_WPREFIX + lda #<-1 + sta (tcbp),y + + ldy #0 + lda (pp),y + clc + adc pp + sta pd + iny + lda (pp),y + adc pp+1 + sta pd+1 + iny + lda (pp),y + sta pdl + iny + lda (pp),y + sta pdl+1 +#ifdef DEBUGWWW +ldy #0:x4 lda (pd),y:jsr ECout:iny:cpy pdl:bcc x4 +#endif + + lda pdl+1 + bne oklen + lda pdl + cmp #5 /* at least GET + space + one_char_URL */ + bcc noget1 +oklen + ldy #0 + lda (pd),y + cmp #"G" + beq get2 + cmp #"g" + bne noget1 +get2 iny + lda (pd),y + cmp #"E" + beq get3 + cmp #"e" + bne noget1 +get3 iny + lda (pd),y + cmp #"T" + beq get4 + cmp #"t" + beq get4 +noget1 jmp noget +get4 + iny + beq noget1 /* length overflow */ + cpy pdl + bcc ok /* low counter below length */ + lda pdl+1 + beq noget1 /* gotten to end length */ +ok + lda (pd),y + cmp #" " + beq get4 + + tya + sta ppl /* well, we need temp. storage... */ + clc + adc pd + sta pd + bcc a0 + inc pd+1 +a0 lda pdl + sec + sbc ppl + sta pdl + bcs a1 + dec pdl+1 +a1 + ldy #0 + beq a2a +a2 iny + beq noget1 /* length overflow */ +a2a cpy pdl + bcc ok1 /* low counter below length */ + lda pdl+1 + beq noget1 /* gotten to end length */ +ok1 + lda (pd),y + cmp #32 + bcc end + cmp #" " + beq end + cmp #"#" + beq end + cmp #"/" + bne a2 + lda #DIRSIGN + sta (pd),y + jmp a2 +end sty pdl + lda #0 + sta pdl+1 + + cpy #64 /* filename too long! */ + bcs noget + +#ifdef DEBUGWWW +DB("GET detected:") +ldy #0:x3 lda (pd),y:jsr ECout:iny:cpy pdl:bcc x3 +DB(", len=") +lda pdl:jsr EHexout:jsr ECrlfout +#endif + + ldy #0 + lda pd + sec + sbc pp + sta (pp),y + iny + lda pd+1 + sbc pp+1 + sta (pp),y + iny + lda pdl + sta (pp),y + iny + lda pdl+1 + sta (pp),y + + lda pslot + ldy #TCB_WSLOT + sta (tcbp),y + ldy #TCB_WS + lda #WS_RXD + sta (tcbp),y + ldy #TCB_WCNT + lda #100 + sta (tcbp),y + clc + rts + +noget lda pslot + pha + ldx #WE_ILLFORMED + jsr senderr + pla + sta pslot + lda #WS_CLOSING +set + ldy #TCB_WS + sta (tcbp),y +close + ldx pslot + jsr bfree + + clc + rts + .) + +senderr .( + dex + txa + asl + tax + + lda msgtab,x + sta zp + lda msgtab+1,x + sta zp+1 + + lda lentab+1,x + tay + lda lentab,x + sec + +&sendprefix + php + clc + adc #TCP_DOFFSET + pha + tya + adc #0 + tay + pla + jsr balloc + bcc xerrp + jmp errp +xerrp + lda #TCP_DOFFSET + jsr getpinfo +/* +DB("sendprefix: pd=") +lda pd+1:jsr EHexout:lda pd:jsr EHexout +DB(" pp=") +lda pp+1:jsr EHexout:lda pp:jsr EHexout +jsr ECrlfout +*/ + ldy #0 + lda pd + sec + sbc pp + sta (pp),y + iny + lda pd+1 + sbc pp+1 + sta (pp),y + iny + lda pdl + sta (pp),y + iny + lda pdl+1 + sta (pp),y + + ldy #0 +loop cpy pdl + bcc okl + lda pdl+1 + beq end +okl + lda (zp),y + sta (pd),y + iny + bne loop + dec pdl+1 + jmp loop + +end +/* +DB("sendprefix: pd=") +lda pd+1:jsr EHexout:lda pd:jsr EHexout +DB(" pp=") +lda pp+1:jsr EHexout:lda pp:jsr EHexout +jsr ECrlfout +*/ + ldx pslot + plp + bcc notx + + jmp tx_queue_packet +errp + plp + sec +notx lda #<-1 + sta pslot + rts + + .data + +msgtab .word m_illf, m_again, m_notf +lentab .word e_illf-m_illf, e_again-m_again, e_notf-m_notf + +m_illf .asc "HTTP/1.0 400^m^jContent-Type: text/html^m^j^m^j" + .asc "^m^j^m^jError^m^j^m^j" + .asc "^m^j

Error 400

^m^j^m^j" + .asc "OS/A65" + .asc " TCP simple WWW server error: malformed request^m^j" + .asc "^m^j^m^j" +e_illf +m_again .asc "HTTP/1.0 400^m^jContent-Type: text/html^m^j^m^j" + .asc "^m^j^m^jError^m^j^m^j" + .asc "^m^j

Error 400

^m^j^m^j" + .asc "OS/A65" + .asc " TCP simple WWW server error: try again^m^j" + .asc "^m^j^m^j" +e_again +m_notf .asc "HTTP/1.0 400^m^jContent-Type: text/html^m^j^m^j" + .asc "^m^j^m^jError^m^j^m^j" + .asc "^m^j

Error 400

^m^j^m^j" + .asc "OS/A65" + .asc " TCP simple WWW server error: file not found^m^j" + .asc "^m^j^m^j" +e_notf + .text + + .) + +wwwsrv_loop .( + ldy #TCB_WS + lda (tcbp),y + cmp #WS_CLOSED+1 + bcc noerr + jmp err +noerr + asl + tay + lda looptab+1,y + pha + lda looptab,y + pha + rts + +looptab .word loop_free-1, loop_rxd-1, loop_sent-1, loop_wr-1 + .word loop_wait-1, loop_wait-1, loop_close-1, loop_closed-1 + +loop_rxd .( + ldy #TCB_WSLOT + lda (tcbp),y + tax + jsr getbadr + sta pp + sty pp+1 + ldy #0 + lda (pp),y + clc + adc pp + sta pd + iny + lda (pp),y + adc pp+1 + sta pd+1 + iny + lda (pp),y + sta pdl + iny + lda (pp),y + sta pdl+1 + +#if 1 /* def NOMMU */ + ldx #SEM_SENDBUF + sec + jsr PSEM + bcc semerrok + jmp semerr +semerrok +#endif + inc sendbuf + + lda www_drv + sta PCBUF+FS_OPEN_DRV + lda #0 + sta PCBUF+FS_OPEN_PFAD + + jsr GETSTR + bcs strerr + + txa + sta PCBUF+FS_OPEN_STR + ldy #TCB_WSTR + sta (tcbp),y + + ldx #0 +l0 lda wwwpath,x + beq l1 + sta PCBUF+FS_OPEN_NAME,x + inx + bne l0 +l1 + ldy #0 + lda (pd),y + cmp #"/" ;DIRSIGN + bne l2 + iny +l2 + cpy pdl + bcs l3 + lda (pd),y + cmp #" " + beq l3 + sta PCBUF+FS_OPEN_NAME,x + iny + inx + bne l2 +l3 + txa + beq def + lda PCBUF+FS_OPEN_NAME-1,x + cmp #DIRSIGN + bne l4 +def + ldy #0 +l5 lda wwwdef,y + beq l4 + sta PCBUF+FS_OPEN_NAME,x + iny + inx + bne l5 +l4 + lda #0 + sta PCBUF+FS_OPEN_NAME,x + inx + txa + clc + adc #FS_OPEN_NAME + + jsr send_filetype + + tay + lda #FS_OPEN_RD + ldx #SEND_FM + jsr SEND /* warning: this blocks if own task or weird confs! */ + bcs send_err + + txa + ldy #TCB_WTASK + sta (tcbp),y + + lda #WS_FSENT + ldy #TCB_WS + sta (tcbp),y + + ldy #TCB_WSLOT + lda (tcbp),y + tax + jsr bfree + + clc + rts + +send_err + ldy #TCB_WSTR + lda (tcbp),y + tax + jsr FRESTR +strerr + dec sendbuf +#if 1 /* def NOMMU */ + ldx #SEM_SENDBUF + jsr VSEM +semerr +#endif + ldy #TCB_WCNT + lda (tcbp),y + sec + sbc #1 + sta (tcbp),y + bne end + + ldx #WE_TRYAGAIN + jsr senderr + + ldy #TCB_WSLOT + lda (tcbp),y + tax + jsr bfree + + ldy #TCB_WS + lda #WS_CLOSING + sta (tcbp),y + +end rts + +wwwpath .byte WWW_PATH,0 +wwwdef .byte WWW_DEFAULT,0 + .) + +send_filetype .( + .bss +cnt .byt 0 + .text + + pha +/* +DB("filtetype for ") +lda #PCBUF+FS_OPEN_NAME:jsr ETxtout +DB("^m^jprefix=") +ldy #TCB_WPREFIX:lda (tcbp),y:jsr EHexout:jsr ECrlfout +*/ + jsr clrprefix +fo + pla + pha + tax + ldy #TCB_WPREFIX + lda #<-1 + sta (tcbp),y + + ldy #0 + sty cnt +l0 lda types,y + beq found + cmp PCBUF-2,x + bne next + dex + iny + bne l0 + +next pla + pha + tax + inc cnt +n2 iny + lda types,y + bne n2 + iny + lda types,y + bne l0 + pla + rts + +found asl cnt + ldx cnt + lda tadrs,x + sta zp + lda tadrs+1,x + sta zp+1 +/* +DB("header="):lda zp:ldy zp+1:jsr ETxtout:jsr ECrlfout +DB("len="):lda tlens+1,x:jsr EHexout:lda tlens:jsr EHexout:jsr ECrlfout +*/ + lda tlens+1,x + tay + lda tlens,x + clc ; do not send, just get slot + jsr sendprefix + ldy #TCB_WPREFIX + txa + sta (tcbp),y +/* +DB("send packet:") +.( :ldy #0: lll lda (pp),y:jsr EHexout:iny: cpy #4:bcc lll: .): jsr ECrlfout +*/ +ret + pla + rts + +types .asc "lmth.",0, "fig.",0, "gpj.",0, 0 +tadrs .word tt0, tt1, tt2 +tlens .word tt1-tt0-1, tt2-tt1-1, tt3-tt2-1 + +tt0 .asc "HTTP/1.0 200 OK^m^jContent-Type: text/html^m^j^m^j",0 +tt1 .asc "HTTP/1.0 200 OK^m^jContent-Type: image/gif^m^j^m^j",0 +tt2 .asc "HTTP/1.0 200 OK^m^jContent-Type: image/jpg^m^j^m^j",0 +tt3 + .) + +&clrprefix .( + ldy #TCB_WPREFIX + lda (tcbp),y + tax + lda #<-1 + sta (tcbp),y + cpx #<-1 + beq nopr + jsr bfree +nopr rts + .) + +loop_sent .( + ldy #TCB_WTASK + lda (tcbp),y + tax + clc + jsr XRECEIVE + bcc gotit + rts +gotit + dec sendbuf +#if 1 /* def NOMMU */ + pha + ldx #SEM_SENDBUF + jsr VSEM + pla +#endif + cmp #0 + bne err1 + + ldy #TCB_WPREFIX + lda (tcbp),y + + cmp #<-1 + beq ll + tax + lda #<-1 + sta (tcbp),y + ; jsr tx_queue_packet + txa + ldy #TCB_WSLOT + sta (tcbp),y + jmp qslot +ll + lda #WS_WR +set + ldy #TCB_WS + sta (tcbp),y + rts + +err1 jsr clrprefix + + ldx #WE_NOTFOUND + jsr senderr + + ldy #TCB_WSTR + lda (tcbp),y + tax + jsr FRESTR + + lda #WS_CLOSING + jmp set + .) + +loop_wr .( +/* +DB("loop_wr:") +jsr printlist:jsr printmem +*/ + ldy #TCB_WSTR + lda (tcbp),y + tax + lda #SC_STAT + jsr STRCMD + cmp #E_SFULL + beq send2 + cmp #E_SHWM + beq send2 + lda #SC_RWANZ + jsr STRCMD + cmp #0 + beq send2 +l0c1 rts +send2 + lda #TCP_DOFFSET+64 + ldy #0 + jsr balloc + bcs l0c1 + ;stx pslot + ;sta pp + ;sty pp+1 + txa + ldy #TCB_WSLOT + sta (tcbp),y + lda #TCP_DOFFSET + jsr getpinfo +/* +DB("Write block to pp=") +lda pp+1:jsr EHexout:lda pp:jsr EHexout:DB(", pd=") +lda pd+1:jsr EHexout:lda pd:jsr EHexout +jsr ECrlfout + +DB("sadr=") +ldy #TCB_WSLOT: lda (tcbp),y: tax: jsr getbadr: pha: tya: jsr EHexout: pla: jsr EHexout: jsr ECrlfout +*/ + ldy #TCB_WSTR + lda (tcbp),y + tax + ldy #0 +wrl jsr GETC + bcs wrle + sta (pd),y + iny + cpy #64 + bcc wrl + lda #E_OK +wrle pha + tya + + pha + ldy #TCB_WSLOT + lda (tcbp),y + tax +/* +DB("pd=") +lda pd+1:jsr EHexout:lda pd:jsr EHexout:jsr ECrlfout +DB("sadr=") +ldy #TCB_WSLOT:lda (tcbp),y:tax:jsr getbadr:pha:tya:jsr EHexout:pla:jsr EHexout:jsr ECrlfout +*/ + pla + + sta pdl + ldy #0 + clc + adc #TCP_DOFFSET + bcc w2 + iny +w2 jsr btrunc +/* +DB("pp=") +lda pp+1:jsr EHexout:lda pp:jsr EHexout +DB("sadr=") +ldy #TCB_WSLOT:lda (tcbp),y:tax:jsr getbadr:pha:tya:jsr EHexout:pla:jsr EHexout:jsr ECrlfout +*/ + ldy #0 + lda #TCP_DOFFSET + sta (pp),y + iny + lda pdl + sta (pp),y + iny + lda #0 + sta (pp),y + pla + + cmp #E_EOF + beq wend +&qslot lda #WS_WR_WAIT + .byt $2c +wend lda #WS_WR_WEOF + ldy #TCB_WS + sta (tcbp),y + + ldy #TCB_WSLOT + lda (tcbp),y +/*pha:DB("slot="):pla:pha:jsr EHexout:jsr ECrlfout:pla*/ + tax + jsr incownr + jsr tx_queue_packet + bcc send_ok + cmp #0 + bne error + rts +error lda #TE_SIG_RESET + jmp wwwsrv_signal + .) + +loop_wait .( + ldy #TCB_WSLOT + lda (tcbp),y + tax + jsr incownr +/* DB("requeue^m^j") */ + jsr tx_requeue_packet + bcs end +&send_ok +;jsr wwwprint + ldy #TCB_WSLOT + lda (tcbp),y + tax + jsr bfree + + ldy #TCB_WS + lda (tcbp),y + cmp #WS_WR_WEOF + bne noeof + + ldy #TCB_WSTR + lda (tcbp),y + tax + lda #SC_NUL + jsr STRCMD + + lda #WS_CLOSING + .byt $2c +noeof lda #WS_WR + ldy #TCB_WS + sta (tcbp),y +end rts + .) + +loop_close +err ldy #TCB_WS + lda #WS_CLOSED + sta (tcbp),y + + ldx conn + jsr tcp_close +loop_closed +loop_free rts + .) + +wwwsrv_signal .( +#ifdef DEBUGTCP2 +pha: +DB("wwwsrv_signal = "):pla:pha:jsr EHexout +DB(", tcbp="):lda tcbp+1:jsr EHexout:lda tcbp:jsr EHexout:jsr ECrlfout +pla +;inc $d020 +#endif + pha + + jsr clrprefix + + ldy #TCB_WS + lda (tcbp),y + cmp #WS_FSENT + bne nosent + + ldy #TCB_WTASK /* unlock filesystem by receiving msg */ + lda (tcbp),y + tax + sec + jsr XRECEIVE + + ldy #TCB_WSTR + lda (tcbp),y + tax + lda PCBUF+FS_X_ERR + beq relbuf + lda #SC_EOF + jsr STRCMD +relbuf + dec sendbuf +#if 1 /* def NOMMU */ + ldx #SEM_SENDBUF + jsr VSEM +#endif + jmp checkstr + +nosent cmp #WS_WR_WAIT + beq wait + cmp #WS_WR_WEOF + bne nowait +wait ldy #TCB_WSLOT + lda (tcbp),y + tax + jsr bfree +nowait +checkstr + ldy #TCB_WS + lda (tcbp),y + cmp #WS_FSENT + bcc end1 + cmp #WS_CLOSING + bcc end1 + ldy #TCB_WSTR + lda (tcbp),y + tax + lda #SC_NUL + jsr STRCMD + +end1 lda #WS_CLOSED + ldy #TCB_WS + sta (tcbp),y + + pla + jmp tcp_signal + .) + +#iflused wwwprint +wwwprint .( + .zero +wp .word 0 +l .word 0 + .text + +; lda tcbp +; cmp #> 8) & 0xFF); + write6502(BASE_STACK + ((sp - 1) & 0xFF), pushval & 0xFF); + sp -= 2; +} + +void push8(uint8_t pushval) { + write6502(BASE_STACK + sp--, pushval); +} + +uint16_t pull16() { + uint16_t temp16; + temp16 = read6502(BASE_STACK + ((sp + 1) & 0xFF)) | ((uint16_t)read6502(BASE_STACK + ((sp + 2) & 0xFF)) << 8); + sp += 2; + return(temp16); +} + +uint8_t pull8() { + return (read6502(BASE_STACK + ++sp)); +} + +void reset6502() { + pc = (uint16_t)read6502(0xFFFC) | ((uint16_t)read6502(0xFFFD) << 8); + a = 0; + x = 0; + y = 0; + sp = 0xFD; + status |= FLAG_CONSTANT; +} + + +static void (*addrtable[256])(); +static void (*optable[256])(); + +uint8_t penaltyop, penaltyaddr; + +//addressing mode functions, calculates effective addresses +static void imp() { //implied +} + +static void acc() { //accumulator +} + +static void imm() { //immediate + ea = pc++; +} + +static void zp() { //zero-page + ea = (uint16_t)read6502((uint16_t)pc++); +} + +static void zpx() { //zero-page,X + ea = ((uint16_t)read6502((uint16_t)pc++) + (uint16_t)x) & 0xFF; //zero-page wraparound +} + +static void zpy() { //zero-page,Y + ea = ((uint16_t)read6502((uint16_t)pc++) + (uint16_t)y) & 0xFF; //zero-page wraparound +} + +static void rel() { //relative for branch ops (8-bit immediate value, sign-extended) + reladdr = (uint16_t)read6502(pc++); + if (reladdr & 0x80) reladdr |= 0xFF00; +} + +static void abso() { //absolute + ea = (uint16_t)read6502(pc) | ((uint16_t)read6502(pc+1) << 8); + pc += 2; +} + +static void absx() { //absolute,X + uint16_t startpage; + ea = ((uint16_t)read6502(pc) | ((uint16_t)read6502(pc+1) << 8)); + startpage = ea & 0xFF00; + ea += (uint16_t)x; + + if (startpage != (ea & 0xFF00)) { //one cycle penlty for page-crossing on some opcodes + penaltyaddr = 1; + } + + pc += 2; +} + +static void absy() { //absolute,Y + uint16_t startpage; + ea = ((uint16_t)read6502(pc) | ((uint16_t)read6502(pc+1) << 8)); + startpage = ea & 0xFF00; + ea += (uint16_t)y; + + if (startpage != (ea & 0xFF00)) { //one cycle penlty for page-crossing on some opcodes + penaltyaddr = 1; + } + + pc += 2; +} + +static void ind() { //indirect + uint16_t eahelp, eahelp2; + eahelp = (uint16_t)read6502(pc) | (uint16_t)((uint16_t)read6502(pc+1) << 8); + eahelp2 = (eahelp & 0xFF00) | ((eahelp + 1) & 0x00FF); //replicate 6502 page-boundary wraparound bug + ea = (uint16_t)read6502(eahelp) | ((uint16_t)read6502(eahelp2) << 8); + pc += 2; +} + +static void indx() { // (indirect,X) + uint16_t eahelp; + eahelp = (uint16_t)(((uint16_t)read6502(pc++) + (uint16_t)x) & 0xFF); //zero-page wraparound for table pointer + ea = (uint16_t)read6502(eahelp & 0x00FF) | ((uint16_t)read6502((eahelp+1) & 0x00FF) << 8); +} + +static void indy() { // (indirect),Y + uint16_t eahelp, eahelp2, startpage; + eahelp = (uint16_t)read6502(pc++); + eahelp2 = (eahelp & 0xFF00) | ((eahelp + 1) & 0x00FF); //zero-page wraparound + ea = (uint16_t)read6502(eahelp) | ((uint16_t)read6502(eahelp2) << 8); + startpage = ea & 0xFF00; + ea += (uint16_t)y; + + if (startpage != (ea & 0xFF00)) { //one cycle penlty for page-crossing on some opcodes + penaltyaddr = 1; + } +} + +static uint16_t getvalue() { + if (addrtable[opcode] == acc) return((uint16_t)a); + else return((uint16_t)read6502(ea)); +} + +static uint16_t getvalue16() { + return((uint16_t)read6502(ea) | ((uint16_t)read6502(ea+1) << 8)); +} + +static void putvalue(uint16_t saveval) { + if (addrtable[opcode] == acc) a = (uint8_t)(saveval & 0x00FF); + else write6502(ea, (saveval & 0x00FF)); +} + + +//instruction handler functions +static void adc() { + penaltyop = 1; + value = getvalue(); + result = (uint16_t)a + value + (uint16_t)(status & FLAG_CARRY); + + carrycalc(result); + zerocalc(result); + overflowcalc(result, a, value); + signcalc(result); + + #ifndef NES_CPU + if (status & FLAG_DECIMAL) { + clearcarry(); + + if ((a & 0x0F) > 0x09) { + a += 0x06; + } + if ((a & 0xF0) > 0x90) { + a += 0x60; + setcarry(); + } + + clockticks6502++; + } + #endif + + saveaccum(result); +} + +static void and() { + penaltyop = 1; + value = getvalue(); + result = (uint16_t)a & value; + + zerocalc(result); + signcalc(result); + + saveaccum(result); +} + +static void asl() { + value = getvalue(); + result = value << 1; + + carrycalc(result); + zerocalc(result); + signcalc(result); + + putvalue(result); +} + +static void bcc() { + if ((status & FLAG_CARRY) == 0) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void bcs() { + if ((status & FLAG_CARRY) == FLAG_CARRY) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void beq() { + if ((status & FLAG_ZERO) == FLAG_ZERO) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void bit() { + value = getvalue(); + result = (uint16_t)a & value; + + zerocalc(result); + status = (status & 0x3F) | (uint8_t)(value & 0xC0); +} + +static void bmi() { + if ((status & FLAG_SIGN) == FLAG_SIGN) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void bne() { + if ((status & FLAG_ZERO) == 0) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void bpl() { + if ((status & FLAG_SIGN) == 0) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void brk() { + pc++; + push16(pc); //push next instruction address onto stack + push8(status | FLAG_BREAK); //push CPU status to stack + setinterrupt(); //set interrupt flag + pc = (uint16_t)read6502(0xFFFE) | ((uint16_t)read6502(0xFFFF) << 8); +} + +static void bvc() { + if ((status & FLAG_OVERFLOW) == 0) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void bvs() { + if ((status & FLAG_OVERFLOW) == FLAG_OVERFLOW) { + oldpc = pc; + pc += reladdr; + if ((oldpc & 0xFF00) != (pc & 0xFF00)) clockticks6502 += 2; //check if jump crossed a page boundary + else clockticks6502++; + } +} + +static void clc() { + clearcarry(); +} + +static void cld() { + cleardecimal(); +} + +static void cli() { + clearinterrupt(); +} + +static void clv() { + clearoverflow(); +} + +static void cmp() { + penaltyop = 1; + value = getvalue(); + result = (uint16_t)a - value; + + if (a >= (uint8_t)(value & 0x00FF)) setcarry(); + else clearcarry(); + if (a == (uint8_t)(value & 0x00FF)) setzero(); + else clearzero(); + signcalc(result); +} + +static void cpx() { + value = getvalue(); + result = (uint16_t)x - value; + + if (x >= (uint8_t)(value & 0x00FF)) setcarry(); + else clearcarry(); + if (x == (uint8_t)(value & 0x00FF)) setzero(); + else clearzero(); + signcalc(result); +} + +static void cpy() { + value = getvalue(); + result = (uint16_t)y - value; + + if (y >= (uint8_t)(value & 0x00FF)) setcarry(); + else clearcarry(); + if (y == (uint8_t)(value & 0x00FF)) setzero(); + else clearzero(); + signcalc(result); +} + +static void dec() { + value = getvalue(); + result = value - 1; + + zerocalc(result); + signcalc(result); + + putvalue(result); +} + +static void dex() { + x--; + + zerocalc(x); + signcalc(x); +} + +static void dey() { + y--; + + zerocalc(y); + signcalc(y); +} + +static void eor() { + penaltyop = 1; + value = getvalue(); + result = (uint16_t)a ^ value; + + zerocalc(result); + signcalc(result); + + saveaccum(result); +} + +static void inc() { + value = getvalue(); + result = value + 1; + + zerocalc(result); + signcalc(result); + + putvalue(result); +} + +static void inx() { + x++; + + zerocalc(x); + signcalc(x); +} + +static void iny() { + y++; + + zerocalc(y); + signcalc(y); +} + +static void jmp() { + pc = ea; +} + +static void jsr() { + push16(pc - 1); + pc = ea; +} + +static void lda() { + penaltyop = 1; + value = getvalue(); + a = (uint8_t)(value & 0x00FF); + + zerocalc(a); + signcalc(a); +} + +static void ldx() { + penaltyop = 1; + value = getvalue(); + x = (uint8_t)(value & 0x00FF); + + zerocalc(x); + signcalc(x); +} + +static void ldy() { + penaltyop = 1; + value = getvalue(); + y = (uint8_t)(value & 0x00FF); + + zerocalc(y); + signcalc(y); +} + +static void lsr() { + value = getvalue(); + result = value >> 1; + + if (value & 1) setcarry(); + else clearcarry(); + zerocalc(result); + signcalc(result); + + putvalue(result); +} + +static void nop() { + switch (opcode) { + case 0x1C: + case 0x3C: + case 0x5C: + case 0x7C: + case 0xDC: + case 0xFC: + penaltyop = 1; + break; + } +} + +static void ora() { + penaltyop = 1; + value = getvalue(); + result = (uint16_t)a | value; + + zerocalc(result); + signcalc(result); + + saveaccum(result); +} + +static void pha() { + push8(a); +} + +static void php() { + push8(status | FLAG_BREAK); +} + +static void pla() { + a = pull8(); + + zerocalc(a); + signcalc(a); +} + +static void plp() { + status = pull8() | FLAG_CONSTANT; +} + +static void rol() { + value = getvalue(); + result = (value << 1) | (status & FLAG_CARRY); + + carrycalc(result); + zerocalc(result); + signcalc(result); + + putvalue(result); +} + +static void ror() { + value = getvalue(); + result = (value >> 1) | ((status & FLAG_CARRY) << 7); + + if (value & 1) setcarry(); + else clearcarry(); + zerocalc(result); + signcalc(result); + + putvalue(result); +} + +static void rti() { + status = pull8(); + value = pull16(); + pc = value; +} + +static void rts() { + value = pull16(); + pc = value + 1; +} + +static void sbc() { + penaltyop = 1; + value = getvalue() ^ 0x00FF; + result = (uint16_t)a + value + (uint16_t)(status & FLAG_CARRY); + + carrycalc(result); + zerocalc(result); + overflowcalc(result, a, value); + signcalc(result); + + #ifndef NES_CPU + if (status & FLAG_DECIMAL) { + clearcarry(); + + a -= 0x66; + if ((a & 0x0F) > 0x09) { + a += 0x06; + } + if ((a & 0xF0) > 0x90) { + a += 0x60; + setcarry(); + } + + clockticks6502++; + } + #endif + + saveaccum(result); +} + +static void sec() { + setcarry(); +} + +static void sed() { + setdecimal(); +} + +static void sei() { + setinterrupt(); +} + +static void sta() { + putvalue(a); +} + +static void stx() { + putvalue(x); +} + +static void sty() { + putvalue(y); +} + +static void tax() { + x = a; + + zerocalc(x); + signcalc(x); +} + +static void tay() { + y = a; + + zerocalc(y); + signcalc(y); +} + +static void tsx() { + x = sp; + + zerocalc(x); + signcalc(x); +} + +static void txa() { + a = x; + + zerocalc(a); + signcalc(a); +} + +static void txs() { + sp = x; +} + +static void tya() { + a = y; + + zerocalc(a); + signcalc(a); +} + +//undocumented instructions +#ifdef UNDOCUMENTED + static void lax() { + lda(); + ldx(); + } + + static void sax() { + sta(); + stx(); + putvalue(a & x); + if (penaltyop && penaltyaddr) clockticks6502--; + } + + static void dcp() { + dec(); + cmp(); + if (penaltyop && penaltyaddr) clockticks6502--; + } + + static void isb() { + inc(); + sbc(); + if (penaltyop && penaltyaddr) clockticks6502--; + } + + static void slo() { + asl(); + ora(); + if (penaltyop && penaltyaddr) clockticks6502--; + } + + static void rla() { + rol(); + and(); + if (penaltyop && penaltyaddr) clockticks6502--; + } + + static void sre() { + lsr(); + eor(); + if (penaltyop && penaltyaddr) clockticks6502--; + } + + static void rra() { + ror(); + adc(); + if (penaltyop && penaltyaddr) clockticks6502--; + } +#else + #define lax nop + #define sax nop + #define dcp nop + #define isb nop + #define slo nop + #define rla nop + #define sre nop + #define rra nop +#endif + + +static void (*addrtable[256])() = { +/* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | */ +/* 0 */ imp, indx, imp, indx, zp, zp, zp, zp, imp, imm, acc, imm, abso, abso, abso, abso, /* 0 */ +/* 1 */ rel, indy, imp, indy, zpx, zpx, zpx, zpx, imp, absy, imp, absy, absx, absx, absx, absx, /* 1 */ +/* 2 */ abso, indx, imp, indx, zp, zp, zp, zp, imp, imm, acc, imm, abso, abso, abso, abso, /* 2 */ +/* 3 */ rel, indy, imp, indy, zpx, zpx, zpx, zpx, imp, absy, imp, absy, absx, absx, absx, absx, /* 3 */ +/* 4 */ imp, indx, imp, indx, zp, zp, zp, zp, imp, imm, acc, imm, abso, abso, abso, abso, /* 4 */ +/* 5 */ rel, indy, imp, indy, zpx, zpx, zpx, zpx, imp, absy, imp, absy, absx, absx, absx, absx, /* 5 */ +/* 6 */ imp, indx, imp, indx, zp, zp, zp, zp, imp, imm, acc, imm, ind, abso, abso, abso, /* 6 */ +/* 7 */ rel, indy, imp, indy, zpx, zpx, zpx, zpx, imp, absy, imp, absy, absx, absx, absx, absx, /* 7 */ +/* 8 */ imm, indx, imm, indx, zp, zp, zp, zp, imp, imm, imp, imm, abso, abso, abso, abso, /* 8 */ +/* 9 */ rel, indy, imp, indy, zpx, zpx, zpy, zpy, imp, absy, imp, absy, absx, absx, absy, absy, /* 9 */ +/* A */ imm, indx, imm, indx, zp, zp, zp, zp, imp, imm, imp, imm, abso, abso, abso, abso, /* A */ +/* B */ rel, indy, imp, indy, zpx, zpx, zpy, zpy, imp, absy, imp, absy, absx, absx, absy, absy, /* B */ +/* C */ imm, indx, imm, indx, zp, zp, zp, zp, imp, imm, imp, imm, abso, abso, abso, abso, /* C */ +/* D */ rel, indy, imp, indy, zpx, zpx, zpx, zpx, imp, absy, imp, absy, absx, absx, absx, absx, /* D */ +/* E */ imm, indx, imm, indx, zp, zp, zp, zp, imp, imm, imp, imm, abso, abso, abso, abso, /* E */ +/* F */ rel, indy, imp, indy, zpx, zpx, zpx, zpx, imp, absy, imp, absy, absx, absx, absx, absx /* F */ +}; + +static void (*optable[256])() = { +/* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | */ +/* 0 */ brk, ora, nop, slo, nop, ora, asl, slo, php, ora, asl, nop, nop, ora, asl, slo, /* 0 */ +/* 1 */ bpl, ora, nop, slo, nop, ora, asl, slo, clc, ora, nop, slo, nop, ora, asl, slo, /* 1 */ +/* 2 */ jsr, and, nop, rla, bit, and, rol, rla, plp, and, rol, nop, bit, and, rol, rla, /* 2 */ +/* 3 */ bmi, and, nop, rla, nop, and, rol, rla, sec, and, nop, rla, nop, and, rol, rla, /* 3 */ +/* 4 */ rti, eor, nop, sre, nop, eor, lsr, sre, pha, eor, lsr, nop, jmp, eor, lsr, sre, /* 4 */ +/* 5 */ bvc, eor, nop, sre, nop, eor, lsr, sre, cli, eor, nop, sre, nop, eor, lsr, sre, /* 5 */ +/* 6 */ rts, adc, nop, rra, nop, adc, ror, rra, pla, adc, ror, nop, jmp, adc, ror, rra, /* 6 */ +/* 7 */ bvs, adc, nop, rra, nop, adc, ror, rra, sei, adc, nop, rra, nop, adc, ror, rra, /* 7 */ +/* 8 */ nop, sta, nop, sax, sty, sta, stx, sax, dey, nop, txa, nop, sty, sta, stx, sax, /* 8 */ +/* 9 */ bcc, sta, nop, nop, sty, sta, stx, sax, tya, sta, txs, nop, nop, sta, nop, nop, /* 9 */ +/* A */ ldy, lda, ldx, lax, ldy, lda, ldx, lax, tay, lda, tax, nop, ldy, lda, ldx, lax, /* A */ +/* B */ bcs, lda, nop, lax, ldy, lda, ldx, lax, clv, lda, tsx, lax, ldy, lda, ldx, lax, /* B */ +/* C */ cpy, cmp, nop, dcp, cpy, cmp, dec, dcp, iny, cmp, dex, nop, cpy, cmp, dec, dcp, /* C */ +/* D */ bne, cmp, nop, dcp, nop, cmp, dec, dcp, cld, cmp, nop, dcp, nop, cmp, dec, dcp, /* D */ +/* E */ cpx, sbc, nop, isb, cpx, sbc, inc, isb, inx, sbc, nop, sbc, cpx, sbc, inc, isb, /* E */ +/* F */ beq, sbc, nop, isb, nop, sbc, inc, isb, sed, sbc, nop, isb, nop, sbc, inc, isb /* F */ +}; + +static const uint32_t ticktable[256] = { +/* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | */ +/* 0 */ 7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6, /* 0 */ +/* 1 */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 1 */ +/* 2 */ 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6, /* 2 */ +/* 3 */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 3 */ +/* 4 */ 6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6, /* 4 */ +/* 5 */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 5 */ +/* 6 */ 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6, /* 6 */ +/* 7 */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 7 */ +/* 8 */ 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* 8 */ +/* 9 */ 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5, /* 9 */ +/* A */ 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* A */ +/* B */ 2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, /* B */ +/* C */ 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* C */ +/* D */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* D */ +/* E */ 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* E */ +/* F */ 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7 /* F */ +}; + + +void nmi6502() { + push16(pc); + push8(status); + status |= FLAG_INTERRUPT; + pc = (uint16_t)read6502(0xFFFA) | ((uint16_t)read6502(0xFFFB) << 8); +} + +void irq6502() { + push16(pc); + push8(status); + status |= FLAG_INTERRUPT; + pc = (uint16_t)read6502(0xFFFE) | ((uint16_t)read6502(0xFFFF) << 8); +} + +uint8_t callexternal = 0; +void (*loopexternal)(); + +void exec6502(uint32_t tickcount) { + clockgoal6502 += tickcount; + + while (clockticks6502 < clockgoal6502) { + opcode = read6502(pc++); + status |= FLAG_CONSTANT; + + penaltyop = 0; + penaltyaddr = 0; + + (*addrtable[opcode])(); + (*optable[opcode])(); + clockticks6502 += ticktable[opcode]; + if (penaltyop && penaltyaddr) clockticks6502++; + + instructions++; + + if (callexternal) (*loopexternal)(); + } + +} + +void step6502() { + opcode = read6502(pc++); + status |= FLAG_CONSTANT; + + penaltyop = 0; + penaltyaddr = 0; + + (*addrtable[opcode])(); + (*optable[opcode])(); + clockticks6502 += ticktable[opcode]; + if (penaltyop && penaltyaddr) clockticks6502++; + clockgoal6502 = clockticks6502; + + instructions++; + + if (callexternal) (*loopexternal)(); +} + +void hookexternal(void *funcptr) { + if (funcptr != (void *)NULL) { + loopexternal = funcptr; + callexternal = 1; + } else callexternal = 0; +} diff --git a/src/emu/include/fake6502.h b/src/emu/include/fake6502.h new file mode 100644 index 0000000..a41f9c0 --- /dev/null +++ b/src/emu/include/fake6502.h @@ -0,0 +1,11 @@ +#include +#include + + +void push16(uint16_t pushval); + +uint16_t pull16(); + +void reset6502(); + +void step6502(); diff --git a/src/emu/main.c b/src/emu/main.c new file mode 100644 index 0000000..25d547d --- /dev/null +++ b/src/emu/main.c @@ -0,0 +1,115 @@ +#include +#include +#include +#include +#include +#include + +#include "fake6502.h" + +#define ROM "./test.o" + +uint8_t *ram; + +char charset[256] = { + '@', 'P', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '1', + 'A', 'Q', '"', '#', '$', '%', '&', '7', '(', ')', '*', '+', ',', '-', '.', '2', + 'B', 'R', '"', '#', '$', '%', '&', 'g', '(', ')', '*', '+', ',', '-', '.', '3', + 'C', 'S', '"', '#', '$', '%', '&', 'w', '(', ')', '*', '+', ',', '-', '.', '4', + 'D', 'T', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '5', + 'E', 'U', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '\0', + 'F', 'V', '"', '#', '$', '%', '&', 'G', '(', ')', '*', '+', ',', '-', '.', '7', + 'G', 'W', '"', '#', '$', '%', '&', 'W', '(', ')', '*', '+', ',', '-', '.', '8', + 'H', 'X', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '9', + 'I', 'Y', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', 'A', + 'J', 'Z', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', 'B', + 'K', '[', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', 'C', + 'L', '\\', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', 'D', + 'M', ']', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', 'E', + 'N', '^', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', 'F', + 'O', '_', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '0' + +}; + +int main( int argc, char **argv ) { + + int fd = 0; + + struct stat sb; + + int x = 0; + + printf( "6502 Emulation\n" ); + + ram = malloc( 65536 ); + + fd = open( ROM, O_RDONLY ); + + if( fd != -1 ) { + + stat( ROM, &sb ); + + read( fd, ram + (0x10000 - sb.st_size), sb.st_size); + + close( fd ); + + } + + reset6502(); + + + //for( x = 0; x < 10000; x++ ) { + while( 1 ) { + + step6502(); + + } + + return( 0x0 ); + +} + +uint8_t read6502(uint16_t address) { + + printf("read6502: 0x%X[0x%04X]\n", address, ram[address] ); +/* + if( address >= 0xC000 && address <= 0xCFFF) + printf("read6502: 0x%X\n", address ); + else if( address <= 0x00FF ) + printf("read6502: 0x%X[0x%04X]\n", address, ram[address] ); + */ + + return( ram[address] ); + +} + +void write6502(uint16_t address, uint8_t value) { + + printf("write6502: 0x%X[0x%X]\n", address, value ); + + if( address <= 0x1FF ) { + //printf("PWS"); + } else if( address >= 0x03D0 && address <= 0x03FF ) { + //printf("V"); + } else if( address >= 0x0400 && address <= 0x07FF ) { + //printf("TP1: [0x%04X]", value); + //printf("TP1: [0x%04X]", value); + if( charset[value] != '\0' ) + printf("%c\n", charset[value]); + //else + //printf("<%i>", value); + } else if( address >= 0x0800 && address <= 0x0BFF ) { + //printf("TP2: [0x%04X]", value); + //printf("TP1: [0x%04X]", value); + //printf("TP1: [0x%04X]", value); + //if( charset[value] != '\0' ) + // printf("%c", charset[value]); + //else + //printf("<%i>", value); + } else if( address >= 0x2000 ) { + // printf("OH: 0x%X", address); + } + + ram[address] = value; + +} diff --git a/src/test.s b/src/test.s new file mode 100644 index 0000000..d59f301 --- /dev/null +++ b/src/test.s @@ -0,0 +1,32 @@ + .org $0 + .org $8000 +reset: + cld + ldx #$FF + txs +print2: +print: + lda $4000,x + cmp $FF + beq loop + jsr print_char + sta $3000 + +loop: + jsr loop2 + sta $7000 + lda #$BE + jmp print2 + +loop2: + sta $5000 + rts + +print_char: + sta $6000 + rts + +.org $FFFA +.dc.w loop +.dc.w reset +.dc.w print_char diff --git a/tools/vasm/.DS_Store b/tools/vasm/.DS_Store new file mode 100644 index 0000000..8645cc9 --- /dev/null +++ b/tools/vasm/.DS_Store Binary files differ diff --git a/tools/vasm/vasm/.DS_Store b/tools/vasm/vasm/.DS_Store new file mode 100644 index 0000000..5774134 --- /dev/null +++ b/tools/vasm/vasm/.DS_Store Binary files differ diff --git a/tools/vasm/vasm/Makefile b/tools/vasm/vasm/Makefile new file mode 100644 index 0000000..f41be38 --- /dev/null +++ b/tools/vasm/vasm/Makefile @@ -0,0 +1,16 @@ +# Unix, using gcc + +CC = gcc +TARGET = +TARGETEXTENSION = + +CCOUT = -o +COPTS = -c -std=c99 -O2 -Wpedantic -DUNIX $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm + +RM = rm -f + +include make.rules diff --git a/tools/vasm/vasm/Makefile.68k b/tools/vasm/vasm/Makefile.68k new file mode 100644 index 0000000..78469d4 --- /dev/null +++ b/tools/vasm/vasm/Makefile.68k @@ -0,0 +1,16 @@ +# AmigaOS/68k + +TARGET = _os3 +TARGETEXTENSION = + +CC = vc +aos68k +CCOUT = -o= +COPTS = -c -c99 -cpu=68020 -DAMIGA $(OUTFMTS) -O1 + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lmieee + +RM = delete force quiet + +include make.rules diff --git a/tools/vasm/vasm/Makefile.Cygwin b/tools/vasm/vasm/Makefile.Cygwin new file mode 100644 index 0000000..7ebda94 --- /dev/null +++ b/tools/vasm/vasm/Makefile.Cygwin @@ -0,0 +1,16 @@ +# Windows compiled with gcc + +TARGET = _win32 +TARGETEXTENSION = .exe + +CC = gcc +CCOUT = -o +COPTS = -c -O2 -DUNIX $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm + +RM = rm -f + +include make.rules diff --git a/tools/vasm/vasm/Makefile.Haiku b/tools/vasm/vasm/Makefile.Haiku new file mode 100644 index 0000000..ea343bf --- /dev/null +++ b/tools/vasm/vasm/Makefile.Haiku @@ -0,0 +1,16 @@ +# Unix + +TARGET = +TARGETEXTENSION = + +CC = gcc +CCOUT = -o +COPTS = -c -O2 $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = + +RM = rm -f + +include make.rules diff --git a/tools/vasm/vasm/Makefile.MOS b/tools/vasm/vasm/Makefile.MOS new file mode 100644 index 0000000..f96e733 --- /dev/null +++ b/tools/vasm/vasm/Makefile.MOS @@ -0,0 +1,16 @@ +# MorphOS + +TARGET = _mos +TARGETEXTENSION = + +CC = vc +morphos +CCOUT = -o= +COPTS = -c -DAMIGA -O1 $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm + +RM = delete force quiet + +include make.rules diff --git a/tools/vasm/vasm/Makefile.MiNT b/tools/vasm/vasm/Makefile.MiNT new file mode 100644 index 0000000..0692e26 --- /dev/null +++ b/tools/vasm/vasm/Makefile.MiNT @@ -0,0 +1,16 @@ +# Atari TOS/MiNT + +TARGET = _MiNT +TARGETEXTENSION = + +CC = vc +mint +CCOUT = -o= +COPTS = -c -c99 -cpu=68020 -O1 $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm + +RM = rm -f + +include make.rules diff --git a/tools/vasm/vasm/Makefile.OS4 b/tools/vasm/vasm/Makefile.OS4 new file mode 100644 index 0000000..96d2f22 --- /dev/null +++ b/tools/vasm/vasm/Makefile.OS4 @@ -0,0 +1,16 @@ +# AmigaOS 4.x/PPC + +TARGET = _os4 +TARGETEXTENSION = + +CC = vc +aosppc +CCOUT = -o= +COPTS = -c -DAMIGA -D__USE_INLINE__ -O1 $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm + +RM = delete force quiet + +include make.rules diff --git a/tools/vasm/vasm/Makefile.PUp b/tools/vasm/vasm/Makefile.PUp new file mode 100644 index 0000000..fe1815a --- /dev/null +++ b/tools/vasm/vasm/Makefile.PUp @@ -0,0 +1,16 @@ +# PowerUp + +TARGET = _pup +TARGETEXTENSION = + +CC = vc +powerup +CCOUT = -o= +COPTS = -c -c99 -DAMIGA -O1 $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm -lamiga + +RM = delete force quiet + +include make.rules diff --git a/tools/vasm/vasm/Makefile.Pelles b/tools/vasm/vasm/Makefile.Pelles new file mode 100644 index 0000000..67c7804 --- /dev/null +++ b/tools/vasm/vasm/Makefile.Pelles @@ -0,0 +1,16 @@ +# Windows compiled with gcc + +TARGET = _win32 +TARGETEXTENSION = .exe + +CC = pocc +CCOUT = -Fo +COPTS = -W0 -Ze -c -O2 -D_WIN32 $(OUTFMTS) + +LD = cc +LDOUT = -Fe +LDFLAGS = + +RM = rm -f + +include make.rules diff --git a/tools/vasm/vasm/Makefile.TOS b/tools/vasm/vasm/Makefile.TOS new file mode 100644 index 0000000..58efbf2 --- /dev/null +++ b/tools/vasm/vasm/Makefile.TOS @@ -0,0 +1,16 @@ +# Atari TOS + +TARGET = _TOS +TARGETEXTENSION = .ttp + +CC = vc +tos +CCOUT = -o= +COPTS = -c -c99 -O1 -DATARI $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm + +RM = rm -f + +include make.rules diff --git a/tools/vasm/vasm/Makefile.WOS b/tools/vasm/vasm/Makefile.WOS new file mode 100644 index 0000000..a7ae849 --- /dev/null +++ b/tools/vasm/vasm/Makefile.WOS @@ -0,0 +1,16 @@ +# WarpOS + +TARGET = _wos +TARGETEXTENSION = + +CC = vc +warpos +CCOUT = -o= +COPTS = -c -c99 -DAMIGA -O1 $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm -lamiga + +RM = delete force quiet + +include make.rules diff --git a/tools/vasm/vasm/Makefile.Win32 b/tools/vasm/vasm/Makefile.Win32 new file mode 100644 index 0000000..25dbb1a --- /dev/null +++ b/tools/vasm/vasm/Makefile.Win32 @@ -0,0 +1,28 @@ +# Windows +# Tested with Visual Studio 2017: works fine under the Developer Command Prompt for VS2017 +# Tested with Visual Studio 2005 Express Edition: works fine +# Tested with Visual C++ Toolkit 2003: works fine, but needs an external make tool (nmake is not included) + +TARGET = _win32 +TARGETEXTENSION = .exe + +# If Visual Studio is unable to find when compiling vlink, try enabling the two +# lines below, and point them to where you have installed the Win32 Platform SDK. + +#WIN32_PLATFORMSDK_INCLUDE = "/IC:\Code\Win32 Platform SDK\Include" +#WIN32_PLATFORMSDK_LIB = "/LIBPATH:C:\Code\Win32 Platform SDK\Lib" + +CC = cl +CCOUT = /Fo +COPTS = $(OUTFMTS) /nologo /O2 /MT /c +COPTS = $(COPTS) /wd4996 # Disable warning regarding deprecated functions + # ("use strcpy_s instead of strcpy" etc) +COPTS = $(COPTS) $(WIN32_PLATFORMSDK_INCLUDE) + +LD = link +LDOUT = /OUT: +LDFLAGS = /NOLOGO $(WIN32_PLATFORMSDK_LIB) + +RM = rem + +include make.rules diff --git a/tools/vasm/vasm/Makefile.Win32FromLinux b/tools/vasm/vasm/Makefile.Win32FromLinux new file mode 100644 index 0000000..c0c7baf --- /dev/null +++ b/tools/vasm/vasm/Makefile.Win32FromLinux @@ -0,0 +1,20 @@ +# Windows compiled on a Linux machine with mingw + +TARGET = _win32 +TARGETEXTENSION = .exe + + +#CC = /usr/bin/i586-mingw32msvc-gcc +CC = /usr/bin/i686-w64-mingw32-gcc +CCOUT = -o +COPTS = -c -O2 $(OUTFMTS) + +LD = $(CC) +LDOUT = $(CCOUT) +LDFLAGS = -lm + +RM = rm -f + + + +include make.rules diff --git a/tools/vasm/vasm/atom.c b/tools/vasm/vasm/atom.c new file mode 100644 index 0000000..2c50fa8 --- /dev/null +++ b/tools/vasm/vasm/atom.c @@ -0,0 +1,716 @@ +/* atom.c - atomic objects from source */ +/* (c) in 2010-2020 by Volker Barthelmann and Frank Wille */ + +#include "vasm.h" + + +/* searches mnemonic list and tries to parse (via the cpu module) + the operands according to the mnemonic requirements; returns an + instruction or 0 */ +instruction *new_inst(char *inst,int len,int op_cnt,char **op,int *op_len) +{ +#if MAX_OPERANDS!=0 + operand ops[MAX_OPERANDS]; + int j,k,mnemo_opcnt,omitted,skipped,again; +#endif + int i,inst_found=0; + hashdata data; + instruction *new; + + new = mymalloc(sizeof(*new)); +#if HAVE_INSTRUCTION_EXTENSION + init_instruction_ext(&new->ext); +#endif +#if MAX_OPERANDS!=0 && CLEAR_OPERANDS_ON_START!=0 + /* reset operands to allow the cpu-backend to parse them only once */ + memset(ops,0,sizeof(ops)); +#endif + + if (find_namelen_nc(mnemohash,inst,len,&data)) { + i = data.idx; + + /* try all mnemonics with the same name until operands match */ + do { + inst_found = 1; + if (!MNEMONIC_VALID(i)) { + i++; + continue; /* try next */ + } + +#if MAX_OPERANDS!=0 + +#if CLEAR_OPERANDS_ON_MNEMO!=0 + /* reset all operands for every new mnemonic */ + memset(ops,0,sizeof(ops)); +#endif + +#if 0 /* @@@ was ALLOW_EMPTY_OPS */ + mnemo_opcnt = op_cnt= op_cnt) { + /* we may be missing mandatory operands */ + if (j == again) + j++; /* but probably not after PO_AGAIN */ + break; + } + + rc = parse_operand(op[k],op_len[k],&ops[j], + mnemonics[i].operand_type[j]); + + if (rc == PO_CORRUPT) { + /* operand has errors and will never match */ + myfree(new); + restore_symbols(); + return 0; + } + if (rc == PO_NOMATCH) + break; /* operand type does not match */ + if (rc == PO_NEXT) + continue; /* after PO_AGAIN: use this arg. on the next operand */ + + /* MATCH, proceed to next parsed operand */ + k++; + if (rc == PO_SKIP) { + /* but skip next operand type from table */ + j++; + skipped++; + } + else if (rc == PO_AGAIN) { + /* try to work on the same operand again with next arg. */ + again = j--; + } + } + } + + if ((!IGNORE_FIRST_EXTRA_OP || mnemo_opcnt>0) && + (jop[j] = mymalloc(sizeof(operand)); + *new->op[j] = ops[j]; + } + for(; jop[j] = NULL; + +#endif /* MAX_OPERANDS!=0 */ + + new->code = i; + return new; + } + while (icode; +#if MAX_QUALIFIERS!=0 + for (i=0; iqualifiers[i]; +#endif +#if MAX_OPERANDS!=0 + for (i=0; iop[i] != NULL) { + newip.op[i] = &newop[i]; + *newip.op[i] = *ip->op[i]; + } + else + newip.op[i] = NULL; + } +#endif +#if HAVE_INSTRUCTION_EXTENSION + memcpy(&newip.ext,&ip->ext,sizeof(instruction_ext)); +#endif + return &newip; +} + + +dblock *new_dblock(void) +{ + dblock *new = mymalloc(sizeof(*new)); + + new->size = 0; + new->data = 0; + new->relocs = 0; + return new; +} + + +sblock *new_sblock(expr *space,size_t size,expr *fill) +{ + sblock *sb = mymalloc(sizeof(sblock)); + + sb->space = 0; + sb->space_exp = space; + sb->size = size; + if (!(sb->fill_exp = fill)) + memset(sb->fill,space_init,MAXPADBYTES); + sb->relocs = 0; + sb->maxalignbytes = 0; + sb->flags = 0; + return sb; +} + + +static size_t space_size(sblock *sb,section *sec,taddr pc) +{ + utaddr space=0; + + if (eval_expr(sb->space_exp,(taddr *)&space,sec,pc) || !final_pass) + sb->space = space; + else + general_error(30); /* expression must be constant */ + + if (final_pass && sb->fill_exp) { + if (sb->size <= sizeof(taddr)) { + /* space is filled with an expression which may also need relocations */ + symbol *base=NULL; + taddr fill; + utaddr i; + + if (!eval_expr(sb->fill_exp,&fill,sec,pc)) { + if (find_base(sb->fill_exp,&base,sec,pc)==BASE_ILLEGAL) + general_error(38); /* illegal relocation */ + } + copy_cpu_taddr(sb->fill,fill,sb->size); + if (base && !sb->relocs) { + /* generate relocations */ + for (i=0; irelocs,base,fill,REL_ABS, + 0,sb->size<<3,sb->size*i); + } + } + else + general_error(30); /* expression must be constant */ + } + + return sb->size * space; +} + + +static size_t roffs_size(reloffs *roffs,section *sec,taddr pc) +{ + taddr offs; + + eval_expr(roffs->offset,&offs,sec,pc); + offs = sec->org + offs - pc; + return offs>0 ? offs : 0; +} + + +/* adds an atom to the specified section; if sec==0, the current + section is used */ +void add_atom(section *sec,atom *a) +{ + if (!sec) { + sec = default_section(); + if (!sec) { + general_error(3); + return; + } + } + + a->changes = 0; + a->src = cur_src; + a->line = cur_src!=NULL ? cur_src->line : 0; + + if (sec->last) { + atom *pa = sec->last; + + pa->next = a; + /* make sure that a label on the same line gets the same alignment */ + if (pa->type==LABEL && pa->line==a->line && + (a->type==INSTRUCTION || a->type==DATADEF || a->type==SPACE)) + pa->align = a->align; + } + else + sec->first = a; + a->next = 0; + sec->last = a; + + sec->pc = pcalign(a,sec->pc); + a->lastsize = atom_size(a,sec,sec->pc); + sec->pc += a->lastsize; + if (a->align > sec->align) + sec->align = a->align; + + if (listena) { + a->list = last_listing; + if (last_listing) { + if (!last_listing->atom) + last_listing->atom = a; + } + } + else + a->list = 0; +} + + +size_t atom_size(atom *p,section *sec,taddr pc) +{ + switch(p->type) { + case VASMDEBUG: + case LABEL: + case LINE: + case OPTS: + case PRINTTEXT: + case PRINTEXPR: + case RORG: + case RORGEND: + case ASSERT: + case NLIST: /* it has a size, but not in the current section */ + return 0; + case DATA: + return p->content.db->size; + case INSTRUCTION: + return p->content.inst->code>=0? + instruction_size(p->content.inst,sec,pc):0; + case SPACE: + return space_size(p->content.sb,sec,pc); + case DATADEF: + return (p->content.defb->bitsize+7)/8; + case ROFFS: + return roffs_size(p->content.roffs,sec,pc); + default: + ierror(0); + break; + } + return 0; +} + + +static void print_instruction(FILE *f,instruction *p) +{ + int i; + + printf("inst %d(%s) ",p->code,p->code>=0?mnemonics[p->code].name:"deleted"); +#if MAX_OPERANDS!=0 + for (i=0; iop[i]); +#endif +} + + +void print_atom(FILE *f,atom *p) +{ + size_t i; + rlist *rl; + + switch (p->type) { + case VASMDEBUG: + fprintf(f,"vasm debug directive"); + break; + case LABEL: + fprintf(f,"symbol: "); + print_symbol(f,p->content.label); + break; + case DATA: + fprintf(f,"data(%lu): ",(unsigned long)p->content.db->size); + for (i=0;icontent.db->size;i++) + fprintf(f,"%02x ",p->content.db->data[i]); + for (rl=p->content.db->relocs; rl; rl=rl->next) + print_reloc(f,rl->type,rl->reloc); + break; + case INSTRUCTION: + print_instruction(f,p->content.inst); + break; + case SPACE: + fprintf(f,"space(%lu,fill=", + (unsigned long)(p->content.sb->space*p->content.sb->size)); + for (i=0; icontent.sb->size; i++) + fprintf(f,"%02x%c",(unsigned char)p->content.sb->fill[i], + (i==p->content.sb->size-1)?')':' '); + for (rl=p->content.sb->relocs; rl; rl=rl->next) + print_reloc(f,rl->type,rl->reloc); + break; + case DATADEF: + fprintf(f,"datadef(%lu bits)",(unsigned long)p->content.defb->bitsize); + break; + case LINE: + fprintf(f,"line: %d of %s",p->content.srcline,getdebugname()); + break; +#if HAVE_CPU_OPTS + case OPTS: + print_cpu_opts(f,p->content.opts); + break; +#endif + case PRINTTEXT: + fprintf(f,"text: \"%s\"",p->content.ptext); + break; + case PRINTEXPR: + fprintf(f,"expr: "); + print_expr(f,p->content.pexpr->print_exp); + break; + case ROFFS: + fprintf(f,"roffs: offset "); + print_expr(f,p->content.roffs->offset); + fprintf(f,",fill="); + if (p->content.roffs->fillval) + print_expr(f,p->content.roffs->fillval); + else + fprintf(f,"none"); + break; + case RORG: + fprintf(f,"rorg: relocate to 0x%llx",ULLTADDR(*p->content.rorg)); + break; + case RORGEND: + fprintf(f,"rorg end"); + break; + case ASSERT: + fprintf(f,"assert: %s (message: %s)\n",p->content.assert->expstr, + p->content.assert->msgstr?p->content.assert->msgstr:emptystr); + break; + case NLIST: + fprintf(f,"nlist: %s (type %d, other %d, desc %d) with value ", + p->content.nlist->name!=NULL ? p->content.nlist->name : "", + p->content.nlist->type,p->content.nlist->other, + p->content.nlist->desc); + if (p->content.nlist->value != NULL) + print_expr(f,p->content.nlist->value); + else + fprintf(f,"NULL"); + break; + default: + ierror(0); + } +} + + +/* prints and formats an expression from a PRINTEXPR atom */ +void atom_printexpr(printexpr *pexp,section *sec,taddr pc) +{ + taddr t; + long long v; + int i; + + eval_expr(pexp->print_exp,&t,sec,pc); + if (pexp->type==PEXP_SDEC && (t&(1LL<<(pexp->size-1)))!=0) { + /* signed decimal */ + v = -1; + v &= ~(long long)MAKEMASK(pexp->size); + } + else + v = 0; + v |= t & MAKEMASK(pexp->size); + + switch (pexp->type) { + case PEXP_HEX: + printf("%llX",(unsigned long long)v); + break; + case PEXP_SDEC: + printf("%lld",v); + break; + case PEXP_UDEC: + printf("%llu",(unsigned long long)v); + break; + case PEXP_BIN: + for (i=pexp->size-1; i>=0; i--) + putchar((v & (1LL<size+7)>>3)-1; i>=0; i--) { + unsigned char c = (v>>(i*8))&0xff; + putchar(isprint(c) ? c : '.'); + } + break; + default: + ierror(0); + break; + } +} + + +atom *clone_atom(atom *a) +{ + atom *new = mymalloc(sizeof(atom)); + void *p; + + memcpy(new,a,sizeof(atom)); + + switch (a->type) { + /* INSTRUCTION and DATADEF have to be cloned as well, because they will + be deallocated and transformed into DATA during assemble() */ + case INSTRUCTION: + p = mymalloc(sizeof(instruction)); + memcpy(p,a->content.inst,sizeof(instruction)); + new->content.inst = p; + break; + case DATADEF: + p = mymalloc(sizeof(defblock)); + memcpy(p,a->content.defb,sizeof(defblock)); + new->content.defb = p; + break; + default: + break; + } + + new->next = 0; + new->src = NULL; + new->line = 0; + new->list = NULL; + return new; +} + + +atom *add_data_atom(section *sec,size_t sz,taddr alignment,taddr c) +{ + dblock *db = new_dblock(); + atom *a; + + db->size = sz; + db->data = mymalloc(sz); + if (sz > 1) + setval(BIGENDIAN,db->data,sz,c); + else + *(db->data) = c; + + a = new_data_atom(db,alignment); + add_atom(sec,a); + return a; +} + + +void add_leb128_atom(section *sec,taddr c) +{ + taddr b; + + do { + b = c & 0x7f; + if ((c >>= 7) != 0) + b |= 0x80; + add_data_atom(sec,1,1,b); + } while (c != 0); +} + + +void add_sleb128_atom(section *sec,taddr c) +{ + int done = 0; + taddr b; + + do { + b = c & 0x7f; + c >>= 7; /* assumes arithmetic shifts! */ + if ((c==0 && !(b&0x40)) || (c==-1 && (b&0x40))) + done = 1; + else + b |= 0x80; + add_data_atom(sec,1,1,b); + } while (!done); +} + + +atom *add_bytes_atom(section *sec,void *p,size_t sz) +{ + dblock *db = new_dblock(); + atom *a; + + db->size = sz; + db->data = mymalloc(sz); + memcpy(db->data,p,sz); + a = new_data_atom(db,1); + add_atom(sec,a); + return a; +} + + +atom *new_atom(int type,taddr align) +{ + atom *new = mymalloc(sizeof(*new)); + + new->next = NULL; + new->type = type; + new->align = align; + return new; +} + + +atom *new_inst_atom(instruction *p) +{ + atom *new = new_atom(INSTRUCTION,inst_alignment); + + new->content.inst = p; + return new; +} + + +atom *new_data_atom(dblock *p,taddr align) +{ + atom *new = new_atom(DATA,align); + + new->content.db = p; + return new; +} + + +atom *new_label_atom(symbol *p) +{ + atom *new = new_atom(LABEL,1); + + new->content.label = p; + return new; +} + + +atom *new_space_atom(expr *space,size_t size,expr *fill) +{ + atom *new = new_atom(SPACE,1); + + if (size<1) + ierror(0); /* usually an error in syntax-module */ + new->content.sb = new_sblock(space,size,fill); + return new; +} + + +atom *new_datadef_atom(size_t bitsize,operand *op) +{ + atom *new = new_atom(DATADEF,DATA_ALIGN(bitsize)); + + new->content.defb = mymalloc(sizeof(*new->content.defb)); + new->content.defb->bitsize = bitsize; + new->content.defb->op = op; + return new; +} + + +atom *new_srcline_atom(int line) +{ + atom *new = new_atom(LINE,1); + + new->content.srcline = line; + return new; +} + + +atom *new_opts_atom(void *o) +{ + atom *new = new_atom(OPTS,1); + + new->content.opts = o; + return new; +} + + +atom *new_text_atom(char *txt) +{ + atom *new = new_atom(PRINTTEXT,1); + + new->content.ptext = txt ? txt : "\n"; + return new; +} + + +atom *new_expr_atom(expr *exp,int type,int size) +{ + atom *new = new_atom(PRINTEXPR,1); + + new->content.pexpr = mymalloc(sizeof(*new->content.pexpr)); + if (exp==NULL || typePEXP_ASC || size<1 + || size>sizeof(long long)*8) + ierror(0); + new->content.pexpr->print_exp = exp; + new->content.pexpr->type = type; + new->content.pexpr->size = size; + return new; +} + + +atom *new_roffs_atom(expr *offs,expr *fill) +{ + atom *new = new_atom(ROFFS,1); + + new->content.roffs = mymalloc(sizeof(*new->content.roffs)); + new->content.roffs->offset = offs; + new->content.roffs->fillval = fill; + return new; +} + + +atom *new_rorg_atom(taddr raddr) +{ + atom *new = new_atom(RORG,1); + taddr *newrorg = mymalloc(sizeof(taddr)); + + *newrorg = raddr; + new->content.rorg = newrorg; + return new; +} + + +atom *new_rorgend_atom(void) +{ + return new_atom(RORGEND,1); +} + + +atom *new_assert_atom(expr *aexp,char *exp,char *msg) +{ + atom *new = new_atom(ASSERT,1); + + new->content.assert = mymalloc(sizeof(*new->content.assert)); + new->content.assert->assert_exp = aexp; + new->content.assert->expstr = exp; + new->content.assert->msgstr = msg; + return new; +} + + +atom *new_nlist_atom(char *name,int type,int other,int desc,expr *value) +{ + atom *new = new_atom(NLIST,1); + + new->content.nlist = mymalloc(sizeof(*new->content.nlist)); + new->content.nlist->name = name; + new->content.nlist->type = type; + new->content.nlist->other = other; + new->content.nlist->desc = desc; + new->content.nlist->value = value; + return new; +} diff --git a/tools/vasm/vasm/atom.h b/tools/vasm/vasm/atom.h new file mode 100644 index 0000000..bfa0643 --- /dev/null +++ b/tools/vasm/vasm/atom.h @@ -0,0 +1,157 @@ +/* atom.h - atomic objects from source */ +/* (c) in 2010-2020 by Volker Barthelmann and Frank Wille */ + +#ifndef ATOM_H +#define ATOM_H + +/* types of atoms */ +#define VASMDEBUG 0 +#define LABEL 1 +#define DATA 2 +#define INSTRUCTION 3 +#define SPACE 4 +#define DATADEF 5 +#define LINE 6 +#define OPTS 7 +#define PRINTTEXT 8 +#define PRINTEXPR 9 +#define ROFFS 10 +#define RORG 11 +#define RORGEND 12 +#define ASSERT 13 +#define NLIST 14 + +/* a machine instruction */ +typedef struct instruction { + int code; +#if MAX_QUALIFIERS!=0 + char *qualifiers[MAX_QUALIFIERS]; +#endif +#if MAX_OPERANDS!=0 + operand *op[MAX_OPERANDS]; +#endif +#if HAVE_INSTRUCTION_EXTENSION + instruction_ext ext; +#endif +} instruction; + +typedef struct defblock { + size_t bitsize; + operand *op; +} defblock; + +struct dblock { + size_t size; + unsigned char *data; + rlist *relocs; +}; + +struct sblock { + size_t space; + expr *space_exp; /* copied to space, when evaluated as constant */ + size_t size; + uint8_t fill[MAXPADBYTES]; + expr *fill_exp; /* copied to fill, when evaluated - may be NULL */ + rlist *relocs; + taddr maxalignbytes; + uint32_t flags; +}; +/* Space is completely uninitialized - may be used as hint by output modules */ +#define SPC_UNINITIALIZED 1 + +typedef struct reloffs { + expr *offset; + expr *fillval; +} reloffs; + +typedef struct printexpr { + expr *print_exp; + short type; /* hex, signed, unsigned */ + short size; /* precision in bits */ +} printexpr; +#define PEXP_HEX 0 +#define PEXP_SDEC 1 +#define PEXP_UDEC 2 +#define PEXP_BIN 3 +#define PEXP_ASC 4 + +typedef struct assertion { + expr *assert_exp; + char *expstr; + char *msgstr; +} assertion; + +typedef struct aoutnlist { + char *name; + int type; + int other; + int desc; + expr *value; +} aoutnlist; + +/* an atomic element of data */ +typedef struct atom { + struct atom *next; + int type; + taddr align; + size_t lastsize; + unsigned changes; + source *src; + int line; + listing *list; + union { + instruction *inst; + dblock *db; + symbol *label; + sblock *sb; + defblock *defb; + void *opts; + int srcline; + char *ptext; + printexpr *pexpr; + reloffs *roffs; + taddr *rorg; + assertion *assert; + aoutnlist *nlist; + } content; +} atom; + +#define MAXSIZECHANGES 5 /* warning, when atom changed size so many times */ + +enum { + PO_CORRUPT=-1,PO_NOMATCH=0,PO_MATCH,PO_SKIP,PO_AGAIN,PO_NEXT +}; +instruction *new_inst(char *inst,int len,int op_cnt,char **op,int *op_len); +instruction *copy_inst(instruction *); +dblock *new_dblock(); +sblock *new_sblock(expr *,size_t,expr *); + +atom *new_atom(int,taddr); +void add_atom(section *,atom *); +size_t atom_size(atom *,section *,taddr); +void print_atom(FILE *,atom *); +void atom_printexpr(printexpr *,section *,taddr); +atom *clone_atom(atom *); + +atom *add_data_atom(section *,size_t,taddr,taddr); +void add_leb128_atom(section *,taddr); +void add_sleb128_atom(section *,taddr); +atom *add_bytes_atom(section *,void *,size_t); +#define add_string_atom(s,p) add_bytes_atom(s,p,strlen(p)+1) + +atom *new_inst_atom(instruction *); +atom *new_data_atom(dblock *,taddr); +atom *new_label_atom(symbol *); +atom *new_space_atom(expr *,size_t,expr *); +atom *new_datadef_atom(size_t,operand *); +atom *new_srcline_atom(int); +atom *new_opts_atom(void *); +atom *new_text_atom(char *); +atom *new_expr_atom(expr *,int,int); +atom *new_roffs_atom(expr *,expr *); +atom *new_rorg_atom(taddr); +atom *new_rorgend_atom(void); +atom *new_assert_atom(expr *,char *,char *); +atom *new_nlist_atom(char *,int,int,int,expr *); + +#endif diff --git a/tools/vasm/vasm/cond.c b/tools/vasm/vasm/cond.c new file mode 100644 index 0000000..dd46320 --- /dev/null +++ b/tools/vasm/vasm/cond.c @@ -0,0 +1,85 @@ +/* cond.c - conditional assembly support routines */ +/* (c) in 2015 by Frank Wille */ + +#include "vasm.h" + +int clev; /* conditional level */ + +static char cond[MAXCONDLEV+1]; +static char *condsrc[MAXCONDLEV+1]; +static int condline[MAXCONDLEV+1]; +static int ifnesting; + + +/* initialize conditional assembly */ +void cond_init(void) +{ + cond[0] = 1; + clev = ifnesting = 0; +} + + +/* return true, when current level allows assembling */ +int cond_state(void) +{ + return cond[clev]; +} + + +/* ensures that all conditional block are closed at the end of the source */ +void cond_check(void) +{ + if (clev > 0) + general_error(66,condsrc[clev],condline[clev]); /* "endc/endif missing */ +} + + +/* establish a new level of conditional assembly */ +void cond_if(char flag) +{ + if (++clev >= MAXCONDLEV) + general_error(65,clev); /* nesting depth exceeded */ + + cond[clev] = flag; + condsrc[clev] = cur_src->name; + condline[clev] = cur_src->line; +} + + +/* handle skipped if statement */ +void cond_skipif(void) +{ + ifnesting++; +} + + +/* handle else statement after skipped if-branch */ +void cond_else(void) +{ + if (ifnesting == 0) + cond[clev] = 1; +} + + +/* handle else statement after assembled if-branch */ +void cond_skipelse(void) +{ + if (clev > 0) + cond[clev] = 0; + else + general_error(63); /* else without if */ +} + + +/* handle end-if statement */ +void cond_endif(void) +{ + if (ifnesting == 0) { + if (clev > 0) + clev--; + else + general_error(64); /* unexpected endif without if */ + } + else /* the whole conditional block was ignored */ + ifnesting--; +} diff --git a/tools/vasm/vasm/cond.h b/tools/vasm/vasm/cond.h new file mode 100644 index 0000000..90a155c --- /dev/null +++ b/tools/vasm/vasm/cond.h @@ -0,0 +1,25 @@ +/* cond.h - conditional assembly support routines */ +/* (c) in 2015 by Frank Wille */ + +#ifndef COND_H +#define COND_H + +/* defines */ +#ifndef MAXCONDLEV +#define MAXCONDLEV 63 +#endif + +/* global variables */ +extern int clev; + +/* functions */ +void cond_init(void); +int cond_state(void); +void cond_check(void); +void cond_if(char); +void cond_skipif(void); +void cond_else(void); +void cond_skipelse(void); +void cond_endif(void); + +#endif /* COND_H */ diff --git a/tools/vasm/vasm/cpus/6502/cpu.c b/tools/vasm/vasm/cpus/6502/cpu.c new file mode 100644 index 0000000..83e53cb --- /dev/null +++ b/tools/vasm/vasm/cpus/6502/cpu.c @@ -0,0 +1,756 @@ +/* +** cpu.c 650x/65C02/6510/6280/45gs02 cpu-description file +** (c) in 2002,2006,2008-2012,2014-2021 by Frank Wille +*/ + +#include "vasm.h" + +mnemonic mnemonics[] = { +#include "opcodes.h" +}; + +int mnemonic_cnt=sizeof(mnemonics)/sizeof(mnemonics[0]); + +char *cpu_copyright="vasm 6502 cpu backend 0.9c (c) 2002,2006,2008-2012,2014-2021 Frank Wille"; +char *cpuname = "6502"; +int bitsperbyte = 8; +int bytespertaddr = 2; + +uint16_t cpu_type = M6502; +static int branchopt = 0; +static int modifier; /* set by find_base() */ +static utaddr dpage = 0; /* default zero/direct page - set with SETDP */ +static char lo_c = '<'; +static char hi_c = '>'; +static int OC_JMPABS,OC_BRA; + + +int ext_unary_type(char *s) +{ + return *s==lo_c ? LOBYTE : HIBYTE; +} + + +int ext_unary_eval(int type,taddr val,taddr *result,int cnst) +{ + switch (type) { + case LOBYTE: + *result = cnst ? (val & 0xff) : val; + return 1; + case HIBYTE: + *result = cnst ? ((val >> 8) & 0xff) : val; + return 1; + default: + break; + } + return 0; /* unknown type */ +} + + +int ext_find_base(symbol **base,expr *p,section *sec,taddr pc) +{ + /* addr/256 equals >addr, addr%256 and addr&255 equal type==DIV || p->type==MOD) { + if (p->right->type==NUM && p->right->c.val==256) + p->type = p->type == DIV ? HIBYTE : LOBYTE; + } + else if (p->type==BAND && p->right->type==NUM && p->right->c.val==255) + p->type = LOBYTE; + + if (p->type==LOBYTE || p->type==HIBYTE) { + modifier = p->type; + return find_base(p->left,base,sec,pc); + } + return BASE_ILLEGAL; +} + + +void init_instruction_ext(instruction_ext *ext) +{ + ext->dp = dpage; /* current DP defined by SETDP directive */ +} + + +int parse_operand(char *p,int len,operand *op,int required) +{ + char *start = p; + int indir = 0; + + op->flags = 0; + + p = skip(p); + if (len>0 && required!=DATAOP && check_indir(p,start+len)) { + indir = 1; + p = skip(p+1); + } + + switch (required) { + case IMMED: + if (*p++ != '#') + return PO_NOMATCH; + p = skip(p); + break; + case INDIR: + case INDIRX: + case INDX: + case INDY: + case INDZ: + case INDZ32: + case IND32: + case DPINDIR: + if (!indir) + return PO_NOMATCH; + break; + case WBIT: + if (*p == '#') /* # is optional */ + p = skip(++p); + if (indir) + return PO_NOMATCH; + break; + case ABS: + if (*p==hi_c || *p=='!' || *p=='|') { + p = skip(++p); + op->flags |= OF_HI; /* force absolute addressing mode */ + } + else if (*p == lo_c) { + p = skip(++p); + op->flags |= OF_LO; /* force zero/direct page addressing mode */ + } + default: + if (indir) + return PO_NOMATCH; + break; + } + + if (required < ACCU) + op->value = parse_expr(&p); + else + op->value = NULL; + + switch (required) { + case INDX: + case INDIRX: + if (*p++ == ',') { + p = skip(p); + if (toupper((unsigned char)*p++) != 'X') + return PO_NOMATCH; + } + else + return PO_NOMATCH; + break; + case ACCU: + if (len != 0) { + if (len!=1 || toupper((unsigned char)*p++) != 'A') + return PO_NOMATCH; + } + break; + case DUMX: + if (toupper((unsigned char)*p++) != 'X') + return PO_NOMATCH; + break; + case DUMY: + if (toupper((unsigned char)*p++) != 'Y') + return PO_NOMATCH; + break; + case DUMZ: + if (toupper((unsigned char)*p++) != 'Z') + return PO_NOMATCH; + break; + } + + if (required>=FIRST_INDIR && required<=LAST_INDIR) { + p = skip(p); + if (*p++ != ')') { + cpu_error(2); /* missing closing parenthesis */ + return PO_CORRUPT; + } + } + + if (required==INDZ32 || required==IND32 ) { + p = skip(p); + if (*p++ != ']') { + cpu_error(13); /* missing closing square bracket */ + return PO_CORRUPT; + } + } + + p = skip(p); + if (p-start < len) + cpu_error(1); /* trailing garbage in operand */ + op->type = required; + return PO_MATCH; +} + + +char *parse_cpu_special(char *start) +{ + const char zeroname[] = ".zero"; + char *name=start,*s=start; + + if (dotdirs && *s=='.') { + s++; + name++; + } + if (ISIDSTART(*s)) { + s++; + while (ISIDCHAR(*s)) + s++; + + if (s-name==5 && !strnicmp(name,"setdp",5)) { + s = skip(s); + dpage = (utaddr)parse_constexpr(&s); + eol(s); + return skip_line(s); + } + else if (s-name==5 && !strnicmp(name,"zpage",5)) { + char *name; + int done; + do{ + s = skip(s); + if (name = parse_identifier(&s)) { + symbol *sym = new_import(name); + myfree(name); + sym->flags |= ZPAGESYM; + } + else + cpu_error(8); /* identifier expected */ + s = skip(s); + if(*s==','){ + s++; + done = 0; + }else + done = 1; + }while(!done); + eol(s); + return skip_line(s); + } + else if (s-name==4 && !strnicmp(name,zeroname+1,4)) { /* zero */ + section *sec = new_section(dotdirs ? + (char *)zeroname : (char *)zeroname+1, + "aurw",1); + sec->flags |= NEAR_ADDRESSING; /* meaning of zero-page addressing */ + set_section(sec); + eol(s); + return skip_line(s); + } + } + return start; +} + + +int parse_cpu_label(char *labname,char **start) +/* parse cpu-specific directives following a label field, + return zero when no valid directive was recognized */ +{ + char *dir=*start,*s=*start; + + if (ISIDSTART(*s)) { + s++; + while (ISIDCHAR(*s)) + s++; + if (dotdirs && *dir=='.') + dir++; + + if (s-dir==3 && !strnicmp(dir,"ezp",3)) { + /* label EZP */ + symbol *sym; + + s = skip(s); + sym = new_equate(labname,parse_expr_tmplab(&s)); + sym->flags |= ZPAGESYM; + eol(s); + *start = skip_line(s); + return 1; + } + } + return 0; +} + + +static void optimize_instruction(instruction *ip,section *sec, + taddr pc,int final) +{ + mnemonic *mnemo = &mnemonics[ip->code]; + symbol *base; + operand *op; + taddr val; + int i; + + for (i=0; iop[i]) != NULL) { + if (op->value != NULL) { + if (eval_expr(op->value,&val,sec,pc)) + base = NULL; /* val is constant/absolute */ + else + find_base(op->value,&base,sec,pc); /* get base-symbol */ + + if (IS_ABS(op->type)) { + if (!mnemo->ext.zp_opcode && (op->flags & OF_LO)) + cpu_error(10); /* zp/dp not available */ + if (mnemo->ext.zp_opcode && ((op->flags & OF_LO) || + (!(op->flags & OF_HI) && + ((base==NULL && ((val>=0 && val<=0xff) || + ((utaddr)val>=ip->ext.dp && + (utaddr)val<=ip->ext.dp+0xff))) || + (base!=NULL && ((base->flags & ZPAGESYM) || (LOCREF(base) && + (base->sec->flags & NEAR_ADDRESSING))))) + ))) { + /* we can use a zero page addressing mode for absolute 16-bit */ + op->type += ZPAGE-ABS; + } + } + else if (op->type==REL8 && (base==NULL || !is_pc_reloc(base,sec))) { + taddr bd = val - (pc + 2); + + if ((bd<-0x80 || bd>0x7f) && branchopt) { + if (mnemo->ext.opcode==0x80 || mnemo->ext.opcode==0x12) { + /* translate out of range 65C02/DTV BRA to JMP */ + ip->code = OC_JMPABS; + op->type = ABS; + } + else /* branch dest. out of range: use a B!cc/JMP combination */ + op->type = RELJMP; + } + } + else if (ip->code==OC_JMPABS && (cpu_type&(DTV|M65C02))!=0 && + branchopt && !(base!=NULL && is_pc_reloc(base,sec))) { + taddr bd = val - (pc + 2); + + if (bd>=-128 && bd<=128) { + /* JMP may be optimized to a BRA */ + ip->code = OC_BRA; + op->type = REL8; + } + } + } + } + } +} + + +static size_t get_inst_size(instruction *ip) +{ + size_t sz = 1; + int i; + + for (i=0; iop[i] != NULL) { + switch (ip->op[i]->type) { + case REL8: + case INDX: + case INDY: + case INDZ: + case IND32: + case INDZ32: + case DPINDIR: + case IMMED: + case ZPAGE: + case ZPAGEX: + case ZPAGEY: + case ZPAGEZ: + sz += 1; + break; + case REL16: + case ABS: + case ABSX: + case ABSY: + case ABSZ: + case INDIR: + case INDIRX: + sz += 2; + break; + case RELJMP: + sz += 4; + break; + } + } + } + return sz; +} + + +size_t instruction_size(instruction *ip,section *sec,taddr pc) +{ + instruction *ipcopy; + int i; + + for (i=0; iop[i]!=NULL && ip->op[i+1]!=NULL) { + if (ip->op[i]->type == ABS) { + if (ip->op[i+1]->type == DUMX) { + ip->op[i]->type = ABSX; + break; + } + else if (ip->op[i+1]->type == DUMY) { + ip->op[i]->type = ABSY; + break; + } + else if (ip->op[i+1]->type == DUMZ) { + ip->op[i]->type = ABSZ; + break; + } + } + else if (ip->op[i]->type == INDIR) { + if (ip->op[i+1]->type == DUMY) { + ip->op[i]->type = INDY; + break; + } + else if (ip->op[i+1]->type == DUMZ) { + ip->op[i]->type = INDZ; + break; + } + } + } + } + + if (++i < MAX_OPERANDS) { + /* we removed a DUMX/DUMY/DUMZ operand at the end */ + myfree(ip->op[i]); + ip->op[i] = NULL; + } + + ipcopy = copy_inst(ip); + optimize_instruction(ipcopy,sec,pc,0); + return get_inst_size(ipcopy); +} + + +static void rangecheck(instruction *ip,symbol *base,taddr val,operand *op) +{ + switch (op->type) { + case ZPAGE: + case ZPAGEX: + case ZPAGEY: + case ZPAGEZ: + case INDX: + case INDY: + case INDZ: + case IND32: + case INDZ32: + case DPINDIR: + if (base!=NULL && base->type==IMPORT) { + if (val<-0x80 || val>0x7f) + cpu_error(12,8); /* addend doesn't fit into 8 bits */ + } + else { + if ((val<0 || val>0xff) && + ((utaddr)valext.dp || (utaddr)val>ip->ext.dp+0xff)) + /*cpu_error(11)*/; /* operand not in zero/direct page */ + } + break; + case IMMED: + if (val<-0x80 || val>0xff) + cpu_error(5,8); /* operand doesn't fit into 8 bits */ + break; + case REL8: + if (val<-0x80 || val>0x7f) + cpu_error(6); /* branch destination out of range */ + break; + case WBIT: + if (val<0 || val>7) + cpu_error(7); /* illegal bit number */ + break; + } +} + + +dblock *eval_instruction(instruction *ip,section *sec,taddr pc) +{ + dblock *db = new_dblock(); + unsigned char *d,oc; + int optype,i; + taddr val; + + optimize_instruction(ip,sec,pc,1); /* really execute optimizations now */ + + db->size = get_inst_size(ip); + d = db->data = mymalloc(db->size); + + /* write opcode */ + oc = mnemonics[ip->code].ext.opcode; + for (i=0; iop[i]!=NULL ? ip->op[i]->type : IMPLIED; + switch (optype) { + case ZPAGE: + case ZPAGEX: + case ZPAGEY: + case ZPAGEZ: + oc = mnemonics[ip->code].ext.zp_opcode; + break; + case RELJMP: + oc ^= 0x20; /* B!cc branch */ + break; + } + } + *d++ = oc; + + for (i=0; iop[i] != NULL){ + operand *op = ip->op[i]; + int offs = d - db->data; + symbol *base; + + optype = (int)op->type; + if (op->value != NULL) { + if (!eval_expr(op->value,&val,sec,pc)) { + taddr add = 0; + int btype; + + modifier = 0; + btype = find_base(op->value,&base,sec,pc); + if (btype==BASE_PCREL && optype==IMMED) + op->flags |= OF_PC; /* immediate value with pc-rel. relocation */ + + if (optype==WBIT || btype==BASE_ILLEGAL || + (btype==BASE_PCREL && !(op->flags & OF_PC))) { + general_error(38); /* illegal relocation */ + } + else { + if (modifier) { + if (op->flags & (OF_LO|OF_HI)) + cpu_error(9); /* multiple hi/lo modifiers */ + switch (modifier) { + case LOBYTE: op->flags |= OF_LO; break; + case HIBYTE: op->flags |= OF_HI; break; + } + } + + if ((optype==REL8 || optype==REL16) && !is_pc_reloc(base,sec)) { + /* relative branch requires no relocation */ + val = val - (pc + offs + 1); + } + else { + int type = REL_ABS; + int size; + rlist *rl; + + switch (optype) { + case ABS: + case ABSX: + case ABSY: + case ABSZ: + op->flags &= ~(OF_LO|OF_HI); + case INDIR: + case INDIRX: + size = 16; + break; + case ZPAGE: + case ZPAGEX: + case ZPAGEY: + case ZPAGEZ: + op->flags &= ~(OF_LO|OF_HI); + case INDX: + case INDY: + case INDZ: + case INDZ32: + case IND32: + case DPINDIR: + size = 8; + break; + case IMMED: + if (op->flags & OF_PC) { + type = REL_PC; + val += offs; + } + size = 8; + break; + case RELJMP: + size = 16; + offs = 3; + break; + case REL8: + type = REL_PC; + size = 8; + add = -1; /* 6502 addend correction */ + break; + case REL16: + type = REL_PC; + size = 16; + add = -1; /* 6502 addend correction */ + break; + default: + ierror(0); + break; + } + + rl = add_extnreloc(&db->relocs,base,val+add,type,0,size,offs); + if (op->flags & OF_LO) { + if (rl) + ((nreloc *)rl->reloc)->mask = 0xff; + val = val & 0xff; + } + else if (op->flags & OF_HI) { + if (rl) + ((nreloc *)rl->reloc)->mask = 0xff00; + val = (val >> 8) & 0xff; + } + } + } + } + else { + /* constant/absolute value */ + base = NULL; + if (optype==REL8 || optype==REL16) + val = val - (pc + offs + 1); + } + + rangecheck(ip,base,val,op); + + /* write operand data */ + switch (optype) { + case ABSX: + case ABSY: + case ABSZ: + if (!*(db->data)) /* STX/STY allow only ZeroPage addressing mode */ + cpu_error(5,8); /* operand doesn't fit into 8 bits */ + case ABS: + case INDIR: + case INDIRX: + case REL16: + *d++ = val & 0xff; + *d++ = (val>>8) & 0xff; + break; + case DPINDIR: + case INDX: + case INDY: + case INDZ: + case INDZ32: + case IND32: + case ZPAGE: + case ZPAGEX: + case ZPAGEY: + if ((utaddr)val>=ip->ext.dp && (utaddr)val<=ip->ext.dp+0xff) + val -= ip->ext.dp; + case IMMED: + case REL8: + *d++ = val & 0xff; + break; + case RELJMP: + if (d - db->data > 1) + ierror(0); + *d++ = 3; /* B!cc *+3 */ + *d++ = 0x4c; /* JMP */ + *d++ = val & 0xff; + *d++ = (val>>8) & 0xff; + break; + case WBIT: + *(db->data) |= (val&7) << 4; /* set bit number in opcode */ + break; + } + } + } + } + + return db; +} + + +dblock *eval_data(operand *op,size_t bitsize,section *sec,taddr pc) +{ + dblock *db = new_dblock(); + taddr val; + + if (bitsize!=8 && bitsize!=16 && bitsize!=32) + cpu_error(3,bitsize); /* data size not supported */ + + db->size = bitsize >> 3; + db->data = mymalloc(db->size); + if (!eval_expr(op->value,&val,sec,pc)) { + symbol *base; + int btype; + rlist *rl; + + modifier = 0; + btype = find_base(op->value,&base,sec,pc); + if (btype==BASE_OK || (btype==BASE_PCREL && modifier==0)) { + rl = add_extnreloc(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS,0,bitsize,0); + switch (modifier) { + case LOBYTE: + if (rl) + ((nreloc *)rl->reloc)->mask = 0xff; + val = val & 0xff; + break; + case HIBYTE: + if (rl) + ((nreloc *)rl->reloc)->mask = 0xff00; + val = (val >> 8) & 0xff; + break; + } + } + else if (btype != BASE_NONE) + general_error(38); /* illegal relocation */ + } + if (bitsize < 16) { + if (val<-0x80 || val>0xff) + cpu_error(5,8); /* operand doesn't fit into 8-bits */ + } else if (bitsize < 32) { + if (val<-0x8000 || val>0xffff) + cpu_error(5,16); /* operand doesn't fit into 16-bits */ + } + + setval(0,db->data,db->size,val); + return db; +} + + +operand *new_operand() +{ + operand *new = mymalloc(sizeof(*new)); + new->type = -1; + new->flags = 0; + return new; +} + + +int cpu_available(int idx) +{ + return (mnemonics[idx].ext.available & cpu_type) != 0; +} + + +int init_cpu() +{ + int i; + + for (i=0; i */ + lo_c = '>'; + hi_c = '<'; + } + else if (!strcmp(p,"-opt-branch")) + branchopt = 1; + else if (!strcmp(p,"-illegal")) + cpu_type |= ILL; + else if (!strcmp(p,"-dtv")) + cpu_type |= DTV; + else if (!strcmp(p,"-c02")) + cpu_type = M6502 | M65C02; + else if (!strcmp(p,"-wdc02")) + cpu_type = M6502 | M65C02 | WDC02 | WDC02ALL; + else if (!strcmp(p,"-ce02")) + cpu_type = M6502 | M65C02 | WDC02 | WDC02ALL | CSGCE02; + else if (!strcmp(p,"-6280")) + cpu_type = M6502 | M65C02 | WDC02 | WDC02ALL | HU6280; + else if (!strcmp(p,"-mega65")) + cpu_type = M6502 | M65C02 | WDC02 | M45GS02; + else + return 0; + + return 1; +} diff --git a/tools/vasm/vasm/cpus/6502/cpu.h b/tools/vasm/vasm/cpus/6502/cpu.h new file mode 100644 index 0000000..c89407e --- /dev/null +++ b/tools/vasm/vasm/cpus/6502/cpu.h @@ -0,0 +1,131 @@ +/* +** cpu.h 650x/65C02/6510/6280/45gs02 cpu-description header-file +** (c) in 2002,2008,2009,2014,2018,2020,2021 by Frank Wille +*/ + +#define BIGENDIAN 0 +#define LITTLEENDIAN 1 +#define VASM_CPU_650X 1 + +/* maximum number of operands for one mnemonic */ +#define MAX_OPERANDS 3 + +/* maximum number of mnemonic-qualifiers per mnemonic */ +#define MAX_QUALIFIERS 0 + +/* data type to represent a target-address */ +typedef int32_t taddr; +typedef uint32_t utaddr; + +/* instruction extension */ +#define HAVE_INSTRUCTION_EXTENSION 1 +typedef struct { + utaddr dp; /* remember current direct page per instruction */ +} instruction_ext; + +/* minimum instruction alignment */ +#define INST_ALIGN 1 + +/* default alignment for n-bit data */ +#define DATA_ALIGN(n) 1 + +/* operand class for n-bit data definitions */ +#define DATA_OPERAND(n) DATAOP + +/* returns true when instruction is valid for selected cpu */ +#define MNEMONIC_VALID(i) cpu_available(i) + +/* parse cpu-specific directives with label */ +#define PARSE_CPU_LABEL(l,s) parse_cpu_label(l,s) + +/* we define two additional unary operations, '<' and '>' */ +int ext_unary_type(char *); +int ext_unary_eval(int,taddr,taddr *,int); +int ext_find_base(symbol **,expr *,section *,taddr); +#define LOBYTE (LAST_EXP_TYPE+1) +#define HIBYTE (LAST_EXP_TYPE+2) +#define EXT_UNARY_NAME(s) (*s=='<'||*s=='>') +#define EXT_UNARY_TYPE(s) ext_unary_type(s) +#define EXT_UNARY_EVAL(t,v,r,c) ext_unary_eval(t,v,r,c) +#define EXT_FIND_BASE(b,e,s,p) ext_find_base(b,e,s,p) + +/* type to store each operand */ +typedef struct { + int type; + unsigned flags; + expr *value; +} operand; + +/* operand flags */ +#define OF_LO (1<<0) +#define OF_HI (1<<1) +#define OF_PC (1<<2) + + +/* additional mnemonic data */ +typedef struct { + unsigned char opcode; + unsigned char zp_opcode; /* !=0 means optimization to zero page allowed */ + uint16_t available; +} mnemonic_extension; + +/* available */ +#define M6502 1 /* standard 6502 instruction set */ +#define ILL 2 /* illegal 6502 instructions */ +#define DTV 4 /* C64 DTV instruction set extension */ +#define M65C02 8 /* basic 65C02 extensions on 6502 instruction set */ +#define WDC02 16 /* basic WDC65C02 extensions on 65C02 instr. set */ +#define WDC02ALL 32 /* all WDC65C02 extensions on 65C02 instr. set */ +#define CSGCE02 64 /* CSG65CE02 extensions on WDC65C02 instruction set */ +#define HU6280 128 /* HuC6280 extensions on WDC65C02 instruction set */ +#define M45GS02 256 /* MEGA65 45GS02 extensions on basic WDC02 instr.set */ + + +/* adressing modes */ +enum { + IMPLIED=0, + DATAOP, /* data operand */ + ABS, /* $1234 */ + ABSX, /* $1234,X */ + ABSY, /* $1234,Y */ + ABSZ, /* $1234,Z */ + ZPAGE, /* $12 - add ZPAGE-ABS to optimize ABS/ABSX/ABSY/ABSZ */ + ZPAGEX, /* $12,X */ + ZPAGEY, /* $12,Y */ + ZPAGEZ, /* $12,Z */ + INDIR, /* ($1234) - JMP only */ + INDX, /* ($12,X) */ + INDY, /* ($12),Y */ + INDZ, /* ($12),Z */ + INDZ32, /* [$12],Z */ + IND32, /* [$12] */ + DPINDIR, /* ($12) */ + INDIRX, /* ($1234,X) - JMP only */ + RELJMP, /* B!cc/JMP construction */ + REL8, /* $1234 - 8-bit signed relative branch */ + REL16, /* $1234 - 16-bit signed relative branch */ + IMMED, /* #$12 */ + WBIT, /* bit-number (WDC65C02) */ + ACCU, /* A - all following addressing modes don't need a value! */ + DUMX, /* dummy X as 'second' operand */ + DUMY, /* dummy Y as 'second' operand */ + DUMZ, /* dummy Z as 'second' operand */ +}; +#define IS_ABS(x) ((x)>=ABS && (x)<=ABSZ) +#define IS_REL +#define FIRST_INDIR INDIR +#define LAST_INDIR INDIRX +/* CAUTION: + - Do not change the order of ABS,ABSX/Y/Z, and ZPAGE,ZPAGEX/Y/Z + - All addressing modes >=ACCU (and IMPLIED) do not require a value! + - All indirect addressing modes are between FIRST_INDIR and LAST_INDIR! +*/ + +/* cpu-specific symbol-flags */ +#define ZPAGESYM (RSRVD_C<<0) /* symbol will reside in the zero/direct-page */ + + +/* exported by cpu.c */ +extern uint16_t cpu_type; +int cpu_available(int); +int parse_cpu_label(char *,char **); diff --git a/tools/vasm/vasm/cpus/6502/cpu_errors.h b/tools/vasm/vasm/cpus/6502/cpu_errors.h new file mode 100644 index 0000000..df8cee5 --- /dev/null +++ b/tools/vasm/vasm/cpus/6502/cpu_errors.h @@ -0,0 +1,14 @@ + "instruction not supported on selected architecture",ERROR, + "trailing garbage in operand",WARNING, + "missing closing parenthesis in addressing mode",ERROR, + "data size %d not supported",ERROR, + "relocation does not allow hi/lo modifier",ERROR, + "operand doesn't fit into %d bits",ERROR, /* 05 */ + "branch destination out of range",ERROR, + "illegal bit number",ERROR, + "identifier expected",ERROR, + "multiple hi/lo modifiers",WARNING, + "zero/direct-page addressing not available",ERROR, /* 10 */ + "operand not in zero/direct-page range",ERROR, + "signed addend doesn't fit into %d bits",WARNING, + "missing closing square-bracket in addressing mode",ERROR, diff --git a/tools/vasm/vasm/cpus/6502/opcodes.h b/tools/vasm/vasm/cpus/6502/opcodes.h new file mode 100644 index 0000000..382a00d --- /dev/null +++ b/tools/vasm/vasm/cpus/6502/opcodes.h @@ -0,0 +1,310 @@ + "adc", {IMMED , }, {0x69,0x00,M6502}, + "adc", {ABS , }, {0x6d,0x65,M6502}, + "adc", {INDX , }, {0x61,0x00,M6502}, + "adc", {DPINDIR, }, {0x72,0x00,M65C02}, + "adc", {INDIR ,DUMY }, {0x71,0x00,M6502}, + "adc", {ABS ,DUMX }, {0x7d,0x75,M6502}, + "adc", {ABS ,DUMY }, {0x79,0x00,M6502}, + "ahx", {INDIR ,DUMY }, {0x93,0x00,ILL}, + "ahx", {ABS ,DUMY }, {0x9f,0x00,ILL}, + "alr", {IMMED , }, {0x4b,0x00,ILL}, + "anc", {IMMED , }, {0x0b,0x00,ILL}, + "anc2", {IMMED , }, {0x2b,0x00,ILL}, + "and", {IMMED , }, {0x29,0x00,M6502}, + "and", {ABS , }, {0x2d,0x25,M6502}, + "and", {INDX , }, {0x21,0x00,M6502}, + "and", {DPINDIR, }, {0x32,0x00,M65C02}, + "and", {INDIR ,DUMY }, {0x31,0x00,M6502}, + "and", {ABS ,DUMX }, {0x3d,0x35,M6502}, + "and", {ABS ,DUMY }, {0x39,0x00,M6502}, + "arr", {IMMED , }, {0x6b,0x00,ILL}, + "asl", {ACCU , }, {0x0a,0x00,M6502}, + "asl", {ABS , }, {0x0e,0x06,M6502}, + "asl", {IMPLIED, }, {0x0a,0x00,M6502}, + "asl", {ABS ,DUMX }, {0x1e,0x16,M6502}, + "aso", {ABS , }, {0x0f,0x07,ILL}, + "aso", {INDX , }, {0x03,0x00,ILL}, + "aso", {INDIR ,DUMY }, {0x13,0x00,ILL}, + "aso", {ABS ,DUMX }, {0x1f,0x17,ILL}, + "aso", {ABS ,DUMY }, {0x1b,0x00,ILL}, + "asw", {ABS , }, {0xcb,0x00,M45GS02}, + "axa", {INDIR ,DUMY }, {0x93,0x00,ILL}, + "axa", {ABS ,DUMY }, {0x9f,0x00,ILL}, + "axs", {IMMED , }, {0xcb,0x00,ILL}, + "axs", {ABS , }, {0x8f,0x87,ILL}, + "axs", {INDX , }, {0x83,0x00,ILL}, + "axs", {ABS ,DUMY }, {0x00,0x97,ILL}, + "bbr", {WBIT ,ZPAGE ,REL8 }, {0x00,0x0f,WDC02}, + "bbr0", {ZPAGE ,REL8 }, {0x00,0x0f,WDC02}, + "bbr1", {ZPAGE ,REL8 }, {0x00,0x1f,WDC02}, + "bbr2", {ZPAGE ,REL8 }, {0x00,0x2f,WDC02}, + "bbr3", {ZPAGE ,REL8 }, {0x00,0x3f,WDC02}, + "bbr4", {ZPAGE ,REL8 }, {0x00,0x4f,WDC02}, + "bbr5", {ZPAGE ,REL8 }, {0x00,0x5f,WDC02}, + "bbr6", {ZPAGE ,REL8 }, {0x00,0x6f,WDC02}, + "bbr7", {ZPAGE ,REL8 }, {0x00,0x7f,WDC02}, + "bbs", {WBIT ,ZPAGE ,REL8 }, {0x00,0x8f,WDC02}, + "bbs0", {ZPAGE ,REL8 }, {0x00,0x8f,WDC02}, + "bbs1", {ZPAGE ,REL8 }, {0x00,0x9f,WDC02}, + "bbs2", {ZPAGE ,REL8 }, {0x00,0xaf,WDC02}, + "bbs3", {ZPAGE ,REL8 }, {0x00,0xbf,WDC02}, + "bbs4", {ZPAGE ,REL8 }, {0x00,0xcf,WDC02}, + "bbs5", {ZPAGE ,REL8 }, {0x00,0xdf,WDC02}, + "bbs6", {ZPAGE ,REL8 }, {0x00,0xef,WDC02}, + "bbs7", {ZPAGE ,REL8 }, {0x00,0xff,WDC02}, + "bcc", {REL8 , }, {0x90,0x00,M6502}, + "bcs", {REL8 , }, {0xb0,0x00,M6502}, + "beq", {REL8 , }, {0xf0,0x00,M6502}, + "bit", {IMMED , }, {0x89,0x00,M65C02}, + "bit", {ABS , }, {0x2c,0x24,M6502}, + "bit", {ABS ,DUMX }, {0x3c,0x34,M65C02}, + "bmi", {REL8 , }, {0x30,0x00,M6502}, + "bne", {REL8 , }, {0xd0,0x00,M6502}, + "bpl", {REL8 , }, {0x10,0x00,M6502}, + "bra", {REL8 , }, {0x12,0x00,DTV}, + "bra", {REL8 , }, {0x80,0x00,M65C02}, + "brk", {IMPLIED, }, {0x00,0x00,M6502}, + "bsr", {REL8 , }, {0x44,0x00,HU6280}, + "bvc", {REL8 , }, {0x50,0x00,M6502}, + "bvs", {REL8 , }, {0x70,0x00,M6502}, + "cla", {IMPLIED, }, {0x62,0x00,HU6280}, + "clc", {IMPLIED, }, {0x18,0x00,M6502}, + "cld", {IMPLIED, }, {0xd8,0x00,M6502}, + "cle", {IMPLIED, }, {0x02,0x00,M45GS02}, + "cli", {IMPLIED, }, {0x58,0x00,M6502}, + "clv", {IMPLIED, }, {0xb8,0x00,M6502}, + "clx", {IMPLIED, }, {0x82,0x00,HU6280}, + "cly", {IMPLIED, }, {0xc2,0x00,HU6280}, + "cmp", {IMMED , }, {0xc9,0x00,M6502}, + "cmp", {ABS , }, {0xcd,0xc5,M6502}, + "cmp", {INDX , }, {0xc1,0x00,M6502}, + "cmp", {DPINDIR, }, {0xd2,0x00,M65C02}, + "cmp", {INDIR ,DUMY }, {0xd1,0x00,M6502}, + "cmp", {ABS ,DUMX }, {0xdd,0xd5,M6502}, + "cmp", {ABS ,DUMY }, {0xd9,0x00,M6502}, + "cpx", {IMMED , }, {0xe0,0x00,M6502}, + "cpx", {ABS , }, {0xec,0xe4,M6502}, + "cpy", {IMMED , }, {0xc0,0x00,M6502}, + "cpy", {ABS , }, {0xcc,0xc4,M6502}, + "csh", {IMPLIED, }, {0xd4,0x00,HU6280}, + "csl", {IMPLIED, }, {0x54,0x00,HU6280}, + "dcm", {ABS , }, {0xcf,0xc7,ILL}, + "dcm", {INDX , }, {0xc3,0x00,ILL}, + "dcm", {INDIR ,DUMY }, {0xd3,0x00,ILL}, + "dcm", {ABS ,DUMX }, {0xdf,0xd7,ILL}, + "dcm", {ABS ,DUMY }, {0xdb,0x00,ILL}, + "dcp", {ABS , }, {0xcf,0xc7,ILL}, + "dcp", {INDX , }, {0xc3,0x00,ILL}, + "dcp", {INDIR ,DUMY }, {0xd3,0x00,ILL}, + "dcp", {ABS ,DUMX }, {0xdf,0xd7,ILL}, + "dcp", {ABS ,DUMY }, {0xdb,0x00,ILL}, + "dea", {IMPLIED, }, {0x3a,0x00,M65C02}, + "dec", {ACCU , }, {0x3a,0x00,M65C02}, + "dec", {IMPLIED, }, {0x3a,0x00,M65C02}, + "dec", {ABS , }, {0xce,0xc6,M6502}, + "dec", {ABS ,DUMX }, {0xde,0xd6,M6502}, + "dew", {ABS , }, {0x00,0xc3,M45GS02}, + "dex", {IMPLIED, }, {0xca,0x00,M6502}, + "dey", {IMPLIED, }, {0x88,0x00,M6502}, + "dez", {IMPLIED, }, {0x3b,0x00,M45GS02}, + "eom", {IMPLIED, }, {0xea,0x00,M45GS02}, + "eor", {IMMED , }, {0x49,0x00,M6502}, + "eor", {ABS , }, {0x4d,0x45,M6502}, + "eor", {INDX , }, {0x41,0x00,M6502}, + "eor", {DPINDIR, }, {0x52,0x00,M65C02}, + "eor", {INDIR ,DUMY }, {0x51,0x00,M6502}, + "eor", {ABS ,DUMX }, {0x5d,0x55,M6502}, + "eor", {ABS ,DUMY }, {0x59,0x00,M6502}, + "ina", {IMPLIED, }, {0x1a,0x00,M65C02}, + "inc", {ACCU , }, {0x1a,0x00,M65C02}, + "inc", {IMPLIED, }, {0x1a,0x00,M65C02}, + "inc", {ABS , }, {0xee,0xe6,M6502}, + "inc", {ABS ,DUMX }, {0xfe,0xf6,M6502}, + "ins", {ABS , }, {0xef,0xe7,ILL}, + "ins", {INDX , }, {0xe3,0x00,ILL}, + "ins", {INDIR ,DUMY }, {0xf3,0x00,ILL}, + "ins", {ABS ,DUMX }, {0xff,0xf7,ILL}, + "ins", {ABS ,DUMY }, {0xfb,0x00,ILL}, + "inw", {ABS , }, {0x00,0xe3,M45GS02}, + "inx", {IMPLIED, }, {0xe8,0x00,M6502}, + "iny", {IMPLIED, }, {0xc8,0x00,M6502}, + "inz", {IMPLIED, }, {0x1b,0x00,M45GS02}, + "isc", {ABS , }, {0xef,0xe7,ILL}, + "isc", {INDX , }, {0xe3,0x00,ILL}, + "isc", {INDIR ,DUMY }, {0xf3,0x00,ILL}, + "isc", {ABS ,DUMX }, {0xff,0xf7,ILL}, + "isc", {ABS ,DUMY }, {0xfb,0x00,ILL}, + "jmp", {ABS , }, {0x4c,0x00,M6502}, + "jmp", {INDIRX , }, {0x7c,0x00,M65C02}, + "jmp", {INDIR , }, {0x6c,0x00,M6502}, + "jsr", {ABS , }, {0x20,0x00,M6502}, + "las", {ABS ,DUMY }, {0xbb,0x00,ILL}, + "lax", {IMMED , }, {0xab,0x00,ILL}, + "lax", {ABS , }, {0xaf,0xa7,ILL}, + "lax", {ABS ,DUMY }, {0xbf,0xb7,ILL}, + "lax", {INDX , }, {0xa3,0x00,ILL}, + "lax", {INDIR ,DUMY }, {0xb3,0x00,ILL}, + "lda", {IMMED , }, {0xa9,0x00,M6502}, + "lda", {ABS , }, {0xad,0xa5,M6502}, + "lda", {INDX , }, {0xa1,0x00,M6502}, + "lda", {DPINDIR, }, {0xb2,0x00,M65C02}, + "lda", {INDIR ,DUMY }, {0xb1,0x00,M6502}, + "lda", {ABS ,DUMX }, {0xbd,0xb5,M6502}, + "lda", {ABS ,DUMY }, {0xb9,0x00,M6502}, + "ldx", {IMMED , }, {0xa2,0x00,M6502}, + "ldx", {ABS , }, {0xae,0xa6,M6502}, + "ldx", {ABS ,DUMY }, {0xbe,0xb6,M6502}, + "ldy", {IMMED , }, {0xa0,0x00,M6502}, + "ldy", {ABS , }, {0xac,0xa4,M6502}, + "ldy", {ABS ,DUMX }, {0xbc,0xb4,M6502}, + "ldz", {IMMED , }, {0xa3,0x00,M45GS02}, + "ldz", {ABS ,DUMX }, {0xbb,0xab,M45GS02}, + "lse", {ABS , }, {0x4f,0x47,ILL}, + "lse", {INDX , }, {0x43,0x00,ILL}, + "lse", {INDIR ,DUMY }, {0x53,0x00,ILL}, + "lse", {ABS ,DUMX }, {0x5f,0x57,ILL}, + "lse", {ABS ,DUMY }, {0x5b,0x00,ILL}, + "lsr", {ACCU , }, {0x4a,0x00,M6502}, + "lsr", {ABS , }, {0x4e,0x46,M6502}, + "lsr", {IMPLIED, }, {0x4a,0x00,M6502}, + "lsr", {ABS ,DUMX }, {0x5e,0x56,M6502}, + "map", {IMPLIED, }, {0x5c,0x00,M45GS02}, + "neg", {ACCU, }, {0x42,0x00,M45GS02}, + "neg", {IMPLIED, }, {0x42,0x00,M45GS02}, + "nop", {IMPLIED, }, {0xea,0x00,M6502}, + "oal", {IMMED , }, {0xab,0x00,ILL}, + "ora", {IMMED , }, {0x09,0x00,M6502}, + "ora", {ABS , }, {0x0d,0x05,M6502}, + "ora", {INDX , }, {0x01,0x00,M6502}, + "ora", {DPINDIR, }, {0x12,0x00,M65C02}, + "ora", {INDIR ,DUMY }, {0x11,0x00,M6502}, + "ora", {ABS ,DUMX }, {0x1d,0x15,M6502}, + "ora", {ABS ,DUMY }, {0x19,0x00,M6502}, + "pha", {IMPLIED, }, {0x48,0x00,M6502}, + "php", {IMPLIED, }, {0x08,0x00,M6502}, + "phx", {IMPLIED, }, {0xda,0x00,M65C02}, + "phy", {IMPLIED, }, {0x5a,0x00,M65C02}, + "phz", {IMPLIED, }, {0xdb,0x00,M45GS02}, + "pla", {IMPLIED, }, {0x68,0x00,M6502}, + "plp", {IMPLIED, }, {0x28,0x00,M6502}, + "plx", {IMPLIED, }, {0xfa,0x00,M65C02}, + "ply", {IMPLIED, }, {0x7a,0x00,M65C02}, + "plz", {IMPLIED, }, {0xfb,0x00,M45GS02}, + "rla", {ABS , }, {0x2f,0x27,ILL}, + "rla", {INDX , }, {0x23,0x00,ILL}, + "rla", {INDIR ,DUMY }, {0x33,0x00,ILL}, + "rla", {ABS ,DUMX }, {0x3f,0x37,ILL}, + "rla", {ABS ,DUMY }, {0x3b,0x00,ILL}, + "rmb", {WBIT ,ZPAGE }, {0x00,0x07,WDC02}, + "rmb0", {ZPAGE }, {0x00,0x07,WDC02}, + "rmb1", {ZPAGE }, {0x00,0x17,WDC02}, + "rmb2", {ZPAGE }, {0x00,0x27,WDC02}, + "rmb3", {ZPAGE }, {0x00,0x37,WDC02}, + "rmb4", {ZPAGE }, {0x00,0x47,WDC02}, + "rmb5", {ZPAGE }, {0x00,0x57,WDC02}, + "rmb6", {ZPAGE }, {0x00,0x67,WDC02}, + "rmb7", {ZPAGE }, {0x00,0x77,WDC02}, + "rol", {ACCU , }, {0x2a,0x00,M6502}, + "rol", {ABS , }, {0x2e,0x26,M6502}, + "rol", {IMPLIED, }, {0x2a,0x00,M6502}, + "rol", {ABS ,DUMX }, {0x3e,0x36,M6502}, + "ror", {ACCU , }, {0x6a,0x00,M6502}, + "ror", {ABS , }, {0x6e,0x66,M6502}, + "ror", {IMPLIED, }, {0x6a,0x00,M6502}, + "ror", {ABS ,DUMX }, {0x7e,0x76,M6502}, + "row", {ABS , }, {0xeb,0x00,M45GS02}, + "rra", {ABS , }, {0x6f,0x67,ILL}, + "rra", {INDX , }, {0x63,0x00,ILL}, + "rra", {INDIR ,DUMY }, {0x73,0x00,ILL}, + "rra", {ABS ,DUMX }, {0x7f,0x77,ILL}, + "rra", {ABS ,DUMY }, {0x7b,0x00,ILL}, + "rti", {IMPLIED, }, {0x40,0x00,M6502}, + "rts", {IMPLIED, }, {0x60,0x00,M6502}, + "rts", {IMMED , }, {0x62,0x60,M45GS02}, + "sac", {IMMED , }, {0x32,0x00,DTV}, + "sax", {IMMED , }, {0xcb,0x00,ILL}, + "sax", {ABS , }, {0x8f,0x87,ILL}, + "sax", {INDX , }, {0x83,0x00,ILL}, + "sax", {ABS ,DUMY }, {0x00,0x97,ILL}, + "sax", {IMPLIED, }, {0x22,0x00,HU6280}, + "say", {ABS ,DUMX }, {0x9c,0x00,ILL}, + "say", {IMPLIED, }, {0x42,0x00,HU6280}, + "sbc", {IMMED , }, {0xe9,0x00,M6502}, + "sbc", {ABS , }, {0xed,0xe5,M6502}, + "sbc", {INDX , }, {0xe1,0x00,M6502}, + "sbc", {DPINDIR, }, {0xf2,0x00,M65C02}, + "sbc", {INDIR ,DUMY }, {0xf1,0x00,M6502}, + "sbc", {ABS ,DUMX }, {0xfd,0xf5,M6502}, + "sbc", {ABS ,DUMY }, {0xf9,0x00,M6502}, + "sbc2", {IMMED , }, {0xeb,0x00,ILL}, + "sec", {IMPLIED, }, {0x38,0x00,M6502}, + "sed", {IMPLIED, }, {0xf8,0x00,M6502}, + "see", {IMPLIED, }, {0x03,0x00,M45GS02}, + "sei", {IMPLIED, }, {0x78,0x00,M6502}, + "set", {IMPLIED, }, {0xf4,0x00,HU6280}, + "shx", {ABS ,DUMY }, {0x9e,0x00,ILL}, + "shy", {ABS ,DUMX }, {0x9c,0x00,ILL}, + "sir", {IMMED , }, {0x42,0x00,DTV}, + "slo", {ABS , }, {0x0f,0x07,ILL}, + "slo", {INDX , }, {0x03,0x00,ILL}, + "slo", {INDIR ,DUMY }, {0x13,0x00,ILL}, + "slo", {ABS ,DUMX }, {0x1f,0x17,ILL}, + "slo", {ABS ,DUMY }, {0x1b,0x00,ILL}, + "smb", {WBIT ,ZPAGE }, {0x00,0x87,WDC02}, + "smb0", {ZPAGE }, {0x00,0x87,WDC02}, + "smb1", {ZPAGE }, {0x00,0x97,WDC02}, + "smb2", {ZPAGE }, {0x00,0xa7,WDC02}, + "smb3", {ZPAGE }, {0x00,0xb7,WDC02}, + "smb4", {ZPAGE }, {0x00,0xc7,WDC02}, + "smb5", {ZPAGE }, {0x00,0xd7,WDC02}, + "smb6", {ZPAGE }, {0x00,0xe7,WDC02}, + "smb7", {ZPAGE }, {0x00,0xf7,WDC02}, + "sre", {ABS , }, {0x4f,0x47,ILL}, + "sre", {INDX , }, {0x43,0x00,ILL}, + "sre", {INDIR ,DUMY }, {0x53,0x00,ILL}, + "sre", {ABS ,DUMX }, {0x5f,0x57,ILL}, + "sre", {ABS ,DUMY }, {0x5b,0x00,ILL}, + "st0", {IMMED , }, {0x03,0x00,HU6280}, + "st1", {IMMED , }, {0x13,0x00,HU6280}, + "st2", {IMMED , }, {0x23,0x00,HU6280}, + "sta", {ABS , }, {0x8d,0x85,M6502}, + "sta", {INDX , }, {0x81,0x00,M6502}, + "sta", {DPINDIR, }, {0x92,0x00,M65C02}, + "sta", {INDIR ,DUMY }, {0x91,0x00,M6502}, + "sta", {ABS ,DUMX }, {0x9d,0x95,M6502}, + "sta", {ABS ,DUMY }, {0x99,0x00,M6502}, + "stp", {IMPLIED, }, {0xdb,0x00,WDC02ALL}, + "stx", {ABS , }, {0x8e,0x86,M6502}, + "stx", {ABS ,DUMY }, {0x00,0x96,M6502}, + "sty", {ABS , }, {0x8c,0x84,M6502}, + "sty", {ABS ,DUMX }, {0x00,0x94,M6502}, + "stz", {ABS , }, {0x9c,0x64,M65C02}, + "stz", {ABS ,DUMX }, {0x9e,0x74,M65C02}, + "sxy", {IMPLIED, }, {0x02,0x00,HU6280}, + "tab", {IMPLIED, }, {0x5b,0x00,M45GS02}, + "tai", {ABS ,ABS ,ABS }, {0xf3,0x00,HU6280}, + "tam", {IMMED , }, {0x53,0x00,HU6280}, + "tas", {ABS ,DUMY }, {0x9b,0x00,ILL}, + "tax", {IMPLIED, }, {0xaa,0x00,M6502}, + "tay", {IMPLIED, }, {0xa8,0x00,M6502}, + "taz", {IMPLIED, }, {0x4b,0x00,M45GS02}, + "tba", {IMPLIED, }, {0x7b,0x00,M45GS02}, + "tdd", {ABS ,ABS ,ABS }, {0xc3,0x00,HU6280}, + "tia", {ABS ,ABS ,ABS }, {0xe3,0x00,HU6280}, + "tii", {ABS ,ABS ,ABS }, {0x73,0x00,HU6280}, + "tin", {ABS ,ABS ,ABS }, {0xd3,0x00,HU6280}, + "tma", {IMMED , }, {0x43,0x00,HU6280}, + "trb", {ABS , }, {0x1c,0x14,M65C02}, + "tsb", {ABS , }, {0x0c,0x04,M65C02}, + "tst", {IMMED ,ABS }, {0x93,0x83,HU6280}, + "tst", {IMMED ,ABS ,DUMX }, {0xb3,0xa3,HU6280}, + "tsx", {IMPLIED, }, {0xba,0x00,M6502}, + "tsy", {IMPLIED, }, {0x0b,0x00,M45GS02}, + "txa", {IMPLIED, }, {0x8a,0x00,M6502}, + "txs", {IMPLIED, }, {0x9a,0x00,M6502}, + "tya", {IMPLIED, }, {0x98,0x00,M6502}, + "tys", {IMPLIED, }, {0x2b,0x00,M45GS02}, + "tza", {IMPLIED, }, {0x6b,0x00,M45GS02}, + "wai", {IMPLIED, }, {0xcb,0x00,WDC02ALL}, + "xaa", {IMMED , }, {0x8b,0x00,ILL}, + "xas", {ABS ,DUMY }, {0x9e,0x00,ILL}, diff --git a/tools/vasm/vasm/cpus/6800/cpu.c b/tools/vasm/vasm/cpus/6800/cpu.c new file mode 100644 index 0000000..5455926 --- /dev/null +++ b/tools/vasm/vasm/cpus/6800/cpu.c @@ -0,0 +1,403 @@ +/* + * cpu.c 6800 cpu description file + * (c) in 2013-2016,2019 by Esben Norby and Frank Wille + */ + +#include "vasm.h" + +mnemonic mnemonics[] = { +#include "opcodes.h" +}; + +int mnemonic_cnt = sizeof(mnemonics) / sizeof(mnemonics[0]); + +int bitsperbyte = 8; +int bytespertaddr = 2; +char * cpu_copyright = "vasm 6800/6801/68hc11 cpu backend 0.4a (c) 2013-2016,2019,2021 Esben Norby"; +char * cpuname = "6800"; + +static uint8_t cpu_type = M6800; +static int modifier; /* set by find_base() */ + + +int +init_cpu() +{ + return 1; +} + + +int +cpu_args(char *p) +{ + if (!strncmp(p, "-m68", 4)) { + p += 4; + if (p[0] == '0' && p[3] == '\0') { + switch(p[1]) { + case '0': + case '2': + case '8': + /* 6802 and 6808 are a 6800 with embedded ROM/RAM */ + cpu_type = M6800; + break; + case '1': + case '3': + /* 6803 is a 6801 with embedded ROM/RAM */ + cpu_type = M6801; + break; + default: + /* 6804 and 6805 are not opcode compatible + * 6809 is somewhat compatible, but not completely + * 6806 and 6807 do not exist, to my knowledge + */ + return 0; + } + } else if (!stricmp(p, "hc11")) + cpu_type = M68HC11; + else + return 0; + return 1; + } + return 0; +} + + +char * +parse_cpu_special(char *start) +{ + return start; +} + + +operand * +new_operand() +{ + operand *new = mymalloc(sizeof(*new)); + new->type = -1; + return new; +} + + +int +parse_operand(char *p, int len, operand *op, int required) +{ + char *start = p; + + op->value = NULL; + + switch (required) { + case IMM: + case IMM16: + if (*p++ != '#') + return PO_NOMATCH; + p = skip(p); + /* fall through */ + case REL: + case DATAOP: + op->value = parse_expr(&p); + break; + + case ADDR: + if (*p == '<') { + required = DIR; + p++; + } + else if (*p == '>') { + required = EXT; + p++; + } + op->value = parse_expr(&p); + break; + + case DIR: + if (*p == '>') + return PO_NOMATCH; + else if (*p == '<') + p++; + op->value = parse_expr(&p); + break; + + case EXT: + if (*p == '<') + return PO_NOMATCH; + else if (*p == '>') + p++; + op->value = parse_expr(&p); + break; + + case REGX: + if (toupper((unsigned char)*p++) != 'X') + return PO_NOMATCH; + break; + case REGY: + if (toupper((unsigned char)*p++) != 'Y') + return PO_NOMATCH; + break; + + default: + return PO_NOMATCH; + } + + p = skip(p); + if (p-start < len) { + cpu_error(0); /* trailing garbage */ + return PO_CORRUPT; + } + op->type = required; + return PO_MATCH; +} + + +static size_t +eval_oper(operand *op, section *sec, taddr pc, taddr offs, dblock *db) +{ + size_t size = 0; + symbol *base = NULL; + int btype; + taddr val; + + if (op->value != NULL && !eval_expr(op->value, &val, sec, pc)) { + modifier = 0; + btype = find_base(op->value, &base, sec, pc); + } + + switch (op->type) { + case ADDR: + if (base != NULL || val < 0 || val > 0xff) { + op->type = EXT; + size = 2; + } + else { + op->type = DIR; + size = 1; + } + break; + case DIR: + size = 1; + if (db != NULL && (val < 0 || val > 0xff)) + cpu_error(2); /* operand doesn't fit into 8-bits */ + break; + case IMM: + size = 1; + if (db != NULL && !modifier && (val < -0x80 || val > 0xff)) + cpu_error(2); /* operand doesn't fit into 8-bits */ + break; + case EXT: + case IMM16: + size = 2; + break; + case REL: + size = 1; + break; + } + + if (size > 0 && db != NULL) { + /* create relocation entry and code for this operand */ + if (op->type == REL && base == NULL) { + /* relative branch to absolute label */ + val = val - (pc + offs + 1); + if (val < -0x80 || val > 0x7f) + cpu_error(3); /* branch out of range */ + } + else if (op->type == REL && base != NULL && btype == BASE_OK) { + /* relative branches */ + if (!is_pc_reloc(base, sec)) { + val = val - (pc + offs + 1); + if (val < -0x80 || val > 0x7f) + cpu_error(3); /* branch out of range */ + } + else + add_extnreloc(&db->relocs, base, val, REL_PC, + 0, 8, offs); + } + else if (base != NULL && btype != BASE_ILLEGAL) { + rlist *rl; + + rl = add_extnreloc(&db->relocs, base, val, + btype==BASE_PCREL? REL_PC : REL_ABS, + 0, size << 3, offs); + switch (modifier) { + case LOBYTE: + if (rl) ((nreloc *)rl->reloc)->mask = 0xff; + val &= 0xff; + break; + case HIBYTE: + if (rl) ((nreloc *)rl->reloc)->mask = 0xff00; + val = (val >> 8) & 0xff; + break; + } + } + else if (base != NULL) + general_error(38); /* illegal relocation */ + + if (size == 1) { + op->code[0] = val & 0xff; + } + else if (size == 2) { + op->code[0] = (val >> 8) & 0xff; + op->code[1] = val & 0xff; + } + else + ierror(0); + } + return (size); +} + + +size_t +instruction_size(instruction *ip, section *sec, taddr pc) +{ + operand op; + int i; + size_t size; + + size = (mnemonics[ip->code].ext.prebyte != 0) ? 2 : 1; + + for (i = 0; i < MAX_OPERANDS && ip->op[i] != NULL; i++) { + op = *(ip->op[i]); + size += eval_oper(&op, sec, pc, size, NULL); + } + + return (size); +} + + +dblock * +eval_instruction(instruction *ip, section *sec, taddr pc) +{ + dblock *db = new_dblock(); + uint8_t opcode; + uint8_t *d; + int i; + size_t size; + + /* evaluate operands and determine instruction size */ + opcode = mnemonics[ip->code].ext.opcode; + size = (mnemonics[ip->code].ext.prebyte != 0) ? 2 : 1; + for (i = 0; i < MAX_OPERANDS && ip->op[i] != NULL; i++) { + size += eval_oper(ip->op[i], sec, pc, size, db); + if (ip->op[i]->type == DIR) + opcode = mnemonics[ip->code].ext.dir_opcode; + } + + /* allocate and fill data block */ + db->size = size; + d = db->data = mymalloc(size); + + if (mnemonics[ip->code].ext.prebyte != 0) + *d++ = mnemonics[ip->code].ext.prebyte; + *d++ = opcode; + + /* write operands */ + for (i = 0; i < MAX_OPERANDS && ip->op[i] != NULL; i++) { + switch (ip->op[i]->type) { + case IMM: + case DIR: + case REL: + *d++ = ip->op[i]->code[0]; + break; + case IMM16: + case EXT: + *d++ = ip->op[i]->code[0]; + *d++ = ip->op[i]->code[1]; + break; + } + } + + return (db); +} + +dblock * +eval_data(operand *op, size_t bitsize, section *sec, taddr pc) +{ + dblock *db = new_dblock(); + uint8_t *d; + taddr val; + + if (bitsize != 8 && bitsize != 16) + cpu_error(1,bitsize); /* data size not supported */ + + db->size = bitsize >> 3; + d = db->data = mymalloc(db->size); + + if (!eval_expr(op->value, &val, sec, pc)) { + symbol *base; + int btype; + rlist *rl; + + modifier = 0; + btype = find_base(op->value, &base, sec, pc); + if (btype==BASE_OK || (btype==BASE_PCREL && modifier==0)) { + rl = add_extnreloc(&db->relocs, base, val, + btype==BASE_PCREL ? REL_PC : REL_ABS, + 0, bitsize, 0); + switch (modifier) { + case LOBYTE: + if (rl) ((nreloc *)rl->reloc)->mask = 0xff; + val &= 0xff; + break; + case HIBYTE: + if (rl) ((nreloc *)rl->reloc)->mask = 0xff00; + val = (val >> 8) & 0xff; + break; + } + } + else if (btype != BASE_NONE) + general_error(38); /* illegal relocation */ + } + + if (bitsize == 8) { + if (val < -0x80 || val > 0xff) + cpu_error(2); /* operand doesn't fit into 8-bits */ + } + else /* 16 bits */ + *d++ = (val >> 8) & 0xff; + *d = val & 0xff; + + return (db); +} + + +int +ext_unary_eval(int type, taddr val, taddr *result, int cnst) +{ + switch (type) { + case LOBYTE: + *result = cnst ? (val & 0xff) : val; + return 1; + case HIBYTE: + *result = cnst ? ((val >> 8) & 0xff) : val; + return 1; + default: + break; + } + + return 0; /* unknown type */ +} + + +int +ext_find_base(symbol **base, expr *p, section *sec, taddr pc) +{ + /* addr/256 equals >addr, addr%256 and addr&255 equal type==DIV || p->type==MOD) { + if (p->right->type==NUM && p->right->c.val==256) + p->type = p->type == DIV ? HIBYTE : LOBYTE; + } + else if (p->type==BAND && p->right->type==NUM && p->right->c.val==255) + p->type = LOBYTE; + + if (p->type==LOBYTE || p->type==HIBYTE) { + modifier = p->type; + return find_base(p->left,base,sec,pc); + } + + return BASE_ILLEGAL; +} + + +int +cpu_available(int idx) +{ + return (mnemonics[idx].ext.available & cpu_type) != 0; +} diff --git a/tools/vasm/vasm/cpus/6800/cpu.h b/tools/vasm/vasm/cpus/6800/cpu.h new file mode 100644 index 0000000..69c739a --- /dev/null +++ b/tools/vasm/vasm/cpus/6800/cpu.h @@ -0,0 +1,80 @@ +/* + * cpu.h 6800 cpu description file + * (c) in 2013-2014 by Esben Norby and Frank Wille +*/ + +#define BIGENDIAN 1 +#define LITTLEENDIAN 0 +#define VASM_CPU_6800 1 + +/* maximum number of operands for one mnemonic */ +#define MAX_OPERANDS 4 + +/* maximum number of mnemonic-qualifiers per mnemonic */ +#define MAX_QUALIFIERS 0 + +/* data type to represent a target-address */ +typedef int16_t taddr; +typedef uint16_t utaddr; + +/* minimum instruction alignment */ +#define INST_ALIGN 1 + +/* default alignment for n-bit data */ +#define DATA_ALIGN(n) 1 + +/* operand class for n-bit data definitions */ +#define DATA_OPERAND(n) DATAOP + +/* returns true when instruction is valid for selected cpu */ +#define MNEMONIC_VALID(i) cpu_available(i) + +/* allow commas and blanks at the same time to separate instruction operands */ +#define OPERSEP_COMMA 1 +#define OPERSEP_BLANK 1 + +/* we define two additional unary operations, '<' and '>' */ +int ext_unary_eval(int,taddr,taddr *,int); +int ext_find_base(symbol **,expr *,section *,taddr); +#define LOBYTE (LAST_EXP_TYPE+1) +#define HIBYTE (LAST_EXP_TYPE+2) +#define EXT_UNARY_NAME(s) (*s=='<'||*s=='>') +#define EXT_UNARY_TYPE(s) (*s=='<'?LOBYTE:HIBYTE) +#define EXT_UNARY_EVAL(t,v,r,c) ext_unary_eval(t,v,r,c) +#define EXT_FIND_BASE(b,e,s,p) ext_find_base(b,e,s,p) + +/* type to store each operand */ +typedef struct { + uint16_t type; + uint8_t code[2]; + expr *value; +} operand; + + +/* additional mnemonic data */ +typedef struct { + unsigned char prebyte; + unsigned char opcode; + unsigned char dir_opcode; /* !=0 means optimization to DIR allowed */ + uint8_t available; +} mnemonic_extension; + +/* available */ +#define M6800 1 +#define M6801 2 /* 6801/6803: Adds D register and some extras */ +#define M68HC11 4 /* standard 68HC11 instruction set */ + +/* adressing modes */ +#define INH 0 +#define IMM 1 /* #$12 */ /* IMM ii */ +#define IMM16 2 /* #$1234 */ /* IMM jj kk */ +#define ADDR 3 +#define EXT 4 /* EXT hh */ +#define DIR 5 /* DIR dd */ +#define REL 6 /* REL rr */ +#define REGX 7 +#define REGY 8 +#define DATAOP 9 /* data operand */ + +/* exported by cpu.c */ +int cpu_available(int); diff --git a/tools/vasm/vasm/cpus/6800/cpu_errors.h b/tools/vasm/vasm/cpus/6800/cpu_errors.h new file mode 100644 index 0000000..bed92dd --- /dev/null +++ b/tools/vasm/vasm/cpus/6800/cpu_errors.h @@ -0,0 +1,4 @@ + "trailing garbage in operand",WARNING, + "data size %d not supported",ERROR, + "operand doesn't fit into 8-bits",ERROR, + "branch destination out of range",ERROR, diff --git a/tools/vasm/vasm/cpus/6800/opcodes.h b/tools/vasm/vasm/cpus/6800/opcodes.h new file mode 100644 index 0000000..7ffb13a --- /dev/null +++ b/tools/vasm/vasm/cpus/6800/opcodes.h @@ -0,0 +1,339 @@ + "aba", {INH }, {0x00, 0x1B, 0x00, M6800|M6801|M68HC11}, + "abx", {INH }, {0x00, 0x3A, 0x00, M6801|M68HC11}, + "aby", {INH }, {0x18, 0x3A, 0x00, M68HC11}, + "adca", {IMM }, {0x00, 0x89, 0x00, M6800|M6801|M68HC11}, + "adca", {ADDR }, {0x00, 0xB9, 0x99, M6800|M6801|M68HC11}, + "adca", {DIR, REGX }, {0x00, 0x00, 0xA9, M6800|M6801|M68HC11}, + "adca", {DIR, REGY }, {0x18, 0x00, 0xA9, M68HC11}, + "adcb", {IMM }, {0x00, 0xC9, 0x00, M6800|M6801|M68HC11}, + "adcb", {ADDR }, {0x00, 0xF9, 0xD9, M6800|M6801|M68HC11}, + "adcb", {DIR, REGX }, {0x00, 0x00, 0xE9, M6800|M6801|M68HC11}, + "adcb", {DIR, REGY }, {0x18, 0x00, 0xE9, M68HC11}, + "adda", {IMM }, {0x00, 0x8B, 0x00, M6800|M6801|M68HC11}, + "adda", {ADDR }, {0x00, 0xBB, 0x9B, M6800|M6801|M68HC11}, + "adda", {DIR, REGX }, {0x00, 0x00, 0xAB, M6800|M6801|M68HC11}, + "adda", {DIR, REGY }, {0x18, 0x00, 0xAB, M68HC11}, + "addb", {IMM }, {0x00, 0xCB, 0x00, M6800|M6801|M68HC11}, + "addb", {ADDR }, {0x00, 0xFB, 0xDB, M6800|M6801|M68HC11}, + "addb", {DIR, REGX }, {0x00, 0x00, 0xEB, M6800|M6801|M68HC11}, + "addb", {DIR, REGY }, {0x18, 0x00, 0xEB, M68HC11}, + "addd", {IMM16 }, {0x00, 0xC3, 0x00, M6801|M68HC11}, + "addd", {ADDR }, {0x00, 0xF3, 0xD3, M6801|M68HC11}, + "addd", {DIR, REGX }, {0x00, 0x00, 0xE3, M6801|M68HC11}, + "addd", {DIR, REGY }, {0x18, 0x00, 0xE3, M68HC11}, + "anda", {IMM }, {0x00, 0x84, 0x00, M6800|M6801|M68HC11}, + "anda", {ADDR }, {0x00, 0xB4, 0x94, M6800|M6801|M68HC11}, + "anda", {DIR, REGX }, {0x00, 0x00, 0xA4, M6800|M6801|M68HC11}, + "anda", {DIR, REGY }, {0x18, 0x00, 0xA4, M68HC11}, + "andb", {IMM }, {0x00, 0xC4, 0x00, M6800|M6801|M68HC11}, + "andb", {ADDR }, {0x00, 0xF4, 0xD4, M6800|M6801|M68HC11}, + "andb", {DIR, REGX }, {0x00, 0x00, 0xE4, M6800|M6801|M68HC11}, + "andb", {DIR, REGY }, {0x18, 0x00, 0xE4, M68HC11}, + "asl", {EXT }, {0x00, 0x78, 0x00, M6800|M6801|M68HC11}, + "asl", {DIR, REGX }, {0x00, 0x00, 0x68, M6800|M6801|M68HC11}, + "asl", {DIR, REGY }, {0x18, 0x00, 0x68, M68HC11}, + "asla", {INH }, {0x00, 0x48, 0x00, M6800|M6801|M68HC11}, + "aslb", {INH }, {0x00, 0x58, 0x00, M6800|M6801|M68HC11}, + "asld", {INH }, {0x00, 0x05, 0x00, M6800|M6801|M68HC11}, + "asr", {EXT }, {0x00, 0x77, 0x00, M6800|M6801|M68HC11}, + "asr", {DIR, REGX }, {0x00, 0x00, 0x67, M6800|M6801|M68HC11}, + "asr", {DIR, REGY }, {0x18, 0x00, 0x67, M68HC11}, + "asra", {INH, }, {0x00, 0x47, 0x00, M6800|M6801|M68HC11}, + "asrb", {INH, }, {0x00, 0x57, 0x00, M6800|M6801|M68HC11}, + + "bclr", {DIR, IMM }, {0x00, 0x00, 0x15, M68HC11}, + "bclr", {DIR, REGX, IMM }, {0x00, 0x00, 0x1D, M68HC11}, + "bclr", {DIR, REGY, IMM }, {0x18, 0x00, 0x1D, M68HC11}, + + "bcc", {REL, }, {0x00, 0x24, 0x00, M6800|M6801|M68HC11}, + "bcs", {REL, }, {0x00, 0x25, 0x00, M6800|M6801|M68HC11}, + "beq", {REL, }, {0x00, 0x27, 0x00, M6800|M6801|M68HC11}, + "bge", {REL, }, {0x00, 0x2C, 0x00, M6800|M6801|M68HC11}, + "bgt", {REL, }, {0x00, 0x2E, 0x00, M6800|M6801|M68HC11}, + "bhi", {REL, }, {0x00, 0x22, 0x00, M6800|M6801|M68HC11}, + "bhs", {REL, }, {0x00, 0x24, 0x00, M6800|M6801|M68HC11}, + "bita", {IMM }, {0x00, 0x85, 0x00, M6800|M6801|M68HC11}, + "bita", {ADDR, }, {0x00, 0xB5, 0x95, M6800|M6801|M68HC11}, + "bita", {DIR, REGX }, {0x00, 0x00, 0xA5, M6800|M6801|M68HC11}, + "bita", {DIR, REGY }, {0x18, 0x00, 0xA5, M68HC11}, + "bitb", {IMM }, {0x00, 0xC5, 0x00, M6800|M6801|M68HC11}, + "bitb", {ADDR, }, {0x00, 0xF5, 0xD5, M6800|M6801|M68HC11}, + "bitb", {DIR, REGX }, {0x00, 0x00, 0xE5, M6800|M6801|M68HC11}, + "bitb", {DIR, REGY }, {0x18, 0x00, 0xE5, M68HC11}, + + "ble", {REL, }, {0x00, 0x2F, 0x00, M6800|M6801|M68HC11}, + "blo", {REL, }, {0x00, 0x25, 0x00, M6800|M6801|M68HC11}, + "bls", {REL, }, {0x00, 0x23, 0x00, M6800|M6801|M68HC11}, + "blt", {REL, }, {0x00, 0x2D, 0x00, M6800|M6801|M68HC11}, + "bmi", {REL, }, {0x00, 0x2B, 0x00, M6800|M6801|M68HC11}, + "bne", {REL, }, {0x00, 0x26, 0x00, M6800|M6801|M68HC11}, + "bpl", {REL, }, {0x00, 0x2A, 0x00, M6800|M6801|M68HC11}, + "bra", {REL, }, {0x00, 0x20, 0x00, M6800|M6801|M68HC11}, + "jr", {REL, }, {0x00, 0x20, 0x00, M6800|M6801|M68HC11}, /* bra */ + + "brclr",{DIR, IMM, REL }, {0x00, 0x00, 0x13, M68HC11}, + "brclr",{DIR, REGX, IMM, REL}, {0x00, 0x00, 0x1F, M68HC11}, + "brclr",{DIR, REGY, IMM, REL}, {0x18, 0x00, 0x1F, M68HC11}, + + "brn", {REL, }, {0x00, 0x21, 0x00, M6801|M68HC11}, + + "brset",{DIR, IMM, REL }, {0x00, 0x00, 0x12, M68HC11}, + "brset",{DIR, REGX, IMM, REL}, {0x00, 0x00, 0x1E, M68HC11}, + "brset",{DIR, REGY, IMM, REL}, {0x18, 0x00, 0x1E, M68HC11}, + + "bset", {DIR, IMM }, {0x00, 0x00, 0x14, M68HC11}, + "bset", {DIR, REGX, IMM }, {0x00, 0x00 ,0x1C, M68HC11}, + "bset", {DIR, REGY, IMM }, {0x18, 0x00 ,0x1C, M68HC11}, + + "bsr", {REL, }, {0x00, 0x8D, 0x00, M6800|M6801|M68HC11}, + "callr",{REL, }, {0x00, 0x8D, 0x00, M6800|M6801|M68HC11}, /* bsr */ + "bvc", {REL, }, {0x00, 0x28, 0x00, M6800|M6801|M68HC11}, + "bvs", {REL, }, {0x00, 0x29, 0x00, M6800|M6801|M68HC11}, + "cba", {INH, }, {0x00, 0x11, 0x00, M6800|M6801|M68HC11}, + "clc", {INH, }, {0x00, 0x0C, 0x00, M6800|M6801|M68HC11}, + "cli", {INH, }, {0x00, 0x0E, 0x00, M6800|M6801|M68HC11}, + "ei", {INH, }, {0x00, 0x0E, 0x00, M6800|M6801|M68HC11}, /* cli */ + "clr", {EXT, }, {0x00, 0x7F, 0x00, M6800|M6801|M68HC11}, + "clr", {DIR, REGX }, {0x00, 0x00, 0x6F, M6800|M6801|M68HC11}, + "clr", {DIR, REGY }, {0x18, 0x00, 0x6F, M68HC11}, + "clra", {INH, }, {0x00, 0x4F, 0x00, M6800|M6801|M68HC11}, + "clrb", {INH, }, {0x00, 0x5F, 0x00, M6800|M6801|M68HC11}, + "clv", {INH, }, {0x00, 0x0A, 0x00, M6800|M6801|M68HC11}, + "cmpa", {IMM }, {0x00, 0x81, 0x00, M6800|M6801|M68HC11}, + "cmpa", {ADDR, }, {0x00, 0xB1, 0x91, M6800|M6801|M68HC11}, + "cmpa", {DIR, REGX }, {0x00, 0x00, 0xA1, M6800|M6801|M68HC11}, + "cmpa", {DIR, REGY }, {0x18, 0x00, 0xA1, M68HC11}, + "cmpb", {IMM }, {0x00, 0xC1, 0x00, M6800|M6801|M68HC11}, + "cmpb", {ADDR, }, {0x00, 0xF1, 0xD1, M6800|M6801|M68HC11}, + "cmpb", {DIR, REGX }, {0x00, 0x00, 0xE1, M6800|M6801|M68HC11}, + "cmpb", {DIR, REGY }, {0x18, 0x00, 0xE1, M68HC11}, + "com", {EXT, }, {0x00, 0x73, 0x00, M6800|M6801|M68HC11}, + "com", {DIR, REGX }, {0x00, 0x00, 0x63, M6800|M6801|M68HC11}, + "com", {DIR, REGY }, {0x18, 0x00, 0x63, M68HC11}, + "coma", {INH, }, {0x00, 0x43, 0x00, M6800|M6801|M68HC11}, + "comb", {INH, }, {0x00, 0x53, 0x00, M6800|M6801|M68HC11}, + "cpd", {IMM16 }, {0x1A, 0x83, 0x00, M68HC11}, + "cpd", {ADDR, }, {0x1A, 0xB3, 0x93, M68HC11}, + "cpd", {DIR, REGX }, {0x1A, 0x00, 0xA3, M68HC11}, + "cpd", {DIR, REGY }, {0xCD, 0x00, 0xA3, M68HC11}, + "cmpd", {IMM16 }, {0x1A, 0x83, 0x00, M68HC11}, /* cpd */ + "cmpd", {ADDR, }, {0x1A, 0xB3, 0x93, M68HC11}, /* cpd */ + "cmpd", {DIR, REGX }, {0x1A, 0x00, 0xA3, M68HC11}, /* cpd */ + "cmpd", {DIR, REGY }, {0xCD, 0x00, 0xA3, M68HC11}, /* cpd */ + "cpx", {IMM16 }, {0x00, 0x8C, 0x00, M6800|M6801|M68HC11}, + "cpx", {ADDR, }, {0x00, 0xBC, 0x9C, M6800|M6801|M68HC11}, + "cpx", {DIR, REGX }, {0x00, 0x00, 0xAC, M6800|M6801|M68HC11}, + "cpx", {DIR, REGY }, {0xCD, 0x00, 0xAC, M68HC11}, + "cmpx", {IMM16 }, {0x00, 0x8C, 0x00, M6800|M6801|M68HC11}, /* cpx */ + "cmpx", {ADDR, }, {0x00, 0xBC, 0x9C, M6800|M6801|M68HC11}, /* cpx */ + "cmpx", {DIR, REGX }, {0x00, 0x00, 0xAC, M6800|M6801|M68HC11}, /* cpx */ + "cmpx", {DIR, REGY }, {0xCD, 0x00, 0xAC, M68HC11}, /* cpx */ + "cpy", {IMM16 }, {0x18, 0x8C, 0x00, M68HC11}, + "cpy", {ADDR, }, {0x18, 0xBC, 0x9C, M68HC11}, + "cpy", {DIR, REGX }, {0x1A, 0x00, 0xAC, M68HC11}, + "cpy", {DIR, REGY }, {0x18, 0x00, 0xAC, M68HC11}, + "cmpy", {IMM16 }, {0x18, 0x8C, 0x00, M68HC11}, /* cpy */ + "cmpy", {ADDR, }, {0x18, 0xBC, 0x9C, M68HC11}, /* cpy */ + "cmpy", {DIR, REGX }, {0x1A, 0x00, 0xAC, M68HC11}, /* cpy */ + "cmpy", {DIR, REGY }, {0x18, 0x00, 0xAC, M68HC11}, /* cpy */ + "daa", {INH, }, {0x00, 0x19, 0x00, M6800|M6801|M68HC11}, + "dec", {EXT, }, {0x00, 0x7A, 0x00, M6800|M6801|M68HC11}, + "dec", {DIR, REGX }, {0x00, 0x00, 0x6A, M6800|M6801|M68HC11}, + "dec", {DIR, REGY }, {0x18, 0x00, 0x6A, M68HC11}, + "deca", {INH, }, {0x00, 0x4A, 0x00, M6800|M6801|M68HC11}, + "decb", {INH, }, {0x00, 0x5A, 0x00, M6800|M6801|M68HC11}, + "des", {INH, }, {0x00, 0x34, 0x00, M6800|M6801|M68HC11}, + "decs", {INH, }, {0x00, 0x34, 0x00, M6800|M6801|M68HC11}, /* des */ + "dex", {INH, }, {0x00, 0x09, 0x00, M6800|M6801|M68HC11}, + "decx", {INH, }, {0x00, 0x09, 0x00, M6800|M6801|M68HC11}, /* dex */ + "dey", {INH, }, {0x18, 0x09, 0x00, M68HC11}, + "decy", {INH, }, {0x18, 0x09, 0x00, M68HC11}, /* dey */ + "eora", {IMM, }, {0x00, 0x88, 0x00, M6800|M6801|M68HC11}, + "eora", {ADDR, }, {0x00, 0xB8, 0x98, M6800|M6801|M68HC11}, + "eora", {DIR, REGX }, {0x00, 0x00, 0xA8, M6800|M6801|M68HC11}, + "eora", {DIR, REGY }, {0x18, 0x00, 0xA8, M68HC11}, + "xora", {IMM, }, {0x00, 0x88, 0x00, M6800|M6801|M68HC11}, /* eora */ + "xora", {ADDR, }, {0x00, 0xB8, 0x98, M6800|M6801|M68HC11}, /* eora */ + "xora", {DIR, REGX }, {0x00, 0x00, 0xA8, M6800|M6801|M68HC11}, /* eora */ + "xora", {DIR, REGY }, {0x18, 0x00, 0xA8, M68HC11}, /* eora */ + "eorb", {IMM, }, {0x00, 0xC8, 0x00, M6800|M6801|M68HC11}, + "eorb", {ADDR, }, {0x00, 0xF8, 0xD8, M6800|M6801|M68HC11}, + "eorb", {DIR, REGX }, {0x00, 0x00, 0xE8, M6800|M6801|M68HC11}, + "eorb", {DIR, REGY }, {0x18, 0x00, 0xE8, M68HC11}, + "xorb", {IMM, }, {0x00, 0xC8, 0x00, M6800|M6801|M68HC11}, /* eorb */ + "xorb", {ADDR, }, {0x00, 0xF8, 0xD8, M6800|M6801|M68HC11}, /* eorb */ + "xorb", {DIR, REGX }, {0x00, 0x00, 0xE8, M6800|M6801|M68HC11}, /* eorb */ + "xorb", {DIR, REGY }, {0x18, 0x00, 0xE8, M68HC11}, /* eorb */ + "fdiv", {INH, }, {0x00, 0x03, 0x00, M68HC11}, + "idiv", {INH, }, {0x00, 0x02, 0x00, M68HC11}, + "inc", {EXT, }, {0x00, 0x7C, 0x00, M6800|M6801|M68HC11}, + "inc", {DIR, REGX }, {0x00, 0x00, 0x6C, M6800|M6801|M68HC11}, + "inc", {DIR, REGY }, {0x18, 0x00, 0x6C, M68HC11}, + "inca", {INH, }, {0x00, 0x4C, 0x00, M6800|M6801|M68HC11}, + "incb", {INH, }, {0x00, 0x5C, 0x00, M6800|M6801|M68HC11}, + "ins", {INH, }, {0x00, 0x31, 0x00, M6800|M6801|M68HC11}, + "incs", {INH, }, {0x00, 0x31, 0x00, M6800|M6801|M68HC11}, /* ins */ + "inx", {INH, }, {0x00, 0x08, 0x00, M6800|M6801|M68HC11}, + "incx", {INH, }, {0x00, 0x08, 0x00, M6800|M6801|M68HC11}, /* inx */ + "iny", {INH, }, {0x18, 0x08, 0x00, M68HC11}, + "incy", {INH, }, {0x18, 0x08, 0x00, M68HC11}, /* iny */ + "jmp", {EXT, }, {0x00, 0x7E, 0x00, M6800|M6801|M68HC11}, + "jmp", {DIR, REGX }, {0x00, 0x00, 0x6E, M6800|M6801|M68HC11}, + "jmp", {DIR, REGY }, {0x18, 0x00, 0x6E, M68HC11}, + "jsr", {ADDR, }, {0x00, 0xBD, 0x9D, M6800|M6801|M68HC11}, + "jsr", {DIR, REGX }, {0x00, 0x00, 0xAD, M6800|M6801|M68HC11}, + "jsr", {DIR, REGY }, {0x18, 0x00, 0xAD, M68HC11}, + "call", {ADDR, }, {0x00, 0xBD, 0x9D, M6800|M6801|M68HC11}, /* jsr */ + "call", {DIR, REGX }, {0x00, 0x00, 0xAD, M6800|M6801|M68HC11}, /* jsr */ + "call", {DIR, REGY }, {0x18, 0x00, 0xAD, M68HC11}, /* jsr */ + "lda", {IMM, }, {0x00, 0x86, 0x00, M6800|M6801|M68HC11}, + "lda", {ADDR, }, {0x00, 0xB6, 0x96, M6800|M6801|M68HC11}, + "lda", {DIR, REGX }, {0x00, 0x00, 0xA6, M6800|M6801|M68HC11}, + "lda", {DIR, REGY }, {0x18, 0x00, 0xA6, M68HC11}, + "ldaa", {IMM, }, {0x00, 0x86, 0x00, M6800|M6801|M68HC11}, + "ldaa", {ADDR, }, {0x00, 0xB6, 0x96, M6800|M6801|M68HC11}, + "ldaa", {DIR, REGX }, {0x00, 0x00, 0xA6, M6800|M6801|M68HC11}, + "ldaa", {DIR, REGY }, {0x18, 0x00, 0xA6, M68HC11}, + "ldb", {IMM, }, {0x00, 0xC6, 0x00, M6800|M6801|M68HC11}, + "ldb", {ADDR, }, {0x00, 0xF6, 0xD6, M6800|M6801|M68HC11}, + "ldb", {DIR, REGX }, {0x00, 0x00, 0xE6, M6800|M6801|M68HC11}, + "ldb", {DIR, REGY }, {0x18, 0x00, 0xE6, M68HC11}, + "ldab", {IMM, }, {0x00, 0xC6, 0x00, M6800|M6801|M68HC11}, + "ldab", {ADDR, }, {0x00, 0xF6, 0xD6, M6800|M6801|M68HC11}, + "ldab", {DIR, REGX }, {0x00, 0x00, 0xE6, M6800|M6801|M68HC11}, + "ldab", {DIR, REGY }, {0x18, 0x00, 0xE6, M68HC11}, + "ldd", {IMM16, }, {0x00, 0xCC, 0x00, M6801|M68HC11}, + "ldd", {ADDR, }, {0x00, 0xFC, 0xDC, M6801|M68HC11}, + "ldd", {DIR, REGX }, {0x00, 0x00, 0xEC, M6801|M68HC11}, + "ldd", {DIR, REGY }, {0x18, 0x00, 0xEC, M68HC11}, + "lds", {IMM16, }, {0x00, 0x8E, 0x00, M6800|M6801|M68HC11}, + "lds", {ADDR, }, {0x00, 0xBE, 0x9E, M6800|M6801|M68HC11}, + "lds", {DIR, REGX }, {0x00, 0x00, 0xAE, M6800|M6801|M68HC11}, + "lds", {DIR, REGY }, {0x18, 0x00, 0xAE, M68HC11}, + "ldx", {IMM16, }, {0x00, 0xCE, 0x00, M6800|M6801|M68HC11}, + "ldx", {ADDR, }, {0x00, 0xFE, 0xDE, M6800|M6801|M68HC11}, + "ldx", {DIR, REGX }, {0x00, 0x00, 0xEE, M6800|M6801|M68HC11}, + "ldx", {DIR, REGY }, {0xCD, 0x00, 0xEE, M68HC11}, + "ldy", {IMM16, }, {0x18, 0xCE, 0x00, M68HC11}, + "ldy", {ADDR, }, {0x18, 0xFE, 0xDE, M68HC11}, + "ldy", {DIR, REGX }, {0x1A, 0x00, 0xEE, M68HC11}, + "ldy", {DIR, REGY }, {0x18, 0x00, 0xEE, M68HC11}, + "lsl", {EXT, }, {0x00, 0x78, 0x00, M6800|M6801|M68HC11}, + "lsl", {DIR, REGX }, {0x00, 0x00, 0x68, M6800|M6801|M68HC11}, + "lsl", {DIR, REGY }, {0x18, 0x00, 0x68, M68HC11}, + "lsla", {INH, }, {0x00, 0x48, 0x00, M6800|M6801|M68HC11}, + "lslb", {INH, }, {0x00, 0x58, 0x00, M6800|M6801|M68HC11}, + "lsld", {INH, }, {0x00, 0x05, 0x00, M6801|M68HC11}, + "lsr", {EXT, }, {0x00, 0x74, 0x00, M6800|M6801|M68HC11}, + "lsr", {DIR, REGX }, {0x00, 0x00, 0x64, M6800|M6801|M68HC11}, + "lsr", {DIR, REGY }, {0x18, 0x00, 0x64, M68HC11}, + "lsra", {INH, }, {0x00, 0x44, 0x00, M6800|M6801|M68HC11}, + "lsrb", {INH, }, {0x00, 0x54, 0x00, M6800|M6801|M68HC11}, + "lsrd", {INH, }, {0x00, 0x04, 0x00, M6801|M68HC11}, + "mul", {INH, }, {0x00, 0x3D, 0x00, M6801|M68HC11}, + "neg", {EXT, }, {0x00, 0x70, 0x00, M6800|M6801|M68HC11}, + "neg", {DIR, REGX }, {0x00, 0x00, 0x60, M6800|M6801|M68HC11}, + "neg", {DIR, REGY }, {0x18, 0x00, 0x60, M68HC11}, + "nega", {INH, }, {0x00, 0x40, 0x00, M6800|M6801|M68HC11}, + "negb", {INH, }, {0x00, 0x50, 0x00, M6800|M6801|M68HC11}, + "nop", {INH, }, {0x00, 0x01, 0x00, M6800|M6801|M68HC11}, + "oraa", {IMM, }, {0x00, 0x8A, 0x00, M6800|M6801|M68HC11}, + "oraa", {ADDR, }, {0x00, 0xBA, 0x9A, M6800|M6801|M68HC11}, + "oraa", {DIR, REGX }, {0x00, 0x00, 0xAA, M6800|M6801|M68HC11}, + "oraa", {DIR, REGY }, {0x18, 0x00, 0xAA, M68HC11}, + "orab", {IMM, }, {0x00, 0xCA, 0x00, M6800|M6801|M68HC11}, + "orab", {ADDR, }, {0x00, 0xFA, 0xDA, M6800|M6801|M68HC11}, + "orab", {DIR, REGX }, {0x00, 0x00, 0xEA, M6800|M6801|M68HC11}, + "orab", {DIR, REGY }, {0x18, 0x00, 0xEA, M68HC11}, + "psha", {INH, }, {0x00, 0x36, 0x00, M6800|M6801|M68HC11}, + "pusha",{INH, }, {0x00, 0x36, 0x00, M6800|M6801|M68HC11}, /* psha */ + "pshb", {INH, }, {0x00, 0x37, 0x00, M6800|M6801|M68HC11}, + "pushb",{INH, }, {0x00, 0x37, 0x00, M6800|M6801|M68HC11}, /* pshb */ + "pshx", {INH, }, {0x00, 0x3C, 0x00, M6801|M68HC11}, + "pushx",{INH, }, {0x00, 0x3C, 0x00, M6801|M68HC11}, /* pshx */ + "pshy", {INH, }, {0x18, 0x3C, 0x00, M68HC11}, + "pushy", {INH, }, {0x18, 0x3C, 0x00, M68HC11}, /* pshy */ + "pula", {INH, }, {0x00, 0x32, 0x00, M6800|M6801|M68HC11}, + "popa", {INH, }, {0x00, 0x32, 0x00, M6800|M6801|M68HC11}, /* pula */ + "pulb", {INH, }, {0x00, 0x33, 0x00, M6800|M6801|M68HC11}, + "popb", {INH, }, {0x00, 0x33, 0x00, M6800|M6801|M68HC11}, /* pulb */ + "pulx", {INH, }, {0x00, 0x38, 0x00, M6801|M68HC11}, + "popx", {INH, }, {0x00, 0x38, 0x00, M6801|M68HC11}, /* pulx */ + "puly", {INH, }, {0x18, 0x38, 0x00, M68HC11}, + "popy", {INH, }, {0x18, 0x38, 0x00, M68HC11}, /* puly */ + "rol", {EXT, }, {0x00, 0x79, 0x00, M6800|M6801|M68HC11}, + "rol", {DIR, REGX }, {0x00, 0x00, 0x69, M6800|M6801|M68HC11}, + "rol", {DIR, REGY }, {0x18, 0x00, 0x69, M68HC11}, + "rola", {INH, }, {0x00, 0x49, 0x00, M6800|M6801|M68HC11}, + "rolb", {INH, }, {0x00, 0x59, 0x00, M6800|M6801|M68HC11}, + "ror", {EXT, }, {0x00, 0x76, 0x00, M6800|M6801|M68HC11}, + "ror", {DIR, REGX }, {0x00, 0x00, 0x66, M6800|M6801|M68HC11}, + "ror", {DIR, REGY }, {0x18, 0x00, 0x66, M68HC11}, + "rora", {INH, }, {0x00, 0x46, 0x00, M6800|M6801|M68HC11}, + "rorb", {INH, }, {0x00, 0x56, 0x00, M6800|M6801|M68HC11}, + "rti", {INH, }, {0x00, 0x3B, 0x00, M6800|M6801|M68HC11}, + "reti", {INH, }, {0x00, 0x3B, 0x00, M6800|M6801|M68HC11}, /* rti */ + "rts", {INH, }, {0x00, 0x39, 0x00, M6800|M6801|M68HC11}, + "ret", {INH, }, {0x00, 0x39, 0x00, M6800|M6801|M68HC11}, /* rts */ + "sba", {INH, }, {0x00, 0x10, 0x00, M6800|M6801|M68HC11}, + "sbca", {IMM, }, {0x00, 0x82, 0x00, M6800|M6801|M68HC11}, + "sbca", {ADDR, }, {0x00, 0xB2, 0x92, M6800|M6801|M68HC11}, + "sbca", {DIR, REGX }, {0x00, 0x00, 0xA2, M6800|M6801|M68HC11}, + "sbca", {DIR, REGY }, {0x18, 0x00, 0xA2, M68HC11}, + "sbcb", {IMM, }, {0x00, 0xC2, 0x00, M6800|M6801|M68HC11}, + "sbcb", {ADDR, }, {0x00, 0xF2, 0xD2, M6800|M6801|M68HC11}, + "sbcb", {DIR, REGX }, {0x00, 0x00, 0xE2, M6800|M6801|M68HC11}, + "sbcb", {DIR, REGY }, {0x18, 0x00, 0xE2, M68HC11}, + "sec", {INH, }, {0x00, 0x0D, 0x00, M6800|M6801|M68HC11}, + "sei", {INH, }, {0x00, 0x0F, 0x00, M6800|M6801|M68HC11}, + "di", {INH, }, {0x00, 0x0F, 0x00, M6800|M6801|M68HC11}, /* sei */ + "sev", {INH, }, {0x00, 0x0B, 0x00, M6800|M6801|M68HC11}, + "staa", {ADDR, }, {0x00, 0xB7, 0x97, M6800|M6801|M68HC11}, + "staa", {DIR, REGX }, {0x00, 0x00, 0xA7, M6800|M6801|M68HC11}, + "staa", {DIR, REGY }, {0x18, 0x00, 0xA7, M68HC11}, + "stab", {ADDR, }, {0x00, 0xF7, 0xD7, M6800|M6801|M68HC11}, + "stab", {DIR, REGX }, {0x00, 0x00, 0xE7, M6800|M6801|M68HC11}, + "stab", {DIR, REGY }, {0x18, 0x00, 0xE7, M68HC11}, + "std", {ADDR, }, {0x00, 0xFD, 0xDD, M6801|M68HC11}, + "std", {DIR, REGX }, {0x00, 0x00, 0xED, M6801|M68HC11}, + "std", {DIR, REGY }, {0x18, 0x00, 0xED, M68HC11}, + "stop", {INH, }, {0x00, 0xCF, 0x00, M68HC11}, + "sts", {ADDR, }, {0x00, 0xBF, 0x9F, M6800|M6801|M68HC11}, + "sts", {DIR, REGX }, {0x00, 0x00, 0xAF, M6800|M6801|M68HC11}, + "sts", {DIR, REGY }, {0x18, 0x00, 0xAF, M68HC11}, + "stx", {ADDR, }, {0x00, 0xFF, 0xDF, M6800|M6801|M68HC11}, + "stx", {DIR, REGX }, {0x00, 0x00, 0xEF, M6800|M6801|M68HC11}, + "stx", {DIR, REGY }, {0xCD, 0x00, 0xEF, M68HC11}, + "sty", {ADDR, }, {0x18, 0xFF, 0xDF, M68HC11}, + "sty", {DIR, REGX }, {0x1A, 0x00, 0xEF, M68HC11}, + "sty", {DIR, REGY }, {0x18, 0x00, 0xEF, M68HC11}, + "suba", {IMM, }, {0x00, 0x80, 0x00, M6800|M6801|M68HC11}, + "suba", {ADDR, }, {0x00, 0xB0, 0x90, M6800|M6801|M68HC11}, + "suba", {DIR, REGX }, {0x00, 0x00, 0xA0, M6800|M6801|M68HC11}, + "suba", {DIR, REGY }, {0x18, 0x00, 0xA0, M68HC11}, + "subb", {IMM, }, {0x00, 0xC0, 0x00, M6800|M6801|M68HC11}, + "subb", {ADDR, }, {0x00, 0xF0, 0xD0, M6800|M6801|M68HC11}, + "subb", {DIR, REGX }, {0x00, 0x00, 0xE0, M6800|M6801|M68HC11}, + "subb", {DIR, REGY }, {0x18, 0x00, 0xE0, M68HC11}, + "subd", {IMM16, }, {0x00, 0x83, 0x00, M6801|M68HC11}, + "subd", {ADDR, }, {0x00, 0xB3, 0x93, M6801|M68HC11}, + "subd", {DIR, REGX }, {0x00, 0x00, 0xA3, M6801|M68HC11}, + "subd", {DIR, REGY }, {0x18, 0x00, 0xA3, M68HC11}, + "swi", {INH, }, {0x00, 0x3F, 0x00, M6800|M6801|M68HC11}, + "tab", {INH, }, {0x00, 0x16, 0x00, M6800|M6801|M68HC11}, + "tap", {INH, }, {0x00, 0x06, 0x00, M6800|M6801|M68HC11}, + "tba", {INH, }, {0x00, 0x17, 0x00, M6800|M6801|M68HC11}, + "test", {INH, }, {0x00, 0x00, 0x00, M68HC11}, + "tpa", {INH, }, {0x00, 0x07, 0x00, M6800|M6801|M68HC11}, + "tst", {EXT, }, {0x00, 0x7D, 0x00, M6800|M6801|M68HC11}, + "tst", {DIR, REGX }, {0x00, 0x00, 0x6D, M6800|M6801|M68HC11}, + "tst", {DIR, REGY }, {0x18, 0x00, 0x6D, M68HC11}, + "tsta", {INH, }, {0x00, 0x4D, 0x00, M6800|M6801|M68HC11}, + "tstb", {INH, }, {0x00, 0x5D, 0x00, M6800|M6801|M68HC11}, + "tsx", {INH, }, {0x00, 0x30, 0x00, M6800|M6801|M68HC11}, + "tsy", {INH, }, {0x18, 0x30, 0x00, M68HC11}, + "txs", {INH, }, {0x00, 0x35, 0x00, M6800|M6801|M68HC11}, + "tys", {INH, }, {0x18, 0x35, 0x00, M68HC11}, + "wai", {INH, }, {0x00, 0x3E, 0x00, M6800|M6801|M68HC11}, + "xgdx", {INH, }, {0x00, 0x8F, 0x00, M68HC11}, + "xgdy", {INH, }, {0x18, 0x8F, 0x00, M68HC11}, diff --git a/tools/vasm/vasm/cpus/6809/cpu.c b/tools/vasm/vasm/cpus/6809/cpu.c new file mode 100644 index 0000000..9d0abbd --- /dev/null +++ b/tools/vasm/vasm/cpus/6809/cpu.c @@ -0,0 +1,1418 @@ +/* + * cpu.c 6809/6309/68HC12 cpu description file + */ + +#include "vasm.h" + +mnemonic mnemonics[] = { +#include "opcodes.h" +}; +int mnemonic_cnt = sizeof(mnemonics) / sizeof(mnemonics[0]); + +char *cpu_copyright = "vasm 6809/6309/68hc12 cpu backend 0.4 (c)2020-2021 by Frank Wille"; +char *cpuname = "6809"; +int bitsperbyte = 8; +int bytespertaddr = 2; + +static uint8_t cpu_type = M6809; +static int modifier; /* set by find_base() */ +static uint8_t dpage = 0; /* default direct page - set with SETDP */ + +static int opt_off; /* constant offset optimization 0,R to ,R */ +static int opt_bra; /* relative branch optimization/translation */ +static int opt_pc; /* optimize all EXT addressing to PC-relative */ + +static int OC_BRA,OC_BSR,OC_LBRA,OC_LBSR; +static int RIDX_PC; + +static struct CPUReg registers[] = { +#include "registers.h" +}; +static int reg_cnt = sizeof(registers) / sizeof(registers[0]); + +static int psh_postbyte_map[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + 3<<1,1<<4,1<<5,1<<6,1<<6,1<<7,-1,-1,1<<1,1<<2,1<<0,1<<3,-1,-1,-1,-1 +}; +static int ir_postbyte_map09[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + 0,1,2,3,4,5,6,7,8,9,10,11,-1,13,14,15 +}; +static int ir_postbyte_map12[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + 4,5,6,7,7,-1,-1,-1,0,1,2,-1,-1,-1,-1,-1 +}; +static int idx_postbyte_map09[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + -1,0x00,0x20,0x40,0x60,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 +}; +static int idx_postbyte_map12[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + -1,0,1,2,2,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 +}; +static int offs_postbyte_map09[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + 11,-1,-1,-1,-1,-1,14,-1,6,5,-1,-1,-1,-1,7,10 +}; +static int offs_postbyte_map12[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + 2,-1,-1,-1,-1,-1,-1,-1,0,1,-1,-1,-1,-1,-1,-1 +}; +static int bitm_postbyte_map[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + -1,-1,-1,-1,-1,-1,-1,-1,1,2,0,-1,-1,-1,-1,-1 +}; +static int dbr_postbyte_map[] = { + /* D, X, Y, U, S, PC, W, V, A, B, CC, DP, 0, 0, E, F */ + 4,5,6,7,7,-1,-1,-1,0,1,-1,-1,-1,-1,-1,-1 +}; + + +int ext_unary_type(char *s) +{ + return *s=='<' ? LOBYTE : HIBYTE; +} + + +int ext_unary_eval(int type,taddr val,taddr *result,int cnst) +{ + switch (type) { + case LOBYTE: + *result = cnst ? (val & 0xff) : val; + return 1; + case HIBYTE: + *result = cnst ? ((val >> 8) & 0xff) : val; + return 1; + default: + break; + } + return 0; /* unknown type */ +} + + +int ext_find_base(symbol **base,expr *p,section *sec,taddr pc) +{ + /* addr/256 equals >addr, addr%256 and addr&255 equal type==DIV || p->type==MOD) { + if (p->right->type==NUM && p->right->c.val==256) + p->type = p->type == DIV ? HIBYTE : LOBYTE; + } + else if (p->type==BAND && p->right->type==NUM && p->right->c.val==255) + p->type = LOBYTE; + + if (p->type==LOBYTE || p->type==HIBYTE) { + modifier = p->type; + return find_base(p->left,base,sec,pc); + } + return BASE_ILLEGAL; +} + + +void init_instruction_ext(instruction_ext *ext) +{ + ext->ocidx = OCSTD; + ext->dp = dpage; /* current DP defined by SETDP directive */ +} + + +operand *new_operand() +{ + operand *new = mymalloc(sizeof(*new)); + new->mode = 0; + return new; +} + + +static int parse_reg(char **start,uint32_t avail) +{ + char *s,*p; + int i,len; + + p = s = *start; + while (isalnum((unsigned char)*p)) + p++; + + if (!(len = p - s)) + return -1; + + for (i=0; iflags & AF_INDIR) != 0; + int preinc=0,postinc=0; + char *p = *start; + char c = *p; + uint32_t a; + int reg; + + switch (op->mode) { + case AM_NOFFS: + a = indir ? R_ICIX0 : R_DCIX0; + break; + case AM_ROFFS: + a = indir ? R_IAIX : R_DAIX; + break; + case AM_COFFS: + a = indir ? R_ICIDX : R_DCIDX; + break; + default: /* mode still unknown - allow all index variants */ + a = indir ? (R_ICIDX|R_IAIX) : (R_DCIDX|R_DAIX); + break; + } + + /* optional index pre-increment/decrement */ + if (c=='+' || c=='-') { + while (*p == c) { + if (c == '+') + preinc++; + else + preinc--; + p++; + } + } + + if ((reg = parse_reg(&p,indir?R_IIDX:R_DIDX)) < 0) + return 0; + + /* index register ok, now look for post-increment/decrement */ + c = *p; + if (preinc==0 && (c=='+' || c=='-')) { /* both would be strange */ + while (*p == c) { + if (c == '+') + postinc++; + else + postinc--; + p++; + } + } + + /* check if pre/post increment/decrements are valid for this register */ + switch (preinc) { + case -2: + a = indir ? R_IPDIX : R_PD2IX; + break; + case -1: + a = indir ? 0 : R_PD1IX; + break; + case 1: + a = indir ? 0 : R_PI1IX; + case 0: + break; + default: + a = 0; + break; + } + switch (postinc) { + case -1: + a = indir ? 0 : R_QD1IX; + break; + case 1: + a = indir ? 0 : R_QI1IX; + break; + case 2: + a = indir ? R_IQIIX : R_QI2IX; + case 0: + break; + default: + a = 0; + break; + } + if (!(registers[reg].avail & a)) + return 0; /* register does not support increment/decrement */ + + op->opreg = reg; + op->preinc = preinc; + op->postinc = postinc; + *start = p; + return 1; +} + + +int parse_operand(char *p,int len,operand *op,int required) +{ + static int rel_mode_map[] = { AM_REL8, AM_REL9, AM_REL16 }; + char *start = p; + int ret = PO_MATCH; + int indir = 0; + int mode,reg; + + p = skip(p); + + if (mode = required & OTMASK) { + /* instruction allows just a single operand type */ + char *s = p; + + if (p-start >= len) + return PO_NOMATCH; /* empty operand */ + + switch (mode) { + case DT1: + if (*p == '#') /* # is optional here */ + p = skip(++p); + op->mode = AM_IMM8; + op->value = parse_expr(&p); + break; + + case RLS: + case RLD: + case RLL: + /* read an expression, symbol or label */ + op->mode = rel_mode_map[mode-RLS]; + case DTA: + op->value = parse_expr(&p); + break; + + case TFR: + /* transfer/exchange registers */ + if ((reg = parse_reg(&p,R_IRP)) < 0) + return PO_NOMATCH; + op->mode = AM_TFR; + op->opreg = reg; + break; + + case TFM: + /* transfer memory pointer-register, with increment or decrement */ + if ((reg = parse_reg(&p,R_IRP)) < 0) + return PO_NOMATCH; + if (required & (TFM_PLUS|TFM_MINUS)) { + if (((required & TFM_PLUS) && *p=='+') || + ((required & TFM_MINUS) && *p=='-')) + p++; + else + return PO_NOMATCH; + } + op->mode = AM_TFR; + op->opreg = reg; + break; + + case PPL: + /* read next register for a comma-separated register list */ + if ((reg = parse_reg(&p,R_STK)) < 0) + return PO_NOMATCH; + if ((reg = psh_postbyte_map[registers[reg].value]) < 0) + ierror(0); + op->mode = AM_REGXB; + op->curval |= reg; /* encode for PSH/PUL postbyte */ + ret = PO_AGAIN; /* do it again until out of operands */ + break; + + case BMR: + /* read register for bit manipulation instruction */ + if ((reg = parse_reg(&p,R_BMP)) < 0) + return PO_NOMATCH; + op->mode = AM_BITR; + op->opreg = reg; + break; + + case BIT: + /* bit number */ + op->mode = AM_BITN; + op->value = parse_expr(&p); + break; + + case DBR: + /* read register for bit DBcc/IBcc/TBcc instructions */ + if ((reg = parse_reg(&p,R_DBR)) < 0) + return PO_NOMATCH; + op->mode = AM_DBR; + op->opreg = reg; + break; + + default: + ierror(0); + break; + } + + if (p-s == 0) + return PO_NOMATCH; /* nothing read */ + + p = skip(p); + if (p-start < len) { + cpu_error(0); /* trailing garbage */ + return PO_CORRUPT; + } + return ret; + } + + else { + /* immediate, direct, extended and indexed modes may be combined */ + mode = AM_NONE; + op->opreg = -1; + + if (p-start >= len) { + /* empty operand */ + if (!op->mode && (required & IDX0)) { + op->mode = AM_NOFFS; + return PO_AGAIN; /* may be a ,R addressing mode without offset */ + } + return PO_NOMATCH; + } + + if (*p == '#') { + if (required & IMM) { + /* immediate addressing mode */ + p = skip(++p); + op->value = parse_expr(&p); + mode = (required & IM1) ? + AM_IMM8 : ((required & IM2) ? AM_IMM16 : AM_IMM32); + } + else + return PO_NOMATCH; + } + else if (*p == '[') { + if (required & IND) { + /* indirect indexed addressing mode */ + p = skip(++p); + op->flags |= AF_INDIR; + indir = 1; + } + else + return PO_NOMATCH; + } + + if (!op->mode && (required & (IDX0|IIXR))) { + /* check for direct/indirect offset register */ + if ((reg = parse_reg(&p,indir?R_IOFF:R_DOFF)) >= 0) { + op->offs_reg = reg; + mode = AM_ROFFS; + p = skip(p); + } + } + + if (!op->mode && !mode && p-startflags |= AF_LO; /* remember '<' hint */ + p = skip(++p); + mode = AM_DIR; + } + else if ((required & DIR) && !(required & EXT)) + mode = AM_DIR; + else if ((required & EXT) && *p=='>') { + op->flags |= AF_HI; /* remember '>' hint */ + p = skip(++p); + mode = AM_EXT; + } + else if ((required & EXT) && !(required & DIR)) + mode = AM_EXT; + else if (required & MEM) { + if (*p == '<') { + op->flags |= AF_LO; /* remember '<' hint */ + p = skip(++p); + } + else if (*p == '>') { + op->flags |= AF_HI; /* remember '>' hint */ + p = skip(++p); + } + mode = AM_ADDR; /* size unknown, will become AM_DIR or AM_EXT */ + } + else + return PO_NOMATCH; + + op->value = parse_expr(&p); + } + + /* handle the index register part right of the comma */ + if (indir) { + if (*p == ',') { + /* indirect addressing mode has an index register */ + p = skip(++p); + if (!mode) + mode = AM_NOFFS; + else if (mode != AM_ROFFS) + mode = AM_COFFS; + if (!read_index(&p,op)) { + cpu_error(2); /* missing valid index reg. */ + return PO_CORRUPT; + } + p = skip(p); + } + else if (!(cpu_type & HC12) && + (mode==AM_DIR || mode==AM_ADDR || mode==AM_EXT)) + mode = AM_EXT; + else + ret = PO_NOMATCH; + + if (*p++ != ']') { + cpu_error(1); /* ] expected */ + return PO_CORRUPT; + } + } + else if (op->mode) { + /* continue parsing the same operand with a new argument */ + + switch (op->mode) { + case AM_NOFFS: + case AM_ROFFS: + case AM_COFFS: + case AM_DIR: + case AM_EXT: + case AM_ADDR: + /* read second part of indirect addressing mode */ + if (!(read_index(&p,op))) + return PO_NEXT; /* no index found - continue with next operand */ + mode = (op->mode >= AM_NOFFS) ? op->mode : AM_COFFS; + break; + + default: + ierror(0); + return PO_CORRUPT; + } + } + else if (!op->mode && (required & (IDX0|IDX1|IDX2))) { + /* certain indexed addressing modes might need a second pass */ + + switch (mode) { + case AM_NOFFS: + case AM_ROFFS: + case AM_COFFS: + case AM_DIR: + case AM_EXT: + case AM_ADDR: + ret = PO_AGAIN; + break; + } + } + } + + p = skip(p); + if (p-start < len) { + cpu_error(0); /* trailing garbage */ + return PO_CORRUPT; + } + + op->mode = mode; + return ret; +} + + +char *parse_cpu_special(char *start) +{ + char *name=start,*s=start; + + if (ISIDSTART(*s)) { + s++; + while (ISIDCHAR(*s)) + s++; + + if (dotdirs && *name=='.') + ++name; + + if (s-name==5 && !strnicmp(name,"setdp",5)) { + utaddr dp; + s = skip(s); + dp = (utaddr)parse_constexpr(&s); + if (dp > 0xff) + dp >>= 8; + if (!(cpu_type & HC12)) + dpage = dp; + else + cpu_error(16); /* setdp ignored on HC12 */ + eol(s); + return skip_line(s); + } + else if (s-name==6 && !strnicmp(name,"direct",6)) { + char *name; + s = skip(s); + if (name = parse_identifier(&s)) { + symbol *sym = new_import(name); + myfree(name); + if (!(cpu_type & HC12)) + sym->flags |= DPAGESYM; + else + cpu_error(16); /* dpage ignored on HC12 */ + eol(s); + } + else + cpu_error(8); /* identifier expected */ + return skip_line(s); + } + } + return start; +} + + +static void check_opreg(operand *op,int final) +{ + if (op->opreg < 0) { + if (final) + cpu_error(2); /* missing valid index register */ + op->opreg = 0; + } +} + + +static size_t process_instruction(instruction *ip,section *sec, + taddr orig_pc,int final) +{ + static int coffs_size[4] = { 0,1,1,2 }; /* OFF5,OFF8,OFF9,OFF16 */ + static int rel_size[3] = { 1,1,2 }; /* REL8,REL9,REL16 */ + static int mov_val_offs[4] = { -1,-2,1,2 }; /* IMMIDX,EXTIDX,IDXIDX,IDXEXT */ + static int mov_pc_offs[4] = { 1,2,1,2 }; /* IMMIDX,EXTIDX,IDXIDX,IDXEXT */ + taddr pc = orig_pc; + taddr pcd; + operand *op; + int ocidx = -1; + int mcvoff = 0; /* curval offset for mov pc-addressing mode */ + int mpcoff = 0; /* pc offset for mov pc-addressing mode */ + int i,j,btype; + + /* evaluate all expressions */ + for (i=0; iop[i]) == NULL) + break; + op->base = NULL; + + if (op->value != NULL) { + if (!eval_expr(op->value,&op->curval,sec,pc)) { + modifier = 0; + btype = find_base(op->value,&op->base,sec,pc); + if (btype==BASE_PCREL && modifier==0) { + switch (op->mode) { + case AM_IMM8: + case AM_IMM16: + case AM_IMM32: + op->flags |= AF_PC; /* create a PC-relative relocation */ + break; + } + } + if (final) { + if (btype==BASE_ILLEGAL || + (btype==BASE_PCREL && !(op->flags & AF_PC))) + general_error(38); /* illegal relocation */ + } + if (modifier) { + if (op->flags & (AF_LO|AF_HI)) + cpu_error(17); /* double size modifier ignored */ + switch (modifier) { + case LOBYTE: op->flags |= AF_LO; break; + case HIBYTE: op->flags |= AF_HI; break; + } + } + } + } + } + + if (mnemonics[ip->code].ext.flags & MOVE) { + for (i=0,j=0; iop[i] == NULL) { + if (i != 2) + ierror(0); /* movb/movw must have two operands */ + break; + } + switch (ip->op[i]->mode) { + case AM_COFFS: + case AM_NOFFS: + case AM_ROFFS: + mpcoff = 1; /* found an indexed addressing mode */ + j += i ? 0 : 2; + break; + case AM_EXT: + j++; + break; + } + } + if (mpcoff) { + /* corrective offsets for mov PC-relative addressing */ + mcvoff = mov_val_offs[j]; + mpcoff = mov_pc_offs[j]; + if (j < 2) { + /* swap operands to make sure indexed addressing is processed first */ + op = ip->op[0]; + ip->op[0] = ip->op[1]; + ip->op[1] = op; + if (j==0 && ip->op[0]->mode==AM_IMM16) { + mcvoff <<= 1; /* double offsets for 16-bit immediate */ + mpcoff <<= 1; + } + } + } + } + else { + /* determine opcode type from operands */ + for (i=0; iop[i] == NULL) + break; + switch (ip->op[i]->mode) { + case AM_DIR: + if (ocidx >= 0) ierror(0); + ocidx = OCDIR; + break; + case AM_ADDR: /* treat as EXT, while unknown */ + case AM_EXT: + if (ocidx >= 0) ierror(0); + ocidx = (ip->op[i]->flags & AF_INDIR) ? OCIDX : OCEXT; + break; + case AM_COFFS: + case AM_NOFFS: + case AM_ROFFS: + if (ocidx >= 0) ierror(0); + ocidx = OCIDX; + break; + } + } + } + if (ocidx < 0) + ocidx = OCSTD; + pc += (mnemonics[ip->code].ext.opcode[ocidx] > 0xff ? 2 : 1); + + /* optimize and get operand sizes */ + for (i=0; iop[i]) == NULL) + break; + + switch (op->mode) { + case AM_ADDR: + /* convert to either AM_DIR or AM_EXT, depending on address size */ + if ((!op->base && (utaddr)op->curval>=(ip->ext.dp<<8) && + (utaddr)op->curval<=(ip->ext.dp<<8)+0xff) || + (op->base && (op->base->flags&DPAGESYM))) { + op->curval &= 0xff; + op->mode = AM_DIR; + ocidx = OCDIR; + pc++; + break; + } + else + op->mode = AM_EXT; /* always EXT, when exact address is unknown */ + case AM_EXT: + if (op->flags & AF_INDIR) { + if (opt_pc && (mnemonics[ip->code].operand_type[i] & IND)) { + /* [ext] -> [rel,PC] */ + ocidx = OCIDX; + op->mode = AM_COFFS; + op->opreg = RIDX_PC; + goto do_coffs; + } + pc++; /* postbyte for indirect */ + } + else { + if ((opt_bra || opt_pc) && *mnemonics[ip->code].name=='j') { + /* jmp/jsr optimizations */ + if (!(op->base && is_pc_reloc(op->base,sec))) { + /* try optimizing jmp/jsr EXT to bra/bsr REL8 */ + pcd = op->curval - (pc + 2); + if (pcd>=-129 && pcd<=127) { + ip->code = mnemonics[ip->code].name[1]=='s' ? OC_BSR : OC_BRA; + ocidx = OCSTD; + op->mode = AM_REL8; + op->flags |= AF_PC | AF_PCREL; + pcd++; /* adjust for EXT -> REL8 */ + goto rel_final; + } + } + if (opt_pc) { + /* jmp/jsr -> lbra/lbsr, even when slower/larger */ + int oc; + + if (oc = mnemonics[ip->code].name[1]=='s' ? OC_LBSR : OC_LBRA) { + ip->code = oc; + ocidx = OCSTD; + op->mode = AM_REL16; + if (cpu_type & HC12) + pc++; /* LBRA opcode needs additional byte on HC12 */ + goto do_rel; + } + } + } + if (opt_pc && op->base!=NULL && + (mnemonics[ip->code].operand_type[i] & DIX)) { + /* ext -> rel,PC */ + ocidx = OCIDX; + op->mode = AM_COFFS; + op->opreg = RIDX_PC; + goto do_coffs; + } + } + pc++; + case AM_DIR: + pc++; + break; + + case AM_TFR: + if (i != 0) /* only the first TFR operand generates a byte */ + break; + case AM_NOFFS: + if ((cpu_type & HC12) && (op->flags & AF_INDIR)) { + /* [,r] -> [0,r] is always 16 bit on the HC12 */ + op->flags |= AF_OFF16; + pc += 2; + } + case AM_ROFFS: + check_opreg(op,final); + case AM_IMM8: + case AM_REGXB: + case AM_BITR: + pc++; + case AM_BITN: + case AM_DBR: + break; + + case AM_IMM16: + pc += 2; + break; + + case AM_IMM32: + pc += 4; + break; + + case AM_COFFS: + /* indexed with constant offset - determine optimal offset size */ + do_coffs: + op->flags &= ~AF_COSIZ; + pc++; /* the postbyte is always there */ + + if (i) { + mcvoff = -mcvoff; /* a second postbyte would negate this offset */ + mpcoff = 0; /* a second postbyte invalidates this offset */ + } + + check_opreg(op,final); + + if (registers[op->opreg].value == REG_PC) { + /* PC-relative */ + int secrel = (sec->flags & ABSOLUTE) ? op->base==NULL : + op->base!=NULL && LOCREF(op->base) && op->base->sec==sec; + + op->flags |= AF_PC; + if (secrel) { + /* calculate PC-relative distance to known label/address, + assume worst case of 16-bit distance at first */ + pcd = (op->curval + mcvoff) - (pc + 2 + mpcoff); + op->flags |= AF_PCREL; + } + else + pcd = op->curval + mcvoff; + + if (final && (pcd>0xffff || pcd<-0x8000)) + cpu_error(3,(long)pcd); /* pc-relative offset out of range */ + + if (op->base && is_pc_reloc(op->base,sec)) { + /* external symbol or label from different section usually + needs 16 bits, except there was a '<' size selector */ + if (cpu_type & HC12) + op->flags |= (op->flags&AF_LO) ? AF_OFF9 : AF_OFF16; /* @@@ */ + else + op->flags |= (op->flags&AF_LO) ? AF_OFF8 : AF_OFF16; + } + else { + if (cpu_type & HC12) { + if (!(op->flags & AF_INDIR) && pcd>=-18 && pcd<=15) { + if (secrel) + pcd = (op->curval + mcvoff) - (pc + mpcoff); + op->flags |= AF_OFF5; + } + else if (!(op->flags & AF_INDIR) && pcd>=-257 && pcd<=255) { + if (secrel) + pcd = op->curval - (pc + 1); + op->flags |= AF_OFF9; + } + else + op->flags |= AF_OFF16; + } + else { /* 6809/6309 */ + if (op->flags & AF_LO) { + if (secrel) + pcd = op->curval - (pc + 1); + op->flags |= AF_OFF8; + if (final && (pcd<-128 || pcd>127)) + cpu_error(3,(long)pcd); /* pc-rel. offset out of range */ + } + else if (!(op->flags&AF_HI) && pcd>=-129 && pcd<=127) { + if (secrel) + pcd = op->curval - (pc + 1); + op->flags |= AF_OFF8; + } + else + op->flags |= AF_OFF16; + } + } + op->curval = pcd; /* update curval */ + } + + else { + /* constant offset */ + taddr val = bf_sign_extend(op->curval,16); + + if (final && (val>0xffff || val<-0x8000)) + cpu_error(4,(long)val); /* constant offset out of range */ + + if (cpu_type & HC12) { + if (op->preinc || op->postinc) { + if (final && (val<1 || val>8)) + cpu_error(5,(int)val); /* bad auto decr./incr. value */ + if (final && (op->flags & AF_INDIR)) { + cpu_error(6); /* indirect addressing not allowed */ + op->flags &= ~AF_INDIR; + } + } + else if (!(op->flags & AF_INDIR) && val>=-16 && val<=15) + op->flags |= AF_OFF5; + else if (!(op->flags & AF_INDIR) && val>=-256 && val<=255) + op->flags |= AF_OFF9; + else + op->flags |= AF_OFF16; + } + else { /* 6809/6309 */ + int wreg = registers[op->opreg].value == REG_W; + int abs = op->base == NULL; + + if (op->preinc || op->postinc) { + if (final) + cpu_error(7); /* auto increment/decrement not allowed */ + op->preinc = op->postinc = 0; + } + + if (opt_off && val==0 && abs) { + /* 0,R -> ,R */ + op->mode = AM_NOFFS; + if (final) + free_expr(op->value); + op->value = NULL; + } + else if ((op->flags & AF_LO) && !wreg) { + op->flags |= AF_OFF8; + if (final && (val<-128 || val>127)) + cpu_error(4,(long)val); /* constant offset out of range */ + } + else if (op->flags & AF_HI) + op->flags |= AF_OFF16; + else if (!(op->flags & AF_INDIR) && + abs && val>=-16 && val<=15 && !wreg) + op->flags |= AF_OFF5; + else if (abs && val>=-128 && val<=127 && !wreg) + op->flags |= AF_OFF8; + else + op->flags |= AF_OFF16; + } + } + + pc += coffs_size[op->flags & AF_COSIZ]; + break; + + case AM_REL8: + case AM_REL9: + case AM_REL16: + do_rel: + if (op->base && is_pc_reloc(op->base,sec)) { + pcd = op->curval; /* reloc addend */ + op->flags |= AF_PC; + } + else { + pcd = op->curval - (pc + rel_size[op->mode-AM_REL8]); + op->flags |= AF_PC | AF_PCREL; + } + + /* optimize/translate Bcc and LBcc instructions */ + if (opt_bra && i==0 && (op->flags & AF_PCREL)) { + int ocsz_diff = pc - orig_pc; /* init with current opcode size */ + + switch (op->mode) { + case AM_REL8: + if ((pcd<-128 || pcd>127) && + (mnemonics[ip->code+2].operand_type[0] & OTMASK) == RLL) { + op->mode = AM_REL16; + ip->code += 2; + ocsz_diff = (mnemonics[ip->code].ext.opcode[OCSTD]>0xff? 2 : 1) + - ocsz_diff; + pc += ocsz_diff; /* LBcc opcode may be larger */ + pcd -= 1 + ocsz_diff; /* adjust for LBcc and 16-bit branch */ + } + break; + case AM_REL16: + if ((pcd>=-129 && pcd<=127) && + (mnemonics[ip->code-2].operand_type[0] & OTMASK) == RLS) { + op->mode = AM_REL8; + ip->code -= 2; + ocsz_diff = 1 - ocsz_diff; + pc += ocsz_diff; /* Bcc opcode may be smaller */ + pcd += 1 - ocsz_diff; /* adjust for Bcc and 8-bit branch */ + } + break; + } + } + + rel_final: + if (final) { + switch (op->mode) { + case AM_REL8: + if (pcd<-128 || pcd>127) + cpu_error(8,(long)pcd); /* short branch out of range */ + break; + case AM_REL9: + if (pcd<-256 || pcd>255) + cpu_error(9,(long)pcd); /* decrement branch out of range */ + break; + case AM_REL16: + if (pcd<-0x8000 || pcd>0xffff) + cpu_error(10,(long)pcd); /* long branch out of range */ + break; + } + } + op->curval = pcd; + pc += rel_size[op->mode-AM_REL8]; + break; + + default: + ierror(0); + break; + } + } + + ip->ext.ocidx = ocidx; + return pc - orig_pc; +} + + +size_t instruction_size(instruction *ip,section *sec,taddr pc) +{ + return process_instruction(copy_inst(ip),sec,pc,0); +} + + +dblock *eval_instruction(instruction *ip,section *sec,taddr pc) +{ + dblock *db = new_dblock(); + operand *op; + int offs = 1; + rlist *rl; + int16_t oc; + uint8_t *d; + taddr val; + int i,ocsz; + + /* execute all optimizations for real and determine final size */ + db->size = process_instruction(ip,sec,pc,1); + d = db->data = mymalloc(db->size); + + /* write one or two opcode bytes */ + oc = mnemonics[ip->code].ext.opcode[ip->ext.ocidx]; + if (oc == NA) { + cpu_error(18); /* addressing mode not supported */ + return db; + } + if (oc > 0xff) { + *d++ = oc >> 8; + offs++; + } + *d++ = oc; + ocsz = offs; + + for (i=0; iop[i]) == NULL) + break; + val = op->curval; + + if (op->base!=NULL && (op->flags & AF_PC)) { + switch (op->mode) { + case AM_IMM8: + case AM_IMM16: + case AM_IMM32: + /* late fix for BASE_PCREL, taking reloc-position into account */ + val += offs; + break; + } + } + + switch (op->mode) { + case AM_DIR: + case AM_IMM8: + if (op->base) { + rl = add_extnreloc(&db->relocs,op->base,val, + (op->flags&AF_PC)?REL_PC:REL_ABS,0,8,offs); + if (op->flags & AF_LO) { + ((nreloc *)rl->reloc)->mask = 0xff; + val &= 0xff; + } + else if (op->flags & AF_HI) { + ((nreloc *)rl->reloc)->mask = 0xff00; + val = (val >> 8) & 0xff; + } + } + if (val<-0x80 || val>0xff) + cpu_error(15,8); /* immediate expression doesn't fit */ + *d++ = val; + offs++; + break; + + case AM_REL9: + if (op->base && is_pc_reloc(op->base,sec)) { + val -= 2; /* reloc addend adjustment */ + add_extnreloc_masked(&db->relocs,op->base,val,REL_PC, + 3,1,offs-1,0x100); + add_extnreloc_masked(&db->relocs,op->base,val,REL_PC, + 8,8,offs-1,0xff); + } + if (val < 0) + *(db->data+1) |= 0x10; /* set sign-bit in extbyte */ + *d++ = val; + offs++; + break; + + case AM_REL8: + if (op->base && is_pc_reloc(op->base,sec)) { + val--; /* reloc addend adjustment */ + add_extnreloc(&db->relocs,op->base,val,REL_PC,0,8,offs); + } + *d++ = val; + offs++; + break; + + case AM_REL16: + if (op->base && is_pc_reloc(op->base,sec)) { + val -= 2; /* reloc addend adjustment */ + add_extnreloc(&db->relocs,op->base,val,REL_PC,0,16,offs); + } + *d++ = val >> 8; + *d++ = val; + offs += 2; + break; + + case AM_REGXB: + *d++ = op->curval; + offs++; + break; + + case AM_TFR: + if (offs == ocsz) { + *d++ = (cpu_type & HC12) ? + ir_postbyte_map12[registers[op->opreg].value]<<4 : + ir_postbyte_map09[registers[op->opreg].value]<<4; + offs++; + } + else { + *(d-1) |= (cpu_type & HC12) ? + ir_postbyte_map12[registers[op->opreg].value] : + ir_postbyte_map09[registers[op->opreg].value]; + } + break; + + case AM_BITR: + *d++ = bitm_postbyte_map[registers[op->opreg].value] << 6; + offs++; + break; + + case AM_BITN: + if (val<0 || val>7) + cpu_error(13,(int)val); /* illegal bit number */ + + if (offs==ocsz+1 && ip->op[0]->mode==AM_BITR) { + if (op->base) { + if (op->flags & (AF_HI|AF_LO)) + general_error(38); /* illegal relocation */ + else + add_extnreloc(&db->relocs,op->base,val,REL_ABS, + i==1?2:5,3,offs-1); + } + switch (i) { + case 1: + *(d-1) |= (val&7) << 3; + break; + case 2: + *(d-1) |= (val&7); + break; + default: + ierror(0); + break; + } + } + else + ierror(0); + break; + + case AM_DBR: + *(db->data+1) |= dbr_postbyte_map[registers[op->opreg].value]; + break; + + case AM_EXT: + if (op->flags & AF_INDIR) { + *d++ = 0x9f; /* [ext] needs postbyte */ + offs++; + } + case AM_IMM16: + if (op->base) + add_extnreloc(&db->relocs,op->base,val, + (op->flags&AF_PC)?REL_PC:REL_ABS,0,16,offs); + if (val<-0x8000 || val>0xffff) + cpu_error(15,16); /*immediate expression doesn't fit */ + *d++ = val >> 8; + *d++ = val; + offs += 2; + break; + + case AM_IMM32: + if (op->base) + add_extnreloc(&db->relocs,op->base,val, + (op->flags&AF_PC)?REL_PC:REL_ABS,0,32,offs); + *d++ = val >> 24; + *d++ = val >> 16; + *d++ = val >> 8; + *d++ = val; + offs += 4; + break; + + case AM_NOFFS: + if (cpu_type & HC12) { + /* this addressing mode does not exist on the HC12 */ + cpu_error(14); /* omitted offset taken as 5-bit zero offset */ + op->mode = AM_COFFS; + op->base = NULL; + val = 0; + goto gen_coffs; + } + else { /* 6809/6309 */ + if (registers[op->opreg].value == REG_W) { + *d = (op->flags & AF_INDIR) ? 0x90 : 0x8f; + if (op->postinc) + *d |= 0x40; + else if (op->preinc) + *d |= 0x60; + } + else { + *d = idx_postbyte_map09[registers[op->opreg].value] | + ((op->flags & AF_INDIR) ? 0x90 : 0x80); + if (op->preinc < 0) + *d |= (-op->preinc) + 1; + else if (op->postinc > 0) + *d |= op->postinc - 1; + else + *d |= 4; + } + } + d++; + offs++; + break; + + case AM_ROFFS: + if (cpu_type & HC12) { + *d++ = 0xe4 | (idx_postbyte_map12[registers[op->opreg].value]<<3) | + ((op->flags & AF_INDIR) ? 0x03 : + offs_postbyte_map12[registers[op->offs_reg].value]); + } + else { /* 6809/6309 */ + *d++ = idx_postbyte_map09[registers[op->opreg].value] | + offs_postbyte_map09[registers[op->offs_reg].value] | + ((op->flags & AF_INDIR) ? 0x90 : 0x80); + } + offs++; + break; + + case AM_COFFS: + gen_coffs: + { + static int boff[4] = { 3,0,7,0 }; + static int bsiz[4] = { 5,8,9,16 }; + static int offa[4] = { 0,1,0,1 }; + int cosz = op->flags & AF_COSIZ; + + if (cpu_type & HC12) { + if (!(op->flags & AF_INDIR)) { + if (op->preinc || op->postinc) { + /* n,-r n,+r n,r- n,r+ */ + uint8_t xb = 0x20; + int p; + + if (op->base) { + general_error(38); /* illegal relocation */ + op->base = NULL; + } + if (p = op->postinc) + xb = 0x30; + else + p = op->preinc; + if (p < 0) + val = -val & 15; + else + val--; + *d = xb | (idx_postbyte_map12[registers[op->opreg].value]<<6); + } + else { + /* n,r -n,r (5, 9, 16 bits) */ + if (cosz == AF_OFF5) + *d = idx_postbyte_map12[registers[op->opreg].value] << 6; + else + *d = (cosz==AF_OFF16 ? 0xe2 : 0xe0) | + (idx_postbyte_map12[registers[op->opreg].value] << 3); + } + } + else + *d = 0xe3 | (idx_postbyte_map12[registers[op->opreg].value]<<3); + } + else { /* 6809/6309 */ + if (registers[op->opreg].value == REG_W) { + *d = (op->flags & AF_INDIR) ? 0xb0 : 0xaf; + } + else { + if (registers[op->opreg].value == REG_PC) { + *d = (op->flags & AF_INDIR) ? 0x9c : 0x8c; + } + else { + *d = idx_postbyte_map09[registers[op->opreg].value]; + if (cosz != AF_OFF5) + *d |= (op->flags & AF_INDIR) ? 0x98 : 0x88; + } + *d |= cosz == AF_OFF16; + } + } + + if (op->base!=NULL && + (!(op->flags & AF_PC) || is_pc_reloc(op->base,sec))) { + int rtyp = (op->flags & AF_PC) ? REL_PC : REL_ABS; + + if (rtyp == REL_PC) + val -= cosz==AF_OFF16 ? 2 : 1; /* fix addend for reloc */ + add_extnreloc(&db->relocs,op->base,val,rtyp, + boff[cosz],bsiz[cosz],offs+offa[cosz]); + } + switch (cosz) { + case AF_OFF5: + *d |= val & 0x1f; + d++; + offs++; + break; + case AF_OFF8: + d++; + *d++ = val; + offs += 2; + break; + case AF_OFF9: + *d++ |= (val >> 8) & 1; + *d++ = val; + offs += 2; + break; + case AF_OFF16: + d++; + *d++ = val >> 8; + *d++ = val; + offs += 3; + break; + } + } + break; + + default: + ierror(0); + break; + } + } + if (offs != db->size) + ierror(0); + + return db; +} + + +dblock *eval_data(operand *op,size_t bitsize,section *sec,taddr pc) +{ + dblock *db = new_dblock(); + taddr val; + + if (bitsize!=8 && bitsize!=16 && bitsize!=32) + cpu_error(11,bitsize); /* data size not supported */ + + db->size = bitsize >> 3; + db->data = mymalloc(db->size); + + if (!eval_expr(op->value,&val,sec,pc)) { + symbol *base; + int btype; + rlist *rl; + + modifier = 0; + btype = find_base(op->value,&base,sec,pc); + if (btype==BASE_OK || (btype==BASE_PCREL && modifier==0)) { + rl = add_extnreloc(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS,0,bitsize,0); + switch (modifier) { + case LOBYTE: + if (rl) + ((nreloc *)rl->reloc)->mask = 0xff; + val = val & 0xff; + break; + case HIBYTE: + if (rl) + ((nreloc *)rl->reloc)->mask = 0xff00; + val = (val >> 8) & 0xff; + break; + } + } + else if (btype != BASE_NONE) + general_error(38); /* illegal relocation */ + } + + if (bitsize < 16) { + if (val<-0x80 || val>0xff) + cpu_error(12,8); /* data doesn't fit into 8-bits */ + } else if (bitsize < 32) { + if (val<-0x8000 || val>0xffff) + cpu_error(12,16); /* data doesn't fit into 16-bits */ + } + + setval(1,db->data,db->size,val); + return db; +} + + +int cpu_available(int idx) +{ + return (mnemonics[idx].ext.flags & cpu_type) != 0; +} + + +int init_cpu() +{ + int i; + + for (i=0; i' */ +int ext_unary_eval(int,taddr,taddr *,int); +int ext_find_base(symbol **,expr *,section *,taddr); +#define LOBYTE (LAST_EXP_TYPE+1) +#define HIBYTE (LAST_EXP_TYPE+2) +#define EXT_UNARY_NAME(s) (*s=='<'||*s=='>') +#define EXT_UNARY_TYPE(s) (*s=='<'?LOBYTE:HIBYTE) +#define EXT_UNARY_EVAL(t,v,r,c) ext_unary_eval(t,v,r,c) +#define EXT_FIND_BASE(b,e,s,p) ext_find_base(b,e,s,p) + + +/* type to store each operand */ +typedef struct { + int8_t mode; + uint8_t flags; + int8_t opreg; /* single register or register list */ + int8_t offs_reg; /* accumulator A, B or D (E, F, W) */ + int8_t preinc,postinc; /* -R, +R, R-, R+, --R, R++ */ + expr *value; + symbol *base; + taddr curval; +} operand; + +/* addressing modes */ +enum { + AM_NONE=0, + AM_IMM8, + AM_IMM16, + AM_IMM32, + AM_ADDR, /* will become AM_DIR or AM_EXT later */ + AM_DIR, + AM_EXT, + AM_NOFFS, /* warning: xOFFS must be higher than ADDR/DIR/EXT! */ + AM_COFFS, + AM_ROFFS, + AM_REL8, /* warning: do not change order of REL8, REL9, REL16! */ + AM_REL9, + AM_REL16, + AM_REGXB, + AM_TFR, + AM_BITR, + AM_BITN, + AM_DBR +}; + +/* addressing mode flags */ +#define AF_COSIZ 0x03 /* mask for constant offset size */ +#define AF_OFF5 0 +#define AF_OFF8 1 +#define AF_OFF9 2 +#define AF_OFF16 3 +#define AF_INDIR (1<<2) +#define AF_PC (1<<3) +#define AF_PCREL (1<<4) /* curval is calculated relative to PC */ +#define AF_LO (1<<5) /* expression with '<'-prefix */ +#define AF_HI (1<<6) /* expression with '>'-prefix */ + + +/* additional mnemonic data */ +typedef struct { + uint16_t opcode[4]; /* opcodes for different addr. modes */ + uint16_t flags; +} mnemonic_extension; + +#define NA ~0 /* mnemo-tab: addressing mode not available */ + +/* opcodes */ +#define OCSTD 0 /* inherent, relative or immediate */ +#define OCDIR 1 /* direct page addressing mode: $12 */ +#define OCIDX 2 /* indexed addressing mode exp,R */ +#define OCEXT 3 /* extended addressing mode: $1234 */ + +/* flags: cpu instructions */ +#define M6809 (1<<0) /* 6809 is default */ +#define HD6309 (1<<1) /* 6309: new registers, additional instr. */ +#define HC12 (1<<2) /* standard 68HC12 instruction set */ +/* other flags */ +#define MOVE (1<<15) /* movb, movw instruction */ + + +/* operand types */ + +/* single operand types per instruction */ +#define INH 0 /* -- inherent - no operand */ +#define DTA 1 /* any 8/16/32-bit data */ +#define DT1 2 /* 8-bit value/mask */ +#define RLS 3 /* rr relative 8-bit short branch */ +#define RLD 4 /* rr relative 9-bit loop branch */ +#define RLL 5 /* qq rr relative 16-bit long branch */ +#define TFR 6 /* xb transfer registers */ +#define TFM 7 /* xb transfer memory */ +#define PPL 8 /* xb push/pull register list */ +#define BMR 9 /* bit manipulation register */ +#define BIT 10 /* bit number 0-7 */ +#define DBR 11 /* dbcc,ibcc,tbcc register */ +#define OTMASK 0xf /* lowest four bits for single modes */ + +/* flags for TFM and pseudo modes with these flags */ +#define TFM_PLUS (1<<14) /* r+ */ +#define TFM_MINUS (1<<15) /* r- */ +#define TMP (TFM|TFM_PLUS) +#define TMM (TFM|TFM_MINUS) + +/* the remaining operand types may be combined */ +#define IM1 (1<<4) /* ii immediate 8-bit: #$12 */ +#define IM2 (1<<5) /* jj kk immediate 16-bit: #$1234 */ +#define IM4 (1<<6) /* jj kk ll mm immediate 32-bit: #$12345678 */ +#define DIR (1<<7) /* dd direct page: $12 */ +#define IDX0 (1<<8) /* xb indexed 5-bit or register offset */ +#define IDX1 (1<<9) /* xb ff indexed 8/9-bit */ +#define IDX2 (1<<10) /* xb ee ff indexed 16-bit */ +#define IIXN (1<<11) /* xb indir. indexed no offs. or auto-incr. */ +#define IIXC (1<<12) /* xb ee ff indirect indexed 8/16-bit offset */ +#define IIXR (1<<13) /* xb indirect indexed register-offset */ +#define EXT (1<<14) /* hh ll extended: $1234 */ + +#define IND (IIXN|IIXC|IIXR) /* indirect indexed */ +#define DIX (IDX0|IDX1|IDX2) /* direct indexed */ +#define IDX (DIX|IND) /* all indexed */ +#define AL1 (IM1|DIR|IDX|EXT) /* all with 8bit imm. */ +#define AL2 (IM2|DIR|IDX|EXT) /* all with 16bit imm. */ +#define AL4 (IM4|DIR|IDX|EXT) /* all with 32bit imm. */ +#define MEM (DIR|IDX|EXT) /* memory addr. only */ +#define MNI (DIR|DIX|EXT) /* non-indirect memory */ +#define IXE (IDX|EXT) /* indexed and extended */ +#define IX0 (IDX0|IIXN|IIXR) /* indexed xb only */ +#define DI0 IDX0 /* direct indexed xb only */ +#define IMM (IM1|IM2|IM4) /* all immeditate */ + + +/* CPU registers */ +enum { + REG_D=0,REG_X=1,REG_Y=2,REG_U=3, + REG_S=4,REG_PC=5,REG_W=6,REG_V=7, + REG_A=8,REG_B=9,REG_CC=10,REG_DP=11, + REG_0=13,REG_E=14,REG_F=15 +}; + +struct CPUReg { + char name[4]; + int len; + int16_t value; + uint32_t avail; + uint16_t cpu; /* compares with cpu_type for availability */ +}; + +/* avail: defines in which situations the register is available */ +#define R_DCIX0 (1<<0) /* index reg. without constant offset */ +#define R_DCIX5 (1<<1) /* index reg. with 5-bit constant offset */ +#define R_DCIX8 (1<<2) /* index reg. with 8-bit constant offset */ +#define R_DCIX16 (1<<3) /* index reg. with 16-bit constant offset */ +#define R_ICIX0 (1<<4) /* indir. index reg. without const. offset */ +#define R_ICIX8 (1<<5) /* indir. index reg. with 8-bit const. offs. */ +#define R_ICIX16 (1<<6) /* indir. index reg. with 16-bit const. offs. */ +#define R_PI1IX (1<<7) /* index reg. with byte pre-incr. */ +#define R_PD1IX (1<<8) /* index reg. with byte pre-decr. */ +#define R_PD2IX (1<<9) /* index reg. with word pre-decr. */ +#define R_QI1IX (1<<10) /* index reg. with byte post-incr. */ +#define R_QI2IX (1<<11) /* index reg. with word post-incr. */ +#define R_QD1IX (1<<12) /* index reg. with byte post-decr. */ +#define R_IPDIX (1<<13) /* indirect index reg. with word pre-decr. */ +#define R_IQIIX (1<<14) /* indirect index reg. with word post-incr. */ +#define R_DAIX (1<<15) /* index reg. with direct accum. offset */ +#define R_IAIX (1<<16) /* index reg. with indirect accum. offset */ +#define R_DOFF (1<<17) /* direct offset register */ +#define R_IOFF (1<<18) /* indirect offset register */ +#define R_IRP (1<<19) /* inter-register operations */ +#define R_STK (1<<20) /* stack push/pull register lists */ +#define R_BMP (1<<21) /* bit-manipulation register */ +#define R_DBR (1<<22) /* decr./incr./test-branch register */ + +/* used to get any register */ +#define R_ANY (0xffffffff) + +/* direct index registers with constant offset */ +#define R_DCIDX (R_DCIX0|R_DCIX5|R_DCIX8|R_DCIX16) + +/* indirect index registers with constant offset */ +#define R_ICIDX (R_ICIX0|R_ICIX8|R_ICIX16) + +/* direct index registers with increment/decrement */ +#define R_DPIDX (R_PI1IX|R_PD1IX|R_PD2IX|R_QI1IX|R_QI2IX|R_QD1IX) + +/* indirect index registers with increment/decrement */ +#define R_IPIDX (R_IPDIX|R_IQIIX) + +/* any direct/indirect index register */ +#define R_DIDX (R_DCIDX|R_DPIDX|R_DAIX) +#define R_IIDX (R_ICIDX|R_IPIDX|R_IAIX) + +/* Index availability for 6809 X,Y,U,S: */ +#define R_CIX09 (R_DCIX0|R_DCIX5|R_DCIX8|R_DCIX16|R_ICIX0|R_ICIX8|R_ICIX16) +#define R_AIX09 (R_DAIX|R_IAIX) +#define R_PIX09 (R_PD1IX|R_PD2IX|R_QI1IX|R_QI2IX|R_IPIDX) +#define R_IDX09 (R_CIX09|R_AIX09|R_PIX09) + +/* Index availability for 6309 W: */ +#define R_CIXW (R_DCIX0|R_DCIX16|R_ICIX0|R_ICIX16) +#define R_PIXW (R_PD2IX|R_QI2IX|R_IPIDX) +#define R_IDXW (R_CIXW|R_AIX09|R_PIXW) + +/* Index availability for 6809 PCR: */ +#define R_IDXPCR (R_DCIX8|R_DCIX16|R_ICIX8|R_ICIX16) + +/* Index availability for HC12 X,Y,SP: */ +#define R_CIX12 (R_DCIX0|R_DCIX5|R_DCIX8|R_DCIX16|R_ICIX16) +#define R_PIX12 (R_PD1IX|R_PI1IX|R_QD1IX|R_QI1IX) +#define R_IDX12 (R_CIX12|R_AIX09|R_PIX12) + +/* Index availability for HC12 PC: */ +#define R_IDX12PC (R_CIX12|R_AIX09) + +/* Offset availability for 6809 A,B,D and 6309 E, F, W: */ +#define R_OFF (R_DOFF|R_IOFF) + + +/* cpu-specific symbol-flags */ +#define DPAGESYM (RSRVD_C<<0) /* symbol will reside in the direct-page */ + + +/* exported by cpu.c */ +int cpu_available(int); diff --git a/tools/vasm/vasm/cpus/6809/cpu_errors.h b/tools/vasm/vasm/cpus/6809/cpu_errors.h new file mode 100644 index 0000000..55c7d4b --- /dev/null +++ b/tools/vasm/vasm/cpus/6809/cpu_errors.h @@ -0,0 +1,19 @@ + "trailing garbage in operand",WARNING, + "] expected for indirect addressing mode",ERROR, + "missing valid index register",ERROR, + "pc-relative offset out of range: %ld",ERROR, + "constant offset out of range: %ld",ERROR, + "bad auto decrement/increment value: %d",ERROR, /* 05 */ + "indirect addressing not allowed",ERROR, + "auto increment/decrement not allowed",ERROR, + "short branch out of range: %ld",ERROR, + "long branch out of range: %ld",ERROR, + "decrement branch out of range: %ld",ERROR, /* 10 */ + "data size %d not supported",ERROR, + "data expression doesn't fit into %d bits",ERROR, + "illegal bit number specification: %d",ERROR, + "omitted offset taken as 5-bit zero offset",WARNING, + "immediate expression doesn't fit into %d bits",ERROR, /* 15 */ + "directive ignored as selected CPU has no DP register",WARNING, + "double size modifier ignored",WARNING, + "addressing mode not supported",ERROR, diff --git a/tools/vasm/vasm/cpus/6809/opcodes.h b/tools/vasm/vasm/cpus/6809/opcodes.h new file mode 100644 index 0000000..334bc60 --- /dev/null +++ b/tools/vasm/vasm/cpus/6809/opcodes.h @@ -0,0 +1,415 @@ + "aba", {INH }, {0x1807, NA, NA, NA, HC12}, + "abx", {INH }, { 0x3a, NA, NA, NA, M6809|HD6309}, + "abx", {INH }, {0x1ae5, NA, NA, NA, HC12}, + "aby", {INH }, {0x19ed, NA, NA, NA, HC12}, + "adca", {AL1 }, { 0x89, 0x99, 0xa9, 0xb9, M6809|HD6309|HC12}, + "adcb", {AL1 }, { 0xc9, 0xd9, 0xe9, 0xf9, M6809|HD6309|HC12}, + "adcd", {AL2 }, {0x1089,0x1099,0x10a9,0x10b9, HD6309}, + "adcr", {TFR,TFR }, {0x1031, NA, NA, NA, HD6309}, + "adda", {AL1 }, { 0x8b, 0x9b, 0xab, 0xbb, M6809|HD6309|HC12}, + "addb", {AL1 }, { 0xcb, 0xdb, 0xeb, 0xfb, M6809|HD6309|HC12}, + "addd", {AL2 }, { 0xc3, 0xd3, 0xe3, 0xf3, M6809|HD6309|HC12}, + "adde", {AL1 }, {0x118b,0x119b,0x11ab,0x11bb, HD6309}, + "addf", {AL1 }, {0x11cb,0x11db,0x11eb,0x11fb, HD6309}, + "addr", {TFR,TFR }, {0x1030, NA, NA, NA, HD6309}, + "addw", {AL2 }, {0x108b,0x109b,0x10ab,0x10bb, HD6309}, + "aim", {IM1,MEM }, { NA, 0x02, 0x62, 0x72, HD6309}, + "anda", {AL1 }, { 0x84, 0x94, 0xa4, 0xb4, M6809|HD6309|HC12}, + "andb", {AL1 }, { 0xc4, 0xd4, 0xe4, 0xf4, M6809|HD6309|HC12}, + "andcc", {IM1 }, { 0x1c, NA, NA, NA, M6809|HD6309}, + "andcc", {IM1 }, { 0x10, NA, NA, NA, HC12}, + "andd", {AL2 }, {0x1084,0x1094,0x10a4,0x10b4, HD6309}, + "andr", {TFR,TFR }, {0x1034, NA, NA, NA, HD6309}, + "asl", {MEM }, { NA, 0x08, 0x68, 0x78, M6809|HD6309}, + "asl", {IXE }, { NA, NA, 0x68, 0x78, HC12}, + "asla", {INH }, { 0x48, NA, NA, NA, M6809|HD6309|HC12}, + "aslb", {INH }, { 0x58, NA, NA, NA, M6809|HD6309|HC12}, + "asld", {INH }, {0x1048, NA, NA, NA, HD6309}, + "asld", {INH }, { 0x59, NA, NA, NA, HC12}, + "asr", {MEM }, { NA, 0x07, 0x67, 0x77, M6809|HD6309}, + "asr", {IXE }, { NA, NA, 0x67, 0x77, HC12}, + "asra", {INH }, { 0x47, NA, NA, NA, M6809|HD6309|HC12}, + "asrb", {INH }, { 0x57, NA, NA, NA, M6809|HD6309|HC12}, + "asrd", {INH }, {0x1047, NA, NA, NA, HD6309}, + "band", {BMR,BIT,BIT,DIR}, { NA,0x1130, NA, NA, HD6309}, + "biand", {BMR,BIT,BIT,DIR}, { NA,0x1131, NA, NA, HD6309}, + "beor", {BMR,BIT,BIT,DIR}, { NA,0x1134, NA, NA, HD6309}, + "bieor", {BMR,BIT,BIT,DIR}, { NA,0x1135, NA, NA, HD6309}, + "bor", {BMR,BIT,BIT,DIR}, { NA,0x1132, NA, NA, HD6309}, + "bior", {BMR,BIT,BIT,DIR}, { NA,0x1133, NA, NA, HD6309}, + "bclr", {MNI,DT1 }, { NA, 0x4d, 0x0d, 0x1d, HC12}, + "bset", {MNI,DT1 }, { NA, 0x4c, 0x0c, 0x1c, HC12}, + "bgnd", {INH }, { 0x00, NA, NA, NA, HC12}, + "bita", {AL1 }, { 0x85, 0x95, 0xa5, 0xb5, M6809|HD6309|HC12}, + "bitb", {AL1 }, { 0xc5, 0xd5, 0xe5, 0xf5, M6809|HD6309|HC12}, + "bitd", {AL2 }, {0x1085,0x1095,0x10a5,0x10b5, HD6309}, + "bitmd", {IM1 }, {0x113c, NA, NA, NA, HD6309}, + "brclr", {MNI,DT1,RLS }, { NA, 0x4f, 0x0f, 0x1f, HC12}, + "brset", {MNI,DT1,RLS }, { NA, 0x4e, 0x0e, 0x1e, HC12}, + "call", {IXE,DT1 }, { NA, NA, 0x4b, 0x4a, HC12}, + "cba", {INH }, {0x1817, NA, NA, NA, HC12}, + "clc", {INH }, {0x10fe, NA, NA, NA, HC12}, + "cli", {INH }, {0x10ef, NA, NA, NA, HC12}, + "clv", {INH }, {0x10fd, NA, NA, NA, HC12}, + "clr", {MEM }, { NA, 0x0f, 0x6f, 0x7f, M6809|HD6309}, + "clr", {IXE }, { NA, NA, 0x69, 0x79, HC12}, + "clra", {INH }, { 0x4f, NA, NA, NA, M6809|HD6309}, + "clra", {INH }, { 0x87, NA, NA, NA, HC12}, + "clrb", {INH }, { 0x5f, NA, NA, NA, M6809|HD6309}, + "clrb", {INH }, { 0xc7, NA, NA, NA, HC12}, + "clrd", {INH }, {0x104f, NA, NA, NA, HD6309}, + "clre", {INH }, {0x114f, NA, NA, NA, HD6309}, + "clrf", {INH }, {0x115f, NA, NA, NA, HD6309}, + "clrw", {INH }, {0x105f, NA, NA, NA, HD6309}, + "cmpa", {AL1 }, { 0x81, 0x91, 0xa1, 0xb1, M6809|HD6309|HC12}, + "cmpb", {AL1 }, { 0xc1, 0xd1, 0xe1, 0xf1, M6809|HD6309|HC12}, + "cmpd", {AL2 }, {0x1083,0x1093,0x10a3,0x10b3, M6809|HD6309}, + "cmpe", {AL1 }, {0x1181,0x1191,0x11a1,0x11b1, HD6309}, + "cmpf", {AL1 }, {0x11c1,0x11d1,0x11e1,0x11f1, HD6309}, + "cmps", {AL2 }, {0x118c,0x119c,0x11ac,0x11bc, M6809|HD6309}, + "cmpu", {AL2 }, {0x1183,0x1193,0x11a3,0x11b3, M6809|HD6309}, + "cmpw", {AL2 }, {0x1081,0x1091,0x10a1,0x10b1, HD6309}, + "cmpx", {AL2 }, { 0x8c, 0x9c, 0xac, 0xbc, M6809|HD6309}, + "cmpy", {AL2 }, {0x108c,0x109c,0x10ac,0x10bc, M6809|HD6309}, + "cmpr", {TFR,TFR }, {0x1037, NA, NA, NA, HD6309}, + "com", {MEM }, { NA, 0x03, 0x63, 0x73, M6809|HD6309}, + "com", {IXE }, { NA, NA, 0x61, 0x71, HC12}, + "coma", {INH }, { 0x43, NA, NA, NA, M6809|HD6309}, + "coma", {INH }, { 0x41, NA, NA, NA, HC12}, + "comb", {INH }, { 0x53, NA, NA, NA, M6809|HD6309}, + "comb", {INH }, { 0x51, NA, NA, NA, HC12}, + "comd", {INH }, {0x1043, NA, NA, NA, HD6309}, + "come", {INH }, {0x1143, NA, NA, NA, HD6309}, + "comf", {INH }, {0x1153, NA, NA, NA, HD6309}, + "comw", {INH }, {0x1053, NA, NA, NA, HD6309}, + "cpd", {AL2 }, { 0x8c, 0x9c, 0xac, 0xbc, HC12}, + "cps", {AL2 }, { 0x8f, 0x9f, 0xaf, 0xbf, HC12}, + "cpx", {AL2 }, { 0x8e, 0x9e, 0xae, 0xbe, HC12}, + "cpy", {AL2 }, { 0x8d, 0x9d, 0xad, 0xbd, HC12}, + "cwai", {IM1 }, { 0x3c, NA, NA, NA, M6809|HD6309}, + "daa", {INH }, { 0x19, NA, NA, NA, M6809|HD6309}, + "daa", {INH }, {0x1807, NA, NA, NA, HC12}, + "dbeq", {DBR,RLD }, {0x0400, NA, NA, NA, HC12}, + "dbne", {DBR,RLD }, {0x0420, NA, NA, NA, HC12}, + "dec", {MEM }, { NA, 0x0a, 0x6a, 0x7a, M6809|HD6309}, + "dec", {IXE }, { NA, NA, 0x63, 0x73, HC12}, + "deca", {INH }, { 0x4a, NA, NA, NA, M6809|HD6309}, + "deca", {INH }, { 0x43, NA, NA, NA, HC12}, + "decb", {INH }, { 0x5a, NA, NA, NA, M6809|HD6309}, + "decb", {INH }, { 0x53, NA, NA, NA, HC12}, + "decd", {INH }, {0x104a, NA, NA, NA, HD6309}, + "dece", {INH }, {0x114a, NA, NA, NA, HD6309}, + "decf", {INH }, {0x115a, NA, NA, NA, HD6309}, + "decw", {INH }, {0x105a, NA, NA, NA, HD6309}, + "des", {INH }, {0x1b9f, NA, NA, NA, HC12}, + "dex", {INH }, { 0x09, NA, NA, NA, HC12}, + "dey", {INH }, { 0x03, NA, NA, NA, HC12}, + "divd", {AL1 }, {0x118d,0x119d,0x11ad,0x11bd, HD6309}, + "divq", {AL2 }, {0x118e,0x119e,0x11ae,0x11be, HD6309}, + "ediv", {INH }, { 0x11, NA, NA, NA, HC12}, + "edivs", {INH }, {0x1814, NA, NA, NA, HC12}, + "eim", {IM1,MEM }, { NA, 0x05, 0x65, 0x75, HD6309}, + "emacs", {EXT }, {0x1812, NA, NA, NA, HC12}, + "emaxd", {IDX }, { NA, NA,0x181a, NA, HC12}, + "emaxm", {IDX }, { NA, NA,0x181e, NA, HC12}, + "emind", {IDX }, { NA, NA,0x181b, NA, HC12}, + "eminm", {IDX }, { NA, NA,0x181f, NA, HC12}, + "emul", {INH }, { 0x13, NA, NA, NA, HC12}, + "emuls", {INH }, {0x1813, NA, NA, NA, HC12}, + "eora", {AL1 }, { 0x88, 0x98, 0xa8, 0xb8, M6809|HD6309|HC12}, + "eorb", {AL1 }, { 0xc8, 0xd8, 0xe8, 0xf8, M6809|HD6309|HC12}, + "eord", {AL2 }, {0x1088,0x1098,0x10a8,0x10b8, HD6309}, + "eorr", {TFR,TFR }, {0x1036, NA, NA, NA, HD6309}, + "etbl", {IX0 }, {0x183f, NA, NA, NA, HC12}, + "exg", {TFR,TFR }, { 0x1e, NA, NA, NA, M6809|HD6309}, + "exg", {TFR,TFR }, { 0xb7, NA, NA, NA, HC12}, + "fdiv", {INH }, {0x1811, NA, NA, NA, HC12}, + "ibeq", {DBR,RLD }, {0x0480, NA, NA, NA, HC12}, + "ibne", {DBR,RLD }, {0x04a0, NA, NA, NA, HC12}, + "idiv", {INH }, {0x1810, NA, NA, NA, HC12}, + "idivs", {INH }, {0x1815, NA, NA, NA, HC12}, + "inc", {MEM }, { NA, 0x0c, 0x6c, 0x7c, M6809|HD6309}, + "inc", {IXE }, { NA, NA, 0x62, 0x72, HC12}, + "inca", {INH }, { 0x4c, NA, NA, NA, M6809|HD6309}, + "inca", {INH }, { 0x42, NA, NA, NA, HC12}, + "incb", {INH }, { 0x5c, NA, NA, NA, M6809|HD6309}, + "incb", {INH }, { 0x52, NA, NA, NA, HC12}, + "incd", {INH }, {0x104c, NA, NA, NA, HD6309}, + "ince", {INH }, {0x114c, NA, NA, NA, HD6309}, + "incf", {INH }, {0x115c, NA, NA, NA, HD6309}, + "incw", {INH }, {0x105c, NA, NA, NA, HD6309}, + "ins", {INH }, {0x1b81, NA, NA, NA, HC12}, + "inx", {INH }, { 0x08, NA, NA, NA, HC12}, + "iny", {INH }, { 0x02, NA, NA, NA, HC12}, + "jmp", {MEM }, { NA, 0x0e, 0x6e, 0x7e, M6809|HD6309}, + "jmp", {IXE }, { NA, NA, 0x05, 0x06, HC12}, + "jsr", {MEM }, { NA, 0x9d, 0xad, 0xbd, M6809|HD6309}, + "jsr", {MEM }, { NA, 0x17, 0x15, 0x16, HC12}, + "lda", {AL1 }, { 0x86, 0x96, 0xa6, 0xb6, M6809|HD6309}, + "ldaa", {AL1 }, { 0x86, 0x96, 0xa6, 0xb6, HC12}, + "ldb", {AL1 }, { 0xc6, 0xd6, 0xe6, 0xf6, M6809|HD6309}, + "ldab", {AL1 }, { 0xc6, 0xd6, 0xe6, 0xf6, HC12}, + "ldd", {AL2 }, { 0xcc, 0xdc, 0xec, 0xfc, M6809|HD6309|HC12}, + "lde", {AL1 }, {0x1186,0x1196,0x11a6,0x11b6, HD6309}, + "ldf", {AL1 }, {0x11c6,0x11d6,0x11e6,0x11f6, HD6309}, + "ldmd", {IM1 }, {0x013d, NA, NA, NA, HD6309}, + "ldq", {AL4 }, { 0xcd,0x10dc,0x10ec,0x10fc, HD6309}, + "lds", {AL2 }, {0x10ce,0x10de,0x10ee,0x10fe, M6809|HD6309}, + "lds", {AL2 }, { 0xcf, 0xdf, 0xef, 0xff, HC12}, + "ldu", {AL2 }, { 0xce, 0xde, 0xee, 0xfe, M6809|HD6309}, + "ldw", {AL2 }, {0x1086,0x1096,0x10ae,0x10b6, HD6309}, + "ldx", {AL2 }, { 0x8e, 0x9e, 0xae, 0xbe, M6809|HD6309}, + "ldx", {AL2 }, { 0xce, 0xde, 0xee, 0xfe, HC12}, + "ldy", {AL2 }, {0x108e,0x109e,0x10ae,0x10be, M6809|HD6309}, + "ldy", {AL2 }, { 0xcd, 0xdd, 0xed, 0xfd, HC12}, + "ldbt", {BMR,BIT,BIT,DIR}, { NA,0x1136, NA, NA, HD6309}, + "leas", {IDX }, { NA, NA, 0x32, NA, M6809|HD6309}, + "leas", {DIX }, { NA, NA, 0x1b, NA, HC12}, + "leau", {IDX }, { NA, NA, 0x33, NA, M6809|HD6309}, + "leax", {IDX }, { NA, NA, 0x30, NA, M6809|HD6309}, + "leax", {DIX }, { NA, NA, 0x1a, NA, HC12}, + "leay", {IDX }, { NA, NA, 0x31, NA, M6809|HD6309}, + "leay", {DIX }, { NA, NA, 0x19, NA, HC12}, + "lsl", {MEM }, { NA, 0x08, 0x68, 0x78, M6809|HD6309}, + "lsl", {IXE }, { NA, NA, 0x68, 0x78, HC12}, + "lsla", {INH }, { 0x48, NA, NA, NA, M6809|HD6309|HC12}, + "lslb", {INH }, { 0x58, NA, NA, NA, M6809|HD6309|HC12}, + "lsld", {INH }, {0x1048, NA, NA, NA, HD6309}, + "lsld", {INH }, { 0x59, NA, NA, NA, HC12}, + "lsr", {MEM }, { NA, 0x04, 0x64, 0x74, M6809|HD6309}, + "lsr", {IXE }, { NA, NA, 0x64, 0x74, HC12}, + "lsra", {INH }, { 0x44, NA, NA, NA, M6809|HD6309|HC12}, + "lsrb", {INH }, { 0x54, NA, NA, NA, M6809|HD6309|HC12}, + "lsrd", {INH }, {0x1044, NA, NA, NA, HD6309}, + "lsrd", {INH }, { 0x49, NA, NA, NA, HC12}, + "maxa", {IDX }, { NA, NA,0x1818, NA, HC12}, + "maxm", {IDX }, { NA, NA,0x181c, NA, HC12}, + "mem", {INH }, { 0x01, NA, NA, NA, HC12}, + "mina", {IDX }, { NA, NA,0x1819, NA, HC12}, + "minm", {IDX }, { NA, NA,0x181d, NA, HC12}, + "movb", {IM1,EXT }, {0x180b, NA, NA, NA, HC12|MOVE}, + "movb", {IM1,DI0 }, {0x1808, NA, NA, NA, HC12|MOVE}, + "movb", {EXT,EXT }, {0x180c, NA, NA, NA, HC12|MOVE}, + "movb", {EXT,DI0 }, {0x1809, NA, NA, NA, HC12|MOVE}, + "movb", {DI0,EXT }, {0x180d, NA, NA, NA, HC12|MOVE}, + "movb", {DI0,DI0 }, {0x180a, NA, NA, NA, HC12|MOVE}, + "movw", {IM2,EXT }, {0x1803, NA, NA, NA, HC12|MOVE}, + "movw", {IM2,DI0 }, {0x1800, NA, NA, NA, HC12|MOVE}, + "movw", {EXT,EXT }, {0x1804, NA, NA, NA, HC12|MOVE}, + "movw", {EXT,DI0 }, {0x1801, NA, NA, NA, HC12|MOVE}, + "movw", {DI0,EXT }, {0x1805, NA, NA, NA, HC12|MOVE}, + "movw", {DI0,DI0 }, {0x1802, NA, NA, NA, HC12|MOVE}, + "mul", {INH }, { 0x3d, NA, NA, NA, M6809|HD6309}, + "mul", {INH }, { 0x12, NA, NA, NA, HC12}, + "muld", {AL2 }, {0x118f,0x119f,0x11af,0x11bf, HD6309}, + "neg", {MEM }, { NA, 0x00, 0x60, 0x70, M6809|HD6309}, + "neg", {IXE }, { NA, NA, 0x60, 0x70, HC12}, + "nega", {INH }, { 0x40, NA, NA, NA, M6809|HD6309|HC12}, + "negb", {INH }, { 0x50, NA, NA, NA, M6809|HD6309|HC12}, + "negd", {INH }, {0x1040, NA, NA, NA, HD6309}, + "nop", {INH }, { 0x12, NA, NA, NA, M6809|HD6309}, + "nop", {INH }, { 0xa7, NA, NA, NA, HC12}, + "oim", {IM1,MEM }, { NA, 0x01, 0x61, 0x71, HD6309}, + "ora", {AL1 }, { 0x8a, 0x9a, 0xaa, 0xba, M6809|HD6309}, + "orb", {AL1 }, { 0xca, 0xda, 0xea, 0xfa, M6809|HD6309}, + "oraa", {AL1 }, { 0x8a, 0x9a, 0xaa, 0xba, HC12}, + "orab", {AL1 }, { 0xca, 0xda, 0xea, 0xfa, HC12}, + "ord", {AL2 }, {0x108a,0x109a,0x10aa,0x10ba, HD6309}, + "orr", {TFR,TFR }, {0x1035, NA, NA, NA, HD6309}, + "orcc", {IM1 }, { 0x1a, NA, NA, NA, M6809|HD6309}, + "orcc", {IM1 }, { 0x14, NA, NA, NA, HC12}, + "pshs", {PPL }, { 0x34, NA, NA, NA, M6809|HD6309}, + "pshs", {IM1 }, { 0x34, NA, NA, NA, M6809|HD6309}, + "pshsw", {INH }, {0x1038, NA, NA, NA, HD6309}, + "pshu", {PPL }, { 0x36, NA, NA, NA, M6809|HD6309}, + "pshu", {IM1 }, { 0x36, NA, NA, NA, M6809|HD6309}, + "pshuw", {INH }, {0x103a, NA, NA, NA, HD6309}, + "psha", {INH }, { 0x36, NA, NA, NA, HC12}, + "pshb", {INH }, { 0x37, NA, NA, NA, HC12}, + "pshc", {INH }, { 0x39, NA, NA, NA, HC12}, + "pshd", {INH }, { 0x3b, NA, NA, NA, HC12}, + "pshx", {INH }, { 0x34, NA, NA, NA, HC12}, + "pshy", {INH }, { 0x35, NA, NA, NA, HC12}, + "puls", {PPL }, { 0x35, NA, NA, NA, M6809|HD6309}, + "puls", {IM1 }, { 0x35, NA, NA, NA, M6809|HD6309}, + "pulsw", {INH }, {0x1039, NA, NA, NA, HD6309}, + "pulu", {PPL }, { 0x37, NA, NA, NA, M6809|HD6309}, + "pulu", {IM1 }, { 0x37, NA, NA, NA, M6809|HD6309}, + "puluw", {INH }, {0x103b, NA, NA, NA, HD6309}, + "pula", {INH }, { 0x32, NA, NA, NA, HC12}, + "pulb", {INH }, { 0x33, NA, NA, NA, HC12}, + "pulc", {INH }, { 0x38, NA, NA, NA, HC12}, + "puld", {INH }, { 0x3a, NA, NA, NA, HC12}, + "pulx", {INH }, { 0x30, NA, NA, NA, HC12}, + "puly", {INH }, { 0x31, NA, NA, NA, HC12}, + "rev", {INH }, {0x183a, NA, NA, NA, HC12}, + "revw", {INH }, {0x183b, NA, NA, NA, HC12}, + "rol", {MEM }, { NA, 0x09, 0x69, 0x79, M6809|HD6309}, + "rol", {IXE }, { NA, NA, 0x65, 0x75, HC12}, + "rola", {INH }, { 0x49, NA, NA, NA, M6809|HD6309}, + "rola", {INH }, { 0x45, NA, NA, NA, HC12}, + "rolb", {INH }, { 0x59, NA, NA, NA, M6809|HD6309}, + "rolb", {INH }, { 0x55, NA, NA, NA, HC12}, + "rold", {INH }, {0x1049, NA, NA, NA, HD6309}, + "rolw", {INH }, {0x1059, NA, NA, NA, HD6309}, + "ror", {MEM }, { NA, 0x06, 0x66, 0x76, M6809|HD6309}, + "ror", {IXE }, { NA, NA, 0x66, 0x76, HC12}, + "rora", {INH }, { 0x46, NA, NA, NA, M6809|HD6309|HC12}, + "rorb", {INH }, { 0x56, NA, NA, NA, M6809|HD6309|HC12}, + "rord", {INH }, {0x1046, NA, NA, NA, HD6309}, + "rorw", {INH }, {0x1056, NA, NA, NA, HD6309}, + "rtc", {INH }, { 0x0a, NA, NA, NA, HC12}, + "rti", {INH }, { 0x3b, NA, NA, NA, M6809|HD6309}, + "rti", {INH }, { 0x0b, NA, NA, NA, HC12}, + "rts", {INH }, { 0x39, NA, NA, NA, M6809|HD6309}, + "rts", {INH }, { 0x3d, NA, NA, NA, HC12}, + "sba", {INH }, {0x1816, NA, NA, NA, HC12}, + "sbca", {AL1 }, { 0x82, 0x92, 0xa2, 0xb2, M6809|HD6309|HC12}, + "sbcb", {AL1 }, { 0xc2, 0xd2, 0xe2, 0xf2, M6809|HD6309|HC12}, + "sbcd", {AL2 }, {0x1082,0x1092,0x10a2,0x10b2, HD6309}, + "sbcr", {TFR,TFR }, {0x1033, NA, NA, NA, HD6309}, + "sec", {INH }, {0x1401, NA, NA, NA, HC12}, + "sei", {INH }, {0x1410, NA, NA, NA, HC12}, + "sev", {INH }, {0x1402, NA, NA, NA, HC12}, + "sex", {TFR,TFR }, { 0xb7, NA, NA, NA, HC12}, + "sex", {INH }, { 0x1d, NA, NA, NA, M6809|HD6309}, + "sexw", {INH }, { 0x14, NA, NA, NA, HD6309}, + "sta", {MEM }, { NA, 0x97, 0xa7, 0xb7, M6809|HD6309}, + "staa", {MEM }, { NA, 0x5a, 0x6a, 0x7a, HC12}, + "stb", {MEM }, { NA, 0xd7, 0xe7, 0xf7, M6809|HD6309}, + "stab", {MEM }, { NA, 0x5b, 0x6b, 0x7b, HC12}, + "std", {MEM }, { NA, 0xdd, 0xed, 0xfd, M6809|HD6309}, + "std", {MEM }, { NA, 0x5c, 0x6c, 0x7c, HC12}, + "ste", {MEM }, { NA,0x1197,0x11a7,0x11b7, HD6309}, + "stf", {MEM }, { NA,0x11d7,0x11e7,0x11f7, HD6309}, + "stq", {MEM }, { NA,0x10dd,0x10ed,0x10fd, HD6309}, + "sts", {MEM }, { NA,0x10df,0x10ef,0x10ff, M6809|HD6309}, + "sts", {MEM }, { NA, 0x5f, 0x6f, 0x7f, HC12}, + "stu", {MEM }, { NA, 0xdf, 0xef, 0xff, M6809|HD6309}, + "stw", {MEM }, { NA,0x1097,0x10a7,0x10b7, HD6309}, + "stx", {MEM }, { NA, 0x9f, 0xaf, 0xbf, M6809|HD6309}, + "stx", {MEM }, { NA, 0x5e, 0x6e, 0x7e, HC12}, + "sty", {MEM }, { NA,0x109f,0x10af,0x10bf, M6809|HD6309}, + "sty", {MEM }, { NA, 0x5d, 0x6d, 0x7d, HC12}, + "stbt", {BMR,BIT,BIT,DIR}, { NA,0x1137, NA, NA, HD6309}, + "stop", {INH }, {0x183e, NA, NA, NA, HC12}, + "suba", {AL1 }, { 0x80, 0x90, 0xa0, 0xb0, M6809|HD6309|HC12}, + "subb", {AL1 }, { 0xc0, 0xd0, 0xe0, 0xf0, M6809|HD6309|HC12}, + "subd", {AL2 }, { 0x83, 0x93, 0xa3, 0xb3, M6809|HD6309|HC12}, + "sube", {AL1 }, {0x1180,0x1190,0x11a0,0x11b0, HD6309}, + "subf", {AL1 }, {0x11c0,0x11d0,0x11e0,0x11f0, HD6309}, + "subr", {TFR,TFR }, {0x1032, NA, NA, NA, HD6309}, + "subw", {AL2 }, {0x1080,0x1090,0x10a0,0x10b0, HD6309}, + "swi", {INH }, { 0x3f, NA, NA, NA, M6809|HD6309|HC12}, + "swi2", {INH }, {0x103f, NA, NA, NA, M6809|HD6309}, + "swi3", {INH }, {0x113f, NA, NA, NA, M6809|HD6309}, + "sync", {INH }, { 0x13, NA, NA, NA, M6809|HD6309}, + "tab", {INH }, {0x180e, NA, NA, NA, HC12}, + "tap", {INH }, {0xb702, NA, NA, NA, HC12}, + "tba", {INH }, {0x180f, NA, NA, NA, HC12}, + "tbeq", {DBR,RLD }, {0x0440, NA, NA, NA, HC12}, + "tbne", {DBR,RLD }, {0x0460, NA, NA, NA, HC12}, + "tbl", {DI0 }, { NA, NA, 0x183d,NA, HC12}, + "tfm", {TMP,TMP }, {0x1138, NA, NA, NA, HD6309}, + "tfm", {TMM,TMM }, {0x1139, NA, NA, NA, HD6309}, + "tfm", {TMP,TFM }, {0x113a, NA, NA, NA, HD6309}, + "tfm", {TFM,TMP }, {0x113b, NA, NA, NA, HD6309}, + "tfr", {TFR,TFR }, { 0x1f, NA, NA, NA, M6809|HD6309}, + "tfr", {TFR,TFR }, { 0xb7, NA, NA, NA, HC12}, + "tim", {IM1,MEM }, { NA, 0x0b, 0x6b, 0x7b, HD6309}, + "tpa", {INH }, {0xb720, NA, NA, NA, HC12}, + "trap", {DT1, }, { 0x18, NA, NA, NA, HC12}, + "tst", {MEM }, { NA, 0x0d, 0x6d, 0x7d, M6809|HD6309}, + "tst", {IXE }, { NA, NA, 0xe7, 0xf7, HC12}, + "tsta", {INH }, { 0x4d, NA, NA, NA, M6809|HD6309}, + "tsta", {INH }, { 0x97, NA, NA, NA, HC12}, + "tstb", {INH }, { 0x5d, NA, NA, NA, M6809|HD6309}, + "tstb", {INH }, { 0xd7, NA, NA, NA, HC12}, + "tstd", {INH }, {0x104d, NA, NA, NA, HD6309}, + "tste", {INH }, {0x114d, NA, NA, NA, HD6309}, + "tstf", {INH }, {0x115d, NA, NA, NA, HD6309}, + "tstw", {INH }, {0x105d, NA, NA, NA, HD6309}, + "tsx", {INH }, {0xb775, NA, NA, NA, HC12}, + "tsy", {INH }, {0xb776, NA, NA, NA, HC12}, + "txs", {INH }, {0xb757, NA, NA, NA, HC12}, + "tys", {INH }, {0xb767, NA, NA, NA, HC12}, + "wai", {INH }, { 0x3e, NA, NA, NA, HC12}, + "wav", {INH }, {0x183c, NA, NA, NA, HC12}, + "wavr", {INH }, { 0x3c, NA, NA, NA, HC12}, + "xgdx", {INH }, {0xb7c5, NA, NA, NA, HC12}, + "xgdy", {INH }, {0xb7c6, NA, NA, NA, HC12}, + "bsr", {RLS }, { 0x8d, NA, NA, NA, M6809|HD6309}, + "bsr", {RLS }, { 0x07, NA, NA, NA, HC12}, + "lbsr", {RLL }, { 0x17, NA, NA, NA, M6809|HD6309}, + "bra", {RLS }, { 0x20, NA, NA, NA, M6809|HD6309}, + "bra", {RLS }, { 0x20, NA, NA, NA, HC12}, + "lbra", {RLL }, { 0x16, NA, NA, NA, M6809|HD6309}, + "lbra", {RLL }, {0x1820, NA, NA, NA, HC12}, + "brn", {RLS }, { 0x21, NA, NA, NA, M6809|HD6309}, + "brn", {RLS }, { 0x21, NA, NA, NA, HC12}, + "lbrn", {RLL }, {0x1021, NA, NA, NA, M6809|HD6309}, + "lbrn", {RLL }, {0x1821, NA, NA, NA, HC12}, + "bhi", {RLS }, { 0x22, NA, NA, NA, M6809|HD6309}, + "bhi", {RLS }, { 0x22, NA, NA, NA, HC12}, + "lbhi", {RLL }, {0x1022, NA, NA, NA, M6809|HD6309}, + "lbhi", {RLL }, {0x1822, NA, NA, NA, HC12}, + "bls", {RLS }, { 0x23, NA, NA, NA, M6809|HD6309}, + "bls", {RLS }, { 0x23, NA, NA, NA, HC12}, + "lbls", {RLL }, {0x1023, NA, NA, NA, M6809|HD6309}, + "lbls", {RLL }, {0x1823, NA, NA, NA, HC12}, + "bcc", {RLS }, { 0x24, NA, NA, NA, M6809|HD6309}, + "bcc", {RLS }, { 0x24, NA, NA, NA, HC12}, + "lbcc", {RLL }, {0x1024, NA, NA, NA, M6809|HD6309}, + "lbcc", {RLL }, {0x1824, NA, NA, NA, HC12}, + "bcs", {RLS }, { 0x25, NA, NA, NA, M6809|HD6309}, + "bcs", {RLS }, { 0x25, NA, NA, NA, HC12}, + "lbcs", {RLL }, {0x1025, NA, NA, NA, M6809|HD6309}, + "lbcs", {RLL }, {0x1825, NA, NA, NA, HC12}, + "bne", {RLS }, { 0x26, NA, NA, NA, M6809|HD6309}, + "bne", {RLS }, { 0x26, NA, NA, NA, HC12}, + "lbne", {RLL }, {0x1026, NA, NA, NA, M6809|HD6309}, + "lbne", {RLL }, {0x1826, NA, NA, NA, HC12}, + "beq", {RLS }, { 0x27, NA, NA, NA, M6809|HD6309}, + "beq", {RLS }, { 0x27, NA, NA, NA, HC12}, + "lbeq", {RLL }, {0x1027, NA, NA, NA, M6809|HD6309}, + "lbeq", {RLL }, {0x1827, NA, NA, NA, HC12}, + "bvc", {RLS }, { 0x28, NA, NA, NA, M6809|HD6309}, + "bvc", {RLS }, { 0x28, NA, NA, NA, HC12}, + "lbvc", {RLL }, {0x1028, NA, NA, NA, M6809|HD6309}, + "lbvc", {RLL }, {0x1828, NA, NA, NA, HC12}, + "bvs", {RLS }, { 0x29, NA, NA, NA, M6809|HD6309}, + "bvs", {RLS }, { 0x29, NA, NA, NA, HC12}, + "lbvs", {RLL }, {0x1029, NA, NA, NA, M6809|HD6309}, + "lbvs", {RLL }, {0x1829, NA, NA, NA, HC12}, + "bpl", {RLS }, { 0x2a, NA, NA, NA, M6809|HD6309}, + "bpl", {RLS }, { 0x2a, NA, NA, NA, HC12}, + "lbpl", {RLL }, {0x102a, NA, NA, NA, M6809|HD6309}, + "lbpl", {RLL }, {0x182a, NA, NA, NA, HC12}, + "bmi", {RLS }, { 0x2b, NA, NA, NA, M6809|HD6309}, + "bmi", {RLS }, { 0x2b, NA, NA, NA, HC12}, + "lbmi", {RLL }, {0x102b, NA, NA, NA, M6809|HD6309}, + "lbmi", {RLL }, {0x182b, NA, NA, NA, HC12}, + "bge", {RLS }, { 0x2c, NA, NA, NA, M6809|HD6309}, + "bge", {RLS }, { 0x2c, NA, NA, NA, HC12}, + "lbge", {RLL }, {0x102c, NA, NA, NA, M6809|HD6309}, + "lbge", {RLL }, {0x182c, NA, NA, NA, HC12}, + "blt", {RLS }, { 0x2d, NA, NA, NA, M6809|HD6309}, + "blt", {RLS }, { 0x2d, NA, NA, NA, HC12}, + "lblt", {RLL }, {0x102d, NA, NA, NA, M6809|HD6309}, + "lblt", {RLL }, {0x182d, NA, NA, NA, HC12}, + "bgt", {RLS }, { 0x2e, NA, NA, NA, M6809|HD6309}, + "bgt", {RLS }, { 0x2e, NA, NA, NA, HC12}, + "lbgt", {RLL }, {0x102e, NA, NA, NA, M6809|HD6309}, + "lbgt", {RLL }, {0x182e, NA, NA, NA, HC12}, + "ble", {RLS }, { 0x2f, NA, NA, NA, M6809|HD6309}, + "ble", {RLS }, { 0x2f, NA, NA, NA, HC12}, + "lble", {RLL }, {0x102f, NA, NA, NA, M6809|HD6309}, + "lble", {RLL }, {0x182f, NA, NA, NA, HC12}, + "bhs", {RLS }, { 0x24, NA, NA, NA, M6809|HD6309}, + "bhs", {RLS }, { 0x24, NA, NA, NA, HC12}, + "lbhs", {RLL }, {0x1024, NA, NA, NA, M6809|HD6309}, + "lbhs", {RLL }, {0x1824, NA, NA, NA, HC12}, + "blo", {RLS }, { 0x25, NA, NA, NA, M6809|HD6309}, + "blo", {RLS }, { 0x25, NA, NA, NA, HC12}, + "lblo", {RLL }, {0x1025, NA, NA, NA, M6809|HD6309}, + "lblo", {RLL }, {0x1825, NA, NA, NA, HC12}, diff --git a/tools/vasm/vasm/cpus/6809/registers.h b/tools/vasm/vasm/cpus/6809/registers.h new file mode 100644 index 0000000..864b8c7 --- /dev/null +++ b/tools/vasm/vasm/cpus/6809/registers.h @@ -0,0 +1,22 @@ +{ "A", 1, REG_A, R_OFF|R_BMP|R_IRP|R_STK, M6809|HD6309 }, +{ "A", 1, REG_A, R_DOFF|R_IRP|R_DBR, HC12 }, +{ "B", 1, REG_B, R_OFF|R_BMP|R_IRP|R_STK, M6809|HD6309 }, +{ "B", 1, REG_B, R_DOFF|R_IRP|R_DBR, HC12 }, +{ "CC", 2, REG_CC, R_BMP|R_IRP|R_STK, M6809|HD6309 }, +{ "CCR",3, REG_CC, R_IRP, HC12 }, +{ "D", 1, REG_D, R_OFF|R_IRP|R_STK|R_DBR, M6809|HD6309|HC12 }, +{ "E", 1, REG_E, R_OFF|R_IRP, HD6309 }, +{ "DP", 2, REG_DP, R_IRP|R_STK, M6809|HD6309 }, +{ "PC", 2, REG_PC, R_IDXPCR|R_IRP|R_STK, M6809|HD6309 }, +{ "PCR",3, REG_PC, R_IDXPCR|R_IRP|R_STK, M6809|HD6309 }, +{ "PC", 2, REG_PC, R_IDX12PC, HC12 }, +{ "S", 1, REG_S, R_IDX09|R_IRP|R_STK, M6809|HD6309 }, +{ "SP", 2, REG_S, R_IDX12|R_IRP|R_DBR, HC12 }, +{ "U", 1, REG_U, R_IDX09|R_IRP|R_STK, M6809|HD6309 }, +{ "V", 1, REG_V, R_IRP, HD6309 }, +{ "W", 1, REG_W, R_OFF|R_IDXW|R_IRP, HD6309 }, +{ "X", 1, REG_X, R_IDX09|R_IRP|R_STK, M6809|HD6309 }, +{ "X", 1, REG_X, R_IDX12|R_IRP|R_DBR, HC12 }, +{ "Y", 1, REG_Y, R_IDX09|R_IRP|R_STK, M6809|HD6309 }, +{ "Y", 1, REG_Y, R_IDX12|R_IRP|R_DBR, HC12 }, +{ "0", 1, REG_0, R_IRP, HD6309 } diff --git a/tools/vasm/vasm/cpus/arm/cpu.c b/tools/vasm/vasm/cpus/arm/cpu.c new file mode 100644 index 0000000..b48c905 --- /dev/null +++ b/tools/vasm/vasm/cpus/arm/cpu.c @@ -0,0 +1,1754 @@ +/* +** cpu.c ARM cpu-description file +** (c) in 2004,2006,2010,2011,2014-2020 by Frank Wille +*/ + +#include "vasm.h" + +mnemonic mnemonics[] = { +#include "opcodes.h" +}; +int mnemonic_cnt = sizeof(mnemonics)/sizeof(mnemonics[0]); + +char *cpu_copyright = "vasm ARM cpu backend 0.4h (c) 2004,2006,2010,2011,2014-2020 Frank Wille"; +char *cpuname = "ARM"; +int bitsperbyte = 8; +int bytespertaddr = 4; + +uint32_t cpu_type = AAANY; +int arm_be_mode = 0; /* Little-endian is default */ +int thumb_mode = 0; /* 1: Thumb instruction set (16 bit) is active */ + +/* options */ +static unsigned char opt_ldrpc = 0; /* LDR r,sym -> ADD / LDR */ +static unsigned char opt_adr = 0; /* ADR r,sym -> ADRL (ADD/ADD|SUB/SUB) */ + +/* constant data */ +static const char *condition_codes = "eqnecsccmiplvsvchilsgeltgtlealnvhsloul"; + +static const char *addrmode_strings[] = { + "da","ia","db","ib", + "fa","fd","ea","ed", + "bt","tb","sb","sh","t","b","h","s","l", + "p",NULL,"" +}; +enum { + AM_DA=0,AM_IA,AM_DB,AM_IB,AM_FA,AM_FD,AM_EA,AM_ED, + AM_BT,AM_TB,AM_SB,AM_SH,AM_T,AM_B,AM_H,AM_S,AM_L, + AM_P,AM_NULL,AM_NONE +}; + +#define NUM_SHIFTTYPES 6 +static const char *shift_strings[NUM_SHIFTTYPES] = { + "LSL","LSR","ASR","ROR","RRX","ASL" +}; + +static int OC_SWP,OC_NOP; +static int elfoutput = 0; /* output will be an ELF object file */ + +static section *last_section = 0; +static int last_data_type = -1; /* for mapping symbol generation */ +#define TYPE_ARM 0 +#define TYPE_THUMB 1 +#define TYPE_DATA 2 + +#define THB_PREFETCH 4 /* prefetch-correction for Thumb-branches */ +#define ARM_PREFETCH 8 /* prefetch-correction for ARM-branches */ + + + +operand *new_operand(void) +{ + return mycalloc(sizeof(operand)); +} + + +int cpu_available(int idx) +{ + return (mnemonics[idx].ext.available & cpu_type) != 0; +} + + +char *parse_cpu_special(char *start) +/* parse cpu-specific directives; return pointer to end of + cpu-specific text */ +{ + char *name=start,*s=start; + + if (ISIDSTART(*s)) { + s++; + while (ISIDCHAR(*s)) + s++; + if (dotdirs && *name=='.') + name++; + if (s-name==5 && !strncmp(name,"thumb",5)) { + thumb_mode = 1; + if (inst_alignment > 1) + inst_alignment = 2; + return s; + } + else if (s-name==3 && !strncmp(name,"arm",3)) { + thumb_mode = 0; + if (inst_alignment > 1) + inst_alignment = 4; + return s; + } + } + return start; +} + + +char *parse_instruction(char *s,int *inst_len,char **ext,int *ext_len, + int *ext_cnt) +/* parse instruction and save extension locations */ +{ + char *inst = s; + int cnt = *ext_cnt; + + while (*s && !isspace((unsigned char)*s)) + s++; + + if (thumb_mode) { /* no qualifiers in THUMB code */ + *inst_len = s - inst; + } + + else { /* ARM mode - we might have up to 2 different qualifiers */ + int len = s - inst; + char c = tolower((unsigned char)*inst); + + if (len > 2) { + if (c=='b' && strnicmp(inst,"bic",3) && (len==3 || len==4)) { + *inst_len = len - 2; + } + else if ((c=='u' || c=='s') && + tolower((unsigned char)*(inst+1))=='m' && len>=5) { + *inst_len = 5; + } + else + *inst_len = 3; + len -= *inst_len; + + if (len > 0) { + char *p = inst + *inst_len; + + if (len >= 2) { + const char *cc = condition_codes; + + while (*cc) { + if (!strnicmp(p,cc,2)) + break; + cc += 2; + } + if (*cc) { /* matched against a condition code */ + ext[cnt] = p; + ext_len[cnt++] = 2; + p += 2; + len -= 2; + } + } + if (len >= 1) { + const char **am = addrmode_strings; + + do { + if (len==strlen(*am) && !strnicmp(*am,p,len)) + break; + am++; + } + while (*am); + if (*am!=NULL || (len==1 && tolower((unsigned char)*p)=='s')) { + ext[cnt] = p; + ext_len[cnt++] = len; + } + } + } + else if (len < 0) + ierror(0); + } + else + *inst_len = len; + + *ext_cnt = cnt; + } + + return s; +} + + +int set_default_qualifiers(char **q,int *q_len) +/* fill in pointers to default qualifiers, return number of qualifiers */ +{ + return 0; +} + + +static int parse_reg(char **pp) +/* parse register, return -1 on error */ +{ + char *p = *pp; + char *name = p; + regsym *sym; + + if (ISIDSTART(*p)) { + p++; + while (ISIDCHAR(*p)) + p++; + if (sym = find_regsym_nc(name,p-name)) { + *pp = p; + return sym->reg_num; + } + } + return -1; /* no valid register found */ +} + + +static int parse_reglist(char **pp) +/* parse register-list, return -1 on error */ +{ + int r=0,list=0,lastreg=-1; + char *p = *pp; + char *name; + regsym *sym; + + if (*p++ == '{') { + p = skip(p); + + do { + if (ISIDSTART(*p)) { + name = p++; + while (ISIDCHAR(*p)) + p++; + if (sym = find_regsym_nc(name,p-name)) { + r = sym->reg_num; + if (lastreg >= 0) { /* range-mode? */ + if (lastreg < r) { + r = lastreg; + lastreg = sym->reg_num; + } + for (; r<=lastreg; list |= 1<type = optype; + op->flags = 0; + op->value = NULL; + p = skip(p); + + if (optype == DATA64_OP) { + op->value = parse_expr_huge(&p); + } + else if (op->type == DATA_OP) { + op->value = parse_expr(&p); + } + + else if (thumb_mode) { + if (ARMOPER(optype)) { /* standard ARM instruction */ + return PO_NOMATCH; + } + + else if (THREGOPER(optype)) { + /* parse a register */ + int r; + + if (optype==TR5IN || optype==TPCPR || optype==TSPPR) { + if (*p++ != '[') + return PO_NOMATCH; + p = skip(p); + } + + if ((r = parse_reg(&p)) < 0) + return PO_NOMATCH; + op->value = number_expr((taddr)r); + + if (optype==TPCRG || optype==TPCPR) { + if (r != 15) + return PO_NOMATCH; + } + else if (optype==TSPRG || optype==TSPPR) { + if (r != 13) + return PO_NOMATCH; + } + else if (optype==THR02 || optype==THR05) { + if (r<8 || r>15) + return PO_NOMATCH; + } + else { + if (r<0 || r>7) + return PO_NOMATCH; + } + if (optype == TR8IN) { + p = skip(p); + if (*p++ != ']') + return PO_NOMATCH; + } + else if (optype == TR10W) { + if (*p++ != '!') + return PO_NOMATCH; + } + } + + else if (THREGLIST(optype)) { + taddr list = parse_reglist(&p); + + if (optype == TRLST) { + if (list & ~0xff) + return PO_NOMATCH; /* only r0-r7 allowed */ + } + else { + if ((list&0x8000) && optype==TRLPC) { + list = list&~0x8000 | 0x100; + } + else if ((list&0x4000) && optype==TRLLR) { + list = list&~0x4000 | 0x100; + } + if (list & ~0x1ff) + return PO_NOMATCH; /* only r0-r7 / pc / lr allowed */ + } + op->value = number_expr(list); + } + + else if (THIMMOPER(optype)) { + if (*p++ != '#') + return PO_NOMATCH; + p = skip(p); + op->value = parse_expr(&p); + + if (THIMMINDIR(optype)) { + p = skip(p); + if (*p++ != ']') + return PO_NOMATCH; + } + } + + else { /* just parse an expression */ + char *q = p; + + /* check that this isn't any other valid operand */ + if (*p=='#' || *p=='[' || *p=='{' || parse_reg(&q)>=0) + return PO_NOMATCH; + op->value = parse_expr(&p); + } + } + + else { /* ARM mode */ + if (THUMBOPER(optype)) { /* Thumb instruction */ + return PO_NOMATCH; + } + + else if (STDOPER(optype)) { + /* parse an expression (register, label, imm.) and assign to 'value' */ + if (IMMEDOPER(optype)) { + if (*p++ != '#') + return PO_NOMATCH; + p = skip(p); + } + else if (optype==R19PR || optype==R19PO) { + if (*p++ != '[') + return PO_NOMATCH; + p = skip(p); + } + + if (UPDOWNOPER(optype)) { + if (*p == '-') { + p = skip(p+1); + } + else { + if (*p == '+') + p = skip(p+1); + op->flags |= OFL_UP; + } + } + + if (REGOPER(optype)) { + int r = parse_reg(&p); + + if (r >= 0) + op->value = number_expr((taddr)r); + else + return PO_NOMATCH; + } + else { /* an expression */ + if (ISIDSTART(*p) || isdigit((unsigned char)*p) || + (!UPDOWNOPER(optype) && (*p=='-' || *p=='+'))) + op->value = parse_expr(&p); + else + return PO_NOMATCH; + } + + if (optype==R19PO || optype==R3UD1 || optype==IMUD1 || optype==IMCP1) { + p = skip(p); + if (*p++ != ']') + return PO_NOMATCH; + } + if (optype==R19WB || optype==R3UD1 || optype==IMUD1 || optype==IMCP1) { + if (*p == '!') { + p++; + op->flags |= OFL_WBACK; + } + } + } + + else if (SHIFTOPER(optype)) { + char *name = p; + int i; + + p = skip_identifier(p); + if (p == NULL) + return PO_NOMATCH; + for (i=0; i= NUM_SHIFTTYPES) + return PO_NOMATCH; + if (i == 4) { + /* RRX is ROR with immediate value 0 */ + op->flags |= OFL_IMMEDSHIFT; + op->value = number_expr(0); + i = 3; /* ROR */ + } + else { + /* parse immediate or register for LSL, LSR, ASR, ROR */ + p = skip(p); + if (i == 5) + i = 0; /* ASL -> LSL */ + if (*p == '#') { + p++; + op->flags |= OFL_IMMEDSHIFT; + op->value = parse_expr(&p); + } + else if (optype == SHIFT) { + int r = parse_reg(&p); + + if (r >= 0) + op->value = number_expr((taddr)r); + else + return PO_NOMATCH; + } + else + return PO_NOMATCH; /* no shift-count in register allowed */ + } + op->flags |= i & OFL_SHIFTOP; + + if (optype == SHIM1) { + /* check for pre-indexed with optional write-back */ + p = skip(p); + if (*p++ != ']') + return PO_NOMATCH; + if (*p == '!') { + p++; + op->flags |= OFL_WBACK; + } + } + } + + else if (optype == CSPSR) { + char *name = p; + + p = skip_identifier(p); + if (p == NULL) + return PO_NOMATCH; + if (!strnicmp(name,"CPSR",p-name)) + op->flags &= ~OFL_SPSR; + else if (!strnicmp(name,"SPSR",p-name)) + op->flags |= OFL_SPSR; + else + return PO_NOMATCH; + op->value = number_expr(0xf); /* all fields f,s,x,c */ + } + + else if (optype == PSR_F) { + char *name = p; + taddr fields = 0xf; + + p = skip_identifier(p); + if (p==NULL || (p-name)<4) + return PO_NOMATCH; + if (!strnicmp(name,"CPSR",4)) + op->flags &= ~OFL_SPSR; + else if (!strnicmp(name,"SPSR",4)) + op->flags |= OFL_SPSR; + else + return PO_NOMATCH; + + if ((p-name)>5 && *(name+4)=='_') { + fields = 0; + name += 5; + while (name < p) { + switch (tolower((unsigned char)*name++)) { + case 'f': fields |= 8; break; + case 's': fields |= 4; break; + case 'x': fields |= 2; break; + case 'c': fields |= 1; break; + default: return PO_NOMATCH; + } + } + } + else if ((p-name) > 4) + return PO_NOMATCH; + op->value = number_expr(fields); + } + + else if (optype == RLIST) { + taddr list = parse_reglist(&p); + + if (list >= 0) { + op->value = number_expr(list); + if (*p == '^') { + p++; + op->flags |= OFL_FORCE; /* set "load PSR / force user mode" flag */ + } + } + else + return PO_NOMATCH; + } + + else + ierror(0); + } + + return (skip(p)-start < len) ? PO_NOMATCH : PO_MATCH; +} + + +static void create_mapping_symbol(int type,section *sec,taddr pc) +/* create mapping symbol ($a, $t, $d) as required by ARM ELF ABI */ +{ + static char names[3][4] = { "$a","$t","$d" }; + static int types[3] = { TYPE_FUNCTION,TYPE_FUNCTION,TYPE_OBJECT }; + symbol *sym; + + if (typeTYPE_DATA) + ierror(0); + if (elfoutput) { + sym = mymalloc(sizeof(symbol)); + sym->type = LABSYM; + sym->flags = types[type]; + sym->name = names[type]; + sym->sec = sec; + sym->pc = pc; + sym->expr = 0; + sym->size = 0; + sym->align = 0; + add_symbol(sym); + } + last_data_type = type; +} + + +size_t eval_thumb_operands(instruction *ip,section *sec,taddr pc, + uint16_t *insn,dblock *db) +/* evaluate expressions and try to optimize THUMB instruction, + return size of instruction */ +{ + operand op; + mnemonic *mnemo = &mnemonics[ip->code]; + int opcnt = 0; + size_t isize = 2; + + if (insn) { + if (pc & 1) + cpu_error(27); /* instruction at unaligned address */ + + if (ip->op[0] == NULL) { + /* handle inst. without operands, which don't have Thumb entries */ + if (ip->code == OC_NOP) + *insn = 0x46c0; /* nop => mov r0,r0 */ + + return 2; + } + else + *insn = (uint16_t)mnemo->ext.opcode; + } + + for (opcnt=0; opcntop[opcnt]!=NULL; opcnt++) { + taddr val; + symbol *base = NULL; + int btype; + + op = *(ip->op[opcnt]); + if (!eval_expr(op.value,&val,sec,pc)) + btype = find_base(op.value,&base,sec,pc); + + /* do optimizations first */ + + if (op.type==TPCLW || THBRANCH(op.type)) { + /* PC-relative offsets (take prefetch into account: PC+4) */ + if ((base!=NULL && btype==BASE_OK && !is_pc_reloc(base,sec)) || + base==NULL) { + /* no relocation required, can be resolved immediately */ + if (op.type == TPCLW) { + /* bit 1 of PC is forced to 0 */ + val -= (pc&~2) + 4; + } + else + val -= pc + 4; + + if (op.type == TBR08) { + if (val<-0x100 || val>0xfe) { + /* optimize to: B .+4 ; B label */ + if (insn) { + *insn++ ^= 0x100; /* negate branch-condition */ + *insn = 0xe000; /* B unconditional to label */ + } + if (val < 0) + val -= 2; /* backward-branches are 2 bytes longer */ + isize += 2; + op.type = TBR11; + } + } + else if (op.type == TBRHL) { + /* BL always consists of two instructions */ + isize += 2; + } + else if (op.type == TPCLW) { + /* @@@ optimization makes any sense? */ + op.type = TUIMA; + base = NULL; /* no more checks */ + } + } + else if (btype == BASE_OK) { + /* symbol is in a different section or externally declared */ + if (op.type == TBRHL) { + val -= THB_PREFETCH; + if (db) { + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?5:0,11,0,0x7ff000); + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?16+5:16+0,11,0,0xffe); + } + isize += 2; /* we need two instructions for a 23-bit branch */ + } + else if (op.type == TPCLW) { + /* val -= THB_PREFETCH; @@@ only positive offsets allowed! */ + op.type = TUIMA; + if (db) + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?8:0,8,0,0x3fc); + base = NULL; /* no more checks */ + } + else if (insn) + cpu_error(22); /* operation not allowed on external symbols */ + } + else if (insn) + cpu_error(22); /* operation not allowed on external symbols */ + } + + /* optimizations should be finished at this stage - + inserts operands into the opcode now: */ + + if (insn) { + + if (THREGOPER(op.type)) { + /* insert register operand, check was already done in parse_operand */ + if (!THPCORSP(op.type)) { + switch (op.type) { + case TRG02: + case THR02: + *insn |= val&7; + break; + case TRG05: + case THR05: + case TR5IN: + *insn |= (val&7) << 3; + break; + case TRG08: + case TR8IN: + *insn |= (val&7) << 6; + break; + case TRG10: + case TR10W: + *insn |= (val&7) << 8; + break; + default: + ierror(0); + break; + } + } + } + + else if (THREGLIST(op.type)) { + /* register list was already checked in parse_operand - just insert */ + *insn |= val; + } + + else if (THIMMOPER(op.type) || op.type==TSWI8) { + /* immediate operand */ + switch (op.type) { + case TUIM3: + if (val>=0 && val<=7) { + *insn |= val<<6; + } + else + cpu_error(25,3,(long)val); /* immediate offset out of range */ + break; + case TUIM5: + case TUI5I: + if (val>=0 && val<=0x1f) { + *insn |= val<<6; + } + else + cpu_error(25,5,(long)val); /* immediate offset out of range */ + break; + case TUI6I: + if (val>=0 && val<=0x3e) { + if ((val & 1) == 0) + *insn |= (val&0x3e)<<5; + else + cpu_error(26,2); /* offset has to be a multiple of 2 */ + } + else + cpu_error(25,6,(long)val); /* immediate offset out of range */ + break; + case TUI7I: + if (val>=0 && val<=0x7c) { + if ((val & 3) == 0) + *insn |= (val&0x7c)<<4; + else + cpu_error(26,4); /* offset has to be a multiple of 4 */ + } + else + cpu_error(25,7,(long)val); /* immediate offset out of range */ + break; + case TUIM8: + case TSWI8: + if (val>=0 && val<=0xff) { + *insn |= val; + } + else + cpu_error(25,8,(long)val); /* immediate offset out of range */ + break; + case TUIM9: + if (val>=0 && val<=0x1fc) { + if ((val & 3) == 0) + *insn |= val>>2; + else + cpu_error(26,4); /* offset has to be a multiple of 4 */ + } + else + cpu_error(25,9,(long)val); /* immediate offset out of range */ + break; + case TUIMA: + case TUIAI: + if (val>=0 && val<=0x3fc) { + if ((val & 3) == 0) + *insn |= val>>2; + else + cpu_error(26,4); /* offset has to be a multiple of 4 */ + } + else + cpu_error(25,10,(long)val); /* immediate offset out of range */ + break; + } + + if (base!=NULL && db!=NULL) { + if (btype == BASE_OK) { + if (op.type==TUIM5 || op.type==TUI5I) + add_extnreloc_masked(&db->relocs,base,val,REL_ABS, + arm_be_mode?5:6,5,0,0x1f); + else if (op.type == TSWI8) + add_extnreloc_masked(&db->relocs,base,val,REL_ABS, + arm_be_mode?8:0,8,0,0xff); + else + cpu_error(6); /* constant integer expression required */ + } + else + general_error(38); /* illegal relocation */ + } + } + + else if (op.type == TBR08) { + /* only write offset, relocs and optimizations are handled above */ + if (val & 1) + cpu_error(8,(long)val); /* branch to unaligned address */ + *insn |= (val>>1) & 0xff; + } + + else if (op.type == TBR11) { + /* only write offset, relocs and optimizations are handled above */ + if (val<-0x800 || val>0x7fe) + cpu_error(3,(long)val); /* branch offset is out of range */ + if (val & 1) + cpu_error(8,(long)val); /* branch to unaligned address */ + *insn |= (val>>1) & 0x7ff; + } + + else if (op.type == TBRHL) { + /* split 23-bit offset over two instructions, ignoring bit 0 */ + if (val<-0x400000 || val>0x3ffffe) + cpu_error(3,(long)val); /* branch offset is out of range */ + if (val & 1) + cpu_error(8,(long)val); /* branch to unaligned address */ + *insn++ |= (val>>12) & 0x7ff; + *insn = 0xf800 | ((val>>1) & 0x7ff); + } + + else + ierror(0); + } + } + + return isize; +} + + +#define ROTFAIL (0xffffff) + +static uint32_t rotated_immediate(uint32_t val) +/* check if a 32-bit value can be represented as 8-bit-rotated, + return ROTFAIL when impossible */ +{ + uint32_t a; + int i; + + if (val <= 0xff) + return val; /* no rotation needed */ + + for (i=2; i<32; i+=2) { + if ((a = val<>(32-i)) <= 0xff) + return ((uint32_t)i << 7) | a; + } + return ROTFAIL; +} + + +static int negated_rot_immediate(uint32_t val,mnemonic *mnemo, + uint32_t *insn) +/* check if negating the ALU-operation makes a valid 8-bit-rotated value, + insert it into the current instruction, when successful */ +{ + uint32_t neg = rotated_immediate(-val); + uint32_t inv = rotated_immediate(~val); + uint32_t op = (mnemo->ext.opcode & 0x01e00000) >> 21; + + switch (op) { + /* AND <-> BIC */ + case 0: op=14; val=inv; break; + case 14: op=0; val=inv; break; + /* ADD <-> SUB */ + case 2: op=4; val=neg; break; + case 4: op=2; val=neg; break; + /* ADC <-> SBC */ + case 5: op=6; val=inv; break; + case 6: op=5; val=inv; break; + /* CMP <-> CMN */ + case 10: op=11; val=neg; break; + case 11: op=10; val=neg; break; + /* MOV <-> MVN */ + case 13: op=15; val=inv; break; + case 15: op=13; val=inv; break; + + default: return 0; + } + + if (val == ROTFAIL) + return 0; + + if (insn) { + *insn &= ~0x01e00000; + *insn |= (op<<21) | val; + } + return 1; +} + + +static uint32_t double_rot_immediate(uint32_t val,uint32_t *hi) +/* check if a 32-bit value can be represented by combining two + 8-bit rotated values, return ROTFAIL otherwise */ +{ + static uint32_t masks[] = { 0x000000ff,0xc000003f,0xf000000f,0xfc000003, + 0xff000000,0x3fc00000,0x0ff00000,0x03fc0000, + 0x00ff0000,0x003fc000,0x000ff000,0x0003fc00, + 0x0000ff00,0x00003fc0,0x00000ff0,0x000003fc }; + uint32_t a,m; + int i; + + for (i=0; i<16; i++) { + m = masks[i]; + if ((val & m) && (a = rotated_immediate(val & ~m)) != ROTFAIL) { + *hi = a; + i <<= 1; + a = i==0 ? val : (val<>(32-i)); + return ((uint32_t)i << 7) | (a & 0xff); + } + } + + return ROTFAIL; +} + + +static uint32_t calc_2nd_rot_opcode(uint32_t op) +/* calculates ALU operation for second instruction */ +{ + if (op == 13) + op = 12; /* MOV + ORR */ + else if (op == 15) + op = 1; /* MVN + EOR */ + /* ADD and SUB stay the same */ + + return op << 21; +} + + +static int negated_double_rot_immediate(uint32_t val,uint32_t *insn) +/* check if negating the ALU-operation and/or a second ADD/SUB operation + makes a valid 8-bit-rotated value, insert it into the current + instruction, when successful */ +{ + uint32_t op = (*insn & 0x01e00000) >> 21; + + if ((op==2 || op==4 || op==13 || op==15) && insn!=NULL) { + /* combined instructions only possible for ADD/SUB/MOV/MVN */ + uint32_t lo,hi; + + *(insn+1) = *insn & ~0x01ef0000; + *(insn+1) |= (*insn&0xf000) << 4; /* Rn = Rd of first instruction */ + + if ((lo = double_rot_immediate(val,&hi)) != ROTFAIL) { + *insn++ |= hi; + *insn |= calc_2nd_rot_opcode(op) | lo; + return 1; + } + + /* @@@ try negated or inverted values */ + } + + return 0; +} + + +static uint32_t get_condcode(instruction *ip) +/* returns condition (bit 31-28) from instruction's qualifiers */ +{ + const char *cc = condition_codes; + char *q; + + if (q = ip->qualifiers[0]) { + uint32_t code = 0; + + while (*cc) { + if (!strnicmp(q,cc,2) && *(q+2)=='\0') + break; + cc += 2; + code++; + } + if (*cc) { /* condition code in qualifier valid */ + if (code == 16) /* hs -> cs */ + code = 2; + else if (code==17 || code==18) /* lo/ul -> cc */ + code = 3; + + return code<<28; + } + } + + return 0xe0000000; /* AL - always */ +} + + +static int get_addrmode(instruction *ip) +/* return addressing mode from instruction's qualifiers */ +{ + char *q; + + if ((q = ip->qualifiers[1]) == NULL) + q = ip->qualifiers[0]; + + if (q) { + const char **am = addrmode_strings; + int mode = AM_DA; + + do { + if (!stricmp(*am,q)) + break; + am++; + mode++; + } + while (*am); + + if (*am != NULL) + return mode; + } + + return AM_NONE; +} + + +size_t eval_arm_operands(instruction *ip,section *sec,taddr pc, + uint32_t *insn,dblock *db) +/* evaluate expressions and try to optimize ARM instruction, + return size of instruction */ +{ + operand op; + mnemonic *mnemo = &mnemonics[ip->code]; + int am = get_addrmode(ip); + int aa4ldst = 0; + int opcnt = 0; + size_t isize = 4; + taddr chkreg = -1; + + if (insn) { + if (pc & 3) + cpu_error(27); /* instruction at unaligned address */ + + *insn = mnemo->ext.opcode | get_condcode(ip); + + if ((mnemo->ext.flags & SETCC)!=0 && am==AM_S) + *insn |= 0x00100000; /* set-condition-codes flag */ + + if ((mnemo->ext.flags & SETPSR)!=0 && am==AM_P) { + /* Rd = R15 for changing the PSR. Recommended for ARM2/250/3 only. */ + *insn |= 0x0000f000; + if (cpu_type & ~AA2) + cpu_error(28); /* deprecated on 32-bit architectures */ + } + + if (!strcmp(mnemo->name,"ldr") || !strcmp(mnemo->name,"str")) { + if (am==AM_T || am==AM_B || am==AM_BT || am==AM_TB) { /* std. ldr/str */ + if (am != AM_B) { + *insn |= 0x00200000; /* W-flag for post-indexed mode */ + *insn &= ~0x01000000; /* force post-indexed */ + } + if (am != AM_T) + *insn |= 0x00400000; /* B-flag for byte-transfer */ + } + else if (am==AM_SB || am==AM_H || am==AM_SH) { /* arch.4 ldr/str */ + if (cpu_type & AA4UP) { + /* take P-, I- and L-bit from previous standard instruction */ + *insn = (*insn&0xf1100000) + | (((*insn&0x02000000)^0x02000000)>>3) /* I-bit is flipped */ + | 0x90; + if (am != AM_H) { + if (*insn & 0x00100000) /* load */ + *insn |= 0x40; /* signed transfer */ + else + cpu_error(18,addrmode_strings[am]); /* illegal addr. mode */ + } + if (am != AM_SB) + *insn |= 0x20; /* halfword-transfer */ + aa4ldst = 1; + } + else + cpu_error(0); /* instruction not supported on selected arch. */ + } + else if (am != AM_NONE) + cpu_error(18,addrmode_strings[am]); /* illegal addr. mode */ + } + else if (ip->code == OC_SWP) { + if (am == AM_B) + *insn |= 0x00400000; /* swap bytes */ + else if (am != AM_NONE) + cpu_error(18,addrmode_strings[am]); /* illegal addr. mode */ + } + } + else { /* called by instruction_size() */ + if (am==AM_SB || am==AM_H || am==AM_SH) + aa4ldst = 1; + } + + for (opcnt=0; opcntop[opcnt]!=NULL; opcnt++) { + symbol *base = NULL; + uint32_t rotval; + taddr val; + int btype; + + op = *(ip->op[opcnt]); + if (!eval_expr(op.value,&val,sec,pc)) + btype = find_base(op.value,&base,sec,pc); + + /* do optimizations first */ + + if (op.type==PCL12 || op.type==PCLRT || + op.type==PCLCP || op.type==BRA24) { + /* PC-relative offsets (take prefetch into account: PC+8) */ + if ((base!=NULL && btype==BASE_OK && !is_pc_reloc(base,sec)) || + base==NULL) { + /* no relocation required, can be resolved immediately */ + val -= pc + 8; + + switch (op.type) { + case BRA24: + if (val>=0x2000000 || val<-0x2000000) { + /* @@@ optimize? to what? */ + if (insn) + cpu_error(3,(long)val); /* branch offset is out of range */ + } + break; + + case PCL12: + if ((!aa4ldst && val<0x1000 && val>-0x1000) || + (aa4ldst && val<0x100 && val>-0x100)) { + op.type = IMUD2; /* handle as normal #+/-Imm12 */ + if (val < 0) + val = -val; + else + op.flags |= OFL_UP; + base = NULL; /* no more checks */ + } + else { + if (opt_ldrpc && + ((!aa4ldst && val<0x100000 && val>-0x100000) || + (aa4ldst && val<0x10000 && val>-0x10000))) { + /* ADD/SUB Rd,PC,#offset&0xff000 */ + /* LDR/STR Rd,[Rd,#offset&0xfff] */ + if (insn) { + taddr v; + + *(insn+1) = *insn; + *insn &= 0xf0000000; /* clear all except cond. */ + if (val < 0) { + v = -val; + *insn |= 0x024f0a00; /* SUB */ + *(insn+1) &= ~0x00800000; /* clear U-bit */ + } + else { + v = val; + *insn |= 0x028f0a00; /* ADD */ + *(insn+1) |= 0x00800000; /* set U-bit */ + } + if (aa4ldst) + *insn |= (*(insn+1)&0xf000) | ((v&0xff00)>>8); + else + *insn |= (*(insn+1)&0xf000) | ((v&0xff000)>>12); + *(insn+1) &= ~0x000f0000; /* replace PC by Rd */ + *(insn+1) |= (*insn & 0xf000) << 4; + insn++; + } + if (val < 0) + val = -val; + else + op.flags |= OFL_UP; + val = aa4ldst ? (val & 0xff) : (val & 0xfff); + isize += 4; + op.type = IMUD2; + base = NULL; /* no more checks */ + } + else { + op.type = NOOP; + if (insn) + cpu_error(4,val); /* PC-relative ldr/str out of range */ + } + } + break; + + case PCLCP: + if (val<0x400 && val>-0x400) { + op.type = IMCP2; /* handle as normal #+/-Imm10>>2 */ + if (val < 0) + val = -val; + else + op.flags |= OFL_UP; + base = NULL; /* no more checks */ + } + else { + /* no optimization, because we don't have a free register */ + op.type = NOOP; + if (insn) + cpu_error(4,val); /* PC-relative ldc/stc out of range */ + } + break; + + case PCLRT: + op.type = NOOP; /* is handled here */ + if (val < 0) { + /* use SUB instead of ADD */ + if (insn) + *insn ^= 0x00c00000; + val = -val; + } + if (am!=AM_L && (rotval = rotated_immediate(val))!=ROTFAIL && + !(opt_adr && (sec->flags&RESOLVE_WARN))) { + if (insn) + *insn |= rotval; + } + else if (opt_adr || am==AM_L) { + /* ADRL or optimize ADR automatically to ADRL */ + uint32_t hi,lo; + + isize += 4; + if ((lo = double_rot_immediate(val,&hi)) != ROTFAIL) { + /* ADD/SUB Rd,PC,#hi8rotated */ + /* ADD/SUB Rd,Rd,#lo8rotated */ + if (insn) { + *(insn+1) = *insn & ~0xf0000; + *(insn+1) |= (*insn&0xf000) << 4; + *insn++ |= hi; + *insn |= lo; + } + } + else if (insn) + cpu_error(5,(uint32_t)val); /* Cannot make rot.immed.*/ + } + else if (insn) + cpu_error(5,(uint32_t)val); /* Cannot make rot.immed.*/ + break; + + default: + ierror(0); + } + } + else if (btype == BASE_OK) { + /* symbol is in a different section or externally declared */ + switch (op.type) { + case BRA24: + val -= ARM_PREFETCH; + if (db) + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?8:0,24,0,0x3fffffc); + break; + case PCL12: + op.type = IMUD2; + if (db) { + if (val<0x1000 && val>-0x1000) { + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?20:0,12,0,0x1fff); + base = NULL; /* don't add another REL_ABS below */ + } + else + cpu_error(22); /* operation not allowed on external symbols */ + } + break; + case PCLCP: + if (db) + cpu_error(22); /* operation not allowed on external symbols */ + break; + case PCLRT: + op.type = NOOP; + if (am==AM_L && val==0) { /* ADRL */ + isize += 4; /* always reserve two ADD instructions */ + if (insn!=NULL && db!=NULL) { + *(insn+1) = *insn & ~0xf0000; + *(insn+1) |= (*insn&0xf000) << 4; + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?24:0,8,0,0xff00); + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?32+24:32+0,8,0,0xff); + } + } + else if (val == 0) { /* ADR */ + if (db) + add_extnreloc_masked(&db->relocs,base,val,REL_PC, + arm_be_mode?24:0,8,0,0xff); + } + else if (db) + cpu_error(22); /* operation not allowed on external symbols */ + break; + default: + ierror(0); + } + } + else if (db) + cpu_error(22); /* operation not allowed on external symbols */ + } + + else if (op.type == IMROT) { + op.type = NOOP; /* is handled here */ + + if (base == NULL) { + if ((rotval = rotated_immediate(val)) != ROTFAIL) { + if (insn) + *insn |= rotval; + } + else if (!negated_rot_immediate(val,mnemo,insn)) { + /* rotation, negation and inversion failed - try a 2nd operation */ + isize += 4; + if (insn) { + if (!negated_double_rot_immediate(val,insn)) + cpu_error(7,(uint32_t)val); /* const not suitable */ + } + } + } + else if (insn) + cpu_error(6); /* constant integer expression required */ + } + + /* optimizations should be finished at this stage - + inserts operands into the opcode now: */ + + if (insn) { + + if (REGOPER(op.type)) { + /* insert register operand */ + if (base!=NULL || val<0 || val>15) + cpu_error(9); /* not a valid ARM register */ + + if (REG19OPER(op.type)) + *insn |= val<<16; + else if (REG15OPER(op.type)) + *insn |= val<<12; + else if (REG11OPER(op.type)) + *insn |= val<<8; + else if (REG03OPER(op.type)) + *insn |= val; + + if (op.type==R3UD1 && !(*insn&0x01000000)) + cpu_error(21); /* post-indexed addressing mode expected */ + if (op.flags & OFL_WBACK) + *insn |= 0x00200000; + if (op.flags & OFL_UP) + *insn |= 0x00800000; + + /* some more checks: */ + if ((mnemo->ext.flags&NOPC) && val==15) + cpu_error(10); /* PC (r15) not allowed in this mode */ + if ((mnemo->ext.flags&NOPCR03) && val==15 && REG03OPER(op.type)) + cpu_error(11); /* PC (r15) not allowed for offset register Rm */ + if ((mnemo->ext.flags&NOPC) && val==15 && (op.flags&OFL_WBACK)) + cpu_error(12); /* PC (r15) not allowed with write-back */ + + /* check for illegal double register specifications */ + if (((mnemo->ext.flags&DIFR03) && REG03OPER(op.type)) || + ((mnemo->ext.flags&DIFR11) && REG11OPER(op.type)) || + ((mnemo->ext.flags&DIFR15) && REG15OPER(op.type)) || + ((mnemo->ext.flags&DIFR19) && REG19OPER(op.type))) { + if (chkreg != -1) { + if (val == chkreg) + cpu_error(13,(long)val); /* register was used multiple times */ + } + else + chkreg = val; + } + } + + else if (op.type == BRA24) { + /* only write offset, relocs and optimizations are handled above */ + if (val & 3) + cpu_error(8,(long)val); /* branch to unaligned address */ + *insn |= (val>>2) & 0xffffff; + } + + else if (op.type==IMUD1 || op.type==IMUD2) { + if (aa4ldst) { + /* insert splitted 8-bit immediate for signed/halfword ldr/str */ + if (val>=0 && val<=0xff) { + *insn |= ((val&0xf0)<<4) | (val&0x0f); + } + else + cpu_error(20,8,(long)val); /* immediate offset out of range */ + } + else { + /* insert immediate 12-bit with up/down flag */ + if (val>=0 && val<=0xfff) { + *insn |= val; + } + else + cpu_error(20,12,(long)val); /* immediate offset out of range */ + } + + if (op.type==IMUD1 && !(*insn&0x01000000)) + cpu_error(21); /* post-indexed addressing mode exptected */ + if (op.flags & OFL_WBACK) + *insn |= 0x00200000; /* set write-back flag */ + if (op.flags & OFL_UP) + *insn |= 0x00800000; /* set UP-flag */ + + if (base) { + if (btype == BASE_OK) { + if (EXTREF(base)) { + if (!aa4ldst) { + /* @@@ does this make any sense? */ + *insn |= 0x00800000; /* only UP */ + add_extnreloc_masked(&db->relocs,base,val,REL_ABS, + arm_be_mode?20:0,12,0,0xfff); + } + else + cpu_error(22); /* operation not allowed on external symbols */ + } + else + cpu_error(6); /* constant integer expression required */ + } + else + general_error(38); /* illegal relocation */ + } + } + + else if (op.type==IMCP1 || op.type==IMCP2) { + /* insert immediate 10-bit shifted left by 2, with up/down flag */ + if (val>=0 && val<=0x3ff) { + if ((val & 3) == 0) + *insn |= val>>2; + else + cpu_error(23); /* ldc/stc offset has to be a multiple of 4 */ + } + else + cpu_error(20,10,(long)val); /* immediate offset out of range */ + + if (op.flags & OFL_WBACK) + *insn |= 0x00200000; /* set write-back flag */ + if (op.flags & OFL_UP) + *insn |= 0x00800000; /* set UP-flag */ + + if (base) + cpu_error(6); /* constant integer expression required */ + } + + else if (op.type == SWI24) { + /* insert 24-bit immediate (SWI instruction) */ + if (val>=0 && val<0x1000000) { + *insn |= val; + if (base!=NULL && db!=NULL) + add_extnreloc_masked(&db->relocs,base,val,REL_ABS, + arm_be_mode?8:0,24,0,0xffffff); + } + else + cpu_error(16); /* 24-bit unsigned immediate expected */ + if (base) + cpu_error(6); /* constant integer expression required */ + } + + else if (op.type == IROTV) { + /* insert 4-bit rotate constant (even value, shifted right) */ + if (val>=0 && val<=30 && (val&1)==0) + *insn |= val << 7; + else + cpu_error(29,(long)val); /* must be even number between 0 and 30 */ + if (base) + cpu_error(6); /* constant integer expression required */ + } + + else if (op.type == IMMD8) { + /* unsigned 8-bit immediate constant, used together with IROTV */ + if (val>=0 && val<0x100 && base==NULL) + *insn |= val; + else + cpu_error(30,8,(long)val); /* 8-bit unsigned constant required */ + } + + else if (SHIFTOPER(op.type)) { + /* insert a register- or immediate shift */ + int sh_op = op.flags & OFL_SHIFTOP; + + if (aa4ldst) + cpu_error(19); /* signed/halfword ldr/str doesn't support shifts */ + if (op.type==SHIM1 && !(*insn&0x01000000)) + cpu_error(21); /* post-indexed addressing mode exptected */ + + if (op.flags & OFL_IMMEDSHIFT) { + if (sh_op==1 || sh_op==2) { /* lsr/asr permit shift-count #32 */ + if (val == 32) + val = 0; + } + if (base==NULL && val>=0 && val<32) { + *insn |= (val<<7) | ((op.flags&OFL_SHIFTOP)<<5); + if (op.flags & OFL_WBACK) + *insn |= 0x00200000; + } + else + cpu_error(14,(long)val); /* illegal immediate shift count */ + } + else { /* shift count in register */ + if (base==NULL && val>=0 && val<16) { + *insn |= (val<<8) | ((op.flags&OFL_SHIFTOP)<<5) | 0x10; + } + else + cpu_error(15); /* not a valid shift register */ + } + } + + else if (CPOPCODE(op.type)) { + /* insert coprocessor operation/type */ + if (base == NULL) { + switch (op.type) { + case CPOP3: + if (val>=0 && val<8) + *insn |= val<<21; + else + cpu_error(24,val); /* illegal coprocessor operation */ + break; + case CPOP4: + if (val>=0 && val<16) + *insn |= val<<20; + else + cpu_error(24,val); /* illegal coprocessor operation */ + break; + case CPTYP: + if (val>=0 && val<8) + *insn |= val<<5; + else + cpu_error(24,val); /* illegal coprocessor operation */ + break; + default: ierror(0); + } + } + else + cpu_error(24,val); /* illegal coprocessor operation */ + } + + else if (op.type==CSPSR || op.type==PSR_F) { + /* insert PSR type - no checks needed */ + *insn |= val<<16; + if (op.flags & OFL_SPSR) + *insn |= 0x00400000; + } + + else if (op.type == RLIST) { + /* insert register-list field */ + if (amAM_ED) + cpu_error(18,addrmode_strings[am]); /* illegal addr. mode */ + if (am>=AM_FA && am<=AM_ED) { + /* fix stack-addressing mode */ + if (!(mnemo->ext.opcode & 0x00100000)) + am ^= 3; /* invert P/U modes for store operations */ + } + *insn |= ((am&3)<<23) | val; + if (op.flags & OFL_FORCE) + *insn |= 0x00400000; + } + + else if (op.type != NOOP) + ierror(0); + } + } + + return isize; +} + + +size_t instruction_size(instruction *ip,section *sec,taddr pc) +/* Calculate the size of the current instruction; must be identical + to the data created by eval_instruction. */ +{ + if (mnemonics[ip->code].ext.flags & THUMB) + return eval_thumb_operands(ip,sec,pc,NULL,NULL); + + /* ARM mode */ + return eval_arm_operands(ip,sec,pc,NULL,NULL); +} + + +dblock *eval_instruction(instruction *ip,section *sec,taddr pc) +/* Convert an instruction into a DATA atom including relocations, + if necessary. */ +{ + dblock *db = new_dblock(); + int inst_type; + + if (sec != last_section) { + last_section = sec; + last_data_type = -1; + } + inst_type = (mnemonics[ip->code].ext.flags & THUMB) ? TYPE_THUMB : TYPE_ARM; + + if (inst_type == TYPE_THUMB) { + uint16_t insn[2]; + + if (db->size = eval_thumb_operands(ip,sec,pc,insn,db)) { + unsigned char *d = db->data = mymalloc(db->size); + int i; + + for (i=0; isize/2; i++) + d = setval(arm_be_mode,d,2,insn[i]); + } + } + + else { /* ARM mode */ + uint32_t insn[2]; + + if (db->size = eval_arm_operands(ip,sec,pc,insn,db)) { + unsigned char *d = db->data = mymalloc(db->size); + int i; + + for (i=0; isize/4; i++) + d = setval(arm_be_mode,d,4,insn[i]); + } + } + + if (inst_type != last_data_type) + create_mapping_symbol(inst_type,sec,pc); + + return db; +} + + +dblock *eval_data(operand *op,size_t bitsize,section *sec,taddr pc) +/* Create a dblock (with relocs, if necessary) for size bits of data. */ +{ + dblock *db = new_dblock(); + taddr val; + + if (sec != last_section) { + last_section = sec; + last_data_type = -1; + } + + if ((bitsize & 7) || bitsize > 64) + cpu_error(17,bitsize); /* data size not supported */ + + if (op->type!=DATA_OP && op->type!=DATA64_OP) + ierror(0); + + db->size = bitsize >> 3; + db->data = mymalloc(db->size); + + if (op->type == DATA64_OP) { + thuge hval; + + if (!eval_expr_huge(op->value,&hval)) + general_error(59); /* cannot evaluate huge integer */ + huge_to_mem(arm_be_mode,db->data,db->size,hval); + } + else { + if (!eval_expr(op->value,&val,sec,pc)) { + symbol *base; + int btype; + + btype = find_base(op->value,&base,sec,pc); + if (base) + add_extnreloc(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS,0,bitsize,0); + else if (btype != BASE_NONE) + general_error(38); /* illegal relocation */ + } + switch (db->size) { + case 1: + db->data[0] = val & 0xff; + break; + case 2: + case 4: + setval(arm_be_mode,db->data,db->size,val); + break; + default: + ierror(0); + break; + } + } + + if (last_data_type != TYPE_DATA) + create_mapping_symbol(TYPE_DATA,sec,pc); + + return db; +} + + +int init_cpu() +{ + char r[4]; + int i; + + for (i=0; i 1) + inst_alignment = thumb_mode ? 2 : 4; + return 1; +} + + +int cpu_args(char *p) +{ + if (!strncmp(p,"-m",2)) { + p += 2; + if (!strcmp(p,"2")) cpu_type = ARM2; + else if (!strcmp(p,"250")) cpu_type = ARM250; + else if (!strcmp(p,"3")) cpu_type = ARM3; + else if (!strcmp(p,"6")) cpu_type = ARM6; + else if (!strcmp(p,"600")) cpu_type = ARM600; + else if (!strcmp(p,"610")) cpu_type = ARM610; + else if (!strcmp(p,"7")) cpu_type = ARM7; + else if (!strcmp(p,"710")) cpu_type = ARM710; + else if (!strcmp(p,"7500")) cpu_type = ARM7500; + else if (!strcmp(p,"7d")) cpu_type = ARM7d; + else if (!strcmp(p,"7di")) cpu_type = ARM7di; + else if (!strcmp(p,"7dm")) cpu_type = ARM7dm; + else if (!strcmp(p,"7dmi")) cpu_type = ARM7dmi; + else if (!strcmp(p,"7tdmi")) cpu_type = ARM7tdmi; + else if (!strcmp(p,"8")) cpu_type = ARM8; + else if (!strcmp(p,"810")) cpu_type = ARM810; + else if (!strcmp(p,"9")) cpu_type = ARM9; + else if (!strcmp(p,"920")) cpu_type = ARM920; + else if (!strcmp(p,"920t")) cpu_type = ARM920t; + else if (!strcmp(p,"9tdmi")) cpu_type = ARM9tdmi; + else if (!strcmp(p,"sa1")) cpu_type = SA1; + else if (!strcmp(p,"strongarm")) cpu_type = STRONGARM; + else if (!strcmp(p,"strongarm110")) cpu_type = STRONGARM110; + else if (!strcmp(p,"strongarm1100")) cpu_type = STRONGARM1100; + else return 0; + } + else if (!strncmp(p,"-a",2)) { + p += 2; + if (!strcmp(p,"2")) cpu_type = AA2; + else if (!strcmp(p,"3")) cpu_type = AA3; + else if (!strcmp(p,"3m")) cpu_type = AA3M; + else if (!strcmp(p,"4")) cpu_type = AA4; + else if (!strcmp(p,"4t")) cpu_type = AA4T; + else return 0; + } + else if (!strcmp(p,"-little")) + arm_be_mode = 0; + else if (!strcmp(p,"-big")) + arm_be_mode = 1; + else if (!strcmp(p,"-thumb")) + thumb_mode = 1; + else if (!strcmp(p,"-opt-ldrpc")) + opt_ldrpc = 1; + else if (!strcmp(p,"-opt-adr")) + opt_adr = 1; + + return 1; +} diff --git a/tools/vasm/vasm/cpus/arm/cpu.h b/tools/vasm/vasm/cpus/arm/cpu.h new file mode 100644 index 0000000..0c0bbd7 --- /dev/null +++ b/tools/vasm/vasm/cpus/arm/cpu.h @@ -0,0 +1,214 @@ +/* cpu.h ARM cpu-description header-file */ +/* (c) in 2004,2014,2016 by Frank Wille */ + +#define LITTLEENDIAN (!arm_be_mode) +#define BIGENDIAN (arm_be_mode) +#define VASM_CPU_ARM 1 + +/* maximum number of operands in one mnemonic */ +#define MAX_OPERANDS 6 + +/* maximum number of mnemonic-qualifiers per mnemonic */ +#define MAX_QUALIFIERS 2 +/* but no qualifiers for macros */ +#define NO_MACRO_QUALIFIERS + +/* valid parentheses for cpu's operands */ +#define START_PARENTH(x) ((x)=='(' || (x)=='{') +#define END_PARENTH(x) ((x)==')' || (x)=='}') + +/* data type to represent a target-address */ +typedef int32_t taddr; +typedef uint32_t utaddr; + +/* minimum instruction alignment */ +#define INST_ALIGN 0 /* Handled internally! */ + +/* default alignment for n-bit data */ +#define DATA_ALIGN(n) ((n)<=8 ? 1 : ((n)<=16 ? 2 : 4)) + +/* operand class for n-bit data definitions */ +#define DATA_OPERAND(n) (n==64 ? DATA64_OP : DATA_OP) + +/* returns true when instruction is valid for selected cpu */ +#define MNEMONIC_VALID(i) cpu_available(i) + + +/* type to store each operand */ +typedef struct { + uint16_t type; /* type of operand from mnemonic.operand_type */ + uint16_t flags; /* see below */ + expr *value; /* single register, immed. val. or branch loc.*/ +} operand; + +/* flags: */ +#define OFL_SHIFTOP (0x0003) /* mask for shift-operation */ +#define OFL_IMMEDSHIFT (0x0004) /* uses immediate shift value */ +#define OFL_WBACK (0x0008) /* set write-back flag in opcode */ +#define OFL_UP (0x0010) /* set up-flag, add offset to base */ +#define OFL_SPSR (0x0020) /* 1:SPSR, 0:CPSR */ +#define OFL_FORCE (0x0040) /* LDM/STM PSR & force user bit */ + + +/* operand types - WARNING: the order is important! See defines below. */ +enum { + /* ARM operands */ + NOOP=0, + DATA_OP, /* data operand */ + DATA64_OP, /* 64-bit data operand (greater than taddr) */ + BRA24, /* 24-bit branch offset to label */ + PCL12, /* 12-bit PC-relative offset with up/down-flag to label */ + PCLCP, /* 8-bit * 4 PC-relative offset with up/down-flag to label */ + PCLRT, /* 8-bit rotated PC-relative offset to label */ + CPOP4, /* 4-bit coprocessor operation code at 23..20 */ + CPOP3, /* 3-bit coprocessor operation code at 23..21 */ + CPTYP, /* 3-bit coprocessor operation type at 7..5 */ + SWI24, /* 24-bit immediate at 23..0 (SWI instruction) */ + IROTV, /* explicit 4-bit rotate value at 11..8 */ + REG03, /* Rn at 3..0 */ + REG11, /* Rn at 11..8 */ + REG15, /* Rn at 15..12 */ + REG19, /* Rn at 19..16 */ + R19WB, /* Rn at 19..16 with optional write-back '!' */ + R19PR, /* [Rn, pre-indexed at 19..16 */ + R19PO, /* [Rn], post-indexed or indir. without index, at 19..16 */ + R3UD1, /* +/-Rn], pre-indexed at 3..0 with optional write-back '!' */ + R3UD2, /* +/-Rn, at 3..0, pre- or post-indexed */ + IMUD1, /* #+/-Imm12] pre-indexed with ']' and optional w-back '!' */ + IMUD2, /* #+/-Imm12 post-indexed */ + IMCP1, /* #+/-Imm10>>2 pre-indexed with ']' and optional w-back '!' */ + IMCP2, /* #+/-Imm10>>2 post-indexed */ + IMMD8, /* #Immediate, 8-bit */ + IMROT, /* #Imm32, 8-bit auto-rotated */ + SHIFT, /* Rs | #Imm5 | RRX = ROR #0 */ + SHIM1, /* #Imm5 | RRX, pre-indexed with terminating ] or ]! */ + SHIM2, /* #Imm5 | RRX, post-indexed */ + CSPSR, /* CPSR or SPSR */ + PSR_F, /* PSR-field: SPSR_, CPSR_ */ + RLIST, /* register list */ + + /* THUMB operands */ + TRG02, /* Rn at 2..0 */ + TRG05, /* Rn at 5..3 */ + TRG08, /* Rn at 8..6 */ + TRG10, /* Rn at 10..8 */ + THR02, /* Hi-Rn at 2..0 */ + THR05, /* Hi-Rn at 5..3 */ + TR5IN, /* [Rn at 5..3 */ + TR8IN, /* Rn] at 8..6 */ + TR10W, /* Rn! at 10..8 with write-back '!' */ + TPCRG, /* "PC" */ + TSPRG, /* "SP" */ + TPCPR, /* "[PC" */ + TSPPR, /* "[SP" */ + TRLST, /* register list for r0-r7 */ + TRLLR, /* extended register list, includes LR */ + TRLPC, /* extended register list, includes PC */ + TUIM3, /* 3-bit unsigned immediate at 8..6 */ + TUIM5, /* 5-bit unsigned immediate at 10..6 */ + TUIM8, /* 8-bit unsigned immediate at 7..0 */ + TUIM9, /* 9-bit unsigned immediate >> 2 at 6..0 */ + TUIMA, /* 10-bit unsigned immediate >> 2 at 7..0 */ + TUI5I, /* 5-bit unsigned immediate at 10..6 with terminating ] */ + TUI6I, /* 6-bit unsigned immediate >> 1 at 10..6 with terminating ] */ + TUI7I, /* 7-bit unsigned immediate >> 2 at 10..6 with terminating ] */ + TUIAI, /* 10-bit unsigned immediate >> 2 at 7..0 with terminating ] */ + TSWI8, /* 8-bit immediate at 7..0 (SWI instruction) */ + TPCLW, /* PC-relative label, has to fit into 10-bit uns.imm. >> 2 */ + TBR08, /* 9-bit branch offset >> 1 to label at 7..0 */ + TBR11, /* 12-bit branch offset >> 1 to label at 10..0 */ + TBRHL /* 23-bit branch offset >> 1 splitted into two 11-bit instr. */ +}; + +#define ARMOPER(x) ((x)>=BRA24 && (x)<=RLIST) +#define STDOPER(x) ((x)>=DATA_OP && (x)<=IMROT) +#define CPOPCODE(x) ((x)>=CPOP4 && (x)<=CPTYP) +#define REGOPER(x) ((x)>=REG03 && (x)<=R3UD2) +#define REG19OPER(x) ((x)>=REG19 && (x)<=R19PO) +#define REG15OPER(x) ((x)==REG15) +#define REG11OPER(x) ((x)==REG11) +#define REG03OPER(x) ((x)==REG03 || (x)==R3UD1 || (x)==R3UD2) +#define UPDOWNOPER(x) ((x)>=R3UD1 && (x)<=IMCP2) +#define IMMEDOPER(x) ((x)>=IMUD1 && (x)<=IMROT) +#define SHIFTOPER(x) ((x)>=SHIFT && (x)<=SHIM2) + +#define THUMBOPER(x) ((x)==0 || (x)>=TRG02) +#define THREGOPER(x) ((x)>=TRG02 && (x)<=TSPPR) +#define THPCORSP(x) ((x)>=TPCRG && (x)<=TSPPR) +#define THREGLIST(x) ((x)>=TRLST && (x)<=TRLPC) +#define THIMMOPER(x) ((x)>=TUIM3 && (x)<=TUIAI) +#define THIMMINDIR(x) ((x)>=TUI5I && (x)<=TUIAI) +#define THBRANCH(x) ((x)>=TBR08 && (x)<=TBRHL) + + +/* additional mnemonic data */ +typedef struct { + uint32_t opcode; + uint32_t available; + uint32_t flags; +} mnemonic_extension; + +/* flags: */ +#define DIFR19 (0x00000001) /* DIFFRxx registers must be different */ +#define DIFR15 (0x00000002) +#define DIFR11 (0x00000004) +#define DIFR03 (0x00000008) +#define NOPC (0x00000010) /* R15 is not allowed as source or dest. */ +#define NOPCR03 (0x00000020) /* R15 is not allowed for Rm (3..0) */ +#define NOPCWB (0x00000040) /* R15 is not allowed in Write-Back mode */ +#define SETCC (0x00000100) /* instruction supports S-bit */ +#define SETPSR (0x00000200) /* instruction supports P-bit */ +#define THUMB (0x10000000) /* THUMB instruction */ + + +/* register symbols */ +#define HAVE_REGSYMS +#define REGSYMHTSIZE 256 + + +/* cpu types for availability check */ +#define ARM2 (1L<<0) +#define ARM250 (1L<<1) +#define ARM3 (1L<<2) +#define ARM6 (1L<<3) +#define ARM60 (1L<<4) +#define ARM600 (1L<<5) +#define ARM610 (1L<<6) +#define ARM7 (1L<<7) +#define ARM710 (1L<<8) +#define ARM7500 (1L<<9) +#define ARM7d (1L<<10) +#define ARM7di (1L<<11) +#define ARM7dm (1L<<12) +#define ARM7dmi (1L<<13) +#define ARM7tdmi (1L<<14) +#define ARM8 (1L<<15) +#define ARM810 (1L<<16) +#define ARM9 (1L<<17) +#define ARM920 (1L<<18) +#define ARM920t (1L<<19) +#define ARM9tdmi (1L<<20) +#define SA1 (1L<<21) +#define STRONGARM (1L<<22) +#define STRONGARM110 (1L<<23) +#define STRONGARM1100 (1L<<24) + +/* ARM architectures */ +#define AA2 (ARM2|ARM250|ARM3) +#define AA3 (ARM6|ARM60|ARM600|ARM610|ARM7|ARM710|ARM7500|ARM7d|ARM7di) +#define AA3M (ARM7dm|ARM7dmi) +#define AA4 (ARM8|ARM810|ARM9|ARM920|SA1|STRONGARM|STRONGARM110|STRONGARM1100) +#define AA4T (ARM7tdmi|ARM920t|ARM9tdmi) + +#define AA4TUP (AA4T) +#define AA4UP (AA4|AA4T) +#define AA3MUP (AA3M|AA4|AA4T) +#define AA3UP (AA3|AA3M|AA4|AA4T) +#define AA2UP (AA2|AA3|AA3M|AA4|AA4T) +#define AAANY (~0) + + +/* exported by cpu.c */ +extern int arm_be_mode; + +int cpu_available(int); diff --git a/tools/vasm/vasm/cpus/arm/cpu_errors.h b/tools/vasm/vasm/cpus/arm/cpu_errors.h new file mode 100644 index 0000000..66f7f46 --- /dev/null +++ b/tools/vasm/vasm/cpus/arm/cpu_errors.h @@ -0,0 +1,31 @@ + "instruction not supported on selected architecture",ERROR, + "trailing garbage in operand",WARNING, + "label from current section required",ERROR, + "branch offset (%ld) is out of range",ERROR, + "PC-relative load/store (offset %ld) out of range",ERROR, + "cannot make rotated immediate from PC-relative offset (0x%lx)",ERROR,/*05*/ + "constant integer expression required",ERROR, + "constant (0x%lx) not suitable for 8-bit rotated immediate",ERROR, + "branch to an unaligned address (offset %ld)",ERROR, + "not a valid ARM register",ERROR, + "PC (r15) not allowed in this mode",ERROR, /*10*/ + "PC (r15) not allowed for offset register Rm",ERROR, + "PC (r15) not allowed with write-back",ERROR, + "register r%ld was used multiple times",ERROR, + "illegal immediate shift count (%ld)",ERROR, + "not a valid shift register",ERROR, /*15*/ + "24-bit unsigned immediate expected",ERROR, + "data size %d not supported",ERROR, + "illegal addressing mode: %s",ERROR, + "signed/halfword ldr/str doesn't support shifts",ERROR, + "%d-bit immediate offset out of range (%ld)",ERROR, /*20*/ + "post-indexed addressing mode exptected",ERROR, + "operation not allowed on external symbols",ERROR, + "ldc/stc offset has to be a multiple of 4",ERROR, + "illegal coprocessor operation mode or type: %ld\n",ERROR, + "%d-bit unsigned immediate offset out of range (%ld)",ERROR, /*25*/ + "offset has to be a multiple of %d",ERROR, + "instruction at unaligned address",ERROR, + "TSTP/TEQP/CMNP/CMPP deprecated on 32-bit architectures",WARNING, + "rotate constant must be an even number between 0 and 30: %ld",ERROR, + "%d-bit unsigned constant required: %ld",ERROR, /*30*/ diff --git a/tools/vasm/vasm/cpus/arm/opcodes.h b/tools/vasm/vasm/cpus/arm/opcodes.h new file mode 100644 index 0000000..3302fb2 --- /dev/null +++ b/tools/vasm/vasm/cpus/arm/opcodes.h @@ -0,0 +1,201 @@ + "add", {REG15,REG19,IMROT}, {0x02800000,AAANY,SETCC}, + "add", {REG15,REG19,IMMD8,IROTV}, {0x02800000,AAANY,SETCC}, + "add", {REG15,REG19,REG03}, {0x00800000,AAANY,SETCC}, + "add", {REG15,REG19,REG03,SHIFT}, {0x00800000,AAANY,SETCC}, + "add", {TRG02,TRG05,TRG08}, {0x1800,AA4TUP,THUMB}, + "add", {TRG02,TRG05,TUIM3}, {0x1c00,AA4TUP,THUMB}, + "add", {TRG10,TUIM8}, {0x3000,AA4TUP,THUMB}, + "add", {TRG02,THR05}, {0x4440,AA4TUP,THUMB}, + "add", {THR02,TRG05}, {0x4480,AA4TUP,THUMB}, + "add", {THR02,THR05}, {0x44c0,AA4TUP,THUMB}, + "add", {TRG10,TPCRG,TUIMA}, {0xa000,AA4TUP,THUMB}, + "add", {TRG10,TSPRG,TUIMA}, {0xa800,AA4TUP,THUMB}, + "add", {TSPRG,TUIM9}, {0xb000,AA4TUP,THUMB}, + "adc", {REG15,REG19,IMROT}, {0x02a00000,AAANY,SETCC}, + "adc", {REG15,REG19,IMMD8,IROTV}, {0x02a00000,AAANY,SETCC}, + "adc", {REG15,REG19,REG03}, {0x00a00000,AAANY,SETCC}, + "adc", {REG15,REG19,REG03,SHIFT}, {0x00a00000,AAANY,SETCC}, + "adc", {TRG02,TRG05}, {0x4140,AA4TUP,THUMB}, + "adr", {REG15,PCLRT}, {0x028f0000,AAANY,0}, + "adr", {TRG10,TPCLW}, {0xa000,AA4TUP,THUMB}, + "and", {REG15,REG19,IMROT}, {0x02000000,AAANY,SETCC}, + "and", {REG15,REG19,IMMD8,IROTV}, {0x02000000,AAANY,SETCC}, + "and", {REG15,REG19,REG03}, {0x00000000,AAANY,SETCC}, + "and", {REG15,REG19,REG03,SHIFT}, {0x00000000,AAANY,SETCC}, + "and", {TRG02,TRG05}, {0x4000,AA4TUP,THUMB}, + "asr", {TRG02,TRG05,TUIM5}, {0x1000,AA4TUP,THUMB}, + "asr", {TRG02,TRG05}, {0x4100,AA4TUP,THUMB}, + "b", {BRA24}, {0x0a000000,AAANY,0}, + "b", {TBR11}, {0xe000,AA4TUP,THUMB}, + "beq", {TBR08}, {0xd000,AA4TUP,THUMB}, + "bne", {TBR08}, {0xd100,AA4TUP,THUMB}, + "bcs", {TBR08}, {0xd200,AA4TUP,THUMB}, + "bcc", {TBR08}, {0xd300,AA4TUP,THUMB}, + "bmi", {TBR08}, {0xd400,AA4TUP,THUMB}, + "bpl", {TBR08}, {0xd500,AA4TUP,THUMB}, + "bvs", {TBR08}, {0xd600,AA4TUP,THUMB}, + "bvc", {TBR08}, {0xd700,AA4TUP,THUMB}, + "bhi", {TBR08}, {0xd800,AA4TUP,THUMB}, + "bls", {TBR08}, {0xd900,AA4TUP,THUMB}, + "bge", {TBR08}, {0xda00,AA4TUP,THUMB}, + "blt", {TBR08}, {0xdb00,AA4TUP,THUMB}, + "bgt", {TBR08}, {0xdc00,AA4TUP,THUMB}, + "ble", {TBR08}, {0xdd00,AA4TUP,THUMB}, + "bhs", {TBR08}, {0xd200,AA4TUP,THUMB}, + "blo", {TBR08}, {0xd300,AA4TUP,THUMB}, + "bul", {TBR08}, {0xd300,AA4TUP,THUMB}, + "bic", {REG15,REG19,IMROT}, {0x03c00000,AAANY,SETCC}, + "bic", {REG15,REG19,IMMD8,IROTV}, {0x03c00000,AAANY,SETCC}, + "bic", {REG15,REG19,REG03}, {0x01c00000,AAANY,SETCC}, + "bic", {REG15,REG19,REG03,SHIFT}, {0x01c00000,AAANY,SETCC}, + "bic", {TRG02,TRG05}, {0x4380,AA4TUP,THUMB}, + "bl", {BRA24}, {0x0b000000,AAANY,0}, + "bl", {TBRHL}, {0xf000,AA4TUP,THUMB}, + "bx", {REG03}, {0x012fff10,AA4TUP,NOPC}, + "bx", {TRG05}, {0x4700,AA4TUP,THUMB}, + "bx", {THR05}, {0x4740,AA4TUP,THUMB}, + "cdp", {REG11,CPOP4,REG15,REG19,REG03}, {0x0e000000,AA2UP,0}, + "cdp", {REG11,CPOP4,REG15,REG19,REG03,CPTYP},{0x0e000000,AA2UP,0}, + "cmn", {REG19,IMROT}, {0x03700000,AAANY,SETPSR}, + "cmn", {REG19,IMMD8,IROTV}, {0x03700000,AAANY,SETPSR}, + "cmn", {REG19,REG03}, {0x01700000,AAANY,SETPSR}, + "cmn", {REG19,REG03,SHIFT}, {0x01700000,AAANY,SETPSR}, + "cmn", {TRG02,TRG05}, {0x42c0,AA4TUP,THUMB}, + "cmp", {REG19,IMROT}, {0x03500000,AAANY,SETPSR}, + "cmp", {REG19,IMMD8,IROTV}, {0x03500000,AAANY,SETPSR}, + "cmp", {REG19,REG03}, {0x01500000,AAANY,SETPSR}, + "cmp", {REG19,REG03,SHIFT}, {0x01500000,AAANY,SETPSR}, + "cmp", {TRG10,TUIM8}, {0x2800,AA4TUP,THUMB}, + "cmp", {TRG02,TRG05}, {0x4280,AA4TUP,THUMB}, + "cmp", {TRG02,THR05}, {0x4540,AA4TUP,THUMB}, + "cmp", {THR02,TRG05}, {0x4580,AA4TUP,THUMB}, + "cmp", {THR02,THR05}, {0x45c0,AA4TUP,THUMB}, + "eor", {REG15,REG19,IMROT}, {0x02200000,AAANY,SETCC}, + "eor", {REG15,REG19,IMMD8,IROTV}, {0x02200000,AAANY,SETCC}, + "eor", {REG15,REG19,REG03}, {0x00200000,AAANY,SETCC}, + "eor", {REG15,REG19,REG03,SHIFT}, {0x00200000,AAANY,SETCC}, + "eor", {TRG02,TRG05}, {0x4040,AA4TUP,THUMB}, + "ldc", {REG11,REG15,PCLCP}, {0x0d1f0000,AA2UP,0}, + "ldc", {REG11,REG15,R19PR,IMCP1}, {0x0d100000,AA2UP,0}, + "ldc", {REG11,REG15,R19PO}, {0x0d100000,AA2UP,0}, + "ldc", {REG11,REG15,R19PO,IMCP2}, {0x0c100000,AA2UP,0}, + "ldm", {R19WB,RLIST}, {0x08100000,AAANY,NOPC}, + "ldmia",{TR10W,TRLST}, {0xc800,AA4TUP,THUMB}, + "ldr", {REG15,PCL12}, {0x051f0000,AAANY,NOPCWB}, + "ldr", {REG15,R19PR,IMUD1}, {0x05100000,AAANY,NOPCWB}, + "ldr", {REG15,R19PR,R3UD1}, {0x07100000,AAANY,NOPCWB|NOPCR03}, + "ldr", {REG15,R19PR,R3UD2,SHIM1}, {0x07100000,AAANY,NOPCWB|NOPCR03}, + "ldr", {REG15,R19PO}, {0x05900000,AAANY,NOPCWB}, + "ldr", {REG15,R19PO,IMUD2}, {0x04100000,AAANY,NOPCWB}, + "ldr", {REG15,R19PO,R3UD2}, {0x06100000,AAANY,NOPCWB|NOPCR03}, + "ldr", {REG15,R19PO,R3UD2,SHIM2}, {0x06100000,AAANY,NOPCWB|NOPCR03}, + "ldr", {TRG10,TPCLW}, {0x4800,AA4TUP,THUMB}, + "ldr", {TRG10,TPCPR,TUIAI}, {0x4800,AA4TUP,THUMB}, + "ldr", {TRG02,TR5IN,TR8IN}, {0x5800,AA4TUP,THUMB}, + "ldr", {TRG02,TR5IN,TUI7I}, {0x6800,AA4TUP,THUMB}, + "ldr", {TRG10,TSPPR,TUIAI}, {0x9800,AA4TUP,THUMB}, + "ldrb", {TRG02,TR5IN,TR8IN}, {0x5c00,AA4TUP,THUMB}, + "ldrb", {TRG02,TR5IN,TUI5I}, {0x7800,AA4TUP,THUMB}, + "ldrh", {TRG02,TR5IN,TR8IN}, {0x5a00,AA4TUP,THUMB}, + "ldrh", {TRG02,TR5IN,TUI6I}, {0x8800,AA4TUP,THUMB}, + "ldsb", {TRG02,TR5IN,TR8IN}, {0x5600,AA4TUP,THUMB}, + "ldsh", {TRG02,TR5IN,TR8IN}, {0x5e00,AA4TUP,THUMB}, + "lsl", {TRG02,TRG05,TUIM5}, {0x0000,AA4TUP,THUMB}, + "lsl", {TRG02,TRG05}, {0x4080,AA4TUP,THUMB}, + "lsr", {TRG02,TRG05,TUIM5}, {0x0800,AA4TUP,THUMB}, + "lsr", {TRG02,TRG05}, {0x40c0,AA4TUP,THUMB}, + "mcr", {REG11,CPOP3,REG15,REG19,REG03}, {0x0e000010,AA2UP,0}, + "mcr", {REG11,CPOP3,REG15,REG19,REG03,CPTYP},{0x0e000010,AA2UP,0}, + "mov", {REG15,IMROT}, {0x03a00000,AAANY,SETCC}, + "mov", {REG15,IMMD8,IROTV}, {0x03a00000,AAANY,SETCC}, + "mov", {REG15,REG03}, {0x01a00000,AAANY,SETCC}, + "mov", {REG15,REG03,SHIFT}, {0x01a00000,AAANY,SETCC}, + "mov", {TRG10,TUIM8}, {0x2000,AA4TUP,THUMB}, + "mov", {TRG02,TRG05}, {0x1c00,AA4TUP,THUMB}, + "mov", {TRG02,THR05}, {0x4640,AA4TUP,THUMB}, + "mov", {THR02,TRG05}, {0x4680,AA4TUP,THUMB}, + "mov", {THR02,THR05}, {0x46c0,AA4TUP,THUMB}, + "mrc", {REG11,CPOP3,REG15,REG19,REG03}, {0x0e100010,AA2UP,0}, + "mrc", {REG11,CPOP3,REG15,REG19,REG03,CPTYP},{0x0e100010,AA2UP,0}, + "mrs", {REG15,CSPSR}, {0x01000000,AA3UP,NOPC}, + "mla", {REG19,REG03,REG11,REG15}, {0x00200090,AA2UP,SETCC|NOPC|DIFR19|DIFR03}, + "msr", {PSR_F,IMROT}, {0x0320f000,AA3UP,0}, + "msr", {PSR_F,IMMD8,IROTV}, {0x0320f000,AA3UP,0}, + "msr", {PSR_F,REG03}, {0x0120f000,AA3UP,NOPC}, + "mul", {REG19,REG03,REG11}, {0x00000090,AA2UP,SETCC|NOPC|DIFR19|DIFR03}, + "mul", {TRG02,TRG05}, {0x4340,AA4TUP,THUMB}, + "mvn", {REG15,IMROT}, {0x03e00000,AAANY,SETCC}, + "mvn", {REG15,IMMD8,IROTV}, {0x03e00000,AAANY,SETCC}, + "mvn", {REG15,REG03}, {0x01e00000,AAANY,SETCC}, + "mvn", {REG15,REG03,SHIFT}, {0x01e00000,AAANY,SETCC}, + "mvn", {TRG02,TRG05}, {0x43c0,AA4TUP,THUMB}, + "neg", {TRG02,TRG05}, {0x4240,AA4TUP,THUMB}, + "nop", {0}, {0x01a00000,AAANY,0}, + "orr", {REG15,REG19,IMROT}, {0x03800000,AAANY,SETCC}, + "orr", {REG15,REG19,IMMD8,IROTV}, {0x03800000,AAANY,SETCC}, + "orr", {REG15,REG19,REG03}, {0x01800000,AAANY,SETCC}, + "orr", {REG15,REG19,REG03,SHIFT}, {0x01800000,AAANY,SETCC}, + "orr", {TRG02,TRG05}, {0x4300,AA4TUP,THUMB}, + "pop", {TRLPC}, {0xbc00,AA4TUP,THUMB}, + "push", {TRLLR}, {0xb400,AA4TUP,THUMB}, + "ror", {TRG02,TRG05}, {0x41c0,AA4TUP,THUMB}, + "rsb", {REG15,REG19,IMROT}, {0x02600000,AAANY,SETCC}, + "rsb", {REG15,REG19,IMMD8,IROTV}, {0x02600000,AAANY,SETCC}, + "rsb", {REG15,REG19,REG03}, {0x00600000,AAANY,SETCC}, + "rsb", {REG15,REG19,REG03,SHIFT}, {0x00600000,AAANY,SETCC}, + "rsc", {REG15,REG19,IMROT}, {0x02e00000,AAANY,SETCC}, + "rsc", {REG15,REG19,IMMD8,IROTV}, {0x02e00000,AAANY,SETCC}, + "rsc", {REG15,REG19,REG03}, {0x00e00000,AAANY,SETCC}, + "rsc", {REG15,REG19,REG03,SHIFT}, {0x00e00000,AAANY,SETCC}, + "smlal", {REG15,REG19,REG03,REG11}, {0x00e00090,AA3MUP,SETCC|NOPC|DIFR19|DIFR15|DIFR03}, + "smull", {REG15,REG19,REG03,REG11}, {0x00c00090,AA3MUP,SETCC|NOPC|DIFR19|DIFR15|DIFR03}, + "stc", {REG11,REG15,PCLCP}, {0x0d0f0000,AA2UP,0}, + "stc", {REG11,REG15,R19PR,IMCP1}, {0x0d000000,AA2UP,0}, + "stc", {REG11,REG15,R19PO}, {0x0d000000,AA2UP,0}, + "stc", {REG11,REG15,R19PO,IMCP2}, {0x0c000000,AA2UP,0}, + "stm", {R19WB,RLIST}, {0x08000000,AAANY,NOPC}, + "stmia",{TR10W,TRLST}, {0xc000,AA4TUP,THUMB}, + "str", {REG15,PCL12}, {0x050f0000,AAANY,NOPCWB}, + "str", {REG15,R19PR,IMUD1}, {0x05000000,AAANY,NOPCWB}, + "str", {REG15,R19PR,R3UD1}, {0x07000000,AAANY,NOPCWB|NOPCR03}, + "str", {REG15,R19PR,R3UD2,SHIM1}, {0x07000000,AAANY,NOPCWB|NOPCR03}, + "str", {REG15,R19PO}, {0x05800000,AAANY,NOPCWB}, + "str", {REG15,R19PO,IMUD2}, {0x04000000,AAANY,NOPCWB}, + "str", {REG15,R19PO,R3UD2}, {0x06000000,AAANY,NOPCWB|NOPCR03}, + "str", {REG15,R19PO,R3UD2,SHIM2}, {0x06000000,AAANY,NOPCWB|NOPCR03}, + "str", {TRG02,TR5IN,TR8IN}, {0x5000,AA4TUP,THUMB}, + "str", {TRG02,TR5IN,TUI7I}, {0x6000,AA4TUP,THUMB}, + "str", {TRG10,TSPPR,TUIAI}, {0x9000,AA4TUP,THUMB}, + "strb", {TRG02,TR5IN,TR8IN}, {0x5400,AA4TUP,THUMB}, + "strb", {TRG02,TR5IN,TUI5I}, {0x7000,AA4TUP,THUMB}, + "strh", {TRG02,TR5IN,TR8IN}, {0x5200,AA4TUP,THUMB}, + "strh", {TRG02,TR5IN,TUI6I}, {0x8000,AA4TUP,THUMB}, + "sbc", {REG15,REG19,IMROT}, {0x02c00000,AAANY,SETCC}, + "sbc", {REG15,REG19,IMMD8,IROTV}, {0x02c00000,AAANY,SETCC}, + "sbc", {REG15,REG19,REG03}, {0x00c00000,AAANY,SETCC}, + "sbc", {REG15,REG19,REG03,SHIFT}, {0x00c00000,AAANY,SETCC}, + "sbc", {TRG02,TRG05}, {0x4180,AA4TUP,THUMB}, + "sub", {REG15,REG19,IMROT}, {0x02400000,AAANY,SETCC}, + "sub", {REG15,REG19,IMMD8,IROTV}, {0x02400000,AAANY,SETCC}, + "sub", {REG15,REG19,REG03}, {0x00400000,AAANY,SETCC}, + "sub", {REG15,REG19,REG03,SHIFT}, {0x00400000,AAANY,SETCC}, + "sub", {TRG02,TRG05,TRG08}, {0x1a00,AA4TUP,THUMB}, + "sub", {TRG02,TRG05,TUIM3}, {0x1e00,AA4TUP,THUMB}, + "sub", {TRG10,TUIM8}, {0x3800,AA4TUP,THUMB}, + "sub", {TSPRG,TUIM9}, {0xb080,AA4TUP,THUMB}, + "svc", {SWI24}, {0x0f000000,AAANY,0}, + "svc", {TSWI8}, {0xdf00,AA4TUP,THUMB}, + "swi", {SWI24}, {0x0f000000,AAANY,0}, + "swi", {TSWI8}, {0xdf00,AA4TUP,THUMB}, + "swp", {REG15,REG03,R19PO}, {0x01000090,AA3UP,NOPC}, + "teq", {REG19,IMROT}, {0x03300000,AAANY,SETPSR}, + "teq", {REG19,IMMD8,IROTV}, {0x03300000,AAANY,SETPSR}, + "teq", {REG19,REG03}, {0x01300000,AAANY,SETPSR}, + "teq", {REG19,REG03,SHIFT}, {0x01300000,AAANY,SETPSR}, + "tst", {REG19,IMROT}, {0x03100000,AAANY,SETPSR}, + "tst", {REG19,IMMD8,IROTV}, {0x03100000,AAANY,SETPSR}, + "tst", {REG19,REG03}, {0x01100000,AAANY,SETPSR}, + "tst", {REG19,REG03,SHIFT}, {0x01100000,AAANY,SETPSR}, + "tst", {TRG02,TRG05}, {0x4200,AA4TUP,THUMB}, + "umlal", {REG15,REG19,REG03,REG11}, {0x00a00090,AA3MUP,SETCC|NOPC|DIFR19|DIFR15|DIFR03}, + "umull", {REG15,REG19,REG03,REG11}, {0x00800090,AA3MUP,SETCC|NOPC|DIFR19|DIFR15|DIFR03}, diff --git a/tools/vasm/vasm/cpus/c16x/cpu.c b/tools/vasm/vasm/cpus/c16x/cpu.c new file mode 100644 index 0000000..39bbe3b --- /dev/null +++ b/tools/vasm/vasm/cpus/c16x/cpu.c @@ -0,0 +1,788 @@ +/* cpu.c example cpu-description file */ +/* (c) in 2002 by Volker Barthelmann */ + +#include "vasm.h" + +char *cpu_copyright="vasm c16x/st10 cpu backend 0.2c (c) in 2002-2005 Volker Barthelmann"; +char *cpuname="c16x"; + +mnemonic mnemonics[]={ +#include "opcodes.h" +}; + +int mnemonic_cnt=sizeof(mnemonics)/sizeof(mnemonics[0]); + +int bitsperbyte=8; +int bytespertaddr=4; + +static int JMPA,JMPR,JMPS,JNB,JB,JBC,JNBS,JMP; +static int notrans,tojmpa; + +#define JMPCONV 256 +#define INVCC(c) (((c)&1)?(c)-1:(c)+1) + +#define ISBIT 1 + +typedef struct sfr { + struct sfr *next; + int flags; + unsigned int laddr,saddr,boffset; +} sfr; + + +sfr *first_sfr; +#define SFRHTSIZE 1024 +hashtable *sfrhash; + +static char *skip_reg(char *s,int *reg) +{ + int r=-1; + if(*s!='r'&&*s!='R'){ + cpu_error(1); + return s; + } + s++; + if(*s<'0'||*s>'9'){ + cpu_error(1); + return s; + } + r=*s++-'0'; + if(*s>='0'&&*s<='5') + r=10*r+*s++-'0'; + *reg=r; + return s; +} + +int parse_operand(char *p,int len,operand *op,int requires) +{ + op->type=-1; + op->mod=-1; + p=skip(p); + if(requires==OP_REL){ + char *s=p; + op->type=OP_REL; + op->offset=parse_expr(&s); + simplify_expr(op->offset); + if(s==p) + return 0; + else + return 1; + } + if(requires==OP_CC){ + op->type=OP_CC; + if(len<4||len>6||p[0]!='c'||p[1]!='c'||p[2]!='_') + return 0; + if(len==4){ + if(p[3]=='z') + op->cc=2; + else if(p[3]=='v') + op->cc=4; + else if(p[3]=='n') + op->cc=6; + else if(p[3]=='c') + op->cc=8; + else + return 0; + }else if(len==5){ + if(p[3]=='u'&&p[4]=='c') + op->cc=0; + else if(p[3]=='n'&&p[4]=='z') + op->cc=3; + else if(p[3]=='n'&&p[4]=='v') + op->cc=5; + else if(p[3]=='n'&&p[4]=='n') + op->cc=7; + else if(p[3]=='n'&&p[4]=='c') + op->cc=0; + else if(p[3]=='e'&&p[4]=='q') + op->cc=2; + else if(p[3]=='n'&&p[4]=='e') + op->cc=3; + else + return 0; + }else if(len==6){ + if(!strncmp(p+3,"ult",3)) + op->cc=8; + else if(!strncmp(p+3,"ule",3)) + op->cc=0xf; + else if(!strncmp(p+3,"uge",3)) + op->cc=0x9; + else if(!strncmp(p+3,"ugt",3)) + op->cc=0xe; + else if(!strncmp(p+3,"slt",3)) + op->cc=0xc; + else if(!strncmp(p+3,"sle",3)) + op->cc=0xb; + else if(!strncmp(p+3,"sge",3)) + op->cc=0xd; + else if(!strncmp(p+3,"sgt",3)) + op->cc=0xa; + else if(!strncmp(p+3,"net",3)) + op->cc=0x1; + else + return 0; + } + return 1; + } + if((p[0]=='r'||p[0]=='R')&&p[1]>='0'&&p[1]<='9'&&(len==2||p[2]=='.')){ + op->type=OP_GPR; + op->reg=p[1]-'0'; + op->regsfr=op->reg+0xf0; + if(len>2){ + op->type=OP_BADDR; + if(requires==OP_BADDR){ + p=skip(p+3); + op->boffset=parse_expr(&p); + op->offset=number_expr(op->regsfr); + } + } + }else if((p[0]=='r'||p[0]=='R')&&p[1]=='1'&&p[2]>='0'&&p[2]<='5'&&(len==3||p[3]=='.')){ + op->type=OP_GPR; + op->reg=(p[1]-'0')*10+p[2]-'0'; + op->regsfr=op->reg+0xf0; + if(len>3){ + op->type=OP_BADDR; + if(requires==OP_BADDR){ + p=skip(p+4); + op->boffset=parse_expr(&p); + op->offset=number_expr(op->regsfr); + } + } + }else if(len==3&&(p[0]=='r'||p[0]=='R')&&(p[1]=='l'||p[1]=='L')&&p[2]>='0'&&p[2]<='7'){ + op->type=OP_BGPR; + op->reg=(p[2]-'0')*2; + op->regsfr=op->reg+0xf0; + }else if(len==3&&(p[0]=='r'||p[0]=='R')&&(p[1]=='h'||p[1]=='H')&&p[2]>='0'&&p[2]<='7'){ + op->type=OP_BGPR; + op->reg=(p[2]-'0')*2+1; + op->regsfr=op->reg+0xf0; + }else if(p[0]=='#'){ + op->type=OP_IMM16; + p=skip(p+1); + if((!strncmp("SOF",p,3)||!strncmp("sof",p,3))&&isspace((unsigned char)p[3])){op->mod=MOD_SOF;p=skip(p+3);} + if((!strncmp("SEG",p,3)||!strncmp("seg",p,3))&&isspace((unsigned char)p[3])){op->mod=MOD_SEG;p=skip(p+3);} + if((!strncmp("DPP0:",p,5)||!strncmp("dpp0:",p,5))){op->mod=MOD_DPP0;p=skip(p+5);} + if((!strncmp("DPP1:",p,5)||!strncmp("dpp1:",p,5))){op->mod=MOD_DPP1;p=skip(p+5);} + if((!strncmp("DPP2:",p,5)||!strncmp("dpp2:",p,5))){op->mod=MOD_DPP2;p=skip(p+5);} + if((!strncmp("DPP3:",p,5)||!strncmp("dpp3:",p,5))){op->mod=MOD_DPP3;p=skip(p+5);} + if((!strncmp("DPPX:",p,5)||!strncmp("dppx:",p,5))){op->mod=MOD_DPPX;p=skip(p+5);} + op->offset=parse_expr(&p); + simplify_expr(op->offset); +#if 0 + if(op->offset->type==NUM){ + taddr val=op->offset->c.val; + if(val>=0&&val<=7) + op->type=OP_IMM3; + else if(val>=0&&val<=15) + op->type=OP_IMM4; + else if(val>=0&&val<=127) + op->type=OP_IMM7; + else if(val>=0&&val<=255) + op->type=OP_IMM8; + } +#endif + }else if(*p=='['){ + p=skip(p+1); + if(*p=='-'){ + p=skip(p+1); + p=skip_reg(p,&op->reg); + p=skip(p); + if(*p!=']') + cpu_error(0); + if(op->reg<=3) + op->type=OP_PREDEC03; + else + op->type=OP_PREDEC; + }else{ + p=skip_reg(p,&op->reg); + p=skip(p); + if(*p=='+'){ + p=skip(p+1); + if(*p==']'){ + if(op->reg<=3) + op->type=OP_POSTINC03; + else + op->type=OP_POSTINC; + }else{ + if(*p!='#') + cpu_error(0); + p=skip(p+1); + op->offset=parse_expr(&p); + p=skip(p); + op->type=OP_REGDISP; + } + }else{ + if(op->reg<=3) + op->type=OP_REG03IND; + else + op->type=OP_REGIND; + } + if(*p!=']') + cpu_error(0); + } + }else{ + if(ISIDSTART(*p)){ + char *name=p; + hashdata data; + while((p==name||ISIDCHAR(*p))&&*p!='.') + p++; + if(find_namelen(sfrhash,name,p-name,&data)){ + sfr *sfr; + sfr=data.ptr; + if(sfr->flags&ISBIT){ + op->offset=number_expr(sfr->saddr); + op->type=OP_BADDR; + op->boffset=number_expr(sfr->boffset); + }else{ + if(requires==OP_SFR||requires==OP_BSFR||requires==OP_BWORD){ + op->offset=number_expr(sfr->saddr); + op->type=requires; + }else if(requires==OP_BADDR&&*p=='.'){ + op->offset=number_expr(sfr->saddr); + p=skip(p+1); + op->boffset=parse_expr(&p); + op->type=OP_BADDR; + }else if(requires==OP_ABS||requires==OP_BABS){ + op->type=requires; + op->offset=number_expr((2*sfr->saddr)+(sfr->laddr<<8)); + } + } + } + if(op->type==-1) + p=name; + } + if(op->type==-1){ + if((!strncmp("SOF",p,3)||!strncmp("sof",p,3))&&isspace((unsigned char)p[3])){op->mod=MOD_SOF;p=skip(p+3);} + if((!strncmp("SEG",p,3)||!strncmp("seg",p,3))&&isspace((unsigned char)p[3])){op->mod=MOD_SEG;p=skip(p+3);} + if((!strncmp("DPP0:",p,5)||!strncmp("dpp0:",p,5))){op->mod=MOD_DPP0;p=skip(p+5);} + if((!strncmp("DPP1:",p,5)||!strncmp("dpp1:",p,5))){op->mod=MOD_DPP1;p=skip(p+5);} + if((!strncmp("DPP2:",p,5)||!strncmp("dpp2:",p,5))){op->mod=MOD_DPP2;p=skip(p+5);} + if((!strncmp("DPP3:",p,5)||!strncmp("dpp3:",p,5))){op->mod=MOD_DPP3;p=skip(p+5);} + if((!strncmp("DPPX:",p,5)||!strncmp("dppx:",p,5))){op->mod=MOD_DPPX;p=skip(p+5);} + op->offset=parse_expr(&p); + op->type=OP_ABS; + } + } + if(requires==op->type) + return 1; + if(requires==OP_BWORD&&op->type==OP_SFR) + return 1; + if(op->type==OP_IMM16&&(requires>=OP_IMM2&&requires<=OP_IMM16)) + return 1; + if(op->type==OP_PREDEC03&&requires==OP_PREDEC) + return 1; + if(op->type==OP_POSTINC03&&requires==OP_POSTINC) + return 1; + if(op->type==OP_REG03IND&&requires==OP_REGIND) + return 1; + if((requires==OP_SFR&&op->type==OP_GPR)|| + (requires==OP_BWORD&&op->type==OP_GPR)|| + (requires==OP_BWORD&&op->type==OP_BGPR)|| + (requires==OP_BSFR&&op->type==OP_BGPR)){ + op->offset=number_expr(op->regsfr); + return 1; + } + if(requires==OP_BSFR&&op->type==OP_BGPR) + return 1; + if(requires==OP_JADDR&&op->type==OP_ABS) + return 1; + if(requires==OP_BABS&&op->type==OP_ABS) + return 1; + /*FIXME*/ + return 0; +} + +static taddr reloffset(expr *tree,section *sec,taddr pc) +{ + symbol *sym; + int btype; + taddr val; + simplify_expr(tree); + if(tree->type==NUM){ + /* should we do it like this?? */ + val=tree->c.val; + }else{ + btype=find_base(tree,&sym,sec,pc); + if(btype!=BASE_OK||!LOCREF(sym)||sym->sec!=sec) + val=0xffff; + else{ + eval_expr(tree,&val,sec,pc); + val=val-pc; + } + } + return val; +} + +static taddr absoffset2(expr *tree,int mod,section *sec,taddr pc,rlist **relocs,int roffset,int size,taddr mask) +{ + taddr val; + if(mod==MOD_SOF){ + if(mask!=0xffffffff&&mask!=0xffff) cpu_error(5); + mask=0xffff; + } + if(mod==MOD_SEG){ + if(mask!=0xff&&mask!=0xffff&&mask!=0xffffffff) cpu_error(6); + mask<<=16; + } + if(mod==MOD_DPP0||mod==MOD_DPP1||mod==MOD_DPP2||mod==MOD_DPP3||mod==MOD_DPPX){ + if(mask!=0xffffffff&&mask!=0xffff) cpu_error(7); + mask=0x3fff; + } + if(!eval_expr(tree,&val,sec,pc)){ + taddr addend=val; + symbol *base; + if(find_base(tree,&base,sec,pc)!=BASE_OK){ + general_error(38); + return val; + } + if(mod==MOD_DPP1) val|=0x4000; + if(mod==MOD_DPP2) val|=0x8000; + if(mod==MOD_DPP3) val|=0xc000; + if(mod==MOD_DPPX){ + static int dpplen; + static char *dppname; + char *id=base->name; + symbol *dppsym; + size-=2; + if(strlen(id)+9>dpplen){ + myfree(dppname); + dppname=mymalloc(dpplen=strlen(id)+9); + } + strcpy(dppname,"___DPP_"); + strcat(dppname,id); + dppsym=new_import(dppname); + if(dppsym->type==EXPRESSION){ + if(!eval_expr(dppsym->expr,&val,0,0)) + ierror(0); + val<<=14; + }else{ + add_nreloc_masked(relocs,dppsym,0,REL_ABS,2,roffset+14,0x3); + } + } + add_nreloc_masked(relocs,base,addend,REL_ABS,size,roffset,mask); + return val; + } + val&=mask; + if(mod==MOD_DPPX) cpu_error(7); + if(mod==MOD_DPP1) val|=0x4000; + if(mod==MOD_DPP2) val|=0x8000; + if(mod==MOD_DPP3) val|=0xc000; + if(mod==MOD_SEG) val>>=16; + /*FIXME: range check */ +#if 1 + if(size==16) + return val&0xffff; + else + return val&((1<4) + cpu_error(3,2); + return val; + }else if(val<0||val>=(1<code; + taddr val; + /* choose one of jmpr/jmpa */ + if(c==JMP||(!notrans&&(c==JMPA||c==JMPR||c==JB||c==JNB))){ + val=reloffset(p->op[1]->offset,sec,pc); + if(val<-256||val>254||val%2){ + if(c==JB) return JNB|JMPCONV; + if(c==JNB) return JB|JMPCONV; + if(c==JMPA) return JMPA; + if(tojmpa) return JMPA; + if(p->op[0]->cc==0) + return JMPS; + else + return JMPR|JMPCONV; + }else{ + if(c==JB||c==JNB) + return c; + return JMPR; + } + } + /* choose between gpr,#imm3 and reg,#imm16 */ + if(mnemonics[c].operand_type[1]==OP_IMM3){ + if(!eval_expr(p->op[1]->offset,&val,sec,pc)||val<0||val>7){ + if(!strcmp(mnemonics[c].name,mnemonics[c+1].name)) + return c+1; + } + } + /* choose between gpr,#imm4 and reg,#imm16 */ + if(mnemonics[c].operand_type[1]==OP_IMM4){ + if(!eval_expr(p->op[1]->offset,&val,sec,pc)||val<0||val>7){ + if(!strcmp(mnemonics[c].name,mnemonics[c+1].name)) + return c+1; + } + } + return c; +} + +/* Convert an instruction into a DATA atom including relocations, + if necessary. */ +dblock *eval_instruction(instruction *p,section *sec,taddr pc) +{ + dblock *db=new_dblock(); + int opcode,c,jmpconv=0,osize; + unsigned long code; + unsigned char *d; + taddr val; + rlist *relocs=0; + operand *jmpaddr; + + c=translate(p,sec,pc); + if(c&JMPCONV){ jmpconv=1;c&=~JMPCONV;} + if((mnemonics[p->code].operand_type[0]==OP_GPR&&mnemonics[c].operand_type[0]==OP_SFR)|| + (mnemonics[p->code].operand_type[0]==OP_BGPR&&mnemonics[c].operand_type[0]==OP_BSFR)) + p->op[0]->offset=number_expr(p->op[0]->regsfr); + + + db->size=osize=mnemonics[c].ext.len*2; + if(jmpconv) db->size+=4; + db->data=mymalloc(db->size); + + opcode=mnemonics[c].ext.opcode; + switch(mnemonics[c].ext.encoding){ + case 0: + code=opcode<<16|(opcode>>8)<<8|opcode>>8; + break; + case 1: + code=opcode; + break; + case 2: + code=opcode|p->op[0]->reg<<4|p->op[1]->reg; + break; + case 3: + code=opcode|p->op[0]->reg|p->op[1]->reg<<4; + break; + case 4: + code=opcode|p->op[0]->reg<<4|p->op[1]->reg|8; + break; + case 5: + code=opcode|p->op[0]->reg<<4|p->op[1]->reg|12; + break; + case 6: + code=opcode|p->op[0]->reg<<4|absval(p->op[1]->offset,sec,pc,3); + break; + case 7: + /* fall through */ + case 8: + code=opcode<<16|absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,20,8)<<16|absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,16,16); + break; + case 9: + code=opcode|p->op[0]->reg|absval(p->op[1]->offset,sec,pc,4)<<4; + break; + case 10: +/* rfi: reorder bmov operands */ + code=opcode<<16| + absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,8,8)<<16| + absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,16,8)<<0| + absoffset(p->op[1]->boffset,0,sec,pc,&relocs,24,4)<<12| + absoffset(p->op[0]->boffset,0,sec,pc,&relocs,28,4)<<8; + break; + case 11: + code=opcode|absoffset(p->op[0]->boffset,0,sec,pc,&relocs,0,4)<<12|absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,8,8); + break; + case 12: + code=opcode<<16| + absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,8,8)<<16| + absoffset(p->op[2]->offset,p->op[2]->mod,sec,pc,&relocs,16,8)<<8| + absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,24,8); + break; + case 13: + code=opcode<<16| + absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,8,8)<<16| + absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,16,8)<<8| + absoffset(p->op[2]->offset,p->op[2]->mod,sec,pc,&relocs,24,8); + break; + case 14: + code=opcode<<16|p->op[0]->cc<<20|absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,16,16); + break; + case 15: + code=opcode|p->op[0]->cc<<4|p->op[1]->reg; + break; + case 16: + val=((reloffset(p->op[0]->offset,sec,pc)-2)>>1)&255; + code=opcode|val; + break; + case 17: + if(p->op[0]->type==OP_CC){ + /* jmp cc_uc was converted to jmps */ + code=opcode<<16|absoffset2(p->op[1]->offset,0,sec,pc,&relocs,8,8,0xffff0000)<<16|absoffset2(p->op[1]->offset,0,sec,pc,&relocs,16,16,0xffff); + }else{ + code=opcode<<16|absoffset2(p->op[0]->offset,0,sec,pc,&relocs,8,8,0xffff0000)<<16|absoffset2(p->op[0]->offset,0,sec,pc,&relocs,16,16,0xffff); + } + break; + case 18: + /* fall through */ + case 19: + code=opcode<<16|0xf<<20|p->op[0]->reg<<16|absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,16,16); + break; + case 20: + code=opcode|p->op[0]->reg<<4; + break; + case 21: + code=opcode|p->op[0]->reg<<4|p->op[0]->reg; + break; + case 22: + if(!jmpconv){ + val=((reloffset(p->op[1]->offset,sec,pc)-4)>>1)&255; + code=opcode<<16| + absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,8,8)<<16| + absoffset(p->op[0]->boffset,0,sec,pc,&relocs,24,4)<<12| + val; + }else{ + code=opcode<<16| + absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,8,8)<<16| + absoffset(p->op[0]->boffset,0,sec,pc,&relocs,24,4)<<12| + 2; + jmpaddr=p->op[1]; + } + break; + case 23: + if(!jmpconv){ + val=((reloffset(p->op[1]->offset,sec,pc)-2)>>1)&255; + code=opcode|p->op[0]->cc<<12|val; + }else{ + code=opcode|INVCC(p->op[0]->cc)<<12|2; + jmpaddr=p->op[1]; + } + break; + case 24: + code=opcode<<16|p->op[0]->reg<<20|p->op[1]->reg<<16|absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,16,16); + break; + case 25: + code=opcode<<16|p->op[0]->reg<<16|absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,16,16); + break; + case 26: + code=opcode|absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,8,8); + break; + case 27: + code=opcode|absval(p->op[0]->offset,sec,pc,7)<<1; + break; + case 28: + code=opcode<<16|p->op[0]->reg<<16|p->op[1]->reg<<20|absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,16,16); + break; + case 29: + code=opcode<<16|absoffset(p->op[1]->offset,p->op[1]->mod,sec,pc,&relocs,8,8)<<16|absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,16,16); + break; + case 30: + code=opcode<<16|p->op[1]->reg<<16|absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,16,16); + break; + case 31: + code=opcode|((absval(p->op[0]->offset,sec,pc,2)-1)<<4); + break; + case 32: + code=opcode|p->op[0]->reg|((absval(p->op[1]->offset,sec,pc,2)-1)<<4); + break; + case 34: + code=opcode<<16|((absval(p->op[1]->offset,sec,pc,2)-1)<<20)|absoffset(p->op[0]->offset,p->op[0]->mod,sec,pc,&relocs,16,8); + break; + case 33: + default: + ierror(mnemonics[c].ext.encoding); + } + + d=db->data; + if(osize==4){ + *d++=code>>24; + *d++=code>>16; + *d++=code; + *d++=code>>8; + }else{ + *d++=code>>8; + *d++=code; + } + if(jmpconv){ + *d++=0xfa; + *d++=absoffset2(jmpaddr->offset,0,sec,pc,&relocs,8+8*osize,8,0xffff0000); + val=absoffset2(jmpaddr->offset,0,sec,pc,&relocs,16+8*osize,16,0xffff); + *d++=val>>8; + *d++=val; + } + db->relocs=relocs; + return db; +} + +/* Create a dblock (with relocs, if necessary) for size bits of data. */ +dblock *eval_data(operand *op,size_t bitsize,section *sec,taddr pc) +{ + dblock *new=new_dblock(); + taddr val; + new->size=(bitsize+7)/8; + new->data=mymalloc(new->size); + if(op->type!=OP_ABS) + ierror(0); + if(bitsize!=8&&bitsize!=16&&bitsize!=32) + cpu_error(4); + val=absoffset(op->offset,op->mod,sec,pc,&new->relocs,0,bitsize); + if(bitsize==32){ + new->data[3]=val>>24; + new->data[2]=val>>16; + new->data[1]=val>>8; + new->data[0]=val; + }else if(bitsize==16){ + new->data[1]=val>>8; + new->data[0]=val; + }else + new->data[0]=val; + return new; +} + + +/* Calculate the size of the current instruction; must be identical + to the data created by eval_instruction. */ +size_t instruction_size(instruction *p,section *sec,taddr pc) +{ + int c=translate(p,sec,pc),add=0; + if(c&JMPCONV){ add=4;c&=~JMPCONV;} + return mnemonics[c].ext.len*2+add; +} + +operand *new_operand() +{ + operand *new=mymalloc(sizeof(*new)); + new->type=-1; + return new; +} + +/* return true, if initialization was successfull */ +int init_cpu() +{ + int i; + for(i=0;inext=first_sfr; + first_sfr=new; + } + new->flags=new->laddr=new->saddr=0; + new->boffset=0; + s=skip(s); + if(*s!=',') + cpu_error(0); + else + s=skip(s+1); + tree=parse_expr(&s); + simplify_expr(tree); + if(!tree||tree->type!=NUM) + cpu_error(0); + else + new->laddr=tree->c.val; + s=skip(s); + if(tree->c.val==0xfe||tree->c.val==0xf0){ + if(*s!=',') + cpu_error(0); + else + s=skip(s+1); + free_expr(tree); + tree=parse_expr(&s); + simplify_expr(tree); + if(!tree||tree->type!=NUM) + cpu_error(0); + else + new->saddr=tree->c.val; + free_expr(tree); + s=skip(s); + }else{ + if(tree->c.val>=0xfe00) + new->laddr=0xfe; + else + new->laddr=0xf0; + new->saddr=(tree->c.val-(new->laddr<<8))/2; + if((new->laddr<<8)+2*new->saddr!=tree->c.val) ierror(0); + free_expr(tree); + } + if(*s==','){ + s=skip(s+1); + tree=parse_expr(&s); + simplify_expr(tree); + new->boffset=tree->c.val; + new->flags|=ISBIT; + free_expr(tree); + } + return skip(s); + } + } + return merk; +} diff --git a/tools/vasm/vasm/cpus/c16x/cpu.h b/tools/vasm/vasm/cpus/c16x/cpu.h new file mode 100644 index 0000000..9b282dd --- /dev/null +++ b/tools/vasm/vasm/cpus/c16x/cpu.h @@ -0,0 +1,88 @@ +/* cpu.h c16x/st10 cpu-description header-file */ +/* (c) in 2002 by Volker Barthelmann */ + + +/* maximum number of operands in one mnemonic */ +#define MAX_OPERANDS 3 + +/* maximum number of mnemonic-qualifiers per mnemonic */ +#define MAX_QUALIFIERS 0 + +/* maximum number of additional command-line-flags for this cpu */ + +/* data type to represent a target-address */ +typedef int32_t taddr; +typedef uint32_t utaddr; + +#define LITTLEENDIAN 1 +#define BIGENDIAN 0 +#define VASM_CPU_C16X 1 + +/* minimum instruction alignment */ +#define INST_ALIGN 2 + +/* default alignment for n-bit data */ +#define DATA_ALIGN(n) ((n)<=8?1:2) + +/* operand class for n-bit data definitions */ +#define DATA_OPERAND(n) OP_ABS + +#define cc reg + +/* type to store each operand */ +typedef struct { + int type; + int mod; + int reg,regsfr; /* also cc and boff */ + expr *offset,*boffset; +} operand; + +/* operand-types */ +#define OP_GPR 1 +#define OP_BGPR 2 +#define OP_SFR 3 +#define OP_BSFR 4 +#define OP_ABS 5 +#define OP_SEG OP_ABS +#define OP_BABS 6 +#define OP_REGDISP 7 +#define OP_REGIND 8 +#define OP_REG03IND 9 +#define OP_BWORD 10 +#define OP_BADDR 11 +#define OP_IMM2 12 +#define OP_IMM3 13 +#define OP_IMM4 14 +#define OP_IMM7 15 +#define OP_IMM8 16 +#define OP_IMM16 17 +#define OP_CC 18 +#define OP_REL 19 +#define OP_JADDR 20 +#define OP_POSTINC03 21 +#define OP_PREDEC03 22 +#define OP_POSTINC 23 +#define OP_PREDEC 24 +#define OP_PROTECTED 0 + +/* mod types */ +#define MOD_SOF 1 +#define MOD_SEG 2 +#define MOD_DPP0 3 +#define MOD_DPP1 4 +#define MOD_DPP2 5 +#define MOD_DPP3 6 +#define MOD_DPPX 7 + +#define CPU_C166 1 +#define CPU_C167 2 +#define CPU_ALL (-1) + +typedef struct { + unsigned int len; + unsigned int opcode; + unsigned int match; + unsigned int lose; + unsigned int encoding; + unsigned int available; +} mnemonic_extension; diff --git a/tools/vasm/vasm/cpus/c16x/cpu_errors.h b/tools/vasm/vasm/cpus/c16x/cpu_errors.h new file mode 100644 index 0000000..cffdaad --- /dev/null +++ b/tools/vasm/vasm/cpus/c16x/cpu_errors.h @@ -0,0 +1,8 @@ + "illegal operand",ERROR, + "word register expected",ERROR, + "",ERROR, + "value does not find in %d bits",WARNING, + "data size not supported",ERROR, + "illegal use of SOF",WARNING, + "illegal use of SEG",WARNING, + "illegal use of DPP prefix",WARNING, diff --git a/tools/vasm/vasm/cpus/c16x/opcodes.h b/tools/vasm/vasm/cpus/c16x/opcodes.h new file mode 100644 index 0000000..5b546be --- /dev/null +++ b/tools/vasm/vasm/cpus/c16x/opcodes.h @@ -0,0 +1,233 @@ +"add",OP_GPR,OP_GPR,0,1,0x0000,0x0000,0xff00,2,CPU_ALL, +"add",OP_GPR,OP_REG03IND,0,1,0x0800,0x0808,0xf704,4,CPU_ALL, +"add",OP_GPR,OP_POSTINC03,0,1,0x0800,0x080c,0xf700,5,CPU_ALL, +"add",OP_GPR,OP_IMM3,0,1,0x0800,0x0800,0xf708,6,CPU_ALL, +"add",OP_SFR,OP_IMM16,0,2,0x0600,0x0600,0xf900,7,CPU_ALL, +"add",OP_SFR,OP_ABS,0,2,0x0200,0x0200,0xfd00,8,CPU_ALL, +"add",OP_ABS,OP_SFR,0,2,0x0400,0x0400,0xfb00,29,CPU_ALL, +"addb",OP_BGPR,OP_BGPR,0,1,0x0100,0x0100,0xfe00,2,CPU_ALL, +"addb",OP_BGPR,OP_REG03IND,0,1,0x0900,0x0908,0xf604,4,CPU_ALL, +"addb",OP_BGPR,OP_POSTINC03,0,1,0x0900,0x090c,0xf600,5,CPU_ALL, +"addb",OP_BGPR,OP_IMM3,0,1,0x0900,0x0900,0xf608,6,CPU_ALL, +"addb",OP_BSFR,OP_IMM16,0,2,0x0700,0x0700,0xf800,7,CPU_ALL, +"addb",OP_BSFR,OP_BABS,0,2,0x0300,0x0300,0xfc00,8,CPU_ALL, +"addb",OP_BABS,OP_BSFR,0,2,0x0500,0x0500,0xfa00,29,CPU_ALL, +"addc",OP_GPR,OP_GPR,0,1,0x1000,0x1000,0xef00,2,CPU_ALL, +"addc",OP_GPR,OP_REG03IND,0,1,0x1800,0x1808,0xe704,4,CPU_ALL, +"addc",OP_GPR,OP_POSTINC03,0,1,0x1800,0x180c,0xe700,5,CPU_ALL, +"addc",OP_GPR,OP_IMM3,0,1,0x1800,0x1800,0xe708,6,CPU_ALL, +"addc",OP_SFR,OP_IMM16,0,2,0x1600,0x1600,0xe900,7,CPU_ALL, +"addc",OP_SFR,OP_ABS,0,2,0x1200,0x1200,0xed00,8,CPU_ALL, +"addc",OP_ABS,OP_SFR,0,2,0x1400,0x1400,0xeb00,29,CPU_ALL, +"addcb",OP_BGPR,OP_BGPR,0,1,0x1100,0x1100,0xee00,2,CPU_ALL, +"addcb",OP_BGPR,OP_REG03IND,0,1,0x1900,0x1908,0xe604,4,CPU_ALL, +"addcb",OP_BGPR,OP_POSTINC03,0,1,0x1900,0x190c,0xe600,5,CPU_ALL, +"addcb",OP_BGPR,OP_IMM3,0,1,0x1900,0x1900,0xe608,6,CPU_ALL, +"addcb",OP_BSFR,OP_IMM16,0,2,0x1700,0x1700,0xe800,7,CPU_ALL, +"addcb",OP_BSFR,OP_BABS,0,2,0x1300,0x1300,0xec00,8,CPU_ALL, +"addcb",OP_BABS,OP_BSFR,0,2,0x1500,0x1500,0xea00,29,CPU_ALL, +"and",OP_GPR,OP_GPR,0,1,0x6000,0x6000,0x9f00,2,CPU_ALL, +"and",OP_GPR,OP_REG03IND,0,1,0x6800,0x6808,0x9704,4,CPU_ALL, +"and",OP_GPR,OP_POSTINC03,0,1,0x6800,0x680c,0x9700,5,CPU_ALL, +"and",OP_GPR,OP_IMM3,0,1,0x6800,0x6800,0x9708,6,CPU_ALL, +"and",OP_SFR,OP_IMM16,0,2,0x6600,0x6600,0x9900,7,CPU_ALL, +"and",OP_SFR,OP_ABS,0,2,0x6200,0x6200,0x9d00,8,CPU_ALL, +"and",OP_ABS,OP_SFR,0,2,0x6400,0x6400,0x9b00,29,CPU_ALL, +"andb",OP_BGPR,OP_BGPR,0,1,0x6100,0x6100,0x9e00,2,CPU_ALL, +"andb",OP_BGPR,OP_REG03IND,0,1,0x6900,0x6908,0x9604,4,CPU_ALL, +"andb",OP_BGPR,OP_POSTINC03,0,1,0x6900,0x690c,0x9600,5,CPU_ALL, +"andb",OP_BGPR,OP_IMM3,0,1,0x6900,0x6900,0x9608,6,CPU_ALL, +"andb",OP_BSFR,OP_IMM16,0,2,0x6700,0x6700,0x9800,7,CPU_ALL, +"andb",OP_BSFR,OP_BABS,0,2,0x6300,0x6300,0x9c00,8,CPU_ALL, +"andb",OP_BABS,OP_BSFR,0,2,0x6500,0x6500,0x9a00,29,CPU_ALL, +"ashr",OP_GPR,OP_GPR,0,1,0xac00,0xac00,0x5300,2,CPU_ALL, +"ashr",OP_GPR,OP_IMM4,0,1,0xbc00,0xbc00,0x4300,9,CPU_ALL, +"atomic",OP_IMM3,0,0,1,0xd100,0xd100,0x2ecf,31,CPU_C167, +"band",OP_BADDR,OP_BADDR,0,2,0x6a00,0x6a00,0x9500,10,CPU_ALL, +"bclr",OP_BADDR,0,0,1,0x0e00,0x0e00,0x0100,11,CPU_ALL, +"bcmp",OP_BADDR,OP_BADDR,0,2,0x2a00,0x2a00,0xd500,10,CPU_ALL, +"bfldh",OP_BWORD,OP_IMM8,OP_IMM8,2,0x1a00,0x1a00,0xe500,12,CPU_ALL, +"bfldl",OP_BWORD,OP_IMM8,OP_IMM8,2,0x0a00,0x0a00,0xf500,13,CPU_ALL, +"bmov",OP_BADDR,OP_BADDR,0,2,0x4a00,0x4a00,0xb500,10,CPU_ALL, +"bmovn",OP_BADDR,OP_BADDR,0,2,0x3a00,0x3a00,0xc500,10,CPU_ALL, +"bor",OP_BADDR,OP_BADDR,0,2,0x5a00,0x5a00,0xa500,10,CPU_ALL, +"bset",OP_BADDR,0,0,1,0x0f00,0x0f00,0x0000,11,CPU_ALL, +"bxor",OP_BADDR,OP_BADDR,0,2,0x7a00,0x7a00,0x8500,10,CPU_ALL, +"call",OP_REL,0,0,1,0xbb00,0xbb00,0x4400,16,CPU_ALL, +"calla",OP_CC,OP_JADDR,0,2,0xca00,0xca00,0x350f,14,CPU_ALL, +"calli",OP_CC,OP_REGIND,0,1,0xab00,0xab00,0x5400,15,CPU_ALL, +"callr",OP_REL,0,0,1,0xbb00,0xbb00,0x4400,16,CPU_ALL, +"calls",OP_JADDR,0,0,2,0xda00,0xda00,0x2500,17,CPU_ALL, +"cmp",OP_GPR,OP_GPR,0,1,0x4000,0x4000,0xbf00,2,CPU_ALL, +"cmp",OP_GPR,OP_REG03IND,0,1,0x4800,0x4808,0xb704,4,CPU_ALL, +"cmp",OP_GPR,OP_POSTINC03,0,1,0x4800,0x480c,0xb700,5,CPU_ALL, +"cmp",OP_GPR,OP_IMM3,0,1,0x4800,0x4800,0xb708,6,CPU_ALL, +"cmp",OP_SFR,OP_IMM16,0,2,0x4600,0x4600,0xb900,7,CPU_ALL, +"cmp",OP_SFR,OP_ABS,0,2,0x4200,0x4200,0xbd00,8,CPU_ALL, +"cmpb",OP_BGPR,OP_BGPR,0,1,0x4100,0x4100,0xbe00,2,CPU_ALL, +"cmpb",OP_BGPR,OP_REG03IND,0,1,0x4900,0x4908,0xb604,4,CPU_ALL, +"cmpb",OP_BGPR,OP_POSTINC03,0,1,0x4900,0x490c,0xb600,5,CPU_ALL, +"cmpb",OP_BGPR,OP_IMM3,0,1,0x4900,0x4900,0xb608,6,CPU_ALL, +"cmpb",OP_BSFR,OP_IMM16,0,2,0x4700,0x4700,0xb800,7,CPU_ALL, +"cmpb",OP_BSFR,OP_BABS,0,2,0x4300,0x4300,0xbc00,8,CPU_ALL, +"cmpd1",OP_GPR,OP_IMM4,0,1,0xa000,0xa000,0x5f00,9,CPU_ALL, +"cmpd1",OP_GPR,OP_IMM16,0,2,0xa600,0xa6f0,0x5900,18,CPU_ALL, +"cmpd1",OP_GPR,OP_ABS,0,2,0xa200,0xa2f0,0x5d00,19,CPU_ALL, +"cmpd2",OP_GPR,OP_IMM4,0,1,0xb000,0xb000,0x4f00,9,CPU_ALL, +"cmpd2",OP_GPR,OP_IMM16,0,2,0xb600,0xb6f0,0x4900,18,CPU_ALL, +"cmpd2",OP_GPR,OP_ABS,0,2,0xb200,0xb2f0,0x4d00,19,CPU_ALL, +"cmpi1",OP_GPR,OP_IMM4,0,1,0x8000,0x8000,0x7f00,9,CPU_ALL, +"cmpi1",OP_GPR,OP_IMM16,0,2,0x8600,0x86f0,0x7900,18,CPU_ALL, +"cmpi1",OP_GPR,OP_ABS,0,2,0x8200,0x82f0,0x7d00,19,CPU_ALL, +"cmpi2",OP_GPR,OP_IMM4,0,1,0x9000,0x9000,0x6f00,9,CPU_ALL, +"cmpi2",OP_GPR,OP_IMM16,0,2,0x9600,0x96f0,0x6900,18,CPU_ALL, +"cmpi2",OP_GPR,OP_ABS,0,2,0x9200,0x92f0,0x6d00,19,CPU_ALL, +"cpl",OP_GPR,0,0,1,0x9100,0x9100,0x6e0f,20,CPU_ALL, +"cplb",OP_BGPR,0,0,1,0xb100,0xb100,0x4e0f,20,CPU_ALL, +"diswdt",OP_PROTECTED,0,0,2,0xa55a,0xa55a,0x5aa5,0,CPU_ALL, +"div",OP_GPR,0,0,1,0x4b00,0x4b00,0xb400,21,CPU_ALL, +"divl",OP_GPR,0,0,1,0x6b00,0x6b00,0x9400,21,CPU_ALL, +"divlu",OP_GPR,0,0,1,0x7b00,0x7b00,0x8400,21,CPU_ALL, +"divu",OP_GPR,0,0,1,0x5b00,0x5b00,0xa400,21,CPU_ALL, +"einit",OP_PROTECTED,0,0,2,0xb54a,0xb54a,0x4ab5,0,CPU_ALL, + +"extp",OP_GPR,OP_IMM3,0,1,0xdc40,0xdc40,0x2380,32,CPU_C167, +"extp",OP_IMM16,OP_IMM3,0,2,0xd740,0xd740,0x288f,33,CPU_C167, +"extr",OP_IMM3,0,0,1,0xd180,0xd180,0x2e4f,31,CPU_C167, +"extpr",OP_GPR,OP_IMM3,0,1,0xdcc0,0xdcc0,0x2300,32,CPU_C167, +"extpr",OP_IMM16,OP_IMM3,0,2,0xd7c0,0xd7c0,0x280f,33,CPU_C167, +"exts",OP_GPR,OP_IMM3,0,1,0xdc00,0xdc00,0x23c0,32,CPU_C167, +"exts",OP_IMM8,OP_IMM3,0,2,0xd700,0xd700,0x28cf,34,CPU_C167, +"extsr",OP_GPR,OP_IMM3,0,1,0xdc80,0xdc80,0x2340,32,CPU_C167, +"extsr",OP_IMM8,OP_IMM3,0,2,0xd780,0xd780,0x284f,34,CPU_C167, +"idle",OP_PROTECTED,0,0,2,0x8778,0x8778,0x7887,0,CPU_ALL, +"jb",OP_BADDR,OP_REL,0,2,0x8a00,0x8a00,0x7500,22,CPU_ALL, +"jbc",OP_BADDR,OP_REL,0,2,0xaa00,0xaa00,0x5500,22,CPU_ALL, +"jmp",OP_CC,OP_REL,0,1,0x0d00,0x0d00,0x0200,23,CPU_ALL, +"jmpa",OP_CC,OP_JADDR,0,2,0xea00,0xea00,0x150f,14,CPU_ALL, +"jmpi",OP_CC,OP_REGIND,0,1,0x9c00,0x9c00,0x6300,15,CPU_ALL, +"jmpr",OP_CC,OP_REL,0,1,0x0d00,0x0d00,0x0200,23,CPU_ALL, +"jmps",OP_JADDR,0,0,2,0xfa00,0xfa00,0x0500,17,CPU_ALL, +"jnb",OP_BADDR,OP_REL,0,2,0x9a00,0x9a00,0x6500,22,CPU_ALL, +"jnbs",OP_BADDR,OP_REL,0,2,0xba00,0xba00,0x4500,22,CPU_ALL, +"mov",OP_GPR,OP_GPR,0,1,0xf000,0xf000,0x0f00,2,CPU_ALL, +"mov",OP_GPR,OP_IMM4,0,1,0xe000,0xe000,0x1f00,9,CPU_ALL, +"mov",OP_SFR,OP_IMM16,0,2,0xe600,0xe600,0x1900,7,CPU_ALL, +"mov",OP_GPR,OP_REGIND,0,1,0xa800,0xa800,0x5700,2,CPU_ALL, +"mov",OP_GPR,OP_POSTINC,0,1,0x9800,0x9800,0x6700,2,CPU_ALL, +"mov",OP_REGIND,OP_GPR,0,1,0xb800,0xb800,0x4700,3,CPU_ALL, +"mov",OP_PREDEC,OP_GPR,0,1,0x8800,0x8800,0x7700,3,CPU_ALL, +"mov",OP_REGIND,OP_REGIND,0,1,0xc800,0xc800,0x3700,2,CPU_ALL, +"mov",OP_POSTINC,OP_REGIND,0,1,0xd800,0xd800,0x2700,2,CPU_ALL, +"mov",OP_REGIND,OP_POSTINC,0,1,0xe800,0xe800,0x1700,2,CPU_ALL, +"mov",OP_GPR,OP_REGDISP,0,2,0xd400,0xd400,0x2b00,24,CPU_ALL, +"mov",OP_REGDISP,OP_GPR,0,2,0xc400,0xc400,0x3b00,28,CPU_ALL, +"mov",OP_REGIND,OP_ABS,0,2,0x8400,0x8400,0x7bf0,25,CPU_ALL, +"mov",OP_ABS,OP_REGIND,0,2,0x9400,0x9400,0x6bf0,30,CPU_ALL, +"mov",OP_SFR,OP_ABS,0,2,0xf200,0xf200,0x0d00,8,CPU_ALL, +"mov",OP_ABS,OP_SFR,0,2,0xf600,0xf600,0x0900,29,CPU_ALL, +"movb",OP_BGPR,OP_BGPR,0,1,0xf100,0xf100,0x0e00,2,CPU_ALL, +"movb",OP_BGPR,OP_IMM4,0,1,0xe100,0xe100,0x1e00,9,CPU_ALL, +"movb",OP_BSFR,OP_IMM16,0,2,0xe700,0xe700,0x1800,7,CPU_ALL, +"movb",OP_BGPR,OP_REGIND,0,1,0xa900,0xa900,0x5600,2,CPU_ALL, +"movb",OP_BGPR,OP_POSTINC,0,1,0x9900,0x9900,0x6600,2,CPU_ALL, +"movb",OP_REGIND,OP_BGPR,0,1,0xb900,0xb900,0x4600,3,CPU_ALL, +"movb",OP_PREDEC,OP_BGPR,0,1,0x8900,0x8900,0x7600,3,CPU_ALL, +"movb",OP_REGIND,OP_REGIND,0,1,0xc900,0xc900,0x3600,2,CPU_ALL, +"movb",OP_POSTINC,OP_REGIND,0,1,0xd900,0xd900,0x2600,2,CPU_ALL, +"movb",OP_REGIND,OP_POSTINC,0,1,0xe900,0xe900,0x1600,2,CPU_ALL, +"movb",OP_BGPR,OP_REGDISP,0,2,0xf400,0xf400,0x0b00,24,CPU_ALL, +"movb",OP_REGDISP,OP_BGPR,0,2,0xe400,0xe400,0x1b00,28,CPU_ALL, +"movb",OP_REGIND,OP_BABS,0,2,0xa400,0xa400,0x5bf0,25,CPU_ALL, +"movb",OP_BABS,OP_REGIND,0,2,0xb400,0xb400,0x4bf0,30,CPU_ALL, +"movb",OP_BSFR,OP_BABS,0,2,0xf300,0xf300,0x0c00,8,CPU_ALL, +"movb",OP_BABS,OP_BSFR,0,2,0xf700,0xf700,0x0800,29,CPU_ALL, +"movbs",OP_GPR,OP_BGPR,0,1,0xd000,0xd000,0x2f00,3,CPU_ALL, +"movbs",OP_SFR,OP_BABS,0,2,0xd200,0xd200,0x2d00,8,CPU_ALL, +"movbs",OP_ABS,OP_BSFR,0,2,0xd500,0xd500,0x2a00,29,CPU_ALL, +"movbz",OP_GPR,OP_BGPR,0,1,0xc000,0xc000,0x3f00,3,CPU_ALL, +"movbz",OP_SFR,OP_BABS,0,2,0xc200,0xc200,0x3d00,8,CPU_ALL, +"movbz",OP_ABS,OP_BSFR,0,2,0xc500,0xc500,0x3a00,29,CPU_ALL, +"mul",OP_GPR,OP_GPR,0,1,0x0b00,0x0b00,0xf400,2,CPU_ALL, +"mulu",OP_GPR,OP_GPR,0,1,0x1b00,0x1b00,0xe400,2,CPU_ALL, +"neg",OP_GPR,0,0,1,0x8100,0x8100,0x7e0f,20,CPU_ALL, +"negb",OP_BGPR,0,0,1,0xa100,0xa100,0x5e0f,20,CPU_ALL, +"nop",0,0,0,1,0xcc00,0xcc00,0x33ff,1,CPU_ALL, +"or",OP_GPR,OP_GPR,0,1,0x7000,0x7000,0x8f00,2,CPU_ALL, +"or",OP_GPR,OP_REG03IND,0,1,0x7800,0x7808,0x8704,4,CPU_ALL, +"or",OP_GPR,OP_POSTINC03,0,1,0x7800,0x780c,0x8700,5,CPU_ALL, +"or",OP_GPR,OP_IMM3,0,1,0x7800,0x7800,0x8708,6,CPU_ALL, +"or",OP_SFR,OP_IMM16,0,2,0x7600,0x7600,0x8900,7,CPU_ALL, +"or",OP_SFR,OP_ABS,0,2,0x7200,0x7200,0x8d00,8,CPU_ALL, +"or",OP_ABS,OP_SFR,0,2,0x7400,0x7400,0x8b00,29,CPU_ALL, +"orb",OP_BGPR,OP_BGPR,0,1,0x7100,0x7100,0x8e00,2,CPU_ALL, +"orb",OP_BGPR,OP_REG03IND,0,1,0x7900,0x7908,0x8604,4,CPU_ALL, +"orb",OP_BGPR,OP_POSTINC03,0,1,0x7900,0x790c,0x8600,5,CPU_ALL, +"orb",OP_BGPR,OP_IMM3,0,1,0x7900,0x7900,0x8608,6,CPU_ALL, +"orb",OP_BSFR,OP_IMM16,0,2,0x7700,0x7700,0x8800,7,CPU_ALL, +"orb",OP_BSFR,OP_BABS,0,2,0x7300,0x7300,0x8c00,8,CPU_ALL, +"orb",OP_BABS,OP_BSFR,0,2,0x7500,0x7500,0x8a00,29,CPU_ALL, +"pcall",OP_SFR,OP_JADDR,0,2,0xe200,0xe200,0x1d00,8,CPU_ALL, +"pop",OP_SFR,0,0,1,0xfc00,0xfc00,0x0300,26,CPU_ALL, +"prior",OP_GPR,OP_GPR,0,1,0x2b00,0x2b00,0xd400,2,CPU_ALL, +"push",OP_SFR,0,0,1,0xec00,0xec00,0x1300,26,CPU_ALL, +"pwrdn",OP_PROTECTED,0,0,2,0x9768,0x9768,0x6897,0,CPU_ALL, +"ret",0,0,0,1,0xcb00,0xcb00,0x34ff,1,CPU_ALL, +"reti",0,0,0,1,0xfb88,0xfb88,0x0477,1,CPU_ALL, +"retp",OP_SFR,0,0,1,0xeb00,0xeb00,0x1400,26,CPU_ALL, +"rets",0,0,0,1,0xdb00,0xdb00,0x24ff,1,CPU_ALL, +"rol",OP_GPR,OP_GPR,0,1,0x0c00,0x0c00,0xf300,2,CPU_ALL, +"rol",OP_GPR,OP_IMM4,0,1,0x1c00,0x1c00,0xe300,9,CPU_ALL, +"ror",OP_GPR,OP_GPR,0,1,0x2c00,0x2c00,0xd300,2,CPU_ALL, +"ror",OP_GPR,OP_IMM4,0,1,0x3c00,0x3c00,0xc300,9,CPU_ALL, +"scxt",OP_SFR,OP_IMM16,0,2,0xc600,0xc600,0x3900,7,CPU_ALL, +"scxt",OP_SFR,OP_ABS,0,2,0xd600,0xd600,0x2900,8,CPU_ALL, +"shl",OP_GPR,OP_GPR,0,1,0x4c00,0x4c00,0xb300,2,CPU_ALL, +"shl",OP_GPR,OP_IMM4,0,1,0x5c00,0x5c00,0xa300,9,CPU_ALL, +"shr",OP_GPR,OP_GPR,0,1,0x6c00,0x6c00,0x9300,2,CPU_ALL, +"shr",OP_GPR,OP_IMM4,0,1,0x7c00,0x7c00,0x8300,9,CPU_ALL, +"srst",OP_PROTECTED,0,0,2,0xb748,0xb748,0x48b7,0,CPU_ALL, +"srvwdt",OP_PROTECTED,0,0,2,0xa758,0xa758,0x58a7,0,CPU_ALL, +"sub",OP_GPR,OP_GPR,0,1,0x2000,0x2000,0xdf00,2,CPU_ALL, +"sub",OP_GPR,OP_REG03IND,0,1,0x2800,0x2808,0xd704,4,CPU_ALL, +"sub",OP_GPR,OP_POSTINC03,0,1,0x2800,0x280c,0xd700,5,CPU_ALL, +"sub",OP_GPR,OP_IMM3,0,1,0x2800,0x2800,0xd708,6,CPU_ALL, +"sub",OP_SFR,OP_IMM16,0,2,0x2600,0x2600,0xd900,7,CPU_ALL, +"sub",OP_SFR,OP_ABS,0,2,0x2200,0x2200,0xdd00,8,CPU_ALL, +"sub",OP_ABS,OP_SFR,0,2,0x2400,0x2400,0xdb00,29,CPU_ALL, +"subb",OP_BGPR,OP_BGPR,0,1,0x2100,0x2100,0xde00,2,CPU_ALL, +"subb",OP_BGPR,OP_REG03IND,0,1,0x2900,0x2908,0xd604,4,CPU_ALL, +"subb",OP_BGPR,OP_POSTINC03,0,1,0x2900,0x290c,0xd600,5,CPU_ALL, +"subb",OP_BGPR,OP_IMM3,0,1,0x2900,0x2900,0xd608,6,CPU_ALL, +"subb",OP_BSFR,OP_IMM16,0,2,0x2700,0x2700,0xd800,7,CPU_ALL, +"subb",OP_BSFR,OP_BABS,0,2,0x2300,0x2300,0xdc00,8,CPU_ALL, +"subb",OP_BABS,OP_BSFR,0,2,0x2500,0x2500,0xda00,29,CPU_ALL, +"subc",OP_GPR,OP_GPR,0,1,0x3000,0x3000,0xcf00,2,CPU_ALL, +"subc",OP_GPR,OP_REG03IND,0,1,0x3800,0x3808,0xc704,4,CPU_ALL, +"subc",OP_GPR,OP_POSTINC03,0,1,0x3800,0x380c,0xc700,5,CPU_ALL, +"subc",OP_GPR,OP_IMM3,0,1,0x3800,0x3800,0xc708,6,CPU_ALL, +"subc",OP_SFR,OP_IMM16,0,2,0x3600,0x3600,0xc900,7,CPU_ALL, +"subc",OP_SFR,OP_ABS,0,2,0x3200,0x3200,0xcd00,8,CPU_ALL, +"subc",OP_ABS,OP_SFR,0,2,0x3400,0x3400,0xcb00,29,CPU_ALL, +"subcb",OP_BGPR,OP_BGPR,0,1,0x3100,0x3100,0xce00,2,CPU_ALL, +"subcb",OP_BGPR,OP_REG03IND,0,1,0x3900,0x3908,0xc604,4,CPU_ALL, +"subcb",OP_BGPR,OP_POSTINC03,0,1,0x3900,0x390c,0xc600,5,CPU_ALL, +"subcb",OP_BGPR,OP_IMM3,0,1,0x3900,0x3900,0xc608,6,CPU_ALL, +"subcb",OP_BSFR,OP_IMM16,0,2,0x3700,0x3700,0xc800,7,CPU_ALL, +"subcb",OP_BSFR,OP_BABS,0,2,0x3300,0x3300,0xcc00,8,CPU_ALL, +"subcb",OP_BABS,OP_BSFR,0,2,0x3500,0x3500,0xca00,29,CPU_ALL, +"trap",OP_IMM7,0,0,1,0x9b00,0x9b00,0x6401,27,CPU_ALL, +"xor",OP_GPR,OP_GPR,0,1,0x5000,0x5000,0xaf00,2,CPU_ALL, +"xor",OP_GPR,OP_REG03IND,0,1,0x5800,0x5808,0xa704,4,CPU_ALL, +"xor",OP_GPR,OP_POSTINC03,0,1,0x5800,0x580c,0xa700,5,CPU_ALL, +"xor",OP_GPR,OP_IMM3,0,1,0x5800,0x5800,0xa708,6,CPU_ALL, +"xor",OP_SFR,OP_IMM16,0,2,0x5600,0x5600,0xa900,7,CPU_ALL, +"xor",OP_SFR,OP_ABS,0,2,0x5200,0x5200,0xad00,8,CPU_ALL, +"xor",OP_ABS,OP_SFR,0,2,0x5400,0x5400,0xab00,29,CPU_ALL, +"xorb",OP_BGPR,OP_BGPR,0,1,0x5100,0x5100,0xae00,2,CPU_ALL, +"xorb",OP_BGPR,OP_REG03IND,0,1,0x5900,0x5908,0xa604,4,CPU_ALL, +"xorb",OP_BGPR,OP_POSTINC03,0,1,0x5900,0x590c,0xa600,5,CPU_ALL, +"xorb",OP_BGPR,OP_IMM3,0,1,0x5900,0x5900,0xa608,6,CPU_ALL, +"xorb",OP_BSFR,OP_IMM16,0,2,0x5700,0x5700,0xa800,7,CPU_ALL, +"xorb",OP_BSFR,OP_BABS,0,2,0x5300,0x5300,0xac00,8,CPU_ALL, +"xorb",OP_BABS,OP_BSFR,0,2,0x5500,0x5500,0xaa00,29,CPU_ALL, diff --git a/tools/vasm/vasm/cpus/jagrisc/cpu.c b/tools/vasm/vasm/cpus/jagrisc/cpu.c new file mode 100644 index 0000000..9a195f3 --- /dev/null +++ b/tools/vasm/vasm/cpus/jagrisc/cpu.c @@ -0,0 +1,625 @@ +/* + * cpu.c Jaguar RISC cpu description file + * (c) in 2014-2017,2020 by Frank Wille + */ + +#include "vasm.h" + +mnemonic mnemonics[] = { +#include "opcodes.h" +}; +int mnemonic_cnt = sizeof(mnemonics) / sizeof(mnemonics[0]); + +char *cpu_copyright = "vasm Jaguar RISC cpu backend 0.4d (c) 2014-2017,2020 Frank Wille"; +char *cpuname = "jagrisc"; +int bitsperbyte = 8; +int bytespertaddr = 4; + +int jag_big_endian = 1; /* defaults to big-endian (Atari Jaguar 68000) */ + +static uint8_t cpu_type = GPU|DSP; +static int OC_MOVEI,OC_UNPACK; + +/* condition codes */ +static regsym cc_regsyms[] = { + {"t", RTYPE_CC, 0, 0x00}, + {"a", RTYPE_CC, 0, 0x00}, + {"ne", RTYPE_CC, 0, 0x01}, + {"eq", RTYPE_CC, 0, 0x02}, + {"cc", RTYPE_CC, 0, 0x04}, + {"hs", RTYPE_CC, 0, 0x04}, + {"hi", RTYPE_CC, 0, 0x05}, + {"cs", RTYPE_CC, 0, 0x08}, + {"lo", RTYPE_CC, 0, 0x08}, + {"pl", RTYPE_CC, 0, 0x14}, + {"mi", RTYPE_CC, 0, 0x18}, + {"f", RTYPE_CC, 0, 0x1f}, + {"nz", RTYPE_CC, 0, 0x01}, + {"z", RTYPE_CC, 0, 0x02}, + {"nc", RTYPE_CC, 0, 0x04}, + {"ncnz", RTYPE_CC, 0, 0x05}, + {"ncz" , RTYPE_CC, 0, 0x06}, + {"c", RTYPE_CC, 0, 0x08}, + {"cnz" , RTYPE_CC, 0, 0x09}, + {"cz", RTYPE_CC, 0, 0x0a}, + {"nn", RTYPE_CC, 0, 0x14}, + {"nnnz", RTYPE_CC, 0, 0x15}, + {"nnz", RTYPE_CC, 0, 0x16}, + {"n", RTYPE_CC, 0, 0x18}, + {"n_nz", RTYPE_CC, 0, 0x19}, + {"n_z", RTYPE_CC, 0, 0x1a}, + {NULL, 0, 0, 0} +}; + + +int init_cpu(void) +{ + int i; + regsym *r; + + for (i=0; ireg_name!=NULL; r++) + add_regsym(r); + + return 1; +} + + +int cpu_args(char *p) +{ + if (!strncmp(p,"-m",2)) { + p += 2; + if (!stricmp(p,"gpu") || !stricmp(p,"tom")) + cpu_type = GPU; + else if (!stricmp(p,"dsp") || !stricmp(p,"jerry")) + cpu_type = DSP; + else if (!strcmp(p,"any")) + cpu_type = GPU|DSP; + else + return 0; + } + else if (!strcmp(p,"-big")) + jag_big_endian = 1; + else if (!strcmp(p,"-little")) + jag_big_endian = 0; + else + return 0; + + return 1; +} + + +static int parse_reg(char **p) +{ + int reg = -1; + char *rp = skip(*p); + char *s; + + if (s = skip_identifier(rp)) { + regsym *sym = find_regsym(rp,s-rp); + + if (sym!=NULL && sym->reg_type==RTYPE_R) { + reg = sym->reg_num; + } + else if (toupper((unsigned char)*rp++) == 'R') { + if (sscanf(rp,"%d",®)!=1 || reg<0 || reg>31) + reg = -1; + } + + if (reg >= 0) + *p = s; + } + + return reg; +} + + +static expr *parse_cc(char **p) +{ + char *end; + + *p = skip(*p); + + if (end = skip_identifier(*p)) { + regsym *sym = find_regsym_nc(*p,end-*p); + + if (sym!=NULL && sym->reg_type==RTYPE_CC) { + *p = end; + return number_expr((taddr)sym->reg_num); + } + } + + /* otherwise the condition code is any expression */ + return parse_expr(p); +} + + +static void jagswap32(unsigned char *d,int32_t w) +/* write a 32-bit word with swapped halfs (Jaguar MOVEI) */ +{ + if (jag_big_endian) { + *d++ = (w >> 8) & 0xff; + *d++ = w & 0xff; + *d++ = (w >> 24) & 0xff; + *d = (w >> 16) & 0xff; + } + else { + /* @@@ Need to verify this! */ + *d++ = w & 0xff; + *d++ = (w >> 8) & 0xff; + *d++ = (w >> 16) & 0xff; + *d = (w >> 24) & 0xff; + } +} + + +char *parse_cpu_special(char *start) +/* parse cpu-specific directives; return pointer to end of cpu-specific text */ +{ + char *name=start; + char *s; + + if (s = skip_identifier(name)) { + /* Atari MadMac compatibility directives */ + if (dotdirs && *name=='.') /* ignore leading dot */ + name++; + + if (s-name==3 && !strnicmp(name,"dsp",3)) { + cpu_type = DSP; + eol(s); + return skip_line(s); + } + + else if (s-name==3 && !strnicmp(name,"gpu",3)) { + cpu_type = GPU; + eol(s); + return skip_line(s); + } + + else if (s-name==8 && !strnicmp(name,"regundef",8) || + s-name==9 && !strnicmp(name,"equrundef",9)) { + /* undefine a register symbol */ + s = skip(s); + if (name = parse_identifier(&s)) { + undef_regsym(name,0,RTYPE_R); + myfree(name); + eol(s); + return skip_line(s); + } + } + + else if (s-name==7 && !strnicmp(name,"ccundef",7)) { + /* undefine a condition code symbol */ + s = skip(s); + if (name = parse_identifier(&s)) { + undef_regsym(strtolower(name),0,RTYPE_CC); + myfree(name); + eol(s); + return skip_line(s); + } + } + } + + return start; +} + + +int parse_cpu_label(char *labname,char **start) +/* parse cpu-specific directives following a label field, + return zero when no valid directive was recognized */ +{ + char *dir=*start; + char *s; + + if (dotdirs && *dir=='.') /* ignore leading dot */ + dir++; + + if (s = skip_identifier(dir)) { + + if (s-dir==6 && !strnicmp(dir,"regequ",6) || + s-dir==4 && !strnicmp(dir,"equr",4)) { + /* label REGEQU Rn || label EQUR Rn */ + int r; + + if ((r = parse_reg(&s)) >= 0) + new_regsym(0,0,labname,RTYPE_R,0,r); + else + cpu_error(3); /* register expected */ + eol(s); + *start = skip_line(s); + return 1; + } + + else if (s-dir==5 && !strnicmp(dir,"ccdef",5)) { + /* label CCDEF expr */ + expr *ccexp; + taddr val; + + if ((ccexp = parse_cc(&s)) != NULL) { + if (eval_expr(ccexp,&val,NULL,0)) + new_regsym(0,0,labname,RTYPE_CC,0,(int)val); + else + general_error(30); /* expression must be a constant */ + } + else + general_error(9); /* @@@ */ + eol(s); + *start = skip_line(s); + return 1; + } + } + + return 0; +} + + +operand *new_operand(void) +{ + operand *new = mymalloc(sizeof(*new)); + + new->type = NO_OP; + return new; +} + + +int jag_data_operand(int bits) +/* return data operand type for these number of bits */ +{ + if (bits & OPSZ_SWAP) + return DATAI_OP; + return bits==64 ? DATA64_OP : DATA_OP; +} + + +int parse_operand(char *p, int len, operand *op, int required) +{ + int reg; + + switch (required) { + case IMM0: + case IMM1: + case IMM1S: + case SIMM: + case IMMLW: + if (*p == '#') + p = skip(p+1); /* skip optional '#' */ + case REL: + case DATA_OP: + case DATAI_OP: + if (required == IMM1S) { + op->val = make_expr(SUB,number_expr(32),parse_expr(&p)); + required = IMM1; /* turn into IMM1 32-val for SHLQ */ + } + else + op->val = parse_expr(&p); + break; + + case DATA64_OP: + op->val = parse_expr_huge(&p); + break; + + case REG: /* Rn */ + op->reg = parse_reg(&p); + if (op->reg < 0) + return PO_NOMATCH; + break; + + case IREG: /* (Rn) */ + if (*p++ != '(') + return PO_NOMATCH; + op->reg = parse_reg(&p); + if (op->reg < 0) + return PO_NOMATCH; + if (*p != ')') + return PO_NOMATCH; + break; + + case IR14D: /* (R14+d) */ + case IR15D: /* (R15+d) */ + if (*p++ != '(') + return PO_NOMATCH; + reg = parse_reg(&p); + if ((required==IR14D && reg!=14) || (required==IR15D && reg!=15)) + return PO_NOMATCH; + if (*p++ != '+') + return PO_NOMATCH; + p = skip(p); + op->val = parse_expr(&p); + p = skip(p); + if (*p != ')') + return PO_NOMATCH; + break; + + case IR14R: /* (R14+Rn) */ + case IR15R: /* (R15+Rn) */ + if (*p++ != '(') + return PO_NOMATCH; + reg = parse_reg(&p); + if ((required==IR14R && reg!=14) || (required==IR15R && reg!=15)) + return PO_NOMATCH; + if (*p++ != '+') + return PO_NOMATCH; + op->reg = parse_reg(&p); + if (op->reg < 0) + return PO_NOMATCH; + if (*p != ')') + return PO_NOMATCH; + break; + + case CC: /* condition code: t, eq, ne, mi, pl, cc, cs, ... */ + op->val = parse_cc(&p); + break; + + case PC: /* PC register */ + if (toupper((unsigned char)*p) != 'P' || + toupper((unsigned char)*(p+1)) != 'C' || + ISIDCHAR(*(p+2))) + return PO_NOMATCH; + break; + + default: + return PO_NOMATCH; + } + + op->type = required; + return PO_MATCH; +} + + +static int32_t eval_oper(instruction *ip,operand *op,section *sec, + taddr pc,dblock *db) +{ + symbol *base = NULL; + int optype = op->type; + int btype; + taddr val,loval,hival,mask; + + switch (optype) { + case PC: + return 0; + + case REG: + case IREG: + case IR14R: + case IR15R: + return op->reg; + + case IMM0: + case IMM1: + case SIMM: + case IMMLW: + case IR14D: + case IR15D: + case REL: + case CC: + mask = 0x1f; + if (!eval_expr(op->val,&val,sec,pc)) + btype = find_base(op->val,&base,sec,pc); + + if (optype==IMM0 || optype==CC || optype==IMM1 || optype==SIMM) { + if (base != NULL) { + loval = -32; + hival = 32; + if (btype != BASE_ILLEGAL) { + if (db) { + add_extnreloc_masked(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS, + jag_big_endian?6:5,5,0,0x1f); + base = NULL; + } + } + } + else if (optype==IMM1) { + loval = 1; + hival = 32; + } + else if (optype==SIMM) { + loval = -16; + hival = 15; + } + else { + loval = 0; + hival = 31; + } + } + else if (optype==IR14D || optype==IR15D) { + if (base==NULL && val==0) { + /* Optimize (Rn+0) to (Rn). Assume that the "load/store (Rn+d)" + instructions follow directly after "load/store (Rn)". */ + ip->code -= optype==IR14D ? 1 : 2; + op->type = IREG; + op->reg = optype==IR14D ? 14 : 15; + return op->reg; + } + loval = 1; + hival = 32; + } + else if (optype==IMMLW) { + mask = ~0; + if (base != NULL) { + if (btype != BASE_ILLEGAL) { + if (db) { + /* two relocations for LSW first, then MSW */ + add_extnreloc_masked(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS, + 0,16,2,0xffff); + add_extnreloc_masked(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS, + 16,16,2,0xffff0000); + base = NULL; + } + } + } + } + else if (optype==REL) { + loval = -16; + hival = 15; + if ((base!=NULL && btype==BASE_OK && !is_pc_reloc(base,sec)) || + base==NULL) { + /* known label from same section or absolute label */ + val = (val - (pc + 2)) / 2; + } + else if (btype == BASE_OK) { + /* external label or from a different section (distance / 2) */ + add_extnreloc_masked(&db->relocs,base,val-2,REL_PC, + jag_big_endian?6:5,5,0,0x3e); + } + base = NULL; + } + else ierror(0); + + if (base != NULL) + general_error(38); /* bad or unhandled reloc: illegal relocation */ + + /* range check for this addressing mode */ + if (mask!=~0 && (valhival)) + cpu_error(1,(long)loval,(long)hival); + return val & mask; + + default: + ierror(0); + break; + } + + return 0; /* default */ +} + + +size_t instruction_size(instruction *ip, section *sec, taddr pc) +{ + return ip->code==OC_MOVEI ? 6 : 2; +} + + +dblock *eval_instruction(instruction *ip, section *sec, taddr pc) +{ + dblock *db = new_dblock(); + int32_t src=0,dst=0,extra; + int size = 2; + uint16_t inst; + + /* get source and destination argument, when present */ + if (ip->op[0]) + dst = eval_oper(ip,ip->op[0],sec,pc,db); + if (ip->op[1]) { + if (ip->code == OC_MOVEI) { + extra = dst; + size = 6; + } + else + src = dst; + dst = eval_oper(ip,ip->op[1],sec,pc,db); + } + else if (ip->code == OC_UNPACK) + src = 1; /* pack(src=0)/unpack(src=1) use the same opcode */ + + /* store and jump instructions need the second operand in the source field */ + if (mnemonics[ip->code].ext.flags & OPSWAP) { + extra = src; + src = dst; + dst = extra; + } + + /* allocate dblock data for instruction */ + db->size = size; + db->data = mymalloc(size); + + /* construct the instruction word out of opcode and source/dest. value */ + inst = (mnemonics[ip->code].ext.opcode & 63) << 10; + inst |= ((src&31) << 5) | (dst & 31); + + /* write instruction */ + if (jag_big_endian) { + db->data[0] = (inst >> 8) & 0xff; + db->data[1] = inst & 0xff; + } + else { + db->data[0] = inst & 0xff; + db->data[1] = (inst >> 8) & 0xff; + } + + /* extra words for MOVEI are always written in the order lo-word, hi-word */ + if (size == 6) + jagswap32(&db->data[2],extra); + + return db; +} + + +dblock *eval_data(operand *op, size_t bitsize, section *sec, taddr pc) +{ + dblock *db = new_dblock(); + taddr val; + + if (bitsize!=8 && bitsize!=16 && bitsize!=32 && bitsize!=64) + cpu_error(0,bitsize); /* data size not supported */ + + if (op->type!=DATA_OP && op->type!=DATA64_OP && op->type!=DATAI_OP) + ierror(0); + + db->size = bitsize >> 3; + db->data = mymalloc(db->size); + + if (op->type == DATA64_OP) { + thuge hval; + + if (!eval_expr_huge(op->val,&hval)) + general_error(59); /* cannot evaluate huge integer */ + huge_to_mem(jag_big_endian,db->data,db->size,hval); + } + else { + if (!eval_expr(op->val,&val,sec,pc)) { + symbol *base; + int btype; + + btype = find_base(op->val,&base,sec,pc); + if (base!=NULL && btype!=BASE_ILLEGAL) { + if (op->type == DATAI_OP) { + /* swapped: two relocations for LSW first, then MSW */ + add_extnreloc_masked(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS, + 0,16,0,0xffff); + add_extnreloc_masked(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS, + 16,16,0,0xffff0000); + } + else /* normal 8, 16, 32 bit relocation */ + add_extnreloc(&db->relocs,base,val, + btype==BASE_PCREL?REL_PC:REL_ABS,0,bitsize,0); + } + else if (btype != BASE_NONE) + general_error(38); /* illegal relocation */ + } + + switch (db->size) { + case 1: + db->data[0] = val & 0xff; + break; + case 2: + case 4: + if (op->type == DATAI_OP) + jagswap32(db->data,(int32_t)val); + else + setval(jag_big_endian,db->data,db->size,val); + break; + default: + ierror(0); + break; + } + } + + return db; +} + + +int cpu_available(int idx) +{ + return (mnemonics[idx].ext.flags & cpu_type) != 0; +} diff --git a/tools/vasm/vasm/cpus/jagrisc/cpu.h b/tools/vasm/vasm/cpus/jagrisc/cpu.h new file mode 100644 index 0000000..27d086e --- /dev/null +++ b/tools/vasm/vasm/cpus/jagrisc/cpu.h @@ -0,0 +1,86 @@ +/* +** cpu.h Jaguar RISC cpu-description header-file +** (c) in 2014-2017 by Frank Wille +*/ + +extern int jag_big_endian; +#define BIGENDIAN (jag_big_endian) +#define LITTLEENDIAN (!jag_big_endian) +#define VASM_CPU_JAGRISC 1 + +/* maximum number of operands for one mnemonic */ +#define MAX_OPERANDS 2 + +/* maximum number of mnemonic-qualifiers per mnemonic */ +#define MAX_QUALIFIERS 0 + +/* data type to represent a target-address */ +typedef int32_t taddr; +typedef uint32_t utaddr; + +/* minimum instruction alignment */ +#define INST_ALIGN 2 + +/* default alignment for n-bit data */ +#define DATA_ALIGN(n) ((n<=8)?1:2) + +/* operand class for n-bit data definitions */ +int jag_data_operand(int); +#define DATA_OPERAND(n) jag_data_operand(n) + +/* returns true when instruction is valid for selected cpu */ +#define MNEMONIC_VALID(i) cpu_available(i) + +/* type to store each operand */ +typedef struct { + uint8_t type; + int8_t reg; + expr *val; +} operand; + +/* operand types */ +enum { + NO_OP=0, + DATA_OP, + DATA64_OP, + DATAI_OP, /* 32-bit with swapped halfwords */ + REG, /* register Rn */ + IMM0, /* 5-bit immediate expression (0-31) */ + IMM1, /* 5-bit immediate expression (1-32) */ + IMM1S, /* 5-bit immediate expression 32-(1-32) for SHLQ */ + SIMM, /* 5-bit signed immediate expression (-16 - 15) */ + IMMLW, /* 32-bit immediate expression in extra longword */ + IREG, /* register indirect (Rn) */ + IR14D, /* register R14 plus displacement indirect (R14+n) */ + IR15D, /* register R15 plus displacement indirect (R15+n) */ + IR14R, /* register R14 plus register Rn indirect (R14+Rn) */ + IR15R, /* register R15 plus register Rn indirect (R15+Rn) */ + CC, /* condition code, t, cc, cs, eq, ne, mi, pl, hi */ + REL, /* relative branch, PC + 2 + (-16..15) words */ + PC /* PC register */ +}; + +/* additional mnemonic data */ +typedef struct { + uint8_t opcode; + uint8_t flags; +} mnemonic_extension; + +/* Values defined for the 'flags' field of mnemonic_extension. */ +#define GPU 1 +#define DSP 2 +#define ANY GPU|DSP + +#define OPSWAP 128 /* swapped operands in instruction word encoding */ + +/* Register symbols */ +#define HAVE_REGSYMS +#define REGSYMHTSIZE 64 +#define RTYPE_R 0 /* R0-R31 */ +#define RTYPE_CC 1 /* condition codes (0-31) */ + +/* Prototypes */ +int cpu_available(int); + +int parse_cpu_label(char *,char **); +#define PARSE_CPU_LABEL(l,s) parse_cpu_label(l,s) diff --git a/tools/vasm/vasm/cpus/jagrisc/cpu_errors.h b/tools/vasm/vasm/cpus/jagrisc/cpu_errors.h new file mode 100644 index 0000000..68db758 --- /dev/null +++ b/tools/vasm/vasm/cpus/jagrisc/cpu_errors.h @@ -0,0 +1,3 @@ + "data size %d not supported",ERROR, + "value from %ld to %ld required",ERROR, + "register expected",ERROR, diff --git a/tools/vasm/vasm/cpus/jagrisc/opcodes.h b/tools/vasm/vasm/cpus/jagrisc/opcodes.h new file mode 100644 index 0000000..0995abb --- /dev/null +++ b/tools/vasm/vasm/cpus/jagrisc/opcodes.h @@ -0,0 +1,72 @@ + "abs", { REG }, { 22, ANY }, + "add", { REG, REG }, { 0, ANY }, + "addc", { REG, REG }, { 1, ANY }, + "addq", { IMM1, REG }, { 2, ANY }, + "addqmod", { IMM1, REG }, { 63, DSP }, + "addqt", { IMM1, REG }, { 3, ANY }, + "and", { REG, REG }, { 9, ANY }, + "bclr", { IMM0, REG }, { 15, ANY }, + "bset", { IMM0, REG }, { 14, ANY }, + "btst", { IMM0, REG }, { 13, ANY }, + "cmp", { REG, REG }, { 30, ANY }, + "cmpq", { SIMM, REG }, { 31, ANY }, + "div", { REG, REG }, { 21, ANY }, + "imacn", { REG, REG }, { 20, ANY }, + "imult", { REG, REG }, { 17, ANY }, + "imultn", { REG, REG }, { 18, ANY }, + "jr", { REL }, { 53, ANY|OPSWAP }, + "jr", { CC, REL }, { 53, ANY|OPSWAP }, + "jump", { IREG }, { 52, ANY|OPSWAP }, + "jump", { CC, IREG }, { 52, ANY|OPSWAP }, + "load", { IREG, REG }, { 41, ANY }, + "load", { IR14R, REG }, { 58, ANY }, + "load", { IR15R, REG }, { 59, ANY }, + "load", { IR14D, REG }, { 43, ANY }, + "load", { IR15D, REG }, { 44, ANY }, + "loadb", { IREG, REG }, { 39, ANY }, + "loadp", { IREG, REG }, { 42, GPU }, + "loadw", { IREG, REG }, { 40, ANY }, + "mirror", { REG, IREG }, { 48, DSP|OPSWAP }, + "mmult", { REG, REG }, { 54, ANY }, + "move", { REG, REG }, { 34, ANY }, + "move", { PC, REG }, { 51, ANY }, + "movefa", { REG, REG }, { 37, ANY }, + "movei", { IMMLW, REG }, { 38, ANY }, + "moveq", { IMM0, REG }, { 35, ANY }, + "moveta", { REG, REG }, { 36, ANY }, + "mtoi", { REG, REG }, { 55, ANY }, + "mult", { REG, REG }, { 16, ANY }, + "neg", { REG }, { 8, ANY }, + "nop", { NO_OP }, { 57, ANY }, + "normi", { REG, REG }, { 56, ANY }, + "not", { REG }, { 12, ANY }, + "or", { REG, REG }, { 10, ANY }, + "pack", { REG }, { 63, GPU }, + "resmac", { REG }, { 19, ANY }, + "ror", { REG, REG }, { 28, ANY }, + "rorq", { IMM1, REG }, { 29, ANY }, + "sat8", { REG }, { 32, GPU }, + "sat16", { REG }, { 33, GPU }, + "sat16s", { REG }, { 33, DSP }, + "sat24", { REG }, { 62, GPU }, + "sat32s", { REG }, { 42, DSP }, + "sh", { REG, REG }, { 23, ANY }, + "sha", { REG, REG }, { 26, ANY }, + "sharq", { IMM1, REG }, { 27, ANY }, + "shlq", { IMM1S, REG }, { 24, ANY }, + "shrq", { IMM1, REG }, { 25, ANY }, + "store", { REG, IREG }, { 47, ANY|OPSWAP }, + "store", { REG, IR14R }, { 60, ANY|OPSWAP }, + "store", { REG, IR15R }, { 61, ANY|OPSWAP }, + "store", { REG, IR14D }, { 49, ANY|OPSWAP }, + "store", { REG, IR15D }, { 50, ANY|OPSWAP }, + "storeb", { REG, IREG }, { 45, ANY|OPSWAP }, + "storep", { REG, IREG }, { 48, GPU|OPSWAP }, + "storew", { REG, IREG }, { 46, ANY|OPSWAP }, + "sub", { REG, REG }, { 4, ANY }, + "subc", { REG, REG }, { 5, ANY }, + "subq", { IMM1, REG }, { 6, ANY }, + "subqmod", { IMM1, REG }, { 32, DSP }, + "subqt", { IMM1, REG }, { 7, ANY }, + "unpack", { REG }, { 63, GPU }, + "xor", { REG, REG }, { 11, ANY }, diff --git a/tools/vasm/vasm/cpus/m68k/cpu.c b/tools/vasm/vasm/cpus/m68k/cpu.c new file mode 100644 index 0000000..f331f29 --- /dev/null +++ b/tools/vasm/vasm/cpus/m68k/cpu.c @@ -0,0 +1,6079 @@ +/* +** cpu.c Motorola M68k, CPU32 and ColdFire cpu-description file +** (c) in 2002-2021 by Frank Wille +*/ + +#include +#include "vasm.h" +#include "error.h" + +#include "operands.h" + +struct specreg SpecRegs[] = { +#include "specregs.h" +}; +static int specreg_cnt = sizeof(SpecRegs)/sizeof(SpecRegs[0]); + +mnemonic mnemonics[] = { +#include "opcodes.h" +}; +int mnemonic_cnt = sizeof(mnemonics)/sizeof(mnemonics[0]); + +struct cpu_models models[] = { +#include "cpu_models.h" +}; +int model_cnt = sizeof(models)/sizeof(models[0]); + + +char *cpu_copyright="vasm M68k/CPU32/ColdFire cpu backend 2.4 (c) 2002-2021 Frank Wille"; +char *cpuname = "M68k"; +int bitsperbyte = 8; +int bytespertaddr = 4; + +int m68k_mid = 1; /* default a.out MID: 68000/68010 */ + +static uint32_t cpu_type = m68000; +static expr *baseexp[7]; /* basereg: expression loaded to reg. */ +static signed char sdreg = -1; /* current small-data base register */ +static signed char last_sdreg = -1; +static unsigned char phxass_compat = 0; +static unsigned char devpac_compat = 0; +static unsigned char gas = 0; /* true enables GNU-as mnemonics */ +static unsigned char sgs = 0; /* true enables & as immediate prefix */ +static unsigned char no_fpu = 0; /* true: FPU code/direct. disallowed */ +static unsigned char elfregs = 0; /* true: %Rn instead of Rn reg. names */ +static unsigned char fpu_id = 1; /* default coprocessor id for FPU */ +static unsigned char opt_gen = 1; /* generic optimizations (not Devpac) */ +static unsigned char opt_movem = 0; /* MOVEM Rn -> MOVE Rn */ +static unsigned char opt_pea = 0; /* MOVE.L #x,-(sp) -> PEA x */ +static unsigned char opt_clr = 0; /* MOVE #0, -> CLR */ +static unsigned char opt_st = 0; /* MOVE.B #-1, -> ST */ +static unsigned char opt_lsl = 0; /* LSL #1,Dn -> ADD Dn,Dn */ +static unsigned char opt_mul = 0; /* MULU/MULS #n,Dn -> LSL/ASL #n,Dn */ +static unsigned char opt_div = 0; /* DIVU/DIVS.L #n,Dn -> LSR/ASR #n,Dn */ +static unsigned char opt_fconst = 1; /* Fxxx.D #m,FPn -> Fxxx.S #m,FPn */ +static unsigned char opt_brajmp = 0; /* branch to different sect. into jump */ +static unsigned char opt_pc = 1; /*