├── CHANGES.md
├── CONTACT.md
├── CREDITS.md
├── INSTALL.md
├── LICENSE.txt
├── PROJECTS.md
├── README.md
├── Sim68000.md
├── Sim68360.md
├── doc
├── 68kasm
│ ├── 68kasm.txt
│ └── bugs.txt
├── Manual
│ ├── Readme.txt
│ ├── html
│ │ ├── appa.htm
│ │ ├── appb.htm
│ │ ├── chap1.htm
│ │ ├── chap2.htm
│ │ ├── chap3.htm
│ │ ├── mg1.gif
│ │ ├── mg10.gif
│ │ ├── mg11.gif
│ │ ├── mg12.gif
│ │ ├── mg13.gif
│ │ ├── mg14.gif
│ │ ├── mg15.gif
│ │ ├── mg16.gif
│ │ ├── mg17.gif
│ │ ├── mg18.gif
│ │ ├── mg19.gif
│ │ ├── mg2.gif
│ │ ├── mg20.gif
│ │ ├── mg21.gif
│ │ ├── mg22.gif
│ │ ├── mg23.gif
│ │ ├── mg24.gif
│ │ ├── mg25.gif
│ │ ├── mg26.gif
│ │ ├── mg27.gif
│ │ ├── mg28.gif
│ │ ├── mg29.gif
│ │ ├── mg3.gif
│ │ ├── mg4.gif
│ │ ├── mg5.gif
│ │ ├── mg6.gif
│ │ ├── mg7.gif
│ │ ├── mg8.gif
│ │ ├── mg9.gif
│ │ └── toc.htm
│ └── ps
│ │ ├── appa.ps
│ │ ├── appb.ps
│ │ ├── chap1.ps
│ │ ├── chap2.ps
│ │ ├── chap3.ps
│ │ ├── title.ps
│ │ └── toc.ps
└── Readme.txt
├── misc
└── sim68360
│ ├── gal.py
│ └── gcc-gdb.ps
├── samples
├── m68000
│ ├── MatrixMultiply.h68
│ ├── MatrixMultiply.lis
│ ├── MatrixMultiply.s
│ ├── Readme.txt
│ ├── example.h68
│ ├── example.lis
│ ├── example.s
│ ├── serial.setup
│ ├── simple.setup
│ ├── timer.h68
│ ├── timer.lis
│ ├── timer.s
│ ├── timer.setup
│ └── tutor.h68
└── m68360
│ ├── gas1
│ ├── Makefile
│ ├── boot1.s
│ ├── duart.s
│ ├── test1.cmd
│ ├── test1.s
│ └── test1.setup
│ ├── gcc2
│ ├── Makefile
│ ├── boot2.s
│ ├── duart.s
│ ├── test2.c
│ ├── test2.cmd
│ └── test2.setup
│ ├── gcc3
│ ├── Makefile
│ ├── boot2.s
│ ├── duart.s
│ ├── test3.cmd
│ ├── test3.cpp
│ └── test3.setup
│ ├── gcc4
│ ├── Makefile
│ ├── boot2.s
│ ├── duart.s
│ ├── test4.cmd
│ ├── test4.cpp
│ └── test4.setup
│ ├── gcc5
│ ├── Makefile
│ ├── boot2.s
│ ├── duart.s
│ ├── jump.s
│ ├── libc.c
│ ├── libc.h
│ ├── test5.c
│ ├── test5.cmd
│ └── test5.setup
│ ├── gdb6
│ ├── Makefile
│ ├── astub.c
│ ├── astub.h
│ ├── boot2.s
│ ├── duart.s
│ ├── jump.s
│ ├── libc.c
│ ├── libc.h
│ ├── mstub.c
│ ├── mstub.h
│ ├── test6.bin.cmd
│ ├── test6.c
│ ├── test6.cmd
│ ├── test6.setup
│ ├── ustub.c
│ ├── ustub.h
│ ├── xstub.c
│ └── xstub.h
│ └── gdb7
│ ├── Makefile
│ ├── astub.c
│ ├── astub.h
│ ├── boot2.s
│ ├── duart.s
│ ├── jump.s
│ ├── libc.c
│ ├── libc.h
│ ├── mstub.c
│ ├── mstub.h
│ ├── test7.bin.cmd
│ ├── test7.c
│ ├── test7.cmd
│ ├── test7.setup
│ ├── ustub.c
│ ├── ustub.h
│ ├── xstub.c
│ └── xstub.h
└── src
├── Assemblers
└── 68kasm
│ ├── 68kasm.dsp
│ ├── 68kasm.dsw
│ ├── asm.h
│ ├── assemble.c
│ ├── build.c
│ ├── codegen.c
│ ├── directive.c
│ ├── error.c
│ ├── eval.c
│ ├── globals.c
│ ├── include.c
│ ├── instlookup.c
│ ├── insttable.c
│ ├── listing.c
│ ├── main.c
│ ├── movem.c
│ ├── object.c
│ ├── opparse.c
│ └── symbol.c
├── Framework
├── AddressSpace.cpp
├── AddressSpace.hpp
├── BasicCPU.cpp
├── BasicCPU.hpp
├── BasicDevice.cpp
├── BasicDevice.hpp
├── BasicDeviceRegistry.cpp
├── BasicDeviceRegistry.hpp
├── BasicLoader.hpp
├── BreakpointList.hpp
├── Event.cpp
├── Event.hpp
├── Interface.cpp
├── Interface.hpp
├── RegInfo.cpp
├── RegInfo.hpp
├── StatInfo.cpp
├── StatInfo.hpp
├── Time.hpp
├── Tools.cpp
├── Tools.hpp
└── Types.hpp
├── GNUMakefile.common
├── M68k
├── devices
│ ├── DeviceRegistry.cpp
│ ├── DeviceRegistry.hpp
│ ├── Gdbsock.cpp
│ ├── Gdbsock.hpp
│ ├── Gdbsock.tcl
│ ├── M68681.cpp
│ ├── M68681.hpp
│ ├── M68681.tcl
│ ├── RAM.cpp
│ ├── RAM.hpp
│ ├── RAM.tcl
│ ├── Timer.cpp
│ ├── Timer.hpp
│ ├── Timer.tcl
│ └── tcl2scr
├── instruction.c
├── loader
│ ├── Loader.cpp
│ └── Loader.hpp
├── sim68000
│ ├── decode.cpp
│ ├── exec.cpp
│ ├── instruction.list
│ ├── instruction.list.new
│ ├── m68000.cpp
│ ├── m68000.hpp
│ ├── main.cpp
│ ├── sim68000.dsp
│ └── sim68000.dsw
└── sim68360
│ ├── cpu32.cpp
│ ├── cpu32.hpp
│ ├── decode.cpp
│ ├── exec.cpp
│ ├── instruction.list
│ ├── main.cpp
│ ├── sim68360.dsp
│ └── sim68360.dsw
├── Makefile.BSD
├── Makefile.Linux
├── Makefile.OSX
├── Makefile.Solaris
├── Tools
└── xtermpipe.cpp
├── UI
├── BtkFile.tk
├── bitmaps
│ ├── Down.xbm
│ ├── PageDown.xbm
│ ├── PageUp.xbm
│ ├── Up.xbm
│ ├── bspin.gif
│ ├── bsvc.gif
│ ├── bsvcicon.xbm
│ ├── listicon.xbm
│ ├── memicon.xbm
│ ├── wait.xbm
│ ├── wait0.xbm
│ ├── wait1.xbm
│ ├── wait2.xbm
│ └── wait3.xbm
├── breakpt.tk
├── bsvc.ad
├── bsvc.win
├── device.tk
├── help
│ └── license
├── license.tk
├── listing.tk
├── main.tk
├── memory.tk
└── tools.tk
└── mkdeps.sh
/CONTACT.md:
--------------------------------------------------------------------------------
1 | ```
2 | ===============================================================================
3 | BBBBBB SSSSS VVV VVV CCCCC
4 | BB BB SS SS VV VV CC CC
5 | BB BB SS VV VV CC
6 | BBBBB SSSSS VV VV CC -- "A Microprocessor Simulation Framework"
7 | BB BB SS VV VV CC
8 | BB BB SS SS VVVV CC CC Release 2.1
9 | BBBBBB SSSSS VV CCCCC
10 |
11 | ===============================================================================
12 | ```
13 |
14 | Mailing List (Google Groups)
15 | ----------------------------
16 | There are two mailing lists for BSVC: a 'users' list for general discussions
17 | concerning BSVC including bug reports, enhancements requests, and general usage
18 | tips. Anyone who uses BSVC regularly should probably subscribe to this list:
19 |
20 | * bsvc-users@googlegroups.com
21 | (https://https://groups.google.com/forum/#!forum/bsvc-users)
22 |
23 | Additionally, a low-traffic 'announcements' list has been created for announcing
24 | new releases and major bugs:
25 |
26 | * bsvc-announce@googlegroups.com:
27 | (https://groups.google.com/forum/#!forum/bsvc-announce)
28 |
29 | If you are planning on using BSVC in a course or for non-trivial use, you should
30 | probably subscribe to this list.
31 |
--------------------------------------------------------------------------------
/CREDITS.md:
--------------------------------------------------------------------------------
1 | BSVC was originally written by Bradford W. Mott and came with
2 | this copyright notice:
3 |
4 | BSVC is Copyright (C) 1993 - 1998 by Bradford W. Mott.
5 |
6 | The assembler carried this notice:
7 |
8 | Copyright 1990-1991 North Carolina State University. All Rights Reserved.
9 |
10 | The assembler seems to have been originally written by Paul Franzon and
11 | Tom Miller, with changes by Tan Phan in 1991 and Bradford Mott in 1994.
12 |
13 | MC68360 support was provded by Jorand Didier. Much work was done by Xavier
14 | Plasencia at SDSU.
15 |
16 | On April 29, 2015, BSVC was relicensed under the GNU Public
17 | License, version 2.1.
18 |
--------------------------------------------------------------------------------
/INSTALL.md:
--------------------------------------------------------------------------------
1 | BSVC "A Microprocessor Simulation Framework"
2 | ============================================
3 |
4 | I've tested BSVC under the following operating systems:
5 |
6 | Linux 2.x
7 | Solaris (SunOS 5.5.1)
8 |
9 | The makefiles for these system should work. I'm sure there are still
10 | bugs in BSVC so if you find any please let me know.
11 |
12 | Installation
13 | ------------
14 |
15 | 1. Edit the appropriate operating system-specific Makefile in the src/
16 | directory:
17 |
18 | - Change PREFIX to where you want BSVC installed.
19 |
20 | - Change WISH to the path/filename of the Tcl/Tk "wish"
21 | executable. If you don't know where wish is then try
22 | `which wish` and see if it's in your path anywhere.
23 |
24 | - You can also customize compilers and other tools used
25 | during the build.
26 |
27 | 2. Build the BSVC executables:
28 |
29 | - Using the correct makefile for your system, run GNU Make:
30 |
31 | `make -f Makefile.your_os` (e.g for Linux use Makefile.linux)
32 |
33 | or
34 |
35 | `gmake -f Makefile.your_os` (if GNU make is called `gmake`)
36 |
37 | - If there is no makefile for your system then you'll have to make
38 | one yourself. If you do then please send it to me so I can include
39 | it in the distribution.
40 |
41 | 3. Install the BSVC executable:
42 |
43 | - To install the BSVC executables do:
44 |
45 | `make -f Makefile.your_os install`
46 |
47 |
48 | Testing the installation
49 | ------------------------
50 |
51 | After you have built the programs there are some sample setups and programs
52 | for the Motorola 68000 simulator in the bsvc/samples/m68000 directory.
53 |
54 | Run 'bsvc' from the $BINDIR directory to start the user interface.
55 | Then choose "File / Open Setup..." and select the "serial.setup" in the
56 | bsvc/samples/m68000 directory. After the system starts up choose
57 | "File / Load Program..." and load the "tutor.h68" program. Press "Reset"
58 | and then press "Run" in about 10 seconds you should see "TUTOR >" in the
59 | terminal window that appeared.
60 |
61 | I would suggest adding the $BINDIR directory to your PATH if you're going
62 | to be using it very often.
63 |
64 | There's a postscript version of the user manual in the bsvc/doc/manual
65 | directory.
66 |
67 | If you have any questions or comments send email to the mailing list:
68 |
69 | bsvc-users@googlegroups.com
70 |
71 | If you'd like announcements about new versions, etc, subscribe to the
72 | announcements list:
73 |
74 | bsvc-announce@googlegroups.com
75 |
--------------------------------------------------------------------------------
/PROJECTS.md:
--------------------------------------------------------------------------------
1 | Possible BSVC Projects
2 | ======================
3 |
4 | Here is a list of possible projects that can be done with BSVC. If you're
5 | a brave person with some spare time or a senior who needs a project to work
6 | on think about one of the following. Some of these are very pratical while
7 | others are a little on the far side.
8 |
9 |
10 | 1. It would be nice to have the following microprocessors simulated:
11 |
12 | * Intel 8051
13 | * Intel 8086
14 | * Intel 8088
15 | * Motorola 68HC11
16 | * Power PC 601
17 | * MOS 6502 (I've got most of this written just haven't finished it :-)
18 |
19 | 2. More devices for example:
20 |
21 | * Motorola 6850 UART I've got part of this written but then I found
22 | out that NCSU had started using the MC68681 :-)
23 |
24 | * Motorola 68230 Timer So we can do some multitasking ;-)
25 |
26 | * Simple Video Card A simple device that simulates a very simple
27 | video card. Sould have some wierd bit plane
28 | modes so student will have to do a lot of
29 | bit minipulations.
30 |
31 | * ROM Really simple to implement. Just like RAM
32 | execpt it reads in a file when it's created.
33 |
34 | * Ethernet Adapter I'm not sure how hard this would be.
35 |
36 | * Shared RAM On systems that support shared memory you
37 | could allocate a RAM moduled that shared from
38 | one simulator to the next. Then fire up two
39 | simulators and let the play in the shared memory.
40 | This is really out there but might be interesting
41 | to play with.
42 |
43 | * Hard disk adapter Uses a file as a hard disk image
44 |
45 | 3. 68000 stuff
46 |
47 | * See how hard it would be to build GNU C as a cross compiler for the
48 | M68000. Then add a Loader to the Sim68000 to load the a.out file
49 | generated by gcc.
50 |
51 | * If you get GNU C working then port XINU to the M68000.
52 |
53 | 4. Cache simulations
54 |
55 | * Get GNU C to work as a cross compiler to one of the microprocessors
56 | supported by BSVC. Add a Loader to the simulator to load the a.out
57 | format file generated by gcc.
58 |
59 | * Port a C library to the simulator. This should be complete enough to
60 | allow some UNIX programs to be compiled and ran on the simulator.
61 |
62 | * Subclass the AddressSpace object and implement a Cache simulator. Then
63 | you can use the C programs to benchmark the cache.
64 |
65 | * Might also want to get C++ to work then you could study the effects
66 | of OO on the cache.
67 |
68 | * You could also study GC effects on the Cache.
69 |
70 | This would be really neat if it worked but I would suggest more
71 | than one person on this project :-)
72 |
73 | 5. BSVC Framework
74 |
75 | * Modify the EventHandler to accept file descriptor events, and timed
76 | file descriptor events. This would eliminate the polling done in the
77 | M68681 device.
78 |
79 | * Clean up the interface class and remove some of the C code in there
80 |
81 | 6. Add new feature to the program listing utility
82 |
83 | * Highlight lines were breakpoints are set
84 |
85 | * Allow breakpoints to be set/unset
86 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | BSVC: A Microprocessor Simulation Framework
2 | ===========================================
3 |
4 | BSVC is a microprocessor simulation framework written in C++ and Tcl/Tk.
5 | It was developed as a senior design project at North Carolina State
6 | University by Bradford W. Mott (see the Credits.txt file for copyright
7 | information).
8 |
9 | Since its original development many professors and students have found
10 | BSVC to be a useful tool in courses based on the Motorola 68000. It has
11 | also been used as a starting point for other senior design projects.
12 |
13 | In April 2015, maintenance was restarted by Dan Cross and the system was
14 | relicensed under the GNU Public License, version 2.1.
15 |
16 | The BSVC distribution contains the following:
17 |
18 | * Motorola 68000 simulator & assembler (Supports the M68681 Dual UART)
19 | * Motorola 68360 simulator (CPU32 like simulator)
20 | * Simple devices including the M68681 DUART, a timer, RAM and a GDB interface
21 | * BSVC Graphical User Interface (written in Tcl/Tk)
22 | * BSVC Simulator Framework (C++ classes)
23 |
24 | Code cross-compiled with GCC is known to load and run.
25 |
26 | Supported Systems
27 | -----------------
28 | The BSVC distribution is known to compile on the following systems:
29 |
30 | * Linux
31 | * Solaris
32 | * Mac OS X
33 | * FreeBSD
34 |
35 | Any reasonable POSIX system should work.
36 |
37 | Required Software
38 | -----------------
39 | BSVC requires the following software to compile and run:
40 |
41 | * C++11 and C11 compliant compilers for C++ and C, respectively.
42 | Both clang and recent versions of GCC are known to work.
43 | * GNU Make
44 | * A recent version of Tcl/Tk
45 |
46 | Distribution Site
47 | -----------------
48 | The BSVC distribution can be downloaded from Github:
49 |
50 | https://github.com/BSVC/bsvc
51 |
52 | Copyright and License
53 | ---------------------
54 | BSVC is Copyright (C) 1993 - 1998 by Bradford W. Mott
55 |
56 | BSVC is free software. It is released under the terms of the GNU
57 | General Public License, version 2.1.
58 |
59 | Contacts
60 | --------
61 | For more information see the BSVC site on Github.
62 |
63 | If you have any questions regarding BSVC send mail to:
64 |
65 | * bsvc-users@googlegroups.com
66 | (https://groups.google.com/forum/#!forum/bsvc-users)
67 |
68 | If you want to receive email announcements about future releases,
69 | subscribe to:
70 |
71 | * bsvc-announce@googlegroups.com
72 | (https://groups.google.com/forum/#!forum/bsvc-announce)
73 |
--------------------------------------------------------------------------------
/Sim68000.md:
--------------------------------------------------------------------------------
1 | Motorola 68000 Simulator (sim68000)
2 | ===================================
3 | The following instructions are not currently implemented.
4 |
5 | * CHK
6 | * NBCD
7 | * SBCD
8 |
--------------------------------------------------------------------------------
/Sim68360.md:
--------------------------------------------------------------------------------
1 | Motorola 68360 Simulator (sim68360)
2 | ===================================
3 | This is Jorand Didier's Motorola 68360 (sim68360) simulator. It doesn't
4 | contain all of the 68360 devices but it does provide a CPU32 based simulator.
5 |
6 | Jorand actually uses (used) GCC and GDB to do development work with
7 | BSVC. For more information see the file bsvc/misc/sim68360/gcc-gdb.ps.
8 |
9 | Here's a note about using the samples for sim68360:
10 |
11 | Go in the sample/sim68360 directory and play with the tests: IMPORTANT: for
12 | that to work, you need to define 2 environment variables: BSVC, which
13 | contains the path to the 'bsvc' directory and 'M68K_LIB' which contains
14 | the path to the libgcc.a directory. It can look like
15 | '/usr/local/m68k/lib/gcc-lib/m68k-none-elf/4.9.2'. You've got everything to
16 | test gcc and gdb... enjoy.
17 |
18 | The following instructions are not currently implemented in sim68360:
19 |
20 | * CHK
21 | * NBCD
22 | * SBCD
23 |
--------------------------------------------------------------------------------
/doc/68kasm/bugs.txt:
--------------------------------------------------------------------------------
1 |
2 | 1. October 93: Assembler does not support absolute short addressing modes:
3 |
4 | i.e. LEA A.w,A6
5 | SUB.W A.w,D3
6 |
7 |
8 |
--------------------------------------------------------------------------------
/doc/Manual/Readme.txt:
--------------------------------------------------------------------------------
1 |
2 | BSVC Version 2.0 Manual
3 | =======================
4 |
5 | These subdirectories contain the BSVC manual in different formats. The
6 | manual is split into several files.
7 |
8 | title.??? Title Page
9 | toc.??? Table of Contents
10 | chap1.??? Chapter 1 - Introduction
11 | chap2.??? Chapter 2 - User Interface
12 | chap3.??? Chapter 3 - Motorola 68000 Simulator and Assembler
13 | appa.??? Appendix A - Framework Overview
14 | appb.??? Appendix B - Framework Class Declaration
15 |
16 | If you have any suggestions or corrections for the manual please send me
17 | mail at bwmott@acm.org
18 |
19 |
--------------------------------------------------------------------------------
/doc/Manual/html/chap1.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 | chap1.htm
4 |
5 |
6 |
7 |
8 |
11 |
12 | BSVC is a microprocessor simulation framework. It provides a graphical user interface and an object oriented framework that simplifies the task of writing a microprocessor simulator. The goal of the project was to replace the Motorola 68000 simulator currently in use at North Carolina State University. However by using object oriented techniques and generalizing the user interface a relatively generic framework for writing microprocessor simulators has been developed.
13 | History
14 | BSVC started off as a simple 68000 simulator that supported the 6850 UART, but after decomposing the simulator into its components (processor and devices) it became apparent that it could be expanded into a virtual computer simulator that allowed the user to "build" his/her own computer. Instead of a single 68000 processor object it would consist of several processor objects and several device objects that could be connected together to build a computer. This effectively allows users to build a virtual computer that simulates the single-board 68000 based computers in the ECE 218 lab at North Carolina State University or any other computer as long as the processor and devices are supported.
15 | This document was produced using an evaluation version of HTML Transit
16 |
17 |
--------------------------------------------------------------------------------
/doc/Manual/html/mg1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg1.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg10.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg10.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg11.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg11.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg12.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg12.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg13.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg13.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg14.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg14.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg15.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg15.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg16.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg16.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg17.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg17.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg18.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg18.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg19.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg19.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg2.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg20.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg20.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg21.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg21.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg22.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg22.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg23.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg23.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg24.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg24.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg25.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg25.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg26.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg26.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg27.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg27.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg28.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg28.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg29.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg29.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg3.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg4.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg5.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg6.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg6.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg7.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg7.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg8.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg8.gif
--------------------------------------------------------------------------------
/doc/Manual/html/mg9.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/doc/Manual/html/mg9.gif
--------------------------------------------------------------------------------
/doc/Manual/html/toc.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 | Table of Contents
4 |
5 | Table of Contents
6 |
45 | This document was produced using an evaluation version of HTML Transit
46 |
47 |
--------------------------------------------------------------------------------
/doc/Readme.txt:
--------------------------------------------------------------------------------
1 |
2 | Manual/ : The BSVC User Manual
3 | 68kasm/ : Documentation on the Motorola 68000 assembler
4 |
5 | If you have any suggestions for the documentation please send mail
6 | to bwmott@acm.org.
7 |
8 |
--------------------------------------------------------------------------------
/samples/m68000/Readme.txt:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------------------
2 | M68000 Sample Files
3 | -------------------------------------------------------------------------------
4 |
5 | MatrixMultiply.H68 An interactive matrix multiply program
6 | Use serial.setup and start execution at $1000
7 |
8 | example.H68 A very simple program that calculates a sum.
9 | Use simple.setup and start execution at $2000.
10 |
11 | tutor.h68 The Motorola Tutor monitor
12 |
13 | - I got this off of an ftp site that mirrors the
14 | Motorola BBS
15 | - Use the serial.setup and after you load the program do a
16 | system Reset and press Run
17 |
18 | serial.setup A setup with two RAM banks and a DUART. The output of the
19 | port a is piped to an xterms and port b is not attached
20 | to anything.
21 |
22 | simple.setup A real simple setup with just one RAM chip
23 |
24 |
25 |
--------------------------------------------------------------------------------
/samples/m68000/example.h68:
--------------------------------------------------------------------------------
1 | S004000020DB
2 | S10B0000000080000000200054
3 | S11B200042790000201830390000201AD17900002018534066F648482D
4 | S105201A0019A7
5 | S9030000FC
6 |
--------------------------------------------------------------------------------
/samples/m68000/example.lis:
--------------------------------------------------------------------------------
1 | 00000000 1
2 | 00000000 2 ORG $0
3 | 00000000 00008000 3 DC.L $8000 Stack pointer value after a reset
4 | 00000004 00002000 4 DC.L START Program counter value after a reset
5 | 00000008 5
6 | 00000008 6
7 | 00002000 7 ORG $2000 Start at location 2000 Hex
8 | 00002000 8
9 | 00002000 4279 00002018 9 START CLR.W SUM Clear variable SUM
10 | 00002006 3039 0000201A 10 MOVE.W COUNT,D0 Load COUNT value
11 | 0000200C D179 00002018 11 LOOP ADD.W D0,SUM ADD D0 to SUM
12 | 00002012 5340 12 SUB.W #1,D0 Decrement counter
13 | 00002014 66F6 13 BNE LOOP Loop if counter not zero
14 | 00002016 4848 14 BREAK Tell the simulator to BREAK if we're running
15 | 00002018 15
16 | 00002018 16 SUM DS.W 1 Reserve one word for SUM
17 | 0000201A 0019 17 COUNT DC.W 25 Initial value for COUNT
18 | 0000201C 18
19 |
20 | No errors detected
21 | No warnings generated
22 |
--------------------------------------------------------------------------------
/samples/m68000/example.s:
--------------------------------------------------------------------------------
1 |
2 | ORG $0
3 | DC.L $8000 Stack pointer value after a reset
4 | DC.L START Program counter value after a reset
5 |
6 |
7 | ORG $2000 Start at location 2000 Hex
8 |
9 | START CLR.W SUM Clear variable SUM
10 | MOVE.W COUNT,D0 Load COUNT value
11 | LOOP ADD.W D0,SUM ADD D0 to SUM
12 | SUB.W #1,D0 Decrement counter
13 | BNE LOOP Loop if counter not zero
14 | BREAK Tell the simulator to BREAK if we're running
15 |
16 | SUM DS.W 1 Reserve one word for SUM
17 | COUNT DC.W 25 Initial value for COUNT
18 |
19 |
--------------------------------------------------------------------------------
/samples/m68000/serial.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.2}
4 | SIMULATOR {sim68000}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 RAM {BaseAddress = ff0000 Size = 10000}}
7 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "M68681 Port A" -132 -fn fixed -e xtermpipe PortBCommand = }}
8 |
--------------------------------------------------------------------------------
/samples/m68000/simple.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.2}
4 | SIMULATOR {sim68000}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 |
--------------------------------------------------------------------------------
/samples/m68000/timer.h68:
--------------------------------------------------------------------------------
1 | S004000020DB
2 | S10B0000000080000000200054
3 | S12520002E7C0000800043F900EFFC01137C00100004137C00230000137C00170000137C00BB23
4 | S12520220002137C0005000446FC24004EB900002046C3C108280000000066F608E8000000002B
5 | S125204460EE21FC00002072015041F900010021117C00540002203C0001E84801C80004117C02
6 | S123206600A0000008E8000000004E752F0846FC27004EB90000219E4879000020CC4EB9E9
7 | S1252086000021724EB90000219E41F90001002108A800000014205F4E7341F900010021117C92
8 | S12520A800800000203C0001E84801C8000408E80000000008280000001467F808A800000014E1
9 | S12520CA4E7554696D65723A2054696D6520746F2077616B652075702107004D61696E426F64B1
10 | S11420EC793A20446F696E672074686520446F0700E0
11 | S12520FE2F08207C00EFFC0108280000000267F8103900EFFC07205F4E754E56000048E780801C
12 | S12521200839000200EFFC0367F6102E000813C000EFFC074CDF01014E5E2F570002548F4E75F9
13 | S125214248E78080206F000C4EB820FE1F004EB82118B03C00206700000EB03C000D6700000644
14 | S125216410C060E210BC00004CDF01014E754E56000048E78080206E00084A106700000E10102F
15 | S12521861F004EB82118528860EE4CDF01014E5E2F570004588F4E7548E780801F3C000D4EB803
16 | S11D21A821180839000200EFFC0367F613FC000A00EFFC074CDF01014E7557
17 | S9030000FC
18 |
--------------------------------------------------------------------------------
/samples/m68000/timer.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.2}
4 | SIMULATOR {sim68000}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 RAM {BaseAddress = ff0000 Size = 10000}}
7 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "M68681 Port A" -132 -fn fixed -e xtermpipe PortBCommand = }}
8 | COMMAND {AttachDevice 0 Timer {BaseAddress = 10021 IRQ = 5}}
9 |
--------------------------------------------------------------------------------
/samples/m68360/gas1/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile -*- BASH -*-
3 | #
4 | # USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
5 | # WITH NO WARRANTY FOR ANY PURPOSE.
6 | #
7 |
8 | #-------------------------------------------------------------------------
9 | CPU=68020
10 | #-------------------------------------------------------------------------
11 |
12 | AS=vxworks68-as
13 | ASFLAGS=-m$(CPU)
14 | LD=vxworks68-ld
15 | LDFLAGS=-M
16 | RM=/bin/rm -f
17 | GAL=python $(BSVC)/bin/gal.py
18 |
19 | #-------------------------------------------------------------------------
20 | .SUFFIXES: .s .glis
21 |
22 | PROGRAM=test1
23 | OBJECTS=boot1.o test1.o duart.o
24 | ASMSRC=boot1.s test1.s duart.s
25 | ASMGLIS=boot1.glis test1.glis duart.glis
26 | MAP=$(PROGRAM).map
27 | #-------------------------------------------------------------------------
28 | .s.glis:
29 | $(AS) -a $(ASFLAGS) -o /dev/null $< > $@
30 |
31 | #-------------------------------------------------------------------------
32 | all: $(PROGRAM).H68 $(PROGRAM).LIS
33 |
34 | $(PROGRAM).H68 $(MAP): $(OBJECTS)
35 | $(LD) $(LDFLAGS) -T $(PROGRAM).cmd > $(MAP)
36 |
37 | clean:
38 | $(RM) *.o $(PROGRAM).H68 $(PROGRAM).LIS $(MAP)
39 | $(RM) *.lis *.glis CPU32.debug
40 |
41 | $(PROGRAM).LIS: $(ASMGLIS) $(MAP)
42 | $(GAL) $(MAP) $(ASMGLIS)
43 |
44 |
--------------------------------------------------------------------------------
/samples/m68360/gas1/boot1.s:
--------------------------------------------------------------------------------
1 | | boot1.s
2 | | Set the initial stack and reset vector
3 | |
4 | | DJ (c) 1996
5 | |
6 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | | WITH NO WARRANTY FOR ANY PURPOSE.
8 | |
9 |
10 |
11 | .equ STACK,0xF000
12 | .equ START,0x1000
13 |
14 | | this is absolute address 0 (see linker command file)
15 | .data
16 | .long STACK | Vector 0 (SSP)
17 | .long START | Vector - (PC)
18 | .space 1016 | (256-2)*4 (space for exception vectors)
19 | .even
20 |
--------------------------------------------------------------------------------
/samples/m68360/gas1/duart.s:
--------------------------------------------------------------------------------
1 | |
2 | | duart.s
3 | |
4 | | Assembly language function giving access to the 68881 DUART.
5 | | (Adapted from 'MatrixMultiply.s' example).
6 | |
7 | | DJ 1996/11
8 | |
9 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | | WITH NO WARRANTY FOR ANY PURPOSE.
11 | |
12 |
13 | | Implements:
14 | | - _DUART_INIT: initialize the DUART (can be called from C)
15 | | - _DUART_GETC: get a character, returned in register D0 (can be called from C)
16 | | - _DUART_PUTC: output a character, expected in the stack (can be called from C)
17 | | - _DUART_PRINT: output a string of character (use A0 as parameter)
18 | | (DO NOT CALL FROM C!)
19 |
20 | .equ DUA_ADD, 0xeffc01
21 | .equ DUA_MR1A, 0
22 | .equ DUA_MR2A, 0
23 | .equ DUA_SRA, 2
24 | .equ DUA_CRA, 4
25 | .equ DUA_CSRA, 2
26 | .equ DUA_TBA, 6
27 | .equ DUA_RBA, 6
28 | .equ DUA_IMR, 10
29 | .equ DUA_TBB, 0x16
30 | .equ DUA_CRB, 0x14
31 | .equ DUA_MR1B, 0x10
32 | .equ DUA_MR2B, 0x10
33 | .equ DUA_SRB, 0x12
34 | .equ DUA_IVR, 0x18
35 | .equ LINEFEED, 10 | LineFeed Character value
36 | .equ CARR_RETURN, 13 | Carrage Return character value
37 |
38 | |
39 | | _DUART_INIT: Initialization of the duart
40 | |
41 | .global _DUART_INIT
42 | _DUART_INIT: MOVE.L A1,-(A7) | Save A1
43 | LEA DUA_ADD,A1
44 | ORI #0b0000011100000000,SR | Masks interrupts
45 | MOVE.B #0b00010000,(DUA_CRA,A1) | Reset MR?A pointer
46 | MOVE.B #0b00100011,(DUA_MR1A,A1) | 8 data bits
47 | MOVE.B #0b00010111,(DUA_MR2A,A1) | Normal Mode
48 | MOVE.B #0b10111011,(DUA_SRA,A1) | Set clock to 9600
49 | MOVE.B #0b00000101,(DUA_CRA,A1) | Enable Rx and Tx
50 | MOVE.L (A7)+,A1 | Restore A1
51 | RTS
52 |
53 | |
54 | | _DUART_PUTC: The character in the stack is transmitted to the CONSOLE ACIA.
55 | | The newline character is expanded into /.
56 | | Define a subroutine DUA_PUTC, which print the character contained in D0
57 | |
58 |
59 | DUA_PUTC: BTST #2,DUA_SRA+DUA_ADD | Test Transmit data register empty
60 | BEQ.S DUA_PUTC | If not keep polling
61 | MOVE.B D0,DUA_TBA+DUA_ADD | Transmit the character
62 | CMP.B #LINEFEED,D0 | Check for LINEFEED
63 | BNE DUA_PUTCEXT | if not L/F, exit
64 | MOVE.B #CARR_RETURN,D0 | Load CARR_RETURN into D0
65 | BRA DUA_PUTC | Output C/R
66 | DUA_PUTCEXT: RTS
67 |
68 | .global _DUART_PUTC
69 | _DUART_PUTC: LINK A6,#-2
70 | MOVE.L (8,A6),D0
71 | JSR DUA_PUTC
72 | UNLK A6
73 | RTS
74 |
75 | |
76 | | _DUART_GETC: Get a character from the CONSOLE ACIA and return it in D0
77 | |
78 |
79 | .global _DUART_GETC
80 | _DUART_GETC: BTST #0,DUA_SRA+DUA_ADD | Test Receive data register full
81 | BEQ.S _DUART_GETC | If not keep polling
82 | MOVE.B DUA_RBA+DUA_ADD,D0 | Read the character
83 | RTS
84 |
85 | |
86 | | _DUART_PRINT: print a string of charater, until null
87 | |
88 | .global _DUART_PRINT
89 | _DUART_PRINT: MOVE.L D0,-(A7) | Save register d0 to stack
90 | DUAPRLOOP: MOVE.B (A0)+,D0 | Get a character to print
91 | CMP.B #0x00,D0 | Is it null?
92 | BEQ DUAPRNTEND | yes: it's over
93 | JSR DUA_PUTC | no: print it
94 | BRA DUAPRLOOP | repeat
95 | DUAPRNTEND: MOVE.L (A7)+,D0 | Restore d0
96 | RTS
97 |
98 | |
99 | | End of file
100 | |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/samples/m68360/gas1/test1.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test1.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot1.o (.data) }
20 | .text 0x1000 : { test1.o (.text) duart.o (.text) }
21 | }
22 |
23 | OUTPUT(test1.H68)
24 | OUTPUT_FORMAT(srec)
25 |
--------------------------------------------------------------------------------
/samples/m68360/gas1/test1.s:
--------------------------------------------------------------------------------
1 | | test1.s
2 | | print a simple message and wait
3 | |
4 | | DJ (c) 1996
5 | |
6 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | | WITH NO WARRANTY FOR ANY PURPOSE.
8 | |
9 |
10 | | this is absolute address `START' (0x1000)
11 | | display welcome message
12 | .global start
13 | start:
14 | JSR _DUART_INIT
15 | LEA MESSAGE,A0
16 | JSR _DUART_PRINT
17 | | infinite loop
18 | LOOP: BRA LOOP
19 |
20 | MESSAGE:
21 | .ascii "Welcome on BSVC/68k\12\0"
22 |
--------------------------------------------------------------------------------
/samples/m68360/gas1/test1.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.0}
4 | SIMULATOR {sim68360}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "Port A" -n "Port A" -fn fixed -e xtermpipe PortBCommand = }}
7 |
--------------------------------------------------------------------------------
/samples/m68360/gcc2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile -*- BASH -*-
3 | #
4 | # USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
5 | # WITH NO WARRANTY FOR ANY PURPOSE.
6 | #
7 |
8 | #-------------------------------------------------------------------------
9 | CPU=68020
10 | #-------------------------------------------------------------------------
11 |
12 | CC=m68k-none-elf-gcc
13 | CFLAGS=-g -Wall -m$(CPU) -mnobitfield -I. -U__HAVE_68881__
14 | AS=m68k-none-elf-as --register-prefix-optional
15 | ASFLAGS=-m$(CPU)
16 | LD=m68k-none-elf-ld
17 | LDFLAGS=-M
18 | RM=/bin/rm -f
19 | GAL=python $(BSVC)/bin/gal.py
20 |
21 | #-------------------------------------------------------------------------
22 | LIBS=-L$(M68K_LIB) -lgcc
23 |
24 | .SUFFIXES: .s .glis
25 |
26 | PROGRAM=test2
27 | OBJECTS=boot2.o test2.o duart.o
28 | ASMSRC=boot2.s test2.s duart.s
29 | ASMGLIS=boot2.glis test2.glis duart.glis
30 | MAP=$(PROGRAM).map
31 | #-------------------------------------------------------------------------
32 | .c.o:
33 | $(CC) -c $(CFLAGS) -o $@ $<
34 |
35 | .c.s:
36 | $(CC) -c -S $(CFLAGS) -o $@ $<
37 |
38 | .s.glis:
39 | $(AS) -a $(ASFLAGS) -o /dev/null $< > $@
40 |
41 | #-------------------------------------------------------------------------
42 | all: $(PROGRAM).H68 $(PROGRAM).LIS
43 |
44 | $(PROGRAM).H68 $(MAP): $(OBJECTS)
45 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).cmd $(LIBS) > $(MAP)
46 |
47 | clean:
48 | $(RM) *.o $(PROGRAM).H68 $(PROGRAM).LIS $(MAP)
49 | $(RM) *.lis *.glis CPU32.debug
50 |
51 | $(PROGRAM).LIS: $(ASMGLIS) $(MAP)
52 | $(GAL) $(MAP) $(ASMGLIS)
53 |
54 |
--------------------------------------------------------------------------------
/samples/m68360/gcc2/boot2.s:
--------------------------------------------------------------------------------
1 | |
2 | | boot.s
3 | |
4 | | Set the initial stack and reset vector
5 | | Install exception routines
6 | | Jump to 'main'
7 | |
8 | | DJ (c) 1996
9 | |
10 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
11 | | WITH NO WARRANTY FOR ANY PURPOSE.
12 | |
13 |
14 |
15 | |
16 | | INITIAL STACK AND RESET VECTOR
17 | |
18 | .equ BOO_STACK,0xF000
19 | .equ APP_START,0x4000
20 |
21 | .data
22 | .long BOO_STACK | Vector 0 (SSP)
23 | .long BOO_START | Vector - (PC)
24 | .space 1016 | (256-2)*4
25 | .even
26 | |DS.L 245
27 |
28 | |
29 | | BOOT CODE
30 | |
31 | .text
32 | .global BOO_START
33 | BOO_START:
34 | | initialize exception vectors
35 | LEA 0x08,A0 | start with vector 2
36 | LEA exceptionTable,A1
37 | BOO_START_L1:
38 | MOVE.L A1,(A0)+
39 | ADD.L #6,A1
40 | CMP.L #0x400,A0 | $400 is the end of vector table
41 | BLT BOO_START_L1
42 | | initialize exception table with 'jsr unimplemented-exception'
43 | MOVE.W 0,D0
44 | LEA exceptionTable,A0
45 | BOO_START_L2:
46 | MOVE.W #0x4EB9,(A0)+ | 4EB9 is 'jsr'
47 | MOVE.L #BOO_UNIMP_EXCPT,(A0)+
48 | ADDQ.W #1,D0
49 | CMP.W #255,D0
50 | BLT BOO_START_L2
51 |
52 | | we're ready: unmask interrupt
53 | ANDI #0b1111100011111111,SR
54 |
55 | | jump to main
56 | JMP main
57 |
58 | |
59 | | Exception: unimplemented
60 | |
61 | .global BOO_UNIMP_EXCPT
62 | BOO_UNIMP_EXCPT:
63 | MOVE.L (sp)+,d2 | get return address and
64 | LEA exceptionTable,a3 | compute exception number
65 | SUB.L a3,d2
66 | DIVS.W #6,d2
67 | ADDQ.W #1,d2
68 | MOVE.B d2,d3
69 | AND.B #0xF, d2
70 | CMP.B #10,d2
71 | BGT zz1
72 | ADD.B #'0',d2
73 | BRA zz2
74 | zz1:
75 | ADD.B #'A',d2
76 | zz2:
77 | ASR.B #4,d3
78 | AND.B #0xF, d3
79 | CMP.B #10,d3
80 | BGT zz3
81 | ADD.B #'0',d3
82 | BRA zz4
83 | zz3:
84 | ADD.B #'A',d3
85 | zz4:
86 | LEA BOO_UNIMP_EXCPT_NUM,A0
87 | MOVE.B d3,(A0)+
88 | MOVE.B d2,(A0)+
89 | JSR DUART_INIT
90 | LEA BOO_UNIMP_EXCPT_TEXT,A0
91 | JSR DUART_PRINT
92 |
93 | BOOTL5: BRA BOOTL5
94 |
95 | BOO_UNIMP_EXCPT_TEXT:
96 | .ascii "|| unimplemented exception 0x"
97 | BOO_UNIMP_EXCPT_NUM:
98 | .ascii "XX"
99 | .ascii "||\12\0"
100 | .even
101 |
102 | |
103 | | Exception table
104 | |
105 | | exception table is a set of 255 group of 6 bytes, each group is
106 | | a instruction executed when the 'corresponding' exception occurs
107 | | These group are initialized with an simple instruction
108 | | "jsr unimplemented-exception", but this can be overwritten.
109 | |
110 | .global exceptionTable
111 | exceptionTable:
112 | .space 1530 || (255*6)
113 |
114 | |
115 | | End of file
116 | |
117 |
--------------------------------------------------------------------------------
/samples/m68360/gcc2/duart.s:
--------------------------------------------------------------------------------
1 | |
2 | | duart.s
3 | |
4 | | Assembly language function giving access to the 68881 DUART.
5 | | (Adapted from 'MatrixMultiply.s' example).
6 | |
7 | | DJ 1996/11
8 | |
9 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | | WITH NO WARRANTY FOR ANY PURPOSE.
11 | |
12 |
13 | | Implements:
14 | | - DUART_INIT: initialize the DUART (can be called from C)
15 | | - DUART_GETC: get a character, returned in register D0 (can be called from C)
16 | | - DUART_PUTC: output a character, expected in the stack (can be called from C)
17 | | - DUART_PRINT: output a string of character (use A0 as parameter)
18 | | (DO NOT CALL FROM C!)
19 |
20 | .equ DUA_ADD, 0xeffc01
21 | .equ DUA_MR1A, 0
22 | .equ DUA_MR2A, 0
23 | .equ DUA_SRA, 2
24 | .equ DUA_CRA, 4
25 | .equ DUA_CSRA, 2
26 | .equ DUA_TBA, 6
27 | .equ DUA_RBA, 6
28 | .equ DUA_IMR, 10
29 | .equ DUA_TBB, 0x16
30 | .equ DUA_CRB, 0x14
31 | .equ DUA_MR1B, 0x10
32 | .equ DUA_MR2B, 0x10
33 | .equ DUA_SRB, 0x12
34 | .equ DUA_IVR, 0x18
35 | .equ LINEFEED, 10 | LineFeed Character value
36 | .equ CARR_RETURN, 13 | Carrage Return character value
37 |
38 | |
39 | | DUART_INIT: Initialization of the duart
40 | |
41 | .global DUART_INIT
42 | DUART_INIT: MOVE.L A1,-(A7) | Save A1
43 | LEA DUA_ADD,A1
44 | ORI #0b0000011100000000,SR | Masks interrupts
45 | MOVE.B #0b00010000,(DUA_CRA,A1) | Reset MR?A pointer
46 | MOVE.B #0b00100011,(DUA_MR1A,A1) | 8 data bits
47 | MOVE.B #0b00010111,(DUA_MR2A,A1) | Normal Mode
48 | MOVE.B #0b10111011,(DUA_SRA,A1) | Set clock to 9600
49 | MOVE.B #0b00000101,(DUA_CRA,A1) | Enable Rx and Tx
50 | MOVE.L (A7)+,A1 | Restore A1
51 | RTS
52 |
53 | |
54 | | DUART_PUTC: The character in the stack is transmitted to the CONSOLE ACIA.
55 | | The newline character is expanded into /.
56 | | Define a subroutine DUA_PUTC, which print the character contained in D0
57 | |
58 |
59 | DUA_PUTC: BTST #2,DUA_SRA+DUA_ADD | Test Transmit data register empty
60 | BEQ.S DUA_PUTC | If not keep polling
61 | MOVE.B D0,DUA_TBA+DUA_ADD | Transmit the character
62 | CMP.B #LINEFEED,D0 | Check for LINEFEED
63 | BNE DUA_PUTCEXT | if not L/F, exit
64 | MOVE.B #CARR_RETURN,D0 | Load CARR_RETURN into D0
65 | BRA DUA_PUTC | Output C/R
66 | DUA_PUTCEXT: RTS
67 |
68 | .global DUART_PUTC
69 | DUART_PUTC: LINK A6,#-2
70 | MOVE.L (8,A6),D0
71 | JSR DUA_PUTC
72 | UNLK A6
73 | RTS
74 |
75 | |
76 | | DUART_GETC: Get a character from the CONSOLE ACIA and return it in D0
77 | |
78 |
79 | .global DUART_GETC
80 | DUART_GETC: BTST #0,DUA_SRA+DUA_ADD | Test Receive data register full
81 | BEQ.S DUART_GETC | If not keep polling
82 | MOVE.B DUA_RBA+DUA_ADD,D0 | Read the character
83 | RTS
84 |
85 | |
86 | | DUART_PRINT: print a string of charater, until null
87 | |
88 | .global DUART_PRINT
89 | DUART_PRINT: MOVE.L D0,-(A7) | Save register d0 to stack
90 | DUAPRLOOP: MOVE.B (A0)+,D0 | Get a character to print
91 | CMP.B #0x00,D0 | Is it null?
92 | BEQ DUAPRNTEND | yes: it's over
93 | JSR DUA_PUTC | no: print it
94 | BRA DUAPRLOOP | repeat
95 | DUAPRNTEND: MOVE.L (A7)+,D0 | Restore d0
96 | RTS
97 |
98 | |
99 | | End of file
100 | |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/samples/m68360/gcc2/test2.c:
--------------------------------------------------------------------------------
1 | /*
2 | * test2.c
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | extern void DUART_INIT(void);
12 | extern void DUART_PUTC(char c);
13 | extern char DUART_GETC(void);
14 |
15 | /*
16 | * Function: puts (print a string)
17 | */
18 | int
19 | puts(const char *s)
20 | {
21 | while (*s) {
22 | DUART_PUTC(*s++);
23 | }
24 | return 0;
25 | }
26 |
27 | /*
28 | * Function main
29 | */
30 | int
31 | main(void)
32 | {
33 | DUART_INIT();
34 | puts("Hello world!\n");
35 | DUART_GETC();
36 | puts("Done.\n");
37 | while(1);
38 | return 0;
39 | }
40 |
--------------------------------------------------------------------------------
/samples/m68360/gcc2/test2.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test2.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) *(.rodata) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test2.H68)
25 | OUTPUT_FORMAT(srec)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gcc2/test2.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.0}
4 | SIMULATOR {sim68360}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "Port A" -n "Port A" -fn fixed -e xtermpipe PortBCommand = }}
7 |
--------------------------------------------------------------------------------
/samples/m68360/gcc3/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile -*- BASH -*-
3 | #
4 | # USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
5 | # WITH NO WARRANTY FOR ANY PURPOSE.
6 | #
7 |
8 | #-------------------------------------------------------------------------
9 | CPU=68020
10 | #-------------------------------------------------------------------------
11 |
12 | CC=vxworks68-gcc
13 | CFLAGS=-g -Wall -m$(CPU) -mnobitfield -I. -U__HAVE_68881__
14 | AS=vxworks68-as
15 | ASFLAGS=-m$(CPU)
16 | LD=vxworks68-ld
17 | LDFLAGS=-M
18 | RM=/bin/rm -f
19 | GAL=python $(BSVC)/bin/gal.py
20 |
21 | #-------------------------------------------------------------------------
22 | LIBS=-L$(M68K_LIB) -lgcc
23 |
24 | .SUFFIXES: .cxx .s .glis
25 |
26 | PROGRAM=test3
27 | OBJECTS=boot2.o test3.o duart.o
28 | ASMSRC=boot2.s test3.s duart.s
29 | ASMGLIS=boot2.glis test3.glis duart.glis
30 | MAP=$(PROGRAM).map
31 | #-------------------------------------------------------------------------
32 | .cxx.o:
33 | $(CC) -c $(CFLAGS) -o $@ $<
34 |
35 | .c.o:
36 | $(CC) -c $(CFLAGS) -o $@ $<
37 |
38 | .cxx.s:
39 | $(CC) -c -S $(CFLAGS) -o $@ $<
40 |
41 | .c.s:
42 | $(CC) -c -S $(CFLAGS) -o $@ $<
43 |
44 | .s.glis:
45 | $(AS) -a $(ASFLAGS) -o /dev/null $< > $@
46 |
47 | #-------------------------------------------------------------------------
48 | all: $(PROGRAM).H68 $(PROGRAM).LIS
49 |
50 | $(PROGRAM).H68 $(MAP): $(OBJECTS)
51 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).cmd $(LIBS) > $(MAP)
52 |
53 | clean:
54 | $(RM) *.o $(PROGRAM).H68 $(PROGRAM).LIS $(MAP)
55 | $(RM) *.lis *.glis CPU32.debug
56 |
57 | $(PROGRAM).LIS: $(ASMGLIS) $(MAP)
58 | $(GAL) $(MAP) $(ASMGLIS)
59 |
60 |
--------------------------------------------------------------------------------
/samples/m68360/gcc3/boot2.s:
--------------------------------------------------------------------------------
1 | |
2 | | boot.s
3 | |
4 | | Set the initial stack and reset vector
5 | | Install exception routines
6 | | Jump to '_main'
7 | |
8 | | DJ (c) 1996
9 | |
10 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
11 | | WITH NO WARRANTY FOR ANY PURPOSE.
12 | |
13 |
14 | |
15 | | INITIAL STACK AND RESET VECTOR
16 | |
17 | .equ BOO_STACK,0xF000
18 | .equ APP_START,0x4000
19 |
20 | .data
21 | .long BOO_STACK | Vector 0 (SSP)
22 | .long BOO_START | Vector - (PC)
23 | .space 1016 | (256-2)*4
24 | .even
25 | |DS.L 245
26 |
27 | |
28 | | BOOT CODE
29 | |
30 | .text
31 | .global BOO_START
32 | BOO_START:
33 | | initialize exception vectors
34 | LEA 0x08,A0 | start with vector 2
35 | LEA _exceptionTable,A1
36 | BOO_START_L1:
37 | MOVE.L A1,(A0)+
38 | ADD.L #6,A1
39 | CMP.L #0x400,A0 | $400 is the end of vector table
40 | BLT BOO_START_L1
41 | | initialize exception table with 'jsr unimplemented-exception'
42 | MOVE.W 0,D0
43 | LEA _exceptionTable,A0
44 | BOO_START_L2:
45 | MOVE.W #0x4EB9,(A0)+ | 4EB9 is 'jsr'
46 | MOVE.L #BOO_UNIMP_EXCPT,(A0)+
47 | ADDQ.W #1,D0
48 | CMP.W #255,D0
49 | BLT BOO_START_L2
50 |
51 | | we're ready: unmask interrupt
52 | ANDI #0b1111100011111111,SR
53 |
54 | | jump to _main
55 | JMP _main
56 |
57 | |
58 | | Exception: unimplemented
59 | |
60 | .global BOO_UNIMP_EXCPT
61 | BOO_UNIMP_EXCPT:
62 | MOVE.L (sp)+,d2 | get return address and
63 | LEA _exceptionTable,a3 | compute exception number
64 | SUB.L a3,d2
65 | DIVS.W #6,d2
66 | ADDQ.W #1,d2
67 | MOVE.B d2,d3
68 | AND.B #0xF, d2
69 | CMP.B #10,d2
70 | BGT zz1
71 | ADD.B #'0',d2
72 | BRA zz2
73 | zz1:
74 | ADD.B #'A',d2
75 | zz2:
76 | ASR.B #4,d3
77 | AND.B #0xF, d3
78 | CMP.B #10,d3
79 | BGT zz3
80 | ADD.B #'0',d3
81 | BRA zz4
82 | zz3:
83 | ADD.B #'A',d3
84 | zz4:
85 | LEA BOO_UNIMP_EXCPT_NUM,A0
86 | MOVE.B d3,(A0)+
87 | MOVE.B d2,(A0)+
88 | JSR _DUART_INIT
89 | LEA BOO_UNIMP_EXCPT_TEXT,A0
90 | JSR _DUART_PRINT
91 |
92 | BOOTL5: BRA BOOTL5
93 |
94 | BOO_UNIMP_EXCPT_TEXT:
95 | .ascii "|| unimplemented exception 0x"
96 | BOO_UNIMP_EXCPT_NUM:
97 | .ascii "XX"
98 | .ascii "||\12\0"
99 | .even
100 |
101 | |
102 | | Exception table
103 | |
104 | | exception table is a set of 255 group of 6 bytes, each group is
105 | | a instruction executed when the 'corresponding' exception occurs
106 | | These group are initialized with an simple instruction
107 | | "jsr unimplemented-exception", but this can be overwritten.
108 | |
109 | .global _exceptionTable
110 | _exceptionTable:
111 | .space 1530 || (255*6)
112 |
113 | |
114 | | End of file
115 | |
116 |
--------------------------------------------------------------------------------
/samples/m68360/gcc3/duart.s:
--------------------------------------------------------------------------------
1 | |
2 | | duart.s
3 | |
4 | | Assembly language function giving access to the 68881 DUART.
5 | | (Adapted from 'MatrixMultiply.s' example).
6 | |
7 | | DJ 1996/11
8 | |
9 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | | WITH NO WARRANTY FOR ANY PURPOSE.
11 | |
12 |
13 | | Implements:
14 | | - _DUART_INIT: initialize the DUART (can be called from C)
15 | | - _DUART_GETC: get a character, returned in register D0 (can be called from C)
16 | | - _DUART_PUTC: output a character, expected in the stack (can be called from C)
17 | | - _DUART_PRINT: output a string of character (use A0 as parameter)
18 | | (DO NOT CALL FROM C!)
19 |
20 | .equ DUA_ADD, 0xeffc01
21 | .equ DUA_MR1A, 0
22 | .equ DUA_MR2A, 0
23 | .equ DUA_SRA, 2
24 | .equ DUA_CRA, 4
25 | .equ DUA_CSRA, 2
26 | .equ DUA_TBA, 6
27 | .equ DUA_RBA, 6
28 | .equ DUA_IMR, 10
29 | .equ DUA_TBB, 0x16
30 | .equ DUA_CRB, 0x14
31 | .equ DUA_MR1B, 0x10
32 | .equ DUA_MR2B, 0x10
33 | .equ DUA_SRB, 0x12
34 | .equ DUA_IVR, 0x18
35 | .equ LINEFEED, 10 | LineFeed Character value
36 | .equ CARR_RETURN, 13 | Carrage Return character value
37 |
38 | |
39 | | _DUART_INIT: Initialization of the duart
40 | |
41 | .global _DUART_INIT
42 | _DUART_INIT: MOVE.L A1,-(A7) | Save A1
43 | LEA DUA_ADD,A1
44 | ORI #0b0000011100000000,SR | Masks interrupts
45 | MOVE.B #0b00010000,(DUA_CRA,A1) | Reset MR?A pointer
46 | MOVE.B #0b00100011,(DUA_MR1A,A1) | 8 data bits
47 | MOVE.B #0b00010111,(DUA_MR2A,A1) | Normal Mode
48 | MOVE.B #0b10111011,(DUA_SRA,A1) | Set clock to 9600
49 | MOVE.B #0b00000101,(DUA_CRA,A1) | Enable Rx and Tx
50 | MOVE.L (A7)+,A1 | Restore A1
51 | RTS
52 |
53 | |
54 | | _DUART_PUTC: The character in the stack is transmitted to the CONSOLE ACIA.
55 | | The newline character is expanded into /.
56 | | Define a subroutine DUA_PUTC, which print the character contained in D0
57 | |
58 |
59 | DUA_PUTC: BTST #2,DUA_SRA+DUA_ADD | Test Transmit data register empty
60 | BEQ.S DUA_PUTC | If not keep polling
61 | MOVE.B D0,DUA_TBA+DUA_ADD | Transmit the character
62 | CMP.B #LINEFEED,D0 | Check for LINEFEED
63 | BNE DUA_PUTCEXT | if not L/F, exit
64 | MOVE.B #CARR_RETURN,D0 | Load CARR_RETURN into D0
65 | BRA DUA_PUTC | Output C/R
66 | DUA_PUTCEXT: RTS
67 |
68 | .global _DUART_PUTC
69 | _DUART_PUTC: LINK A6,#-2
70 | MOVE.L (8,A6),D0
71 | JSR DUA_PUTC
72 | UNLK A6
73 | RTS
74 |
75 | |
76 | | _DUART_GETC: Get a character from the CONSOLE ACIA and return it in D0
77 | |
78 |
79 | .global _DUART_GETC
80 | _DUART_GETC: BTST #0,DUA_SRA+DUA_ADD | Test Receive data register full
81 | BEQ.S _DUART_GETC | If not keep polling
82 | MOVE.B DUA_RBA+DUA_ADD,D0 | Read the character
83 | RTS
84 |
85 | |
86 | | _DUART_PRINT: print a string of charater, until null
87 | |
88 | .global _DUART_PRINT
89 | _DUART_PRINT: MOVE.L D0,-(A7) | Save register d0 to stack
90 | DUAPRLOOP: MOVE.B (A0)+,D0 | Get a character to print
91 | CMP.B #0x00,D0 | Is it null?
92 | BEQ DUAPRNTEND | yes: it's over
93 | JSR DUA_PUTC | no: print it
94 | BRA DUAPRLOOP | repeat
95 | DUAPRNTEND: MOVE.L (A7)+,D0 | Restore d0
96 | RTS
97 |
98 | |
99 | | End of file
100 | |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/samples/m68360/gcc3/test3.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test3.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test3.H68)
25 | OUTPUT_FORMAT(srec)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gcc3/test3.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * test3.cxx
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | */
9 |
10 | extern "C"
11 | {
12 | extern void DUART_INIT(void);
13 | extern void DUART_PUTC(char c);
14 | extern char DUART_GETC(void);
15 | }
16 |
17 |
18 | /*
19 | * Function: puts (print a string)
20 | */
21 | void puts(const char*s)
22 | {
23 | while(*s) DUART_PUTC(*s++);
24 | }
25 |
26 | /*
27 | * Function main
28 | */
29 | int main(void)
30 | {
31 | DUART_INIT();
32 | puts("Hello world++!\n");
33 | DUART_GETC();
34 | puts("Done.\n");
35 | while(1);
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/samples/m68360/gcc3/test3.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.0}
4 | SIMULATOR {sim68360}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "Port A" -n "Port A" -fn fixed -e xtermpipe PortBCommand = }}
7 |
--------------------------------------------------------------------------------
/samples/m68360/gcc4/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile -*- BASH -*-
3 | #
4 | # DJ (c) 1996
5 | #
6 | # USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | # WITH NO WARRANTY FOR ANY PURPOSE.
8 | #
9 |
10 | #-------------------------------------------------------------------------
11 | CPU=68020
12 | #-------------------------------------------------------------------------
13 |
14 | CC=vxworks68-gcc
15 | CFLAGS=-g -Wall -m$(CPU) -mnobitfield -I. -U__HAVE_68881__
16 | AS=vxworks68-as
17 | ASFLAGS=-m$(CPU)
18 | LD=vxworks68-ld
19 | LDFLAGS=-M
20 | RM=/bin/rm -f
21 | GAL=python $(BSVC)/bin/gal.py
22 |
23 | #-------------------------------------------------------------------------
24 | LIBS=-L$(M68K_LIB) -lgcc
25 |
26 | .SUFFIXES: .cxx .s .glis
27 |
28 | PROGRAM=test4
29 | OBJECTS=boot2.o test4.o duart.o
30 | ASMSRC=boot2.s test4.s duart.s
31 | ASMGLIS=boot2.glis test4.glis duart.glis
32 | MAP=$(PROGRAM).map
33 | #-------------------------------------------------------------------------
34 | .cxx.o:
35 | $(CC) -c $(CFLAGS) -o $@ $<
36 |
37 | .c.o:
38 | $(CC) -c $(CFLAGS) -o $@ $<
39 |
40 | .cxx.s:
41 | $(CC) -c -S $(CFLAGS) -o $@ $<
42 |
43 | .c.s:
44 | $(CC) -c -S $(CFLAGS) -o $@ $<
45 |
46 | .s.glis:
47 | $(AS) -a $(ASFLAGS) -o /dev/null $< > $@
48 |
49 | #-------------------------------------------------------------------------
50 | all: $(PROGRAM).H68 $(PROGRAM).LIS
51 |
52 | $(PROGRAM).H68 $(MAP): $(OBJECTS)
53 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).cmd $(LIBS) > $(MAP)
54 |
55 | clean:
56 | $(RM) *.o $(PROGRAM).H68 $(PROGRAM).LIS $(MAP)
57 | $(RM) *.lis *.glis CPU32.debug
58 |
59 | $(PROGRAM).LIS: $(ASMGLIS) $(MAP)
60 | $(GAL) $(MAP) $(ASMGLIS)
61 |
62 |
--------------------------------------------------------------------------------
/samples/m68360/gcc4/boot2.s:
--------------------------------------------------------------------------------
1 | |
2 | | boot.s
3 | |
4 | | Set the initial stack and reset vector
5 | | Install exception routines
6 | | Jump to '_main'
7 | |
8 | | DJ (c) 1996
9 | |
10 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
11 | | WITH NO WARRANTY FOR ANY PURPOSE.
12 | |
13 |
14 | |
15 | | INITIAL STACK AND RESET VECTOR
16 | |
17 | .equ BOO_STACK,0xF000
18 | .equ APP_START,0x4000
19 |
20 | .data
21 | .long BOO_STACK | Vector 0 (SSP)
22 | .long BOO_START | Vector - (PC)
23 | .space 1016 | (256-2)*4
24 | .even
25 | |DS.L 245
26 |
27 | |
28 | | BOOT CODE
29 | |
30 | .text
31 | .global BOO_START
32 | BOO_START:
33 | | initialize exception vectors
34 | LEA 0x08,A0 | start with vector 2
35 | LEA _exceptionTable,A1
36 | BOO_START_L1:
37 | MOVE.L A1,(A0)+
38 | ADD.L #6,A1
39 | CMP.L #0x400,A0 | $400 is the end of vector table
40 | BLT BOO_START_L1
41 | | initialize exception table with 'jsr unimplemented-exception'
42 | MOVE.W 0,D0
43 | LEA _exceptionTable,A0
44 | BOO_START_L2:
45 | MOVE.W #0x4EB9,(A0)+ | 4EB9 is 'jsr'
46 | MOVE.L #BOO_UNIMP_EXCPT,(A0)+
47 | ADDQ.W #1,D0
48 | CMP.W #255,D0
49 | BLT BOO_START_L2
50 |
51 | | we're ready: unmask interrupt
52 | ANDI #0b1111100011111111,SR
53 |
54 | | jump to _main
55 | JMP _main
56 |
57 | |
58 | | Exception: unimplemented
59 | |
60 | .global BOO_UNIMP_EXCPT
61 | BOO_UNIMP_EXCPT:
62 | MOVE.L (sp)+,d2 | get return address and
63 | LEA _exceptionTable,a3 | compute exception number
64 | SUB.L a3,d2
65 | DIVS.W #6,d2
66 | ADDQ.W #1,d2
67 | MOVE.B d2,d3
68 | AND.B #0xF, d2
69 | CMP.B #10,d2
70 | BGT zz1
71 | ADD.B #'0',d2
72 | BRA zz2
73 | zz1:
74 | ADD.B #'A',d2
75 | zz2:
76 | ASR.B #4,d3
77 | AND.B #0xF, d3
78 | CMP.B #10,d3
79 | BGT zz3
80 | ADD.B #'0',d3
81 | BRA zz4
82 | zz3:
83 | ADD.B #'A',d3
84 | zz4:
85 | LEA BOO_UNIMP_EXCPT_NUM,A0
86 | MOVE.B d3,(A0)+
87 | MOVE.B d2,(A0)+
88 | JSR _DUART_INIT
89 | LEA BOO_UNIMP_EXCPT_TEXT,A0
90 | JSR _DUART_PRINT
91 |
92 | BOOTL5: BRA BOOTL5
93 |
94 | BOO_UNIMP_EXCPT_TEXT:
95 | .ascii "|| unimplemented exception 0x"
96 | BOO_UNIMP_EXCPT_NUM:
97 | .ascii "XX"
98 | .ascii "||\12\0"
99 | .even
100 |
101 | |
102 | | Exception table
103 | |
104 | | exception table is a set of 255 group of 6 bytes, each group is
105 | | a instruction executed when the 'corresponding' exception occurs
106 | | These group are initialized with an simple instruction
107 | | "jsr unimplemented-exception", but this can be overwritten.
108 | |
109 | .global _exceptionTable
110 | _exceptionTable:
111 | .space 1530 || (255*6)
112 |
113 | |
114 | | End of file
115 | |
116 |
--------------------------------------------------------------------------------
/samples/m68360/gcc4/duart.s:
--------------------------------------------------------------------------------
1 | |
2 | | duart.s
3 | |
4 | | Assembly language function giving access to the 68881 DUART.
5 | | (Adapted from 'MatrixMultiply.s' example).
6 | |
7 | | DJ 1996/11
8 | |
9 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | | WITH NO WARRANTY FOR ANY PURPOSE.
11 | |
12 |
13 | | Implements:
14 | | - _DUART_INIT: initialize the DUART (can be called from C)
15 | | - _DUART_GETC: get a character, returned in register D0 (can be called from C)
16 | | - _DUART_PUTC: output a character, expected in the stack (can be called from C)
17 | | - _DUART_PRINT: output a string of character (use A0 as parameter)
18 | | (DO NOT CALL FROM C!)
19 |
20 | .equ DUA_ADD, 0xeffc01
21 | .equ DUA_MR1A, 0
22 | .equ DUA_MR2A, 0
23 | .equ DUA_SRA, 2
24 | .equ DUA_CRA, 4
25 | .equ DUA_CSRA, 2
26 | .equ DUA_TBA, 6
27 | .equ DUA_RBA, 6
28 | .equ DUA_IMR, 10
29 | .equ DUA_TBB, 0x16
30 | .equ DUA_CRB, 0x14
31 | .equ DUA_MR1B, 0x10
32 | .equ DUA_MR2B, 0x10
33 | .equ DUA_SRB, 0x12
34 | .equ DUA_IVR, 0x18
35 | .equ LINEFEED, 10 | LineFeed Character value
36 | .equ CARR_RETURN, 13 | Carrage Return character value
37 |
38 | |
39 | | _DUART_INIT: Initialization of the duart
40 | |
41 | .global _DUART_INIT
42 | _DUART_INIT: MOVE.L A1,-(A7) | Save A1
43 | LEA DUA_ADD,A1
44 | ORI #0b0000011100000000,SR | Masks interrupts
45 | MOVE.B #0b00010000,(DUA_CRA,A1) | Reset MR?A pointer
46 | MOVE.B #0b00100011,(DUA_MR1A,A1) | 8 data bits
47 | MOVE.B #0b00010111,(DUA_MR2A,A1) | Normal Mode
48 | MOVE.B #0b10111011,(DUA_SRA,A1) | Set clock to 9600
49 | MOVE.B #0b00000101,(DUA_CRA,A1) | Enable Rx and Tx
50 | MOVE.L (A7)+,A1 | Restore A1
51 | RTS
52 |
53 | |
54 | | _DUART_PUTC: The character in the stack is transmitted to the CONSOLE ACIA.
55 | | The newline character is expanded into /.
56 | | Define a subroutine DUA_PUTC, which print the character contained in D0
57 | |
58 |
59 | DUA_PUTC: BTST #2,DUA_SRA+DUA_ADD | Test Transmit data register empty
60 | BEQ.S DUA_PUTC | If not keep polling
61 | MOVE.B D0,DUA_TBA+DUA_ADD | Transmit the character
62 | CMP.B #LINEFEED,D0 | Check for LINEFEED
63 | BNE DUA_PUTCEXT | if not L/F, exit
64 | MOVE.B #CARR_RETURN,D0 | Load CARR_RETURN into D0
65 | BRA DUA_PUTC | Output C/R
66 | DUA_PUTCEXT: RTS
67 |
68 | .global _DUART_PUTC
69 | _DUART_PUTC: LINK A6,#-2
70 | MOVE.L (8,A6),D0
71 | JSR DUA_PUTC
72 | UNLK A6
73 | RTS
74 |
75 | |
76 | | _DUART_GETC: Get a character from the CONSOLE ACIA and return it in D0
77 | |
78 |
79 | .global _DUART_GETC
80 | _DUART_GETC: BTST #0,DUA_SRA+DUA_ADD | Test Receive data register full
81 | BEQ.S _DUART_GETC | If not keep polling
82 | MOVE.B DUA_RBA+DUA_ADD,D0 | Read the character
83 | RTS
84 |
85 | |
86 | | _DUART_PRINT: print a string of charater, until null
87 | |
88 | .global _DUART_PRINT
89 | _DUART_PRINT: MOVE.L D0,-(A7) | Save register d0 to stack
90 | DUAPRLOOP: MOVE.B (A0)+,D0 | Get a character to print
91 | CMP.B #0x00,D0 | Is it null?
92 | BEQ DUAPRNTEND | yes: it's over
93 | JSR DUA_PUTC | no: print it
94 | BRA DUAPRLOOP | repeat
95 | DUAPRNTEND: MOVE.L (A7)+,D0 | Restore d0
96 | RTS
97 |
98 | |
99 | | End of file
100 | |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/samples/m68360/gcc4/test4.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test4.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test4.H68)
25 | OUTPUT_FORMAT(srec)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gcc4/test4.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * test4.cxx
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | */
9 |
10 | extern "C"
11 | {
12 | extern void DUART_INIT(void);
13 | extern void DUART_PUTC(char c);
14 | extern char DUART_GETC(void);
15 | }
16 |
17 |
18 | /*
19 | * Function: puts (print a string)
20 | */
21 | void puts(const char*s)
22 | {
23 | while(*s) DUART_PUTC(*s++);
24 | }
25 |
26 | /*
27 | * Class CHello
28 | */
29 | class CHello
30 | {
31 | public:
32 | CHello(char* who);
33 | void Print() const;
34 |
35 | protected:
36 | char*m_who;
37 | };
38 |
39 | /*
40 | * Constructor CHello
41 | */
42 | CHello::CHello(char *who)
43 | {
44 | DUART_INIT();
45 | m_who=who;
46 | }
47 |
48 | /*
49 | * Method CHello::Print
50 | */
51 | void CHello::Print() const
52 | {
53 | puts("Hello world and ");
54 | puts(m_who);
55 | puts("\n");
56 | }
57 |
58 | /*
59 | * Operator new (if not overloaded, need 'malloc')
60 | */
61 | #if 1
62 | void *operator new(int s)
63 | {
64 | // one shot operator!
65 | static zone[4];
66 |
67 | return (void*)zone;
68 | }
69 | #endif
70 |
71 | /*
72 | * Function main
73 | */
74 | int main(void)
75 | {
76 | CHello c("C++ classes");
77 | c.Print();
78 |
79 | #if 1
80 | // to see what is needed for 'new' operator
81 | CHello *pc;
82 |
83 | pc=new CHello("dynamic");
84 | pc->Print();
85 | #endif
86 |
87 | while(1);
88 | return 0;
89 | }
90 |
--------------------------------------------------------------------------------
/samples/m68360/gcc4/test4.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.0}
4 | SIMULATOR {sim68360}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "Port A" -n "Port A" -fn fixed -e xtermpipe PortBCommand = }}
7 |
--------------------------------------------------------------------------------
/samples/m68360/gcc5/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile -*- BASH -*-
3 | #
4 | # DJ (c) 1996
5 | #
6 | # USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | # WITH NO WARRANTY FOR ANY PURPOSE.
8 | #
9 |
10 | #-------------------------------------------------------------------------
11 | CPU=68020
12 | #-------------------------------------------------------------------------
13 |
14 | CC=vxworks68-gcc
15 | CFLAGS=-g -Wall -m$(CPU) -mnobitfield -I. -U__HAVE_68881__
16 | AS=vxworks68-as
17 | ASFLAGS=-m$(CPU)
18 | LD=vxworks68-ld
19 | LDFLAGS=-M
20 | RM=/bin/rm -f
21 | GAL=python $(BSVC)/bin/gal.py
22 |
23 | #-------------------------------------------------------------------------
24 | LIBS=-L$(M68K_LIB) -lgcc
25 |
26 | .SUFFIXES: .cxx .s .glis
27 |
28 | PROGRAM=test5
29 | OBJECTS=boot2.o test5.o duart.o libc.o jump.o
30 | ASMSRC=boot2.s test5.s duart.s libc.s
31 | ASMGLIS=boot2.glis test5.glis duart.glis libc.glis jump.glis
32 | MAP=$(PROGRAM).map
33 | #-------------------------------------------------------------------------
34 | .cxx.o:
35 | $(CC) -c $(CFLAGS) -o $@ $<
36 |
37 | .c.o:
38 | $(CC) -c $(CFLAGS) -o $@ $<
39 |
40 | .cxx.s:
41 | $(CC) -c -S $(CFLAGS) -o $@ $<
42 |
43 | .c.s:
44 | $(CC) -c -S $(CFLAGS) -o $@ $<
45 |
46 | .s.glis:
47 | $(AS) -a $(ASFLAGS) -o /dev/null $< > $@
48 |
49 | #-------------------------------------------------------------------------
50 | all: $(PROGRAM).H68 $(PROGRAM).LIS
51 |
52 | $(PROGRAM).H68 $(MAP): $(OBJECTS)
53 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).cmd $(LIBS) > $(MAP)
54 |
55 | clean:
56 | $(RM) *.o $(PROGRAM).H68 $(PROGRAM).LIS $(MAP)
57 | $(RM) *.lis *.glis CPU32.debug
58 |
59 | $(PROGRAM).LIS: $(ASMGLIS) $(MAP)
60 | $(GAL) $(MAP) $(ASMGLIS)
61 |
62 |
--------------------------------------------------------------------------------
/samples/m68360/gcc5/boot2.s:
--------------------------------------------------------------------------------
1 | |
2 | | boot.s
3 | |
4 | | Set the initial stack and reset vector
5 | | Install exception routines
6 | | Jump to '_main'
7 | |
8 | | DJ (c) 1996
9 | |
10 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
11 | | WITH NO WARRANTY FOR ANY PURPOSE.
12 | |
13 |
14 | |
15 | | INITIAL STACK AND RESET VECTOR
16 | |
17 | .equ BOO_STACK,0xF000
18 | .equ APP_START,0x4000
19 |
20 | .data
21 | .long BOO_STACK | Vector 0 (SSP)
22 | .long BOO_START | Vector - (PC)
23 | .space 1016 | (256-2)*4
24 | .even
25 | |DS.L 245
26 |
27 | |
28 | | BOOT CODE
29 | |
30 | .text
31 | .global BOO_START
32 | BOO_START:
33 | | initialize exception vectors
34 | LEA 0x08,A0 | start with vector 2
35 | LEA _exceptionTable,A1
36 | BOO_START_L1:
37 | MOVE.L A1,(A0)+
38 | ADD.L #6,A1
39 | CMP.L #0x400,A0 | $400 is the end of vector table
40 | BLT BOO_START_L1
41 | | initialize exception table with 'jsr unimplemented-exception'
42 | MOVE.W 0,D0
43 | LEA _exceptionTable,A0
44 | BOO_START_L2:
45 | MOVE.W #0x4EB9,(A0)+ | 4EB9 is 'jsr'
46 | MOVE.L #BOO_UNIMP_EXCPT,(A0)+
47 | ADDQ.W #1,D0
48 | CMP.W #255,D0
49 | BLT BOO_START_L2
50 |
51 | | we're ready: unmask interrupt
52 | ANDI #0b1111100011111111,SR
53 |
54 | | jump to _main
55 | JMP _main
56 |
57 | |
58 | | Exception: unimplemented
59 | |
60 | .global BOO_UNIMP_EXCPT
61 | BOO_UNIMP_EXCPT:
62 | MOVE.L (sp)+,d2 | get return address and
63 | LEA _exceptionTable,a3 | compute exception number
64 | SUB.L a3,d2
65 | DIVS.W #6,d2
66 | ADDQ.W #1,d2
67 | MOVE.B d2,d3
68 | AND.B #0xF, d2
69 | CMP.B #10,d2
70 | BGT zz1
71 | ADD.B #'0',d2
72 | BRA zz2
73 | zz1:
74 | ADD.B #'A',d2
75 | zz2:
76 | ASR.B #4,d3
77 | AND.B #0xF, d3
78 | CMP.B #10,d3
79 | BGT zz3
80 | ADD.B #'0',d3
81 | BRA zz4
82 | zz3:
83 | ADD.B #'A',d3
84 | zz4:
85 | LEA BOO_UNIMP_EXCPT_NUM,A0
86 | MOVE.B d3,(A0)+
87 | MOVE.B d2,(A0)+
88 | JSR _DUART_INIT
89 | LEA BOO_UNIMP_EXCPT_TEXT,A0
90 | JSR _DUART_PRINT
91 |
92 | BOOTL5: BRA BOOTL5
93 |
94 | BOO_UNIMP_EXCPT_TEXT:
95 | .ascii "|| unimplemented exception 0x"
96 | BOO_UNIMP_EXCPT_NUM:
97 | .ascii "XX"
98 | .ascii "||\12\0"
99 | .even
100 |
101 | |
102 | | Exception table
103 | |
104 | | exception table is a set of 255 group of 6 bytes, each group is
105 | | a instruction executed when the 'corresponding' exception occurs
106 | | These group are initialized with an simple instruction
107 | | "jsr unimplemented-exception", but this can be overwritten.
108 | |
109 | .global _exceptionTable
110 | _exceptionTable:
111 | .space 1530 || (255*6)
112 |
113 | |
114 | | End of file
115 | |
116 |
--------------------------------------------------------------------------------
/samples/m68360/gcc5/duart.s:
--------------------------------------------------------------------------------
1 | |
2 | | duart.s
3 | |
4 | | Assembly language function giving access to the 68881 DUART.
5 | | (Adapted from 'MatrixMultiply.s' example).
6 | |
7 | | DJ 1996/11
8 | |
9 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | | WITH NO WARRANTY FOR ANY PURPOSE.
11 | |
12 |
13 | | Implements:
14 | | - _DUART_INIT: initialize the DUART (can be called from C)
15 | | - _DUART_GETC: get a character, returned in register D0 (can be called from C)
16 | | - _DUART_PUTC: output a character, expected in the stack (can be called from C)
17 | | - _DUART_PRINT: output a string of character (use A0 as parameter)
18 | | (DO NOT CALL FROM C!)
19 |
20 | .equ DUA_ADD, 0xeffc01
21 | .equ DUA_MR1A, 0
22 | .equ DUA_MR2A, 0
23 | .equ DUA_SRA, 2
24 | .equ DUA_CRA, 4
25 | .equ DUA_CSRA, 2
26 | .equ DUA_TBA, 6
27 | .equ DUA_RBA, 6
28 | .equ DUA_IMR, 10
29 | .equ DUA_TBB, 0x16
30 | .equ DUA_CRB, 0x14
31 | .equ DUA_MR1B, 0x10
32 | .equ DUA_MR2B, 0x10
33 | .equ DUA_SRB, 0x12
34 | .equ DUA_IVR, 0x18
35 | .equ LINEFEED, 10 | LineFeed Character value
36 | .equ CARR_RETURN, 13 | Carrage Return character value
37 |
38 | |
39 | | _DUART_INIT: Initialization of the duart
40 | |
41 | .global _DUART_INIT
42 | _DUART_INIT: MOVE.L A1,-(A7) | Save A1
43 | LEA DUA_ADD,A1
44 | ORI #0b0000011100000000,SR | Masks interrupts
45 | MOVE.B #0b00010000,(DUA_CRA,A1) | Reset MR?A pointer
46 | MOVE.B #0b00100011,(DUA_MR1A,A1) | 8 data bits
47 | MOVE.B #0b00010111,(DUA_MR2A,A1) | Normal Mode
48 | MOVE.B #0b10111011,(DUA_SRA,A1) | Set clock to 9600
49 | MOVE.B #0b00000101,(DUA_CRA,A1) | Enable Rx and Tx
50 | MOVE.L (A7)+,A1 | Restore A1
51 | RTS
52 |
53 | |
54 | | _DUART_PUTC: The character in the stack is transmitted to the CONSOLE ACIA.
55 | | The newline character is expanded into /.
56 | | Define a subroutine DUA_PUTC, which print the character contained in D0
57 | |
58 | DUA_PUTC:
59 | BTST #2,DUA_SRA+DUA_ADD | Test Transmit data register empty
60 | BEQ.S DUA_PUTC | If not keep polling
61 | MOVE.B D0,DUA_TBA+DUA_ADD | Transmit the character
62 | CMP.B #LINEFEED,D0 | Check for LINEFEED
63 | BNE DUA_PUTCEXT | if not L/F, exit
64 | MOVE.B #CARR_RETURN,D0 | Load CARR_RETURN into D0
65 | BRA DUA_PUTC | Output C/R
66 | DUA_PUTCEXT:
67 | RTS
68 |
69 | .global _DUART_PUTC
70 | _DUART_PUTC: LINK A6,#-2
71 | MOVE.L (8,A6),D0
72 | JSR DUA_PUTC
73 | UNLK A6
74 | RTS
75 |
76 | |
77 | | _DUART_GETC: Get a character from the CONSOLE ACIA and return it in D0
78 | |
79 | .global _DUART_GETC
80 | _DUART_GETC:
81 | BTST #0,DUA_SRA+DUA_ADD | Test Receive data register full
82 | BEQ.S _DUART_GETC | If not keep polling
83 | MOVE.B DUA_RBA+DUA_ADD,D0 | Read the character
84 | RTS
85 |
86 | |
87 | | _DUART_PRINT: print a string of charater, until null
88 | |
89 | .global _DUART_PRINT
90 | _DUART_PRINT:
91 | MOVE.L D0,-(A7) | Save register d0 to stack
92 | DUAPRLOOP:
93 | MOVE.B (A0)+,D0 | Get a character to print
94 | CMP.B #0x00,D0 | Is it null?
95 | BEQ DUAPRNTEND | yes: it's over
96 | JSR DUA_PUTC | no: print it
97 | BRA DUAPRLOOP | repeat
98 | DUAPRNTEND:
99 | MOVE.L (A7)+,D0 | Restore d0
100 | RTS
101 |
102 | |
103 | | End of file
104 | |
105 |
--------------------------------------------------------------------------------
/samples/m68360/gcc5/jump.s:
--------------------------------------------------------------------------------
1 |
2 | |
3 | | jump.s
4 | |
5 | | DJ 1996/11
6 | |
7 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
8 | | WITH NO WARRANTY FOR ANY PURPOSE.
9 | |
10 | | Assembly language functions providing the 'setjmp/longjmp'
11 | | functionality
12 | |
13 | | Implements:
14 | | - _setjmp
15 | | - _longjmp
16 |
17 | | jump buffer is
18 | | octet 0 to 4: a0
19 | | octet 4 to 60: a1-a7,d1-d7 (movem)
20 | | octet 60 to 64: tmp value (return value for longjmp)
21 | | octet 64 to 67: PC
22 |
23 | .global _setjmp
24 | _setjmp:
25 | | use freely D0
26 | | get jump-buffer address from stack in a0
27 | | stack contains:
28 | | 0-4 bytes: return address
29 | | 4-8 bytes: parameter
30 | | save a0 in d0
31 | movel a0,d0
32 | movel (4,a7),a0
33 | | save registers
34 | movel d0,(a0)
35 | moveml d1-d7/a1-a7,(4,a0)
36 | | save PC (return address is in the stack)
37 | movel (a7),a4
38 | movel a4,(64,a0)
39 |
40 | | return 0
41 | movel #0,d0
42 | rts
43 |
44 | .global _longjmp
45 | _longjmp:
46 | | use freely D0
47 | | get value to be returned from stack
48 | movel (8,a7),d0
49 | | get jump-buffer address from stack in a0
50 | movel (4,a7),a0
51 | | put return value in jump-buffer
52 | movel d0,(60,a0)
53 | | restore registers (especially SP)
54 | moveml (4,a0),d1-d7/a1-a7
55 | | restore PC
56 | movel (64,a0),d0
57 | movel d0,(a7)
58 | | restore d0
59 | movel (60,a0),d0
60 | | restore a0
61 | movel (a0),a0
62 | | return value in d0 has been set above.
63 | rts
64 |
65 |
--------------------------------------------------------------------------------
/samples/m68360/gcc5/libc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libc.h
3 | *
4 | * Declares some useful function of the C standard library
5 | * (should be standard header, such as 'stdio.h', 'string.h'...
6 | *
7 | * DJ (c) 1996
8 | *
9 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | * WITH NO WARRANTY FOR ANY PURPOSE.
11 | */
12 |
13 | #ifndef LIBC_H
14 | #define LIBC_H
15 |
16 | /* stdio.h */
17 | #define NULL ((void*)0)
18 | extern void puts(const char*);
19 | extern void gets(char*);
20 | extern void putchar(char);
21 |
22 | /* string.h */
23 | extern char *strcpy(char* s1, const char *s2);
24 | extern int strlen(const char *s);
25 | extern int strcmp(const char *s1, const char *s2);
26 | extern int strncmp(const char *s1, const char *s2, int n);
27 |
28 | /* memory.h */
29 | extern void *memset(void* addr, int value, int length);
30 | extern void bcopy(char *b1, char*b2, int length);
31 |
32 | /* stdlib.h */
33 | extern int atoi(const char *s);
34 |
35 | /* setjmp.h */
36 | typedef char jmp_buf[68];
37 | extern int setjmp(jmp_buf);
38 | extern int longjmp(jmp_buf,int);
39 |
40 | /* SPECIFIC */
41 | extern void itoa(unsigned short value, char* s);
42 | extern void itox(unsigned short value, char* s);
43 |
44 | #endif /* LIBC_H */
45 |
46 | /*
47 | * End of file
48 | */
49 |
50 |
51 |
--------------------------------------------------------------------------------
/samples/m68360/gcc5/test5.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test5.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test5.H68)
25 | OUTPUT_FORMAT(srec)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gcc5/test5.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.0}
4 | SIMULATOR {sim68360}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "Port A" -n "Port A" -fn fixed -e xtermpipe PortBCommand = }}
7 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile -*- BASH -*-
3 | #
4 | # DJ (c) 1996
5 | #
6 | # USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | # WITH NO WARRANTY FOR ANY PURPOSE.
8 | #
9 |
10 | #-------------------------------------------------------------------------
11 | CPU=68020
12 | #-------------------------------------------------------------------------
13 |
14 | CC=vxworks68-gcc
15 | CFLAGS=-g -Wall -m$(CPU) -mnobitfield -I. -U__HAVE_68881__ -DDEBUG
16 | AS=vxworks68-as
17 | ASFLAGS=-m$(CPU)
18 | LD=vxworks68-ld
19 | LDFLAGS=-M
20 | RM=/bin/rm -f
21 | GAL=python $(BSVC)/bin/gal.py
22 |
23 | #-------------------------------------------------------------------------
24 | LIBS=-L$(M68K_LIB) -lgcc
25 |
26 | .SUFFIXES: .cxx .s .glis
27 |
28 | PROGRAM=test6
29 | GDB_STUB_OBJECTS=astub.o mstub.o ustub.o xstub.o
30 | GDB_STUB_ASMSRC=astub.s mstub.s ustub.s xstub.s
31 | GDB_STUB_ASMGLIS=astub.glis mstub.glis ustub.glis xstub.glis
32 | OBJECTS=boot2.o test6.o duart.o libc.o jump.o $(GDB_STUB_OBJECTS)
33 | ASMSRC=boot2.s test6.s duart.s libc.s $(GDB_STUB_ASMSRC)
34 | ASMGLIS=boot2.glis test6.glis duart.glis libc.glis jump.glis $(GDB_STUB_ASMGLIS)
35 | MAP=$(PROGRAM).map
36 | #-------------------------------------------------------------------------
37 | .cxx.o:
38 | $(CC) -c $(CFLAGS) -o $@ $<
39 |
40 | .c.o:
41 | $(CC) -c $(CFLAGS) -o $@ $<
42 |
43 | .cxx.s:
44 | $(CC) -c -S $(CFLAGS) -o $@ $<
45 |
46 | .c.s:
47 | $(CC) -c -S $(CFLAGS) -o $@ $<
48 |
49 | .s.glis:
50 | $(AS) -a $(ASFLAGS) -o /dev/null $< > $@
51 |
52 | #-------------------------------------------------------------------------
53 | all: $(PROGRAM).H68 $(PROGRAM).bin $(PROGRAM).LIS
54 |
55 | $(PROGRAM).H68 $(MAP): $(OBJECTS)
56 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).cmd $(LIBS) > $(MAP)
57 |
58 | $(PROGRAM).bin: $(OBJECTS)
59 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).bin.cmd $(LIBS) > $(PROGRAM).bin.map
60 |
61 | clean:
62 | $(RM) *.o $(PROGRAM).H68 $(PROGRAM).LIS $(MAP)
63 | $(RM) $(PROGRAM).bin $(PROGRAM).bin.map
64 | $(RM) *.lis *.glis CPU32.debug
65 | $(RM) test6.s libc.s astub.s mstub.s ustub.s xstub.s
66 |
67 | $(PROGRAM).LIS: $(ASMGLIS) $(MAP)
68 | $(GAL) $(MAP) $(ASMGLIS)
69 |
70 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/astub.h:
--------------------------------------------------------------------------------
1 | /*
2 | * astub.h
3 | *
4 | * Assembly language macros for gdb stub (extracted from m68k-stub.c)
5 | *
6 | * DJ, July 96.
7 | *
8 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
9 | * WITH NO WARRANTY FOR ANY PURPOSE.
10 | */
11 |
12 | #ifndef ASTUB_H
13 | #define ASTUB_H
14 |
15 | #define BREAKPOINT() asm(" trap #1");
16 |
17 | #define DISABLE_INTERRUPTS() asm(" oriw #0x0700,sr");
18 | /*
19 | * Assembly written functions
20 | */
21 | extern void return_to_super(void);
22 | extern void return_to_user(void);
23 | extern void _catchException(void);
24 |
25 | #endif /* ASTUB.H */
26 |
27 |
28 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/boot2.s:
--------------------------------------------------------------------------------
1 | |
2 | | boot.s
3 | |
4 | | Set the initial stack and reset vector
5 | | Install exception routines
6 | | Jump to '_main'
7 | |
8 | | DJ (c) 1996
9 | |
10 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
11 | | WITH NO WARRANTY FOR ANY PURPOSE.
12 | |
13 |
14 | |
15 | | INITIAL STACK AND RESET VECTOR
16 | |
17 | .equ BOO_STACK,0xF000
18 | .equ APP_START,0x4000
19 |
20 | .data
21 | .long BOO_STACK | Vector 0 (SSP)
22 | .long BOO_START | Vector - (PC)
23 | .space 1016 | (256-2)*4
24 | .even
25 | |DS.L 245
26 |
27 | |
28 | | BOOT CODE
29 | |
30 | .text
31 | .global BOO_START
32 | BOO_START:
33 | | initialize exception vectors
34 | LEA 0x08,A0 | start with vector 2
35 | LEA _exceptionTable,A1
36 | BOO_START_L1:
37 | MOVE.L A1,(A0)+
38 | ADD.L #6,A1
39 | CMP.L #0x400,A0 | $400 is the end of vector table
40 | BLT BOO_START_L1
41 | | initialize exception table with 'jsr unimplemented-exception'
42 | MOVE.W 0,D0
43 | LEA _exceptionTable,A0
44 | BOO_START_L2:
45 | MOVE.W #0x4EB9,(A0)+ | 4EB9 is 'jsr'
46 | MOVE.L #BOO_UNIMP_EXCPT,(A0)+
47 | ADDQ.W #1,D0
48 | CMP.W #255,D0
49 | BLT BOO_START_L2
50 |
51 | | we're ready: unmask interrupt
52 | ANDI #0b1111100011111111,SR
53 |
54 | | jump to _main
55 | JMP _main
56 |
57 | |
58 | | Exception: unimplemented
59 | |
60 | .global BOO_UNIMP_EXCPT
61 | BOO_UNIMP_EXCPT:
62 | MOVE.L (sp)+,d2 | get return address and
63 | LEA _exceptionTable,a3 | compute exception number
64 | SUB.L a3,d2
65 | DIVS.W #6,d2
66 | ADDQ.W #1,d2
67 | MOVE.B d2,d3
68 | AND.B #0xF, d2
69 | CMP.B #10,d2
70 | BGT zz1
71 | ADD.B #'0',d2
72 | BRA zz2
73 | zz1:
74 | ADD.B #'A',d2
75 | zz2:
76 | ASR.B #4,d3
77 | AND.B #0xF, d3
78 | CMP.B #10,d3
79 | BGT zz3
80 | ADD.B #'0',d3
81 | BRA zz4
82 | zz3:
83 | ADD.B #'A',d3
84 | zz4:
85 | LEA BOO_UNIMP_EXCPT_NUM,A0
86 | MOVE.B d3,(A0)+
87 | MOVE.B d2,(A0)+
88 | JSR _DUART_INIT
89 | LEA BOO_UNIMP_EXCPT_TEXT,A0
90 | JSR _DUART_PRINT
91 |
92 | BOOTL5: BRA BOOTL5
93 |
94 | BOO_UNIMP_EXCPT_TEXT:
95 | .ascii "|| unimplemented exception 0x"
96 | BOO_UNIMP_EXCPT_NUM:
97 | .ascii "XX"
98 | .ascii "||\12\0"
99 | .even
100 |
101 | |
102 | | Exception table
103 | |
104 | | exception table is a set of 255 group of 6 bytes, each group is
105 | | a instruction executed when the 'corresponding' exception occurs
106 | | These group are initialized with an simple instruction
107 | | "jsr unimplemented-exception", but this can be overwritten.
108 | |
109 | .global _exceptionTable
110 | _exceptionTable:
111 | .space 1530 || (255*6)
112 |
113 | |
114 | | End of file
115 | |
116 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/duart.s:
--------------------------------------------------------------------------------
1 | |
2 | | duart.s
3 | |
4 | | Assembly language function giving access to the 68881 DUART.
5 | | (Adapted from 'MatrixMultiply.s' example).
6 | |
7 | | DJ 1996/11
8 | |
9 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | | WITH NO WARRANTY FOR ANY PURPOSE.
11 | |
12 |
13 | | Implements:
14 | | - _DUART_INIT: initialize the DUART (can be called from C)
15 | | - _DUART_GETC: get a character, returned in register D0 (can be called from C)
16 | | - _DUART_PUTC: output a character, expected in the stack (can be called from C)
17 | | - _DUART_PRINT: output a string of character (use A0 as parameter)
18 | | (DO NOT CALL FROM C!)
19 |
20 | .equ DUA_ADD, 0xeffc01
21 | .equ DUA_MR1A, 0
22 | .equ DUA_MR2A, 0
23 | .equ DUA_SRA, 2
24 | .equ DUA_CRA, 4
25 | .equ DUA_CSRA, 2
26 | .equ DUA_TBA, 6
27 | .equ DUA_RBA, 6
28 | .equ DUA_IMR, 10
29 | .equ DUA_TBB, 0x16
30 | .equ DUA_CRB, 0x14
31 | .equ DUA_MR1B, 0x10
32 | .equ DUA_MR2B, 0x10
33 | .equ DUA_SRB, 0x12
34 | .equ DUA_IVR, 0x18
35 | .equ LINEFEED, 10 | LineFeed Character value
36 | .equ CARR_RETURN, 13 | Carrage Return character value
37 |
38 | |
39 | | _DUART_INIT: Initialization of the duart
40 | |
41 | .global _DUART_INIT
42 | _DUART_INIT: MOVE.L A1,-(A7) | Save A1
43 | LEA DUA_ADD,A1
44 | ORI #0b0000011100000000,SR | Masks interrupts
45 | MOVE.B #0b00010000,(DUA_CRA,A1) | Reset MR?A pointer
46 | MOVE.B #0b00100011,(DUA_MR1A,A1) | 8 data bits
47 | MOVE.B #0b00010111,(DUA_MR2A,A1) | Normal Mode
48 | MOVE.B #0b10111011,(DUA_SRA,A1) | Set clock to 9600
49 | MOVE.B #0b00000101,(DUA_CRA,A1) | Enable Rx and Tx
50 | MOVE.L (A7)+,A1 | Restore A1
51 | RTS
52 |
53 | |
54 | | _DUART_PUTC: The character in the stack is transmitted to the CONSOLE ACIA.
55 | | The newline character is expanded into /.
56 | | Define a subroutine DUA_PUTC, which print the character contained in D0
57 | |
58 |
59 | DUA_PUTC: BTST #2,DUA_SRA+DUA_ADD | Test Transmit data register empty
60 | BEQ.S DUA_PUTC | If not keep polling
61 | MOVE.B D0,DUA_TBA+DUA_ADD | Transmit the character
62 | CMP.B #LINEFEED,D0 | Check for LINEFEED
63 | BNE DUA_PUTCEXT | if not L/F, exit
64 | MOVE.B #CARR_RETURN,D0 | Load CARR_RETURN into D0
65 | BRA DUA_PUTC | Output C/R
66 | DUA_PUTCEXT: RTS
67 |
68 | .global _DUART_PUTC
69 | _DUART_PUTC: LINK A6,#-2
70 | MOVE.L (8,A6),D0
71 | JSR DUA_PUTC
72 | UNLK A6
73 | RTS
74 |
75 | |
76 | | _DUART_GETC: Get a character from the CONSOLE ACIA and return it in D0
77 | |
78 |
79 | .global _DUART_GETC
80 | _DUART_GETC: BTST #0,DUA_SRA+DUA_ADD | Test Receive data register full
81 | BEQ.S _DUART_GETC | If not keep polling
82 | MOVE.B DUA_RBA+DUA_ADD,D0 | Read the character
83 | RTS
84 |
85 | |
86 | | _DUART_PRINT: print a string of charater, until null
87 | |
88 | .global _DUART_PRINT
89 | _DUART_PRINT: MOVE.L D0,-(A7) | Save register d0 to stack
90 | DUAPRLOOP: MOVE.B (A0)+,D0 | Get a character to print
91 | CMP.B #0x00,D0 | Is it null?
92 | BEQ DUAPRNTEND | yes: it's over
93 | JSR DUA_PUTC | no: print it
94 | BRA DUAPRLOOP | repeat
95 | DUAPRNTEND: MOVE.L (A7)+,D0 | Restore d0
96 | RTS
97 |
98 | |
99 | | End of file
100 | |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/jump.s:
--------------------------------------------------------------------------------
1 |
2 | |
3 | | jump.s
4 | |
5 | | DJ 1996/11
6 | |
7 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
8 | | WITH NO WARRANTY FOR ANY PURPOSE.
9 | |
10 | | Assembly language functions providing the 'setjmp/longjmp'
11 | | functionality
12 | |
13 | | Implements:
14 | | - _setjmp
15 | | - _longjmp
16 |
17 | | jump buffer is
18 | | octet 0 to 4: a0
19 | | octet 4 to 60: a1-a7,d1-d7 (movem)
20 | | octet 60 to 64: tmp value (return value for longjmp)
21 | | octet 64 to 67: PC
22 |
23 | .global _setjmp
24 | _setjmp:
25 | | use freely D0
26 | | get jump-buffer address from stack in a0
27 | | stack contains:
28 | | 0-4 bytes: return address
29 | | 4-8 bytes: parameter
30 | | save a0 in d0
31 | movel a0,d0
32 | movel (4,a7),a0
33 | | save registers
34 | movel d0,(a0)
35 | moveml d1-d7/a1-a7,(4,a0)
36 | | save PC (return address is in the stack)
37 | movel (a7),a4
38 | movel a4,(64,a0)
39 |
40 | | return 0
41 | movel #0,d0
42 | rts
43 |
44 | .global _longjmp
45 | _longjmp:
46 | | use freely D0
47 | | get value to be returned from stack
48 | movel (8,a7),d0
49 | | get jump-buffer address from stack in a0
50 | movel (4,a7),a0
51 | | put return value in jump-buffer
52 | movel d0,(60,a0)
53 | | restore registers (especially SP)
54 | moveml (4,a0),d1-d7/a1-a7
55 | | restore PC
56 | movel (64,a0),d0
57 | movel d0,(a7)
58 | | restore d0
59 | movel (60,a0),d0
60 | | restore a0
61 | movel (a0),a0
62 | | return value in d0 has been set above.
63 | rts
64 |
65 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/libc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libc.h
3 | *
4 | * Declares some useful function of the C standard library
5 | * (should be standard header, such as 'stdio.h', 'string.h'...
6 | *
7 | * DJ (c) 1996
8 | *
9 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | * WITH NO WARRANTY FOR ANY PURPOSE.
11 | */
12 |
13 | #ifndef LIBC_H
14 | #define LIBC_H
15 |
16 | /* stdio.h */
17 | #define NULL ((void*)0)
18 | extern void puts(const char*);
19 | extern void gets(char*);
20 | extern void putchar(char);
21 |
22 | /* string.h */
23 | extern char *strcpy(char* s1, const char *s2);
24 | extern int strlen(const char *s);
25 | extern int strcmp(const char *s1, const char *s2);
26 | extern int strncmp(const char *s1, const char *s2, int n);
27 |
28 | /* memory.h */
29 | extern void *memset(void* addr, int value, int length);
30 | extern void bcopy(char *b1, char*b2, int length);
31 |
32 | /* stdlib.h */
33 | extern int atoi(const char *s);
34 |
35 | /* setjmp.h */
36 | typedef char jmp_buf[68];
37 | extern int setjmp(jmp_buf);
38 | extern int longjmp(jmp_buf,int);
39 |
40 | /* SPECIFIC */
41 | extern void itoa(unsigned short value, char* s);
42 | extern void itox(unsigned short value, char* s);
43 |
44 | #endif /* LIBC_H */
45 |
46 | /*
47 | * End of file
48 | */
49 |
50 |
51 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/mstub.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mstub.h
3 | *
4 | * Definitions for gdb stub (extracted from m68k-stub.c)
5 | *
6 | * DJ, July 96.
7 | *
8 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
9 | * WITH NO WARRANTY FOR ANY PURPOSE.
10 | */
11 |
12 | #ifndef MSTUB_H
13 | #define MSTUB_H
14 |
15 | /* there are 180 bytes of registers on a 68020 w/68881
16 | * many of the fpa registers are 12 byte (96 bit) registers
17 | */
18 | /* only 16*4+4+4=72 on a 68000/CPU32 ! */
19 | #if 0
20 | #define NUMREGBYTES 180
21 | #else
22 | #define NUMREGBYTES 72
23 | #endif
24 | enum regnames {D0,D1,D2,D3,D4,D5,D6,D7,
25 | A0,A1,A2,A3,A4,A5,A6,A7,
26 | PS,PC,
27 | FP0,FP1,FP2,FP3,FP4,FP5,FP6,FP7,
28 | FPCONTROL,FPSTATUS,FPIADDR
29 | };
30 |
31 |
32 | /* We keep a whole frame cache here. "Why?", I hear you cry, "doesn''t
33 | * GDB handle that sort of thing?" Well, yes, I believe the only
34 | * reason for this cache is to save and restore floating point state
35 | * (fsave/frestore). A cleaner way to do this would be to make the
36 | * fsave data part of the registers which GDB deals with like any
37 | * other registers. This should not be a performance problem if the
38 | * ability to read individual registers is added to the protocol.
39 | */
40 |
41 | typedef struct FrameStruct
42 | {
43 | struct FrameStruct *previous;
44 | int exceptionPC; /* pc value when this frame created */
45 | int exceptionVector; /* cpu vector causing exception */
46 | short frameSize; /* size of cpu frame in words */
47 | short sr; /* for 68000, this not always sr */
48 | int pc;
49 | short format;
50 | int fsaveHeader;
51 | int morejunk[0]; /* exception frame, fp save... */
52 | } Frame;
53 |
54 | #define FRAMESIZE 500
55 |
56 | extern int*stackPtr;
57 |
58 | extern void handle_exception(int exceptionVector);
59 | extern Frame *lastFrame;
60 |
61 | #endif /* MSTUB_H */
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/test6.bin.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test6.bin.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test6.bin)
25 | OUTPUT_FORMAT(a.out-sunos-big)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/test6.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test6.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test6.H68)
25 | OUTPUT_FORMAT(srec)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/test6.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.0}
4 | SIMULATOR {sim68360}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "Port A" -n "Port A" -fn fixed -e xtermpipe PortBCommand = }}
7 | COMMAND {AttachDevice 0 GdbSocket {BaseAddress = e0000 PortNumber = 4545}}
8 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/ustub.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ustub.c
3 | *
4 | * Utilities functions for gdb stub
5 | *
6 | * DJ, July 96.
7 | *
8 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
9 | * WITH NO WARRANTY FOR ANY PURPOSE.
10 | */
11 |
12 | #include "ustub.h"
13 |
14 |
15 | /*=====================================================================*/
16 | const char hexchars[]="0123456789abcdef";
17 | /*=====================================================================*/
18 |
19 | /*=====================================================================*/
20 | int hex(char ch)
21 | /*=====================================================================*/
22 | {
23 | if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10);
24 | if ((ch >= '0') && (ch <= '9')) return (ch-'0');
25 | if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10);
26 | return (-1);
27 | }
28 |
29 |
30 | /*=====================================================================*/
31 | int hexToInt(char **ptr, int *intValue)
32 | /*=====================================================================*/
33 | {
34 | int numChars = 0;
35 | int hexValue;
36 |
37 | *intValue = 0;
38 |
39 | while (**ptr)
40 | {
41 | hexValue = hex(**ptr);
42 | if (hexValue >=0)
43 | {
44 | *intValue = (*intValue <<4) | hexValue;
45 | numChars ++;
46 | }
47 | else
48 | break;
49 |
50 | (*ptr)++;
51 | }
52 |
53 | return (numChars);
54 | }
55 |
56 | /*=====================================================================*/
57 | char* mem2hex(char* mem, char* buf, int count)
58 | /*=====================================================================*/
59 | {
60 | /* convert the memory pointed to by mem into hex, placing result in buf
61 | * return a pointer to the last char put in buf (null)
62 | */
63 | int i;
64 | unsigned char ch;
65 |
66 | for (i=0;i> 4];
70 | *buf++ = hexchars[ch % 16];
71 | }
72 | *buf = 0;
73 | return(buf);
74 | }
75 |
76 | /*=====================================================================*/
77 | char* hex2mem(char *buf, char *mem, int count)
78 | /*=====================================================================*/
79 | {
80 | /* convert the hex array pointed to by buf into binary to be placed
81 | * in mem. return a pointer to the character AFTER the last byte
82 | * written.
83 | */
84 | int i;
85 | unsigned char ch;
86 |
87 | for (i=0;i# */
61 | unsigned char checksum;
62 | unsigned char xmitcsum;
63 | int i;
64 | int count;
65 | char ch, ch1;
66 |
67 | /* char dj_tmp[10]; */
68 |
69 | do
70 | {
71 | /* wait around for the start character, ignore all other characters */
72 | while ((ch = (getDebugChar() & 0x7f)) != '$');
73 | checksum = 0;
74 | xmitcsum = -1;
75 |
76 | count = 0;
77 |
78 | /* now, read until a # or end of buffer is found */
79 | while (count < BUFMAX)
80 | {
81 | ch = getDebugChar() & 0x7f;
82 | if (ch == '#') break;
83 | checksum = checksum + ch;
84 | buffer[count++] = ch;
85 | }
86 | buffer[count] = 0;
87 | if (ch == '#')
88 | {
89 | /* puts("received checksum: "); */
90 | ch1=getDebugChar() & 0x7f;
91 | xmitcsum = hex(ch1) << 4;
92 | /* putchar(ch1); */
93 | ch1=getDebugChar() & 0x7f;
94 | xmitcsum += hex(ch1);
95 | /* putchar(ch1); */
96 | /* putchar('\n'); */
97 |
98 | if (checksum != xmitcsum)
99 | {
100 | putDebugChar('-'); /* failed checksum */
101 | }
102 | else
103 | {
104 | putDebugChar('+'); /* successful transfer */
105 | /* if a sequence char is present, reply the sequence ID */
106 | if (buffer[2] == ':')
107 | {
108 | putDebugChar( buffer[0] );
109 | putDebugChar( buffer[1] );
110 | /* remove sequence chars from buffer */
111 | count = strlen(buffer);
112 | for (i=3; i <= count; i++) buffer[i-3] = buffer[i];
113 | }
114 | }
115 | }
116 | }
117 | while (checksum != xmitcsum);
118 | }
119 |
120 |
121 |
122 | /*-----------------------------------------------------*/
123 | void putpacket(char *buffer)
124 | /*-----------------------------------------------------*/
125 | {
126 | /* send the packet in buffer. The host get''s one chance to read it.
127 | * This routine does not wait for a positive acknowledge.
128 | */
129 | unsigned char checksum;
130 | int count;
131 | char ch;
132 |
133 | /* $#. */
134 | putDebugChar('$');
135 | checksum = 0;
136 | count = 0;
137 |
138 | while ((ch=buffer[count]))
139 | {
140 | putDebugChar(ch&0x7f);
141 | checksum += ch&0x7f;
142 | count += 1;
143 | }
144 |
145 | putDebugChar('#');
146 | putDebugChar(hexchars[checksum >> 4]);
147 | putDebugChar(hexchars[checksum % 16]);
148 | }
149 |
150 |
151 |
--------------------------------------------------------------------------------
/samples/m68360/gdb6/xstub.h:
--------------------------------------------------------------------------------
1 | /*
2 | * xstub.h
3 | *
4 | * Miscellaneous functions for gdb stub
5 | *
6 | * DJ, July 96.
7 | *
8 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
9 | * WITH NO WARRANTY FOR ANY PURPOSE.
10 | */
11 |
12 | #ifndef XSTUB_H
13 | #define XSTUB_H
14 |
15 |
16 | /*
17 | * BUFMAX defines the maximum number of characters in inbound/outbound buffers
18 | * at least NUMREGBYTES*2 are needed for register packets
19 | */
20 | #define BUFMAX 400
21 |
22 | typedef void (*ExceptionHook)(int); /* pointer to function with int parm */
23 |
24 |
25 | extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */
26 |
27 | extern int getDebugChar(void);
28 | extern void putDebugChar(int c);
29 | extern void exceptionHandler(); /* assign an exception handler */
30 | extern void flush_i_cache();
31 |
32 | extern void getpacket(char *buffer);
33 | extern void putpacket(char *buffer);
34 |
35 | #endif /* XSTUB_H */
36 |
37 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile -*- BASH -*-
3 | #
4 | # DJ (c) 1996
5 | #
6 | # USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | # WITH NO WARRANTY FOR ANY PURPOSE.
8 | #
9 |
10 | #-------------------------------------------------------------------------
11 | CPU=68000
12 | #-------------------------------------------------------------------------
13 |
14 | CC=vxworks68-gcc
15 | CFLAGS=-g -Wall -m$(CPU) -mnobitfield -I. -U__HAVE_68881__ -DDEBUG
16 | AS=vxworks68-as
17 | ASFLAGS=-m$(CPU)
18 | LD=vxworks68-ld
19 | LDFLAGS=-M
20 | RM=/bin/rm -f
21 | GAL=python $(BSVC)/bin/gal.py
22 |
23 | #-------------------------------------------------------------------------
24 | LIBS=-L$(M68K_LIB) -lgcc
25 |
26 | .SUFFIXES: .cxx .s .glis
27 |
28 | PROGRAM=test7
29 | GDB_STUB_OBJECTS=astub.o mstub.o ustub.o xstub.o
30 | GDB_STUB_ASMSRC=astub.s mstub.s ustub.s xstub.s
31 | GDB_STUB_ASMGLIS=astub.glis mstub.glis ustub.glis xstub.glis
32 | OBJECTS=boot2.o test7.o duart.o libc.o jump.o $(GDB_STUB_OBJECTS)
33 | ASMSRC=boot2.s test7.s duart.s libc.s $(GDB_STUB_ASMSRC)
34 | ASMGLIS=boot2.glis test7.glis duart.glis libc.glis jump.glis $(GDB_STUB_ASMGLIS)
35 | MAP=$(PROGRAM).map
36 | #-------------------------------------------------------------------------
37 | .cxx.o:
38 | $(CC) -c $(CFLAGS) -o $@ $<
39 |
40 | .c.o:
41 | $(CC) -c $(CFLAGS) -o $@ $<
42 |
43 | .cxx.s:
44 | $(CC) -c -S $(CFLAGS) -o $@ $<
45 |
46 | .c.s:
47 | $(CC) -c -S $(CFLAGS) -o $@ $<
48 |
49 | .s.glis:
50 | $(AS) -a $(ASFLAGS) -o /dev/null $< > $@
51 |
52 | #-------------------------------------------------------------------------
53 | all: $(PROGRAM).H68 $(PROGRAM).bin $(PROGRAM).LIS
54 |
55 | $(PROGRAM).H68 $(MAP): $(OBJECTS)
56 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).cmd $(LIBS) > $(MAP)
57 |
58 | $(PROGRAM).bin: $(OBJECTS)
59 | $(LD) $(LDFLAGS) $(OBJECTS) -T $(PROGRAM).bin.cmd $(LIBS) > $(PROGRAM).bin.map
60 |
61 | clean:
62 | $(RM) *.o $(PROGRAM).H68 $(PROGRAM).LIS $(MAP)
63 | $(RM) $(PROGRAM).bin $(PROGRAM).bin.map
64 | $(RM) *.lis *.glis CPU32.debug
65 | $(RM) test7.s libc.s astub.s mstub.s ustub.s xstub.s
66 |
67 | $(PROGRAM).LIS: $(ASMGLIS) $(MAP)
68 | $(GAL) $(MAP) $(ASMGLIS)
69 |
70 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/astub.h:
--------------------------------------------------------------------------------
1 | /*
2 | * astub.h
3 | *
4 | * Assembly language macros for gdb stub (extracted from m68k-stub.c)
5 | *
6 | * DJ, July 96.
7 | *
8 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
9 | * WITH NO WARRANTY FOR ANY PURPOSE.
10 | */
11 |
12 | #ifndef ASTUB_H
13 | #define ASTUB_H
14 |
15 | #define BREAKPOINT() asm(" trap #1");
16 |
17 | #define DISABLE_INTERRUPTS() asm(" oriw #0x0700,sr");
18 | /*
19 | * Assembly written functions
20 | */
21 | extern void return_to_super(void);
22 | extern void return_to_user(void);
23 | extern void _catchException(void);
24 |
25 | #endif /* ASTUB.H */
26 |
27 |
28 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/boot2.s:
--------------------------------------------------------------------------------
1 | |
2 | | boot.s
3 | |
4 | | Set the initial stack and reset vector
5 | | Install exception routines
6 | | Jump to '_main'
7 | |
8 | | DJ (c) 1996
9 | |
10 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
11 | | WITH NO WARRANTY FOR ANY PURPOSE.
12 | |
13 |
14 | |
15 | | INITIAL STACK AND RESET VECTOR
16 | |
17 | .equ BOO_STACK,0xF000
18 | .equ APP_START,0x4000
19 |
20 | .data
21 | .long BOO_STACK | Vector 0 (SSP)
22 | .long BOO_START | Vector - (PC)
23 | .space 1016 | (256-2)*4
24 | .even
25 | |DS.L 245
26 |
27 | |
28 | | BOOT CODE
29 | |
30 | .text
31 | .global BOO_START
32 | BOO_START:
33 | | initialize exception vectors
34 | LEA 0x08,A0 | start with vector 2
35 | LEA _exceptionTable,A1
36 | BOO_START_L1:
37 | MOVE.L A1,(A0)+
38 | ADD.L #6,A1
39 | CMP.L #0x400,A0 | $400 is the end of vector table
40 | BLT BOO_START_L1
41 | | initialize exception table with 'jsr unimplemented-exception'
42 | MOVE.W 0,D0
43 | LEA _exceptionTable,A0
44 | BOO_START_L2:
45 | MOVE.W #0x4EB9,(A0)+ | 4EB9 is 'jsr'
46 | MOVE.L #BOO_UNIMP_EXCPT,(A0)+
47 | ADDQ.W #1,D0
48 | CMP.W #255,D0
49 | BLT BOO_START_L2
50 |
51 | | we're ready: unmask interrupt
52 | ANDI #0b1111100011111111,SR
53 |
54 | | jump to _main
55 | JMP _main
56 |
57 | |
58 | | Exception: unimplemented
59 | |
60 | .global BOO_UNIMP_EXCPT
61 | BOO_UNIMP_EXCPT:
62 | MOVE.L (sp)+,d2 | get return address and
63 | LEA _exceptionTable,a3 | compute exception number
64 | SUB.L a3,d2
65 | DIVS.W #6,d2
66 | ADDQ.W #1,d2
67 | MOVE.B d2,d3
68 | AND.B #0xF, d2
69 | CMP.B #10,d2
70 | BGT zz1
71 | ADD.B #'0',d2
72 | BRA zz2
73 | zz1:
74 | ADD.B #'A',d2
75 | zz2:
76 | ASR.B #4,d3
77 | AND.B #0xF, d3
78 | CMP.B #10,d3
79 | BGT zz3
80 | ADD.B #'0',d3
81 | BRA zz4
82 | zz3:
83 | ADD.B #'A',d3
84 | zz4:
85 | LEA BOO_UNIMP_EXCPT_NUM,A0
86 | MOVE.B d3,(A0)+
87 | MOVE.B d2,(A0)+
88 | JSR _DUART_INIT
89 | LEA BOO_UNIMP_EXCPT_TEXT,A0
90 | JSR _DUART_PRINT
91 |
92 | BOOTL5: BRA BOOTL5
93 |
94 | BOO_UNIMP_EXCPT_TEXT:
95 | .ascii "|| unimplemented exception 0x"
96 | BOO_UNIMP_EXCPT_NUM:
97 | .ascii "XX"
98 | .ascii "||\12\0"
99 | .even
100 |
101 | |
102 | | Exception table
103 | |
104 | | exception table is a set of 255 group of 6 bytes, each group is
105 | | a instruction executed when the 'corresponding' exception occurs
106 | | These group are initialized with an simple instruction
107 | | "jsr unimplemented-exception", but this can be overwritten.
108 | |
109 | .global _exceptionTable
110 | _exceptionTable:
111 | .space 1530 || (255*6)
112 |
113 | |
114 | | End of file
115 | |
116 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/duart.s:
--------------------------------------------------------------------------------
1 | |
2 | | duart.s
3 | |
4 | | Assembly language function giving access to the 68881 DUART.
5 | | (Adapted from 'MatrixMultiply.s' example).
6 | |
7 | | DJ 1996/11
8 | |
9 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | | WITH NO WARRANTY FOR ANY PURPOSE.
11 | |
12 |
13 | | Implements:
14 | | - _DUART_INIT: initialize the DUART (can be called from C)
15 | | - _DUART_GETC: get a character, returned in register D0 (can be called from C)
16 | | - _DUART_PUTC: output a character, expected in the stack (can be called from C)
17 | | - _DUART_PRINT: output a string of character (use A0 as parameter)
18 | | (DO NOT CALL FROM C!)
19 |
20 | .equ DUA_ADD, 0xeffc01
21 | .equ DUA_MR1A, 0
22 | .equ DUA_MR2A, 0
23 | .equ DUA_SRA, 2
24 | .equ DUA_CRA, 4
25 | .equ DUA_CSRA, 2
26 | .equ DUA_TBA, 6
27 | .equ DUA_RBA, 6
28 | .equ DUA_IMR, 10
29 | .equ DUA_TBB, 0x16
30 | .equ DUA_CRB, 0x14
31 | .equ DUA_MR1B, 0x10
32 | .equ DUA_MR2B, 0x10
33 | .equ DUA_SRB, 0x12
34 | .equ DUA_IVR, 0x18
35 | .equ LINEFEED, 10 | LineFeed Character value
36 | .equ CARR_RETURN, 13 | Carrage Return character value
37 |
38 | |
39 | | _DUART_INIT: Initialization of the duart
40 | |
41 | .global _DUART_INIT
42 | _DUART_INIT: MOVE.L A1,-(A7) | Save A1
43 | LEA DUA_ADD,A1
44 | ORI #0b0000011100000000,SR | Masks interrupts
45 | MOVE.B #0b00010000,(DUA_CRA,A1) | Reset MR?A pointer
46 | MOVE.B #0b00100011,(DUA_MR1A,A1) | 8 data bits
47 | MOVE.B #0b00010111,(DUA_MR2A,A1) | Normal Mode
48 | MOVE.B #0b10111011,(DUA_SRA,A1) | Set clock to 9600
49 | MOVE.B #0b00000101,(DUA_CRA,A1) | Enable Rx and Tx
50 | MOVE.L (A7)+,A1 | Restore A1
51 | RTS
52 |
53 | |
54 | | _DUART_PUTC: The character in the stack is transmitted to the CONSOLE ACIA.
55 | | The newline character is expanded into /.
56 | | Define a subroutine DUA_PUTC, which print the character contained in D0
57 | |
58 |
59 | DUA_PUTC: BTST #2,DUA_SRA+DUA_ADD | Test Transmit data register empty
60 | BEQ.S DUA_PUTC | If not keep polling
61 | MOVE.B D0,DUA_TBA+DUA_ADD | Transmit the character
62 | CMP.B #LINEFEED,D0 | Check for LINEFEED
63 | BNE DUA_PUTCEXT | if not L/F, exit
64 | MOVE.B #CARR_RETURN,D0 | Load CARR_RETURN into D0
65 | BRA DUA_PUTC | Output C/R
66 | DUA_PUTCEXT: RTS
67 |
68 | .global _DUART_PUTC
69 | _DUART_PUTC: LINK A6,#-2
70 | MOVE.L (8,A6),D0
71 | JSR DUA_PUTC
72 | UNLK A6
73 | RTS
74 |
75 | |
76 | | _DUART_GETC: Get a character from the CONSOLE ACIA and return it in D0
77 | |
78 |
79 | .global _DUART_GETC
80 | _DUART_GETC: BTST #0,DUA_SRA+DUA_ADD | Test Receive data register full
81 | BEQ.S _DUART_GETC | If not keep polling
82 | MOVE.B DUA_RBA+DUA_ADD,D0 | Read the character
83 | RTS
84 |
85 | |
86 | | _DUART_PRINT: print a string of charater, until null
87 | |
88 | .global _DUART_PRINT
89 | _DUART_PRINT: MOVE.L D0,-(A7) | Save register d0 to stack
90 | DUAPRLOOP: MOVE.B (A0)+,D0 | Get a character to print
91 | CMP.B #0x00,D0 | Is it null?
92 | BEQ DUAPRNTEND | yes: it's over
93 | JSR DUA_PUTC | no: print it
94 | BRA DUAPRLOOP | repeat
95 | DUAPRNTEND: MOVE.L (A7)+,D0 | Restore d0
96 | RTS
97 |
98 | |
99 | | End of file
100 | |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/jump.s:
--------------------------------------------------------------------------------
1 |
2 | |
3 | | jump.s
4 | |
5 | | DJ 1996/11
6 | |
7 | | USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
8 | | WITH NO WARRANTY FOR ANY PURPOSE.
9 | |
10 | | Assembly language functions providing the 'setjmp/longjmp'
11 | | functionality
12 | |
13 | | Implements:
14 | | - _setjmp
15 | | - _longjmp
16 |
17 | | jump buffer is
18 | | octet 0 to 4: a0
19 | | octet 4 to 60: a1-a7,d1-d7 (movem)
20 | | octet 60 to 64: tmp value (return value for longjmp)
21 | | octet 64 to 67: PC
22 |
23 | .global _setjmp
24 | _setjmp:
25 | | use freely D0
26 | | get jump-buffer address from stack in a0
27 | | stack contains:
28 | | 0-4 bytes: return address
29 | | 4-8 bytes: parameter
30 | | save a0 in d0
31 | movel a0,d0
32 | movel (4,a7),a0
33 | | save registers
34 | movel d0,(a0)
35 | moveml d1-d7/a1-a7,(4,a0)
36 | | save PC (return address is in the stack)
37 | movel (a7),a4
38 | movel a4,(64,a0)
39 |
40 | | return 0
41 | movel #0,d0
42 | rts
43 |
44 | .global _longjmp
45 | _longjmp:
46 | | use freely D0
47 | | get value to be returned from stack
48 | movel (8,a7),d0
49 | | get jump-buffer address from stack in a0
50 | movel (4,a7),a0
51 | | put return value in jump-buffer
52 | movel d0,(60,a0)
53 | | restore registers (especially SP)
54 | moveml (4,a0),d1-d7/a1-a7
55 | | restore PC
56 | movel (64,a0),d0
57 | movel d0,(a7)
58 | | restore d0
59 | movel (60,a0),d0
60 | | restore a0
61 | movel (a0),a0
62 | | return value in d0 has been set above.
63 | rts
64 |
65 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/libc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libc.h
3 | *
4 | * Declares some useful function of the C standard library
5 | * (should be standard header, such as 'stdio.h', 'string.h'...
6 | *
7 | * DJ (c) 1996
8 | *
9 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
10 | * WITH NO WARRANTY FOR ANY PURPOSE.
11 | */
12 |
13 | #ifndef LIBC_H
14 | #define LIBC_H
15 |
16 | /* stdio.h */
17 | #define NULL ((void*)0)
18 | extern void puts(const char*);
19 | extern void gets(char*);
20 | extern void putchar(char);
21 |
22 | /* string.h */
23 | extern char *strcpy(char* s1, const char *s2);
24 | extern int strlen(const char *s);
25 | extern int strcmp(const char *s1, const char *s2);
26 | extern int strncmp(const char *s1, const char *s2, int n);
27 |
28 | /* memory.h */
29 | extern void *memset(void* addr, int value, int length);
30 | extern void bcopy(char *b1, char*b2, int length);
31 |
32 | /* stdlib.h */
33 | extern int atoi(const char *s);
34 |
35 | /* setjmp.h */
36 | typedef char jmp_buf[68];
37 | extern int setjmp(jmp_buf);
38 | extern int longjmp(jmp_buf,int);
39 |
40 | /* SPECIFIC */
41 | extern void itoa(unsigned short value, char* s);
42 | extern void itox(unsigned short value, char* s);
43 |
44 | #endif /* LIBC_H */
45 |
46 | /*
47 | * End of file
48 | */
49 |
50 |
51 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/mstub.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mstub.h
3 | *
4 | * Definitions for gdb stub (extracted from m68k-stub.c)
5 | *
6 | * DJ, July 96.
7 | *
8 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
9 | * WITH NO WARRANTY FOR ANY PURPOSE.
10 | */
11 |
12 | #ifndef MSTUB_H
13 | #define MSTUB_H
14 |
15 | /* there are 180 bytes of registers on a 68020 w/68881
16 | * many of the fpa registers are 12 byte (96 bit) registers
17 | */
18 | /* only 16*4+4+4=72 on a 68000/CPU32 ! */
19 | #if 0
20 | #define NUMREGBYTES 180
21 | #else
22 | #define NUMREGBYTES 72
23 | #endif
24 | enum regnames {D0,D1,D2,D3,D4,D5,D6,D7,
25 | A0,A1,A2,A3,A4,A5,A6,A7,
26 | PS,PC,
27 | FP0,FP1,FP2,FP3,FP4,FP5,FP6,FP7,
28 | FPCONTROL,FPSTATUS,FPIADDR
29 | };
30 |
31 |
32 | /* We keep a whole frame cache here. "Why?", I hear you cry, "doesn''t
33 | * GDB handle that sort of thing?" Well, yes, I believe the only
34 | * reason for this cache is to save and restore floating point state
35 | * (fsave/frestore). A cleaner way to do this would be to make the
36 | * fsave data part of the registers which GDB deals with like any
37 | * other registers. This should not be a performance problem if the
38 | * ability to read individual registers is added to the protocol.
39 | */
40 |
41 | typedef struct FrameStruct
42 | {
43 | struct FrameStruct *previous;
44 | int exceptionPC; /* pc value when this frame created */
45 | int exceptionVector; /* cpu vector causing exception */
46 | short frameSize; /* size of cpu frame in words */
47 | short sr; /* for 68000, this not always sr */
48 | int pc;
49 | short format;
50 | int fsaveHeader;
51 | int morejunk[0]; /* exception frame, fp save... */
52 | } Frame;
53 |
54 | #define FRAMESIZE 500
55 |
56 | extern int*stackPtr;
57 |
58 | extern void handle_exception(int exceptionVector);
59 | extern Frame *lastFrame;
60 |
61 | #endif /* MSTUB_H */
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/test7.bin.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test7.bin.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test7.bin)
25 | OUTPUT_FORMAT(a.out-sunos-big)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/test7.cmd:
--------------------------------------------------------------------------------
1 | /*
2 | * test7.cmd: command file for gnu ld
3 | *
4 | * DJ (c) 1996
5 | *
6 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
7 | * WITH NO WARRANTY FOR ANY PURPOSE.
8 | *
9 | */
10 |
11 | MEMORY
12 | {
13 | ram : ORIGIN = 0, LENGTH = 0x10000
14 | device : ORIGIN = 0xeffc00, LENGTH = 0x100
15 | }
16 |
17 | SECTIONS
18 | {
19 | .data 0x0 : { boot2.o (.data) }
20 | .text 0x1000 : { *(.text) }
21 | .text 0xA000 : { *(.data) }
22 | }
23 |
24 | OUTPUT(test7.H68)
25 | OUTPUT_FORMAT(srec)
26 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/test7.setup:
--------------------------------------------------------------------------------
1 | BSVC Simulator Setup File
2 |
3 | UI_VERSION {2.0}
4 | SIMULATOR {sim68000}
5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 10000}}
6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = effc00 OffsetToFirstRegister = 1 OffsetBetweenRegisters = 2 InterruptLevel = 4 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "Port A" -n "Port A" -fn fixed -e xtermpipe PortBCommand = }}
7 | COMMAND {AttachDevice 0 GdbSocket {BaseAddress = e0000 PortNumber = 4545}}
8 |
--------------------------------------------------------------------------------
/samples/m68360/gdb7/ustub.c:
--------------------------------------------------------------------------------
1 | /*
2 | * ustub.c
3 | *
4 | * Utilities functions for gdb stub
5 | *
6 | * DJ, July 96.
7 | *
8 | * USUAL DISCLAIMER: THIS EXAMPLE IS PROVIDED AS IS
9 | * WITH NO WARRANTY FOR ANY PURPOSE.
10 | */
11 |
12 | #include "ustub.h"
13 |
14 |
15 | /*=====================================================================*/
16 | const char hexchars[]="0123456789abcdef";
17 | /*=====================================================================*/
18 |
19 | /*=====================================================================*/
20 | int hex(char ch)
21 | /*=====================================================================*/
22 | {
23 | if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10);
24 | if ((ch >= '0') && (ch <= '9')) return (ch-'0');
25 | if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10);
26 | return (-1);
27 | }
28 |
29 |
30 | /*=====================================================================*/
31 | int hexToInt(char **ptr, int *intValue)
32 | /*=====================================================================*/
33 | {
34 | int numChars = 0;
35 | int hexValue;
36 |
37 | *intValue = 0;
38 |
39 | while (**ptr)
40 | {
41 | hexValue = hex(**ptr);
42 | if (hexValue >=0)
43 | {
44 | *intValue = (*intValue <<4) | hexValue;
45 | numChars ++;
46 | }
47 | else
48 | break;
49 |
50 | (*ptr)++;
51 | }
52 |
53 | return (numChars);
54 | }
55 |
56 | /*=====================================================================*/
57 | char* mem2hex(char* mem, char* buf, int count)
58 | /*=====================================================================*/
59 | {
60 | /* convert the memory pointed to by mem into hex, placing result in buf
61 | * return a pointer to the last char put in buf (null)
62 | */
63 | int i;
64 | unsigned char ch;
65 |
66 | for (i=0;i> 4];
70 | *buf++ = hexchars[ch % 16];
71 | }
72 | *buf = 0;
73 | return(buf);
74 | }
75 |
76 | /*=====================================================================*/
77 | char* hex2mem(char *buf, char *mem, int count)
78 | /*=====================================================================*/
79 | {
80 | /* convert the hex array pointed to by buf into binary to be placed
81 | * in mem. return a pointer to the character AFTER the last byte
82 | * written.
83 | */
84 | int i;
85 | unsigned char ch;
86 |
87 | for (i=0;i
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | }}}
15 |
16 | ###############################################################################
17 |
18 | Global:
19 |
20 | Package=<5>
21 | {{{
22 | }}}
23 |
24 | Package=<3>
25 | {{{
26 | }}}
27 |
28 | ###############################################################################
29 |
30 |
--------------------------------------------------------------------------------
/src/Assemblers/68kasm/globals.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | *
3 | * GLOBALS.C
4 | * Global Variable Declarations for 68000 Assembler
5 | *
6 | * Author: Paul McKee
7 | * ECE492 North Carolina State University
8 | *
9 | * Date: 12/13/86
10 | *
11 | * Copyright 1990-1991 North Carolina State University. All Rights Reserved.
12 | *
13 | *****************************************************************************/
14 |
15 |
16 | #include
17 | #include "asm.h"
18 |
19 |
20 | /* General */
21 |
22 | int loc; /* The assembler's location counter */
23 | char pass2; /* Flag telling whether or not it's the second pass */
24 | char endFlag; /* Flag set when the END directive is encountered */
25 |
26 |
27 | /* File pointers */
28 |
29 | FILE *inFile; /* Input file */
30 | FILE *listFile; /* Listing file */
31 | FILE *objFile; /* Object file */
32 |
33 |
34 | /* Listing information */
35 |
36 | char line[256]; /* Source line */
37 | int lineNum; /* Source line number */
38 | char *listPtr; /* Pointer to buffer where a listing line is assembled */
39 | char continuation; /* TRUE if the listing line is a continuation */
40 |
41 |
42 | /* Option flags with default values */
43 |
44 | char listFlag = FALSE; /* True if a listing is desired */
45 | char objFlag = TRUE; /* True if an object code file is desired */
46 | char xrefFlag = FALSE; /* True if a cross-reference is desired */
47 | char cexFlag = FALSE; /* True is Constants are to be EXpanded */
48 | char absLongFlag = FALSE; /* True if all long absolute addresses */
49 |
--------------------------------------------------------------------------------
/src/Assemblers/68kasm/include.c:
--------------------------------------------------------------------------------
1 | //
2 | // Handle INCLUDE directives in the source code
3 | //
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | char *
11 | buildCompleteSourceFile(FILE *currentFile, char *currentFileName,
12 | FILE *completeFile, int level)
13 | {
14 | char buffer[2048], directive[2048], operand[2048], *error;
15 |
16 | /* Make sure we don't loop forever */
17 | if (level > 15)
18 | return ("Too many nested INCLUDEs\n");
19 |
20 | while (fgets(buffer, sizeof(buffer), currentFile) != NULL) {
21 | if (sscanf(buffer, "%s %s", directive, operand) != 2) {
22 | fprintf(completeFile, "%s", buffer);
23 | continue;
24 | }
25 | for (int i = 0; i < strlen(directive); ++i)
26 | directive[i] = tolower(directive[i]);
27 | if (strcmp(directive, "include") == 0) {
28 | FILE *includeFile = fopen(operand, "r");
29 | if (!includeFile) {
30 | const char *fmt =
31 | "Could not find INCLUDE file: %s\n"
32 | " for file: %s\n";
33 | size_t len = strlen(operand) +
34 | strlen(currentFileName) +
35 | strlen(fmt) + 1;
36 | char *tmp = malloc(len);
37 | snprintf(tmp, len, fmt,
38 | operand, currentFileName);
39 | return tmp;
40 | }
41 | error = buildCompleteSourceFile(includeFile,
42 | operand,
43 | completeFile,
44 | level + 1);
45 | fclose(includeFile);
46 | if (error) {
47 | return error;
48 | }
49 | continue;
50 | }
51 | fprintf(completeFile, "%s", buffer);
52 | }
53 |
54 | return NULL;
55 | }
56 |
--------------------------------------------------------------------------------
/src/Assemblers/68kasm/instlookup.c:
--------------------------------------------------------------------------------
1 | //
2 | // INSTLOOKUP.C
3 | // Instruction Table Lookup Routine for 68000 Assembler
4 | //
5 | // Function: instLookup()
6 | // Parses an instruction and looks it up in the instruction
7 | // table. The input to the function is a pointer to the
8 | // instruction on a line of assembly code. The routine
9 | // scans the instruction and notes the size code if
10 | // present. It then (binary) searches the instruction
11 | // table for the specified opcode. If it finds the opcode,
12 | // it returns a pointer to the instruction table entry for
13 | // that instruction (via the instPtrPtr argument) as well
14 | // as the size code or 0 if no size was specified (via the
15 | // sizePtr argument). If the opcode is not in the
16 | // instruction table, then the routine returns INV_OPCODE.
17 | // The routine returns an error value via the standard
18 | // mechanism.
19 | //
20 | // Usage: char *instLookup(p, instPtrPtr, sizePtr, errorPtr)
21 | // char *p;
22 | // instruction *(*instPtrPtr);
23 | // char *sizePtr;
24 | // int *errorPtr;
25 | //
26 | // Errors: SYNTAX
27 | // INV_OPCODE
28 | // INV_SIZE_CODE
29 | //
30 | // Author: Paul McKee
31 | // ECE492 North Carolina State University
32 | //
33 | // Date: 9/24/86
34 | //
35 | // Copyright 1990-1991 North Carolina State University. All Rights Reserved.
36 | //
37 |
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | #include "asm.h"
44 |
45 | extern instruction instTable[];
46 | extern int tableSize;
47 |
48 | char *
49 | instLookup(char *p, instruction * (*instPtrPtr), char *sizePtr, int *errorPtr)
50 | {
51 | char opcode[8];
52 | int i, hi, lo, mid, cmp;
53 |
54 | i = 0;
55 | do {
56 | if (i < 7)
57 | opcode[i++] = *p;
58 | p++;
59 | } while (isalpha(*p));
60 | opcode[i] = '\0';
61 | if (*p == '.')
62 | if (isspace(p[2]) || !p[2]) {
63 | if (p[1] == 'B')
64 | *sizePtr = BYTE;
65 | else if (p[1] == 'W')
66 | *sizePtr = WORD;
67 | else if (p[1] == 'L')
68 | *sizePtr = LONG;
69 | else if (p[1] == 'S')
70 | *sizePtr = SHORT;
71 | else {
72 | *sizePtr = 0;
73 | NEWERROR(*errorPtr, INV_SIZE_CODE);
74 | }
75 | p += 2;
76 | } else {
77 | NEWERROR(*errorPtr, SYNTAX);
78 | return NULL;
79 | } else if (!isspace(*p) && *p) {
80 | NEWERROR(*errorPtr, SYNTAX);
81 | return NULL;
82 | } else
83 | *sizePtr = 0;
84 |
85 | lo = 0;
86 | hi = tableSize - 1;
87 | do {
88 | mid = (hi + lo) / 2;
89 | cmp = strcmp(opcode, instTable[mid].mnemonic);
90 | if (cmp > 0)
91 | lo = mid + 1;
92 | else if (cmp < 0)
93 | hi = mid - 1;
94 | } while (cmp && (hi >= lo));
95 | if (!cmp) {
96 | *instPtrPtr = &instTable[mid];
97 | return p;
98 | } else {
99 | NEWERROR(*errorPtr, INV_OPCODE);
100 | return NULL;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/Assemblers/68kasm/listing.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | *
3 | * LISTING.C
4 | * Listing File Routines for 68000 Assembler
5 | *
6 | * Function: initList()
7 | * Opens the specified listing file for writing. If the
8 | * file cannot be opened, then the routine prints a
9 | * message and exits.
10 | *
11 | * listLine()
12 | * Writes the current listing line to the listing file. If
13 | * the line is not a continuation, then the routine
14 | * includes the source line as the last part of the
15 | * listing line. If an error occurs during the writing,
16 | * the routine prints a message and exits.
17 | *
18 | * listLoc()
19 | * Starts the process of assembling a listing line by
20 | * printing the location counter value into listData and
21 | * initializing listPtr.
22 | *
23 | * listObj()
24 | * Prints the data whose size and value are specified in
25 | * the object field of the current listing line. Bytes are
26 | * printed as two digits, words as four digits, and
27 | * longwords as eight digits, and a space follows each
28 | * group of digits.
29 | * If the item to be printed will not fit in the
30 | * object code field, one of two things will occur. If
31 | * cexFlag is TRUE, then the current listing line will be
32 | * output to the listing file and the data will be printed
33 | * on a continuation line. Otherwise, elipses ("...") will
34 | * be printed to indicate the omission of values from the
35 | * listing, and the data will not be added to the file.
36 | *
37 | * Usage: initList(name)
38 | * char *name;
39 | *
40 | * listLine()
41 | *
42 | * listLoc()
43 | *
44 | * listObj(data, size)
45 | * int data, size;
46 | *
47 | * Author: Paul McKee
48 | * ECE492 North Carolina State University
49 | *
50 | * Date: 12/13/86
51 | *
52 | * Copyright 1990-1991 North Carolina State University. All Rights Reserved.
53 | *
54 | *****************************************************************************/
55 |
56 | #include
57 | #include
58 | #include
59 | #include
60 |
61 | #include "asm.h"
62 |
63 | /* Declarations of global variables */
64 | extern int loc;
65 | extern char pass2, cexFlag, continuation;
66 | extern char line[256];
67 | extern FILE *listFile;
68 | extern int lineNum;
69 |
70 | static char listData[49]; // Buffer in which listing lines are assembled
71 | extern char *listPtr; // Pointer to above buffer (this pointer is
72 | // global because it is actually manipulated
73 | // by equ() and set() to put specially formatted
74 | // information in the listing)
75 |
76 | void
77 | initList(char *name)
78 | {
79 |
80 | listFile = fopen(name, "w");
81 | if (!listFile) {
82 | puts("Can't open listing file");
83 | exit(1);
84 | }
85 | }
86 |
87 | void
88 | listLine(void)
89 | {
90 |
91 | fprintf(listFile, "%-41.41s", listData);
92 | if (!continuation)
93 | fprintf(listFile, "%5d %s", lineNum, line);
94 | else
95 | putc('\n', listFile);
96 | if (ferror(listFile)) {
97 | fputs("Error writing to listing file\n", stderr);
98 | exit(1);
99 | }
100 | }
101 |
102 |
103 | void
104 | listLoc(void)
105 | {
106 | sprintf(listData, "%08X ", loc);
107 | listPtr = listData + 10;
108 | }
109 |
110 | void
111 | listObj(int data, int size)
112 | {
113 | if (!cexFlag && (listPtr - listData + size > 40)) {
114 | strcpy(listData + ((size == WORD) ? 35 : 37), "...");
115 | return;
116 | }
117 | if (cexFlag && (listPtr - listData + size > 40)) {
118 | listLine();
119 | strcpy(listData, " ");
120 | listPtr = listData + 10;
121 | continuation = TRUE;
122 | }
123 | switch (size) {
124 | case BYTE:
125 | sprintf(listPtr, "%02X ", data & 0xFF);
126 | listPtr += 3;
127 | break;
128 | case WORD:
129 | sprintf(listPtr, "%04X ", data & 0xFFFF);
130 | listPtr += 5;
131 | break;
132 | case LONG:
133 | sprintf(listPtr, "%08X ", data);
134 | listPtr += 9;
135 | break;
136 | default:
137 | printf("LISTOBJ: INVALID SIZE CODE!\n");
138 | exit(1);
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/src/Framework/AddressSpace.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Maintains a list of devices and provides methods to
3 | // peek and poke into them.
4 | //
5 |
6 | #ifndef FRAMEWORK_ADDRESSSPACE_HPP_
7 | #define FRAMEWORK_ADDRESSSPACE_HPP_
8 |
9 | #include
10 | #include
11 |
12 | #include "Framework/Types.hpp"
13 |
14 | class BasicDevice;
15 |
16 | // Size Constants
17 | enum {
18 | BYTE,
19 | WORD,
20 | LONG,
21 | };
22 |
23 | class AddressSpace {
24 | public:
25 | // Used to retrieve information about attached devices.
26 | struct DeviceInformation {
27 | std::string name;
28 | std::string arguments;
29 | size_t index;
30 | };
31 |
32 | public:
33 | AddressSpace(Address maximumAddress);
34 | virtual ~AddressSpace();
35 |
36 | // Returns the maximum address of the address space.
37 | Address MaximumAddress() const { return myMaximumAddress; }
38 |
39 | // Attaches the given device. Returns true iff successful.
40 | bool AttachDevice(BasicDevice *);
41 |
42 | // Detaches and destroys the indexed device. Returns true iff successful.
43 | bool DetachDevice(size_t index);
44 |
45 | // Resets all the attached devices.
46 | void Reset();
47 |
48 | // Returns the number of attached devices
49 | size_t NumberOfAttachedDevices() const;
50 |
51 | // Gets information about the indexed device. Returns true iff successful.
52 | bool GetDeviceInformation(size_t index,
53 | AddressSpace::DeviceInformation &info) const;
54 |
55 | // Peeks the given location. Returns true iff successful.
56 | virtual bool Peek(Address addr, Byte &c);
57 |
58 | // Pokes the given location. Returns true iff successful.
59 | virtual bool Poke(Address addr, Byte c);
60 |
61 | // Peeks the given location. Returns true iff successful.
62 | virtual bool Peek(Address addr, unsigned long &d, int size);
63 |
64 | // Pokes the given location. Returns true iff successful.
65 | virtual bool Poke(Address addr, unsigned long d, int size);
66 |
67 | private:
68 | BasicDevice *FindCachedDevice(Address address,
69 | std::vector &cache);
70 | BasicDevice *FindReadDevice(Address address);
71 | BasicDevice *FindWriteDevice(Address address);
72 |
73 | // Attached devices.
74 | std::vector devices;
75 |
76 | // Maximum address for this address space in CPU words (not bytes).
77 | const Address myMaximumAddress;
78 |
79 | // Device caches.
80 | std::vector rcache;
81 | std::vector wcache;
82 | };
83 |
84 | #endif // FRAMEWORK_ADDRESSSPACE_HPP_
85 |
--------------------------------------------------------------------------------
/src/Framework/BasicCPU.cpp:
--------------------------------------------------------------------------------
1 | // This is the abstract base class for all microprocessors
2 |
3 | #include "Framework/BasicCPU.hpp"
4 |
5 | BasicCPU::BasicCPU(const std::string &name, int granularity,
6 | std::vector &addressSpaces,
7 | const std::string &traceRecordFormat,
8 | const std::string &defaultTraceRecordEntries)
9 | : myAddressSpaces(addressSpaces),
10 | myName(name),
11 | myGranularity(granularity),
12 | myExecutionTraceRecord(traceRecordFormat),
13 | myDefaultExecutionTraceEntries(defaultTraceRecordEntries) { }
14 |
15 | BasicCPU::~BasicCPU() { }
16 |
--------------------------------------------------------------------------------
/src/Framework/BasicCPU.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Abstract base class for all microprocessors
3 | //
4 |
5 | #ifndef FRAMEWORK_BASICCPU_HPP_
6 | #define FRAMEWORK_BASICCPU_HPP_
7 |
8 | #include
9 | #include
10 |
11 | #include "Framework/Types.hpp"
12 | #include "Framework/AddressSpace.hpp"
13 | #include "Framework/Event.hpp"
14 |
15 | class BasicCPU;
16 | class BasicDevice;
17 | class RegisterInformationList;
18 | class StatisticalInformationList;
19 | class AddressSpace;
20 |
21 | class BasicCPU {
22 | public:
23 | BasicCPU(const std::string &name,
24 | int granularity,
25 | std::vector &addressSpaces,
26 | const std::string &traceRecordFormat,
27 | const std::string &defaultTraceRecordEntries);
28 | virtual ~BasicCPU();
29 |
30 | // Returns name of the microprocessor.
31 | const std::string &Name() const { return myName; }
32 |
33 | // Returns the granularity of the microprocessor.
34 | unsigned int Granularity() const { return myGranularity; }
35 |
36 | // Returns a reference to my event handler.
37 | EventHandler &eventHandler() { return myEventHandler; };
38 |
39 | // Returns the number of address spaces used by the processor.
40 | size_t NumberOfAddressSpaces() const { return myAddressSpaces.size(); }
41 |
42 | // Returns the execution trace record format.
43 | const std::string &ExecutionTraceRecord() const { return myExecutionTraceRecord; }
44 |
45 | // Returns the default execution trace entries.
46 | const std::string &DefaultExecutionTraceEntries() const {
47 | return myDefaultExecutionTraceEntries;
48 | }
49 |
50 | // Returns the indexed address space object.
51 | AddressSpace &addressSpace(size_t addressSpace) {
52 | return *myAddressSpaces[addressSpace];
53 | }
54 |
55 | // Executes the next instruction. Returns an error message or the empty string.
56 | virtual std::string ExecuteInstruction(std::string &traceRecord, bool trace) = 0;
57 |
58 | // Handles an interrupt request from a device.
59 | virtual void InterruptRequest(BasicDevice *device, int level) = 0;
60 |
61 | // Performs a system reset.
62 | virtual void Reset() = 0;
63 |
64 | // Returns value of the program counter register.
65 | virtual Address ValueOfProgramCounter() = 0;
66 |
67 | // Sets named register to the given hexidecimal value.
68 | virtual void SetRegister(const std::string &name, const std::string &hexValue) = 0;
69 |
70 | // Clears the CPU's Statistics.
71 | virtual void ClearStatistics() = 0;
72 |
73 | // Appends all of the CPU's registers to the RegisterInformationList object.
74 | virtual void BuildRegisterInformationList(RegisterInformationList &) = 0;
75 |
76 | // Appends all of the CPU's stats to the StatisticalInformationList object.
77 | virtual void
78 | BuildStatisticalInformationList(StatisticalInformationList &) = 0;
79 |
80 | protected:
81 | // Array of address space objects.
82 | std::vector myAddressSpaces;
83 |
84 | // My event handler.
85 | EventHandler myEventHandler;
86 |
87 | private:
88 | // My name.
89 | const std::string myName;
90 |
91 | // CPU address granularity in bytes.
92 | const unsigned int myGranularity;
93 |
94 | // Trace record format used by the ExecuteInstruction member function.
95 | std::string myExecutionTraceRecord;
96 |
97 | // Default fields of the trace record that should be displayed by UI.
98 | std::string myDefaultExecutionTraceEntries;
99 | };
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/src/Framework/BasicDevice.cpp:
--------------------------------------------------------------------------------
1 | #include "Framework/BasicDevice.hpp"
2 | #include "Framework/BasicCPU.hpp"
3 |
4 | BasicDevice::BasicDevice(const std::string &name, const std::string &args, BasicCPU &cpu)
5 | : EventBase(cpu.eventHandler()), myCPU(cpu), myName(name),
6 | myArguments(args), myInterruptPending(false) {}
7 |
8 | BasicDevice::~BasicDevice() {}
9 |
10 | // Reset device - At the very least the interrupt pending flag has to be reset
11 | void BasicDevice::Reset() { myInterruptPending = false; }
12 |
13 | // This routine should set myInterruptPending flag and send a request
14 | // to the CPU for an interrupt.
15 | void BasicDevice::InterruptRequest(int level) {
16 | // If no interrupt is pending then request one
17 | if (!myInterruptPending) {
18 | myInterruptPending = true;
19 | myCPU.InterruptRequest(this, level);
20 | }
21 | }
22 |
23 | // This routine is called by the CPU when it processes a requested interrupt.
24 | // It should return the vector number associated with the interrupt or
25 | // AUTOVECTOR_INTERRUPT if the device doesn't generate vectors. This default
26 | // routine only does autovector interrupts.
27 | int BasicDevice::InterruptAcknowledge(unsigned int) {
28 | if (myInterruptPending) {
29 | myInterruptPending = false;
30 | return AUTOVECTOR_INTERRUPT;
31 | } else {
32 | return SPURIOUS_INTERRUPT;
33 | }
34 | }
35 |
36 | // Default Peek implementation, for devices not supporting 'size' Peek.
37 | bool BasicDevice::Peek(Address address, unsigned long &data, int size) {
38 | switch (size) {
39 | case BYTE:
40 | data = (unsigned long)Peek(address);
41 | break;
42 |
43 | case WORD:
44 | data = (unsigned long)(Peek(address) * 0x100 + Peek(address + 1));
45 | break;
46 |
47 | case LONG:
48 | data = (unsigned long)((Peek(address) << 24) + (Peek(address + 1) << 16) +
49 | (Peek(address + 2) << 8) + (Peek(address + 3)));
50 | break;
51 |
52 | default:
53 | return false;
54 | }
55 | return true;
56 | }
57 |
58 | // Default Poke implementation, for devices not supporting 'size' Poke.
59 | bool BasicDevice::Poke(Address address, unsigned long data, int size) {
60 | switch (size) {
61 | case BYTE:
62 | Poke(address, (Byte)data);
63 | break;
64 | case WORD:
65 | Poke(address + 1, (Byte)data);
66 | Poke(address, (Byte)(data >> 8));
67 | break;
68 | case LONG:
69 | Poke(address + 3, (Byte)data);
70 | Poke(address + 2, (Byte)(data >> 8));
71 | Poke(address + 1, (Byte)(data >> 16));
72 | Poke(address + 0, (Byte)(data >> 24));
73 | break;
74 | default:
75 | return false;
76 | }
77 | return true;
78 | }
79 |
--------------------------------------------------------------------------------
/src/Framework/BasicDevice.hpp:
--------------------------------------------------------------------------------
1 | // The base class for all devices
2 |
3 | #ifndef FRAMEWORK_BASICDEVICE_HPP_
4 | #define FRAMEWORK_BASICDEVICE_HPP_
5 |
6 | #include
7 |
8 | #include "Framework/Types.hpp"
9 | #include "Framework/Event.hpp"
10 |
11 | class BasicCPU;
12 |
13 | constexpr int AUTOVECTOR_INTERRUPT = -1;
14 | constexpr int SPURIOUS_INTERRUPT = -2;
15 |
16 | class BasicDevice : public EventBase {
17 | public:
18 | BasicDevice(const std::string &name, const std::string &arguments, BasicCPU &cpu);
19 | ~BasicDevice() override;
20 |
21 | void ErrorMessage(const std::string &message) { myErrorMessage = message; }
22 | const std::string &ErrorMessage() const { return myErrorMessage; }
23 | const std::string &Name() const { return myName; }
24 | BasicCPU &CPU() const { return myCPU; }
25 | const std::string &Arguments() const { return myArguments; }
26 |
27 | // Returns true iff the address maps into the device.
28 | virtual bool CheckMapped(Address) const = 0;
29 |
30 | // Returns the lowest address used by the device.
31 | virtual Address LowestAddress() const = 0;
32 |
33 | // Returns the highest address used by the device.
34 | virtual Address HighestAddress() const = 0;
35 |
36 | // Gets a byte from the device.
37 | virtual Byte Peek(Address address) = 0;
38 |
39 | // Puts a byte into the device.
40 | virtual void Poke(Address address, Byte c) = 0;
41 |
42 | // Gets data from the device.
43 | virtual bool Peek(Address address, unsigned long &data, int size);
44 |
45 | // Puts data into the device.
46 | virtual bool Poke(Address address, unsigned long data, int size);
47 |
48 | // Resets the device.
49 | virtual void Reset();
50 |
51 | // Sends an interrupt request (IRQ) to the CPU.
52 | virtual void InterruptRequest(int level);
53 |
54 | // Called by the CPU when it processes an interrupt.
55 | virtual int InterruptAcknowledge(unsigned int level);
56 |
57 | protected:
58 | // Reference to the CPU I belong to.
59 | BasicCPU &myCPU;
60 |
61 | // My name (i.e. RAM, ROM, etc).
62 | const std::string myName;
63 |
64 | // Arguments passed to constructor.
65 | const std::string myArguments;
66 |
67 | // Error that occured during construction.
68 | std::string myErrorMessage;
69 |
70 | // Interrupt pending flag.
71 | bool myInterruptPending;
72 | };
73 |
74 | #endif // FRAMEWORK_BASICDEVICE_HPP_
75 |
--------------------------------------------------------------------------------
/src/Framework/BasicDeviceRegistry.cpp:
--------------------------------------------------------------------------------
1 | #include "Framework/BasicDeviceRegistry.hpp"
2 |
3 | bool BasicDeviceRegistry::Information(size_t i, DeviceInformation &info) {
4 | if (i < myNumberOfDevices) {
5 | info = myDevices[i];
6 | return true;
7 | }
8 | return false;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Framework/BasicDeviceRegistry.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // This abstract base class is used to derive a class that maintains a list
3 | // of all the device in the simulator and allows them to be created.
4 | //
5 |
6 | #ifndef FRAMEWORK_BASICDEVICEREGISTRY_HPP_
7 | #define FRAMEWORK_BASICDEVICEREGISTRY_HPP_
8 |
9 | #include
10 |
11 | class BasicCPU;
12 | class BasicDevice;
13 |
14 | // Device information structure.
15 | struct DeviceInformation {
16 | std::string name; // The name of the device ("RAM", "M68681", etc).
17 | std::string description; // A short description of the device.
18 | std::string script; // UI script to get the device attachment args.
19 | };
20 |
21 | class BasicDeviceRegistry {
22 | public:
23 | BasicDeviceRegistry(const DeviceInformation *devices, unsigned int number)
24 | : myDevices(devices), myNumberOfDevices(number) { }
25 | virtual ~BasicDeviceRegistry() { }
26 |
27 | // Returns the number of devices
28 | unsigned int NumberOfDevices() { return myNumberOfDevices; }
29 |
30 | // Gets device information. Returns true iff successful.
31 | bool Information(size_t index, DeviceInformation &information);
32 |
33 | // Creates a device. Returns true iff successful.
34 | virtual bool Create(const std::string &name,
35 | const std::string &args,
36 | BasicCPU &cpu,
37 | BasicDevice *&device) = 0;
38 |
39 | private:
40 | // Array of devices in the simulator.
41 | const DeviceInformation *myDevices;
42 |
43 | // Number of devices in the simulator.
44 | const unsigned int myNumberOfDevices;
45 | };
46 |
47 | #endif // FRAMEWORK_BASICDEVICEREGISTRY_HPP_
48 |
--------------------------------------------------------------------------------
/src/Framework/BasicLoader.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // This abstract base class provides methods to load object files into the
3 | // the simulator.
4 | //
5 |
6 | #ifndef FRAMEWORK_BASICLOADER_HPP_
7 | #define FRAMEWORK_BASICLOADER_HPP_
8 |
9 | #include
10 |
11 | class BasicCPU;
12 |
13 | class BasicLoader {
14 | public:
15 | BasicLoader(BasicCPU &c) : myCPU(c) { }
16 | virtual ~BasicLoader() { }
17 |
18 | BasicCPU &CPU() { return myCPU; }
19 |
20 | // Loads the named file and answers an error message or the empty string.
21 | virtual std::string Load(const std::string &filename, int addressSpace) = 0;
22 |
23 | protected:
24 | // Load into this CPU.
25 | BasicCPU &myCPU;
26 | };
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/Framework/BreakpointList.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Manage breakpoints.
3 | //
4 |
5 | #ifndef FRAMEWORK_BREAKPOINTLIST_HPP_
6 | #define FRAMEWORK_BREAKPOINTLIST_HPP_
7 |
8 | #include
9 | #include
10 |
11 | class BreakpointList {
12 | public:
13 | // Adds a break point to the list.
14 | void Add(Address address) {
15 | breakpoints.insert(address);
16 | }
17 |
18 | // Deletes a break point from the list.
19 | // Returns true iff breakpoint was in the set.
20 | bool Delete(Address address) {
21 | return breakpoints.erase(address) == 1;
22 | }
23 |
24 | // Returns the number of breakpoints currently in the set.
25 | size_t NumberOfBreakpoints() const {
26 | return breakpoints.size();
27 | }
28 |
29 | // Gets the breakpoint with the given index.
30 | // Returns true iff the address was in the set.
31 | bool GetBreakpoint(size_t index, Address &address) const {
32 | if (index >= breakpoints.size()) { return false; }
33 | auto it = breakpoints.begin();
34 | std::advance(it, index);
35 | address = *it;
36 | return true;
37 | }
38 |
39 | // Returns true iff the given address is a breakpoint.
40 | bool Check(Address address) const {
41 | return breakpoints.find(address) != breakpoints.end();
42 | }
43 |
44 | private:
45 | std::set breakpoints;
46 | };
47 |
48 | #endif // FRAMEWORK_BREAKPOINTLIST_HPP_
49 |
--------------------------------------------------------------------------------
/src/Framework/Event.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "Framework/Event.hpp"
5 | #include "Framework/Time.hpp"
6 |
7 | EventHandler::EventHandler() : myIterations(0), myNSPerCheck(1000) {
8 | myOldTime = Time::seconds();
9 | }
10 |
11 | EventBase::~EventBase() {
12 | // Remove any events in the EventHandler for this object
13 | myEventHandler.Remove(this);
14 | }
15 |
16 | // Checks for a expired events.
17 | void EventHandler::Check() {
18 | myIterations = std::max(myIterations + 1, 1);
19 | auto now = Time::seconds();
20 | if (now > myOldTime) {
21 | constexpr NanoSeconds NS_PER_SECOND{1000000000L};
22 | NanoSeconds delta_ns = (now - myOldTime) * NS_PER_SECOND;
23 | myNSPerCheck = std::max(delta_ns / myIterations, 1);
24 | myOldTime = now;
25 | myIterations = 0;
26 | }
27 | if (myEvents.empty()) {
28 | return;
29 | }
30 | std::vector runnables;
31 | auto nsec = myNSPerCheck;
32 | do {
33 | runnables.clear();
34 | auto it = myEvents.begin();
35 | for (; it != myEvents.end() && it->delta_time <= nsec; ++it) {
36 | nsec -= it->delta_time;
37 | runnables.push_back(*it);
38 | }
39 | myEvents.erase(myEvents.begin(), it);
40 | if (!myEvents.empty()) {
41 | myEvents[0].delta_time -= nsec;
42 | }
43 | for (auto event : runnables) { event.Dispatch(); }
44 | } while (!runnables.empty());
45 | }
46 |
47 | // Adds an event to the event list.
48 | void EventHandler::Add(EventBase *object, int data, void *pointer, USeconds etime) {
49 | Event event{object, data, pointer, etime};
50 | event.delta_time = etime * 1000; // Time in nanoseconds.
51 | NanoSeconds adelta = 0;
52 | auto it = myEvents.begin();
53 | for (; it != myEvents.end(); ++it) {
54 | if (etime < (adelta + it->delta_time)) { break; }
55 | adelta += it->delta_time;
56 | }
57 | event.delta_time -= adelta;
58 | if (it != myEvents.end()) {
59 | it->delta_time -= event.delta_time;
60 | }
61 | myEvents.insert(it, event);
62 | }
63 |
64 | // Removes events for the given object.
65 | void EventHandler::Remove(EventBase *object) {
66 | auto end = std::remove_if(myEvents.begin(), myEvents.end(),
67 | [object](Event &event) {
68 | return event.Owner() == object;
69 | });
70 | myEvents.erase(end, myEvents.end());
71 | }
72 |
--------------------------------------------------------------------------------
/src/Framework/Event.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Maintains a queue of events requested by EventBase derived objects.
3 | //
4 |
5 | #ifndef FRAMEWORK_EVENT_HPP_
6 | #define FRAMEWORK_EVENT_HPP_
7 |
8 | #include
9 | #include
10 | #include
11 |
12 | #include "Framework/Types.hpp"
13 |
14 | class EventHandler;
15 |
16 | // The base class for any class that is going to register
17 | // events with the event handler.
18 | class EventBase {
19 | public:
20 | EventBase(EventHandler &handler) : myEventHandler(handler) { }
21 | virtual ~EventBase();
22 |
23 | // Called when a registered event is dispatched.
24 | virtual void EventCallback(int data, void *pointer) = 0;
25 |
26 | private:
27 | EventHandler &myEventHandler;
28 | };
29 |
30 | class EventHandler {
31 | public:
32 | // Constructor
33 | EventHandler();
34 |
35 | // Checks for expired events.
36 | void Check();
37 |
38 | // Adds an event to the event list.
39 | void Add(EventBase *object, int data, void *pointer, USeconds time);
40 |
41 | // Removes events for the given object.
42 | void Remove(EventBase *object);
43 |
44 | private:
45 | class Event {
46 | public:
47 | Event(EventBase *o, int d, void *p, USeconds t)
48 | : total_time(t), object(o), pointer(p), data(d) { }
49 |
50 | // Dispatches the event by calling the object's callback routine.
51 | void Dispatch() { object->EventCallback(data, pointer); }
52 |
53 | // Returns the owning object.
54 | EventBase *Owner() { return object; }
55 |
56 | // Total amount of time to wait before the event.
57 | NanoSeconds total_time;
58 |
59 | // Time left before the event occurs.
60 | NanoSeconds delta_time;
61 |
62 | private:
63 | // The object that owns this event.
64 | EventBase *object;
65 |
66 | // Data to be passed to the callback method.
67 | void *pointer;
68 | int data;
69 | };
70 |
71 | // Linked list of events.
72 | std::vector myEvents;
73 |
74 | // Number of calls since last second.
75 | std::uint64_t myIterations;
76 |
77 | // Last second Check() was called.
78 | std::time_t myOldTime;
79 |
80 | // Average nanoseconds per call to Check.
81 | NanoSeconds myNSPerCheck;
82 | };
83 |
84 | #endif // FRAMEWORK_EVENT_HPP_
85 |
--------------------------------------------------------------------------------
/src/Framework/Interface.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // This is the user interface command class. It handles all of the
3 | // command's issue by the user interface.
4 | //
5 |
6 | #ifndef FRAMEWORK_INTERFACE_HPP_
7 | #define FRAMEWORK_INTERFACE_HPP_
8 |
9 | #include
10 |
11 | class BasicCPU;
12 | class BasicDeviceRegistry;
13 | class BasicLoader;
14 | class BreakpointList;
15 |
16 | class Interface {
17 | public:
18 | Interface(BasicCPU &cpu, BasicDeviceRegistry ®istry, BasicLoader &loader);
19 |
20 | // Command loop
21 | void CommandLoop();
22 |
23 | private:
24 | // Structure for the interface's command table
25 | struct CommandTable {
26 | std::string name;
27 | void (Interface::*mfp)(const std::string &);
28 | };
29 |
30 | // Table of commands.
31 | static CommandTable ourCommandTable[];
32 |
33 | // Indicates the number of commands in the command table.
34 | const unsigned int myNumberOfCommands;
35 |
36 | // Reference to the CPU I'm managing.
37 | BasicCPU &myCPU;
38 |
39 | // Reference to the device registry.
40 | BasicDeviceRegistry &myDeviceRegistry;
41 |
42 | // Reference to the loader.
43 | BasicLoader &myLoader;
44 |
45 | // Reference to the input stream used to get information from the UI.
46 | std::istream &myInputStream;
47 |
48 | // Reference to the output stream used to send information to the UI.
49 | std::ostream &myOutputStream;
50 |
51 | // Breakpoint list to manage the breakpoints.
52 | BreakpointList &myBreakpointList;
53 |
54 | // Execute the given command.
55 | void ExecuteCommand(const std::string &command);
56 |
57 | // Member funtion for each of the commands.
58 | void AddBreakpoint(const std::string &args);
59 | void AttachDevice(const std::string &args);
60 | void ClearStatistics(const std::string &args);
61 | void DeleteBreakpoint(const std::string &args);
62 | void DetachDevice(const std::string &args);
63 | void FillMemoryBlock(const std::string &args);
64 | void ListAttachedDevices(const std::string &args);
65 | void ListBreakpoints(const std::string &args);
66 | void ListDevices(const std::string &args);
67 | void ListDeviceScript(const std::string &args);
68 | void ListExecutionTraceRecord(const std::string &args);
69 | void ListDefaultExecutionTraceEntries(const std::string &args);
70 | void ListGranularity(const std::string &args);
71 | void ListMemory(const std::string &args);
72 | void ListMaximumAddress(const std::string &args);
73 | void ListNumberOfAddressSpaces(const std::string &args);
74 | void ListRegisters(const std::string &args);
75 | void ListRegisterValue(const std::string &args);
76 | void ListRegisterDescription(const std::string &args);
77 | void ListStatistics(const std::string &args);
78 | void LoadProgram(const std::string &args);
79 | void ProgramCounterValue(const std::string &args);
80 | void Reset(const std::string &args);
81 | void Run(const std::string &args);
82 | void SetRegister(const std::string &args);
83 | void SetMemory(const std::string &args);
84 | void Step(const std::string &args);
85 | };
86 |
87 | #endif // FRAMEWORK_INTERFACE_HPP_
88 |
--------------------------------------------------------------------------------
/src/Framework/RegInfo.cpp:
--------------------------------------------------------------------------------
1 | // Used by CPU classes to manage a list of of register structures.
2 |
3 | #include "Framework/BasicCPU.hpp"
4 | #include "Framework/RegInfo.hpp"
5 |
6 | RegisterInformationList::RegisterInformationList(BasicCPU &cpu) {
7 | // Ask CPU to fill me up with RegisterInformation objects.
8 | cpu.BuildRegisterInformationList(*this);
9 | }
10 |
11 | RegisterInformationList::~RegisterInformationList() { }
12 |
13 | void RegisterInformationList::Append(const std::string &name,
14 | const std::string &hexValue,
15 | const std::string &desc) {
16 | infos.push_back(RegisterInformation(name, hexValue, desc));
17 | }
18 |
19 | bool RegisterInformationList::Element(size_t index, RegisterInformation &info) {
20 | if (index >= infos.size()) { return false; }
21 | info = infos[index];
22 | return true;
23 | }
24 |
--------------------------------------------------------------------------------
/src/Framework/RegInfo.hpp:
--------------------------------------------------------------------------------
1 | #ifndef FRAMEWORK_REGINFO_HPP_
2 | #define FRAMEWORK_REGINFO_HPP_
3 |
4 | #include
5 | #include
6 |
7 | class BasicCPU;
8 |
9 | class RegisterInformation {
10 | public:
11 | RegisterInformation(const std::string &n,
12 | const std::string &v,
13 | const std::string &d)
14 | : name(n), value(v), description(d) { }
15 | RegisterInformation() { }
16 |
17 | // Sets the name, hex value, and the description fields.
18 | void Set(const std::string &n,
19 | const std::string &v,
20 | const std::string &d) {
21 | name = n;
22 | value = v;
23 | description = d;
24 | }
25 |
26 | std::string Name() const { return name; }
27 | std::string HexValue() const { return value; }
28 | std::string Description() const { return description; }
29 |
30 | private:
31 | std::string name; // The name given to the register ("D0", "PC", etc).
32 | std::string value; // The value of the register in hexidecimal.
33 | std::string description; // A short description of the register.
34 | };
35 |
36 | class RegisterInformationList {
37 | public:
38 | RegisterInformationList(BasicCPU &cpu);
39 | ~RegisterInformationList();
40 |
41 | void Append(const std::string &name, const std::string &value,
42 | const std::string &desc);
43 |
44 | size_t NumberOfElements() const { return infos.size(); }
45 |
46 | // Gets the element with the given index.
47 | // Returns true iff the index is valid.
48 | bool Element(size_t index, RegisterInformation &info);
49 |
50 | private:
51 | std::vector infos;
52 | };
53 |
54 | #endif // FRAMEWORK_REGINFO_HPP_
55 |
--------------------------------------------------------------------------------
/src/Framework/StatInfo.cpp:
--------------------------------------------------------------------------------
1 | #include "Framework/BasicCPU.hpp"
2 | #include "Framework/StatInfo.hpp"
3 |
4 | StatisticalInformationList::StatisticalInformationList(BasicCPU &cpu) {
5 | cpu.BuildStatisticalInformationList(*this);
6 | }
7 |
8 | StatisticalInformationList::~StatisticalInformationList() {
9 | for (auto p : myList) delete p;
10 | }
11 |
12 | void StatisticalInformationList::Append(const std::string &statistic) {
13 | myList.push_back(new StatisticInformation(statistic));
14 | }
15 |
16 | bool StatisticalInformationList::Element(unsigned int index,
17 | StatisticInformation &info) {
18 | if (index >= NumberOfElements()) {
19 | return false;
20 | }
21 | auto *element = myList[index];
22 | info.Set(element->Statistic());
23 | return true;
24 | }
25 |
--------------------------------------------------------------------------------
/src/Framework/StatInfo.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Used by BasicCPU (and derived classes) to manage a list of
3 | // of statistics objects.
4 | //
5 |
6 | #ifndef FRAMEWORK_STATINFO_HXX
7 | #define FRAMEWORK_STATINFO_HXX
8 |
9 | #include
10 | #include
11 |
12 | class BasicCPU;
13 |
14 | class StatisticInformation {
15 | public:
16 | StatisticInformation(const std::string &statistic) : myStatistic(statistic) { }
17 | StatisticInformation() { }
18 | ~StatisticInformation() { }
19 |
20 | // Set the statistic fields.
21 | void Set(const std::string &statistic) { myStatistic = statistic; }
22 |
23 | // Returns my statistic.
24 | const std::string &Statistic() const { return myStatistic; }
25 |
26 | private:
27 | std::string myStatistic;
28 | };
29 |
30 | class StatisticalInformationList {
31 | public:
32 | StatisticalInformationList(BasicCPU &cpu);
33 | ~StatisticalInformationList();
34 |
35 | // Appends an element to the list.
36 | void Append(const std::string &statistic);
37 |
38 | // Returns the number of elements in the list.
39 | unsigned int NumberOfElements() const { return myList.size(); }
40 |
41 | // Gets the element with the given index. Returns true iff successful.
42 | bool Element(unsigned int index, StatisticInformation &info);
43 |
44 | private:
45 | std::vector myList;
46 | };
47 |
48 | #endif // FRAMEWORK_STATINFO_HXX
49 |
--------------------------------------------------------------------------------
/src/Framework/Time.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Provides access to the system's time, in seconds.
3 | //
4 |
5 | #ifndef FRAMEWORK_TIME_HPP_
6 | #define FRAMEWORK_TIME_HPP_
7 |
8 | #include
9 |
10 | namespace Time {
11 | // Returns the current system time in seconds.
12 | std::time_t seconds() { return std::time(nullptr); }
13 | }
14 |
15 | #endif // FRAMEWORK_TIME_HPP_
16 |
--------------------------------------------------------------------------------
/src/Framework/Tools.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #include "Framework/Tools.hpp"
7 |
8 | // Convert the hex string to an unsigned integer
9 | unsigned int StringToInt(const std::string &hex) {
10 | return static_cast(std::strtoul(hex.c_str(), NULL, 16));
11 | }
12 |
13 | // Convert the value to a hex string padded with zeros
14 | std::string IntToString(unsigned int value, unsigned int width) {
15 | std::ostringstream oss;
16 | oss << std::setw(width) << std::setfill('0') << std::hex << value;
17 | auto s = oss.str();
18 | return s.substr(s.length() - width);
19 | }
20 |
--------------------------------------------------------------------------------
/src/Framework/Tools.hpp:
--------------------------------------------------------------------------------
1 | #ifndef TOOLS_HXX
2 | #define TOOLS_HXX
3 |
4 | #include
5 |
6 | // Converts the hex string to an unsigned integer.
7 | unsigned int StringToInt(const std::string &hex);
8 |
9 | // Converts the value to a hex string padded with zeros.
10 | // Width is a maximum, counted from the end of the string.
11 | std::string IntToString(unsigned int value, unsigned int width);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/src/Framework/Types.hpp:
--------------------------------------------------------------------------------
1 | #ifndef FRAMEWORK_TYPES_HPP_
2 | #define FRAMEWORK_TYPES_HPP_
3 |
4 | #include
5 |
6 | typedef uint32_t Address;
7 | typedef uint32_t Register;
8 |
9 | typedef uint8_t Byte;
10 |
11 | typedef int64_t USeconds;
12 | typedef int64_t NanoSeconds;
13 |
14 | #endif // FRAMEWORK_TYPES_HPP_
15 |
--------------------------------------------------------------------------------
/src/M68k/devices/DeviceRegistry.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "M68k/devices/DeviceRegistry.hpp"
4 | #include "M68k/devices/Gdbsock.hpp"
5 | #include "M68k/devices/M68681.hpp"
6 | #include "M68k/devices/RAM.hpp"
7 | #include "M68k/devices/Timer.hpp"
8 |
9 | // Array of device information (name, description, tcl script).
10 | const DeviceInformation DeviceRegistry::ourDeviceInfo[] = {
11 | {
12 | "RAM", "Random Access Memory",
13 | #include "M68k/devices/RAM.scr"
14 | },
15 | {
16 | "GdbSocket", "Socket for connecting gdb",
17 | #include "M68k/devices/Gdbsock.scr"
18 | },
19 | {
20 | "M68681", "Motorola 68681 Dual UART",
21 | #include "M68k/devices/M68681.scr"
22 | },
23 | {
24 | "Timer", "Timer",
25 | #include "M68k/devices/Timer.scr"
26 | }
27 | };
28 |
29 | DeviceRegistry::DeviceRegistry()
30 | : BasicDeviceRegistry(ourDeviceInfo,
31 | sizeof(ourDeviceInfo) / sizeof(DeviceInformation)) {}
32 |
33 | bool DeviceRegistry::Create(const std::string &name, const std::string &args,
34 | BasicCPU &cpu, BasicDevice *&device) {
35 | device = nullptr;
36 | if (name == "RAM")
37 | device = new RAM(args, cpu);
38 | else if (name == "GdbSocket")
39 | device = new GdbSocket(args, cpu);
40 | else if (name == "M68681")
41 | device = new M68681(args, cpu);
42 | else if (name == "Timer")
43 | device = new Timer(args, cpu);
44 |
45 | // If the device does not exist or it's error message is not
46 | // empty then return an error.
47 | if (device == nullptr || !device->ErrorMessage().empty()) {
48 | delete device;
49 | return false;
50 | }
51 | return true;
52 | }
53 |
--------------------------------------------------------------------------------
/src/M68k/devices/DeviceRegistry.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Keeps a list of all of the availible devices and allocates them
3 | // on demand. Dervied from the BasicDeviceRegistry.
4 | //
5 |
6 | #ifndef M68K_DEVICES_DEVICEREGISTRY_HPP_
7 | #define M68K_DEVICES_DEVICEREGISTRY_HPP_
8 |
9 | #include "Framework/BasicDeviceRegistry.hpp"
10 |
11 | class DeviceRegistry : public BasicDeviceRegistry {
12 | public:
13 | DeviceRegistry();
14 |
15 | // Creates a device with the given name. Returns true iff successful.
16 | bool Create(const std::string &name, const std::string &args,
17 | BasicCPU &cpu, BasicDevice *&device);
18 |
19 | private:
20 | static const DeviceInformation ourDeviceInfo[];
21 | };
22 |
23 | #endif // M68K_DEVICES_DEVICEREGISTRY_HPP_
24 |
--------------------------------------------------------------------------------
/src/M68k/devices/Gdbsock.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Fake device, connecting a TCP socket in sim68000,
3 | // in order to use (remote) gdb. The goal is to provide
4 | // PutChar and GetChar functions, as required by GDB stub.
5 | // (see m68k_stub.c in gdb sources).
6 | //
7 |
8 | #ifndef M68K_DEVICES_GDBSOCK_HPP_
9 | #define M68K_DEVICES_GDBSOCK_HPP_
10 |
11 | #include "Framework/BasicDevice.hpp"
12 |
13 | class GdbSocket : public BasicDevice {
14 | public:
15 | GdbSocket(const std::string &args, BasicCPU &cpu);
16 | ~GdbSocket();
17 |
18 | // Returns true iff the address maps into the device.
19 | virtual bool CheckMapped(Address addr) const;
20 |
21 | // Returns the lowest address used by the device.
22 | virtual Address LowestAddress() const { return (m_base_address); }
23 |
24 | // Returns the highest address used by the device.
25 | virtual Address HighestAddress() const {
26 | return (m_base_address + 3); // need 4 bytes: status,command,read,write
27 | }
28 |
29 | // Gets a byte from the device.
30 | virtual Byte Peek(Address addr);
31 |
32 | // Puts a byte into the device.
33 | virtual void Poke(Address addr, Byte c);
34 |
35 | // Resets the device.
36 | virtual void Reset();
37 |
38 | // Handles socket events.
39 | void EventCallback(int type, void *pointer);
40 |
41 | private:
42 | Address m_base_address; // Base address of the device
43 | int m_port; // socket port number
44 | int m_server_socket; // server socket identifier
45 | int m_client_socket; // client socket identifier
46 | int m_status; // 1 if connected, 0 otherwise
47 |
48 | Byte *m_received_buffer;
49 | int m_received_first, m_received_last, m_received_length;
50 |
51 | Byte *m_send_buffer;
52 | int m_send_length;
53 |
54 | void SetupServer();
55 | };
56 |
57 | #endif // M68K_DEVICES_GDBSOCK_HPP_
58 |
--------------------------------------------------------------------------------
/src/M68k/devices/Gdbsock.tcl:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/wish -f
2 | #
3 | # Only need base address and port number
4 |
5 | proc DeviceSetupGetValues {} {
6 | set base [.device.inputs.entry.address get]
7 | set port [.device.inputs.entry.port get]
8 |
9 | set result "BaseAddress = $base PortNumber = $port"
10 | return "$result"
11 | }
12 |
13 | proc DeviceSetupCheckValues {} {
14 | set base [.device.inputs.entry.address get]
15 | set port [.device.inputs.entry.port get]
16 |
17 | if {[regexp {^[0-9A-Fa-f]+$} $base] && [regexp {^[0-9]+$} $port]} {
18 | destroy .device
19 | } else {
20 |
21 | }
22 | }
23 |
24 | ###############################################################################
25 | # This is the procedure the User Interface calls
26 | ###############################################################################
27 | proc DeviceSetup {} {
28 | global DeviceSetupReturnValue
29 |
30 | catch {destroy .device}
31 |
32 | toplevel .device
33 | wm title .device "GDB Socket Setup"
34 | wm iconname .device "GDB Socket Setup"
35 |
36 | message .device.message \
37 | -text "Please enter the base address and port for GDB socket.\n\nAddress in hexadecimal\n\nPort in decimal!" \
38 | -width 3i -justify left
39 |
40 | frame .device.inputs -relief ridge -borderwidth 2
41 | frame .device.inputs.label
42 | label .device.inputs.label.address -text "Base Address:"
43 | label .device.inputs.label.port -text "Port:"
44 | pack .device.inputs.label.address -side top
45 | pack .device.inputs.label.port -side right
46 | frame .device.inputs.entry
47 | entry .device.inputs.entry.address -width 10 -relief sunken
48 | bind .device.inputs.entry.address \
49 | { focus .device.inputs.entry.port }
50 | entry .device.inputs.entry.port -width 10 -relief sunken
51 | bind .device.inputs.entry.port \
52 | { focus .device.inputs.entry.address }
53 | pack .device.inputs.entry.address -side top -fill x -expand 1 -pady 2
54 | pack .device.inputs.entry.port -side top -fill x -expand 1 -pady 2
55 | pack .device.inputs.label -side left
56 | pack .device.inputs.entry -side left -fill x -expand 1 -padx 2
57 |
58 | frame .device.buttons
59 | button .device.buttons.ok -text "Okay" \
60 | -command {set DeviceSetupReturnValue [DeviceSetupGetValues]
61 | DeviceSetupCheckValues}
62 | button .device.buttons.cancel -text "Cancel" \
63 | -command {set DeviceSetupReturnValue ""; destroy .device}
64 | pack .device.buttons.ok -side left -expand 1 -fill x -padx 4
65 | pack .device.buttons.cancel -side right -expand 1 -fill x -padx 4
66 |
67 | pack .device.message -side top -fill x -pady 4 -padx 4
68 | pack .device.inputs -side top -fill x -pady 2 -padx 4 -ipady 2
69 | pack .device.buttons -side top -fill x -pady 4
70 |
71 | # Set input focus to the first entry widget
72 | tkwait visibility .device
73 | focus .device.inputs.entry.address
74 |
75 | # Make this a modal dialog
76 | grab set .device
77 | tkwait window .device
78 |
79 | return $DeviceSetupReturnValue
80 | }
81 |
--------------------------------------------------------------------------------
/src/M68k/devices/M68681.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // The Motorola 68681 DUART
3 | //
4 |
5 | #ifndef M68K_DEVICES_M68681_HPP_
6 | #define M68K_DEVICES_M68681_HPP_
7 |
8 | #include
9 | #include
10 |
11 | #include "Framework/BasicDevice.hpp"
12 |
13 | class M68681 : public BasicDevice {
14 | public:
15 | M68681(const std::string &args, BasicCPU &cpu);
16 | ~M68681();
17 |
18 | // Returns true iff the address maps into the device
19 | bool CheckMapped(Address addr) const override;
20 |
21 | // Returns the lowest address used by the device
22 | Address LowestAddress() const override { return base_address; }
23 |
24 | // Returns the highest address used by the device
25 | Address HighestAddress() const override {
26 | return base_address + offset_to_first_register +
27 | 15 * offset_between_registers;
28 | }
29 |
30 | // Gets a byte from the device
31 | Byte Peek(Address addr) override;
32 |
33 | // Puts a byte into the device
34 | void Poke(Address addr, Byte c) override;
35 |
36 | // Resets the DUART.
37 | void Reset() override;
38 |
39 | // The BasicDevice's InterruptAcknowledge does not handle vectored
40 | // interrupts so we'll have to change it.
41 | int InterruptAcknowledge(unsigned int level) override;
42 |
43 | // Handles the DUART's events.
44 | void EventCallback(int type, void *pointer) override;
45 |
46 | private:
47 | Byte MR1A; // Mode register 1 A
48 | Byte MR2A; // Mode register 2 A
49 |
50 | Byte SRA; // Status register A
51 | Byte CSRA; // Clock-select register A
52 |
53 | // No readable register at this address..
54 | Byte CRA; // Command register A
55 |
56 | Byte RBA; // Receiver buffer A
57 | Byte TBA; // Transmitter buffer A
58 |
59 | Byte IPCR; // Input port change register
60 | Byte ACR; // Auxiliary control register
61 |
62 | Byte ISR; // Interrupt status register
63 | Byte IMR; // Interrupt mask register
64 |
65 | Byte CUR; // Counter mode: counter MSB
66 | Byte CTUR; // Counter/timer uppper register
67 |
68 | Byte CLR; // Counter mode: counter LSB
69 | Byte CTLR; // Counter/timer lower register
70 |
71 | Byte MR1B; // Mode register 1 B
72 | Byte MR2B; // Mode register 2 B
73 | Byte SRB; // Status register B
74 | Byte CSRB; // Clock-select register B
75 | Byte CRB; // Command register B
76 | Byte RBB; // Receiver buffer B
77 | Byte TBB; // Transmitter buffer B
78 |
79 | Byte IVR; // Interrupt-vector register
80 |
81 | Byte mr1a_pointer; // Determines MR1A/MR2A
82 | Byte mr1b_pointer; // Determines MR1B/MR2B
83 |
84 | Byte receiver_a_state; // State of receiver A
85 | Byte transmitter_a_state; // State of transmitter A
86 | Byte receiver_b_state; // State of receiver B
87 | Byte transmitter_b_state; // State of transmitter B
88 |
89 | static long baudrate_table[32]; // Table of times for baud rates
90 |
91 | int coma_read_id; // Pipe to command for port a
92 | int coma_write_id; // Pipe to command for port a
93 | int comb_read_id; // Pipe to command for port b
94 | int comb_write_id; // Pipe to command for port b
95 | pid_t coma_pid; // Proccess ID for port a command
96 | pid_t comb_pid; // Proccess ID for port b command
97 |
98 | Address base_address; // Base address of the DUART
99 | size_t offset_to_first_register; // Offset to the first registers
100 | size_t offset_between_registers; // Offset to between registers
101 | unsigned long interrupt_level; // The interrupt level sent to CPU
102 |
103 | bool StartPortCommand(const std::string &command, bool std_flag, int &read,
104 | int &write, pid_t &pid);
105 |
106 | void SetInterruptStatusRegister();
107 | };
108 |
109 | #endif // M68K_DEVICES_M68681_HPP_
110 |
--------------------------------------------------------------------------------
/src/M68k/devices/RAM.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "Framework/Tools.hpp"
5 | #include "Framework/BasicCPU.hpp"
6 | #include "M68k/devices/RAM.hpp"
7 |
8 | RAM::RAM(const std::string &args, BasicCPU &cpu)
9 | : BasicDevice("RAM", args, cpu) {
10 | std::istringstream in(args);
11 | std::string keyword, equals;
12 | Address base;
13 | size_t size;
14 |
15 | // Scan "BaseAddress = nnnn"
16 | in >> keyword >> equals >> std::hex >> base;
17 | if ((!in) || (keyword != "BaseAddress") || (equals != "=")) {
18 | ErrorMessage("Invalid initialization arguments!");
19 | return;
20 | }
21 |
22 | // Scan "Size = nnnn"
23 | in >> keyword >> equals >> std::hex >> size;
24 | if ((!in) || (keyword != "Size") || (equals != "=")) {
25 | ErrorMessage("Invalid initialization arguments!");
26 | return;
27 | }
28 |
29 | myBaseAddress = base * cpu.Granularity();
30 | mySize = size * cpu.Granularity();
31 |
32 | myBuffer = nullptr;
33 | if (mySize > 0)
34 | myBuffer = new unsigned char[mySize];
35 | }
36 |
37 | RAM::~RAM() { delete[] myBuffer; }
38 |
39 | bool RAM::CheckMapped(Address address) const {
40 | return (address >= myBaseAddress) && (address < myBaseAddress + mySize);
41 | }
42 |
--------------------------------------------------------------------------------
/src/M68k/devices/RAM.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Random Access Memory Device.
3 | //
4 |
5 | #ifndef M68K_DEVICES_RAM_HPP_
6 | #define M68K_DEVICES_RAM_HPP_
7 |
8 | #include
9 |
10 | #include "Framework/BasicDevice.hpp"
11 |
12 | class RAM : public BasicDevice {
13 | public:
14 | RAM(const std::string &args, BasicCPU &cpu);
15 | ~RAM();
16 |
17 | // Returns true iff the address maps into the device.
18 | bool CheckMapped(Address addr) const;
19 |
20 | // Returns the lowest address used by the device.
21 | Address LowestAddress() const { return myBaseAddress; }
22 |
23 | // Returns the highest address used by the device.
24 | Address HighestAddress() const { return myBaseAddress + mySize - 1; }
25 |
26 | // Gets a byte from memory.
27 | Byte Peek(Address address) {
28 | if (address < LowestAddress() || HighestAddress() < address) {
29 | return 0xFF;
30 | }
31 | return myBuffer[address - myBaseAddress];
32 | }
33 |
34 | // Puts a byte into memory.
35 | virtual void Poke(Address address, Byte c) {
36 | if (LowestAddress() <= address && address <= HighestAddress()) {
37 | myBuffer[address - myBaseAddress] = c;
38 | }
39 | }
40 |
41 | // RAM never has Events
42 | void EventCallback(int, void *) { }
43 |
44 | protected:
45 | // Buffer to hold the RAM's contents.
46 | Byte *myBuffer;
47 |
48 | private:
49 | // Starting address of the RAM device
50 | Address myBaseAddress;
51 |
52 | // Size of the RAM device in bytes
53 | size_t mySize;
54 | };
55 |
56 | #endif // M68K_DEVICES_RAM_HPP_
57 |
--------------------------------------------------------------------------------
/src/M68k/devices/RAM.tcl:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/wish -f
2 | #
3 | # This Tcl script gets the setup information for the RAM device.
4 | #
5 | # Notes: - All Procedures and global variables begin with "DeviceSetup". This
6 | # should be true for all device scripts.
7 | # - The toplevel window should be .device for all device scripts.
8 | # - The script must return a valid argument for the device's
9 | # constructor. (i.e. "BaseAddress=00000000 Size=00000000")
10 | # - If the cancel button is pressed the empty string should be
11 | # returned
12 | # - All device scripts should be modal dialogs
13 |
14 | proc DeviceSetupGetValues {} {
15 | set base [.device.inputs.entry.address get]
16 | set size [.device.inputs.entry.size get]
17 |
18 | set result "BaseAddress = $base Size = $size"
19 | return "$result"
20 | }
21 |
22 | proc DeviceSetupCheckValues {} {
23 | set base [.device.inputs.entry.address get]
24 | set size [.device.inputs.entry.size get]
25 |
26 | if {[regexp {^[0-9A-Fa-f]+$} $base] && [regexp {^[0-9A-Fa-f]+$} $size]} {
27 | destroy .device
28 | } else {
29 |
30 | }
31 | }
32 |
33 | ###############################################################################
34 | # This is the procedure the User Interface calls
35 | ###############################################################################
36 | proc DeviceSetup {} {
37 | global DeviceSetupReturnValue
38 |
39 | catch {destroy .device}
40 |
41 | toplevel .device
42 | wm title .device "RAM Setup"
43 | wm iconname .device "RAM Setup"
44 |
45 | message .device.message \
46 | -text "Please enter the base address and size of the RAM.\n\nAll values are in hexadecimal!" \
47 | -width 3i -justify left
48 |
49 | frame .device.inputs -relief ridge -borderwidth 2
50 | frame .device.inputs.label
51 | label .device.inputs.label.address -text "Base Address:"
52 | label .device.inputs.label.size -text "Size:"
53 | pack .device.inputs.label.address -side top
54 | pack .device.inputs.label.size -side right
55 | frame .device.inputs.entry
56 | entry .device.inputs.entry.address -width 10 -relief sunken
57 | bind .device.inputs.entry.address \
58 | { focus .device.inputs.entry.size }
59 | entry .device.inputs.entry.size -width 10 -relief sunken
60 | bind .device.inputs.entry.size \
61 | { focus .device.inputs.entry.address }
62 | pack .device.inputs.entry.address -side top -fill x -expand 1 -pady 2
63 | pack .device.inputs.entry.size -side top -fill x -expand 1 -pady 2
64 | pack .device.inputs.label -side left
65 | pack .device.inputs.entry -side left -fill x -expand 1 -padx 2
66 |
67 | frame .device.buttons
68 | button .device.buttons.ok -text "Okay" \
69 | -command {set DeviceSetupReturnValue [DeviceSetupGetValues]
70 | DeviceSetupCheckValues}
71 | button .device.buttons.cancel -text "Cancel" \
72 | -command {set DeviceSetupReturnValue ""; destroy .device}
73 | pack .device.buttons.ok -side left -expand 1 -fill x -padx 4
74 | pack .device.buttons.cancel -side right -expand 1 -fill x -padx 4
75 |
76 | pack .device.message -side top -fill x -pady 4 -padx 4
77 | pack .device.inputs -side top -fill x -pady 2 -padx 4 -ipady 2
78 | pack .device.buttons -side top -fill x -pady 4
79 |
80 | # Set input focus to the first entry widget
81 | tkwait visibility .device
82 | focus .device.inputs.entry.address
83 |
84 | # Make this a modal dialog
85 | grab set .device
86 | tkwait window .device
87 |
88 | return $DeviceSetupReturnValue
89 | }
90 |
--------------------------------------------------------------------------------
/src/M68k/devices/Timer.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // Simulates an ECB timer for the M68000 CPU. Thus giving
3 | // the Simulator the ablility to simulate a timer interrupt.
4 | // Programmers can implement time slicing with this timer.
5 | //
6 | // Contains Register and Offsets for the ECB timer.
7 | //
8 |
9 | #ifndef M68K_DEVICES_TIMER_HPP_
10 | #define M68K_DEVICES_TIMER_HPP_
11 |
12 | #include
13 |
14 | #include "Framework/Types.hpp"
15 | #include "Framework/BasicDevice.hpp"
16 |
17 | // Contants.
18 | #define TCR 0
19 | #define TIVR 2
20 | #define NULR 4
21 | #define CPRH 6
22 | #define CPRM 8
23 | #define CPRL 10 // 0xA in Hex
24 | #define NULTR 12 // 0xC in hex
25 | #define CNTRH 14
26 | #define CNTRM 16
27 | #define CNTRL 18
28 | #define TSR 20 // 0x14 in hex
29 |
30 | #define TIMER_EVENT 100
31 |
32 | class Timer : public BasicDevice {
33 | public:
34 | Timer(const std::string &args, BasicCPU &cpu);
35 | ~Timer() { };
36 |
37 | // Returns true iff the address maps into the device.
38 | bool CheckMapped(Address address) const override;
39 |
40 | // Returns the lowest address used by the device.
41 | Address LowestAddress() const override { return baseAddress; }
42 |
43 | // Returns the highest address used by the device.
44 | Address HighestAddress() const override {
45 | return (baseAddress + (15 * sizeof(char)));
46 | }
47 |
48 | // Gets a byte from the device.
49 | Byte Peek(Address address) override;
50 |
51 | // Puts a byte into the device.
52 | void Poke(Address address, Byte c) override;
53 |
54 | // Resets the device.
55 | void Reset() override;
56 |
57 | // Sends an interrupt request (IRQ) to the CPU.
58 | void InterruptRequest(int level) override;
59 |
60 | // Processes an interrupt when called by the CPU.
61 | int InterruptAcknowledge(unsigned int level) override;
62 |
63 | void EventCallback(int data, void *ptr) override;
64 |
65 | protected:
66 | // Copies CPR register to CNTR.
67 | void copyCPRtoCNTR();
68 |
69 | // Decrements the CNTR and checks for 0.
70 | unsigned int decCNTR();
71 |
72 | // Interrupt pending flag.
73 | bool myInterruptPending;
74 |
75 | // Base location.
76 | Address baseAddress;
77 |
78 | // IRQ level set by the setup file.
79 | unsigned int TIMER_IRQ;
80 |
81 | // Time between event calls.
82 | unsigned int TIMER_CPU_CYCLE;
83 |
84 | // First time the caller is set.
85 | bool firstTime;
86 |
87 | // Timer value.
88 | Byte timerValue[22];
89 | };
90 |
91 | #endif // M68K_DEVICES_TIMER_HPP_
92 |
--------------------------------------------------------------------------------
/src/M68k/devices/Timer.tcl:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/wish -f
2 | #
3 | # CREATED: 7-24-98
4 | # OWNER : Xavier Plasencia
5 | # ORG: SDSU
6 | # DESC: Allows the programmer to set the memory location of the timer
7 | # NOTES: - All Procedures and global variables begin with "DeviceSetup". This
8 | # should be true for all device scripts.
9 | # - The toplevel window should be .device for all device scripts.
10 | # - The script must return a valid argument for the device's
11 | # constructor. (i.e. "BaseAddress= 0x10021 IRQ = 0x5")
12 | # - All device scripts should be modal dialogs
13 |
14 | proc DeviceSetupGetValues {} {
15 | set base [.device.inputs.entry.address get]
16 | set irq [.device.inputs.entry.interrupt get]
17 |
18 | set result "BaseAddress = $base IRQ = $irq"
19 | return "$result"
20 | }
21 |
22 | proc DeviceSetupCheckValues {} {
23 | set base [.device.inputs.entry.address get]
24 | set irq [.device.inputs.entry.interrupt get]
25 |
26 | if {[regexp {^[0-9A-Fa-f]+$} $base] && [regexp {^[57]$} $irq]} {
27 | destroy .device
28 | }
29 | }
30 |
31 | ###############################################################################
32 | # This is the procedure the User Interface calls
33 | ###############################################################################
34 | proc DeviceSetup {} {
35 | global DeviceSetupReturnValue
36 |
37 | catch {destroy .device}
38 |
39 | toplevel .device
40 | wm title .device "Timer Setup"
41 | wm iconname .device "Timer Setup"
42 |
43 | message .device.message -width 4.25i -justify left \
44 | -text "This device is modeled after the digital timer feature of the M68230 PI/T.\n\nPlease enter the base address of the timer as well as its interrupt level. Common values are 10021 for the base address and 5 or 7 for the interrupt level:"
45 |
46 | frame .device.inputs -relief ridge -borderwidth 2
47 | frame .device.inputs.label
48 | label .device.inputs.label.address -text "Base Address:"
49 | label .device.inputs.label.interrupt -text "Interrupt Level:"
50 | pack .device.inputs.label.address -side top
51 | pack .device.inputs.label.interrupt -side top
52 | frame .device.inputs.entry
53 | entry .device.inputs.entry.address -width 10 -relief sunken
54 | bind .device.inputs.entry.address \
55 | { focus .device.inputs.entry.interrupt }
56 | entry .device.inputs.entry.interrupt -width 10 -relief sunken
57 | bind .device.inputs.entry.interrupt \
58 | { focus .device.inputs.entry.address }
59 | pack .device.inputs.entry.address -side top -fill x -expand 1 -pady 2
60 | pack .device.inputs.entry.interrupt -side top -fill x -expand 1 -pady 2
61 | pack .device.inputs.label -side left
62 | pack .device.inputs.entry -side left -fill x -expand 1 -padx 2
63 |
64 | frame .device.buttons
65 | button .device.buttons.ok -text "Okay" \
66 | -command {set DeviceSetupReturnValue [DeviceSetupGetValues]
67 | DeviceSetupCheckValues}
68 | button .device.buttons.cancel -text "Cancel" \
69 | -command {set DeviceSetupReturnValue ""; destroy .device}
70 | pack .device.buttons.ok -side left -expand 1 -fill x -padx 4
71 | pack .device.buttons.cancel -side right -expand 1 -fill x -padx 4
72 |
73 | pack .device.message -side top -fill x -pady 4 -padx 4
74 | pack .device.inputs -side top -fill x -pady 2 -padx 4 -ipady 2
75 | pack .device.buttons -side top -fill x -pady 4
76 |
77 | # Set input focus to the first entry widget
78 | tkwait visibility .device
79 | focus .device.inputs.entry.address
80 |
81 | # Make this a modal dialog
82 | grab set .device
83 | tkwait window .device
84 |
85 | return $DeviceSetupReturnValue
86 | }
87 |
88 |
--------------------------------------------------------------------------------
/src/M68k/devices/tcl2scr:
--------------------------------------------------------------------------------
1 | sed '
2 | /^!/d
3 | /^$/d
4 | s/\\/\\\\/g
5 | s/\\$//g
6 | s/"/\\"/g
7 | s/^/"/
8 | : test
9 | /\\$/b slash
10 | s/$/\\n"/
11 | p
12 | d
13 | : slash
14 | n
15 | /^!/d
16 | /^$/d
17 | s/"/\\"/g
18 | s/\\\\/\\/g
19 | s/\\n/\\\\n/g
20 | s/\\t/\\\\t/g
21 | s/\\f/\\\\f/g
22 | s/\\b/\\\\b/g
23 | b test' "$@"
24 |
25 |
--------------------------------------------------------------------------------
/src/M68k/loader/Loader.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "Framework/Types.hpp"
4 | #include "Framework/AddressSpace.hpp"
5 | #include "Framework/BasicCPU.hpp"
6 | #include "Framework/Tools.hpp"
7 | #include "M68k/loader/Loader.hpp"
8 |
9 | // Loads the named file and answers an error message or the empty string
10 | std::string Loader::Load(const std::string &filename, int addressSpace) {
11 | std::ifstream file(filename);
12 | if (file.fail()) {
13 | return "ERROR: Could not open file!!!";
14 | }
15 | return LoadMotorolaSRecord(file, addressSpace);
16 | }
17 |
18 | std::string Cut(size_t n, std::string &line) {
19 | std::string cut = line.substr(0, n);
20 | line.erase(0, n);
21 | return cut;
22 | }
23 |
24 | // Load in a Motorola S-Record file into an address space
25 | std::string Loader::LoadMotorolaSRecord(std::ifstream &file, int addressSpace) {
26 | Address address;
27 | int length;
28 | Byte byte;
29 | std::string line;
30 |
31 | while (!file.eof() && file.good()) {
32 | file >> line;
33 | if (line.length() <= 0) {
34 | return "ERROR: Bad line in file!!!";
35 | }
36 | if (Cut(1, line) != "S") {
37 | return "ERROR: Incorrect file format!!!";
38 | }
39 | std::string line1 = Cut(1, line);
40 | if (line1 == "1") {
41 | length = StringToInt(Cut(2, line));
42 | address = StringToInt(Cut(4, line));
43 | for (int k = 0; k < length - 3; ++k) {
44 | byte = StringToInt(Cut(2, line));
45 | myCPU.addressSpace(addressSpace).Poke(address + k, byte);
46 | }
47 | } else if (line1 == "2") {
48 | length = StringToInt(Cut(2, line));
49 | address = StringToInt(Cut(6, line));
50 | for (int k = 0; k < length - 4; ++k) {
51 | byte = StringToInt(Cut(2, line));
52 | myCPU.addressSpace(addressSpace).Poke(address + k, byte);
53 | }
54 | } else if (line1 == "3") {
55 | length = StringToInt(Cut(2, line));
56 | address = StringToInt(Cut(8, line));
57 | for (int k = 0; k < length - 5; ++k) {
58 | byte = StringToInt(Cut(2, line));
59 | myCPU.addressSpace(addressSpace).Poke(address + k, byte);
60 | }
61 | } else if (line1 == "7" || line1 == "8" || line1 == "9") {
62 | break;
63 | }
64 | }
65 |
66 | return "";
67 | }
68 |
--------------------------------------------------------------------------------
/src/M68k/loader/Loader.hpp:
--------------------------------------------------------------------------------
1 | #ifndef M68K_LOADER_LOADER_HPP_
2 | #define M68K_LOADER_LOADER_HPP_
3 |
4 | #include
5 | #include
6 |
7 | #include "Framework/BasicLoader.hpp"
8 |
9 | // Loads object files in Motorola S-Record format.
10 | class Loader : public BasicLoader {
11 | public:
12 | Loader(BasicCPU &c) : BasicLoader(c) { }
13 |
14 | // Loads the named file and returns an error message or the empty string.
15 | std::string Load(const std::string &filename, int addressSpace) override;
16 |
17 | private:
18 | // Loads a Motorola S-Record file.
19 | std::string LoadMotorolaSRecord(std::ifstream &file, int addressSpace);
20 | };
21 |
22 | #endif // M68K_LOADER_LOADER_HPP_
23 |
--------------------------------------------------------------------------------
/src/M68k/sim68000/decode.cpp:
--------------------------------------------------------------------------------
1 | // Motorola 68000 instruction decoding.
2 |
3 | #include "M68k/sim68000/m68000.hpp"
4 |
5 | // Table to decode 68000 opcodes.
6 | m68000::DecodeEntry m68000::ourDecodeTable[] = {
7 | #include "M68k/sim68000/DecodeTable.hpp"
8 | };
9 |
10 | // Used to cache opcodes once they've been decoded
11 | m68000::ExecutionPointer *m68000::ourDecodeCacheTable = nullptr;
12 |
13 | // Decode the given opcode
14 | m68000::ExecutionPointer m68000::DecodeInstruction(int opcode) {
15 | // Check to see if this opcode needs to be decoded
16 | if (ourDecodeCacheTable[opcode] == 0) {
17 | // Decode the opcode using a linear search (slow :-{ )
18 | for (size_t s = 0; s < (sizeof(ourDecodeTable) / sizeof(DecodeEntry)); ++s) {
19 | if ((opcode & ourDecodeTable[s].mask) == ourDecodeTable[s].signature) {
20 | ourDecodeCacheTable[opcode] = ourDecodeTable[s].execute;
21 | }
22 | }
23 | // If not found then it's an invalid instruction
24 | if (ourDecodeCacheTable[opcode] == 0)
25 | ourDecodeCacheTable[opcode] = &m68000::ExecuteInvalid;
26 | }
27 | return ourDecodeCacheTable[opcode];
28 | }
29 |
--------------------------------------------------------------------------------
/src/M68k/sim68000/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Instantiates all of the objects and starts the
3 | // user interface command parser.
4 | //
5 |
6 | #include
7 |
8 | #include "Framework/Interface.hpp"
9 | #include "M68k/sim68000/m68000.hpp"
10 | #include "M68k/devices/DeviceRegistry.hpp"
11 | #include "M68k/loader/Loader.hpp"
12 |
13 | int main() {
14 | auto processor = std::unique_ptr(new m68000);
15 | auto loader = std::unique_ptr(new Loader(*processor));
16 | auto registry = std::unique_ptr(new DeviceRegistry);
17 |
18 | Interface interface(*processor, *registry, *loader);
19 | interface.CommandLoop();
20 |
21 | return 0;
22 | }
23 |
--------------------------------------------------------------------------------
/src/M68k/sim68000/sim68000.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 5.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "sim68000"=.\sim68000.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | }}}
15 |
16 | ###############################################################################
17 |
18 | Global:
19 |
20 | Package=<5>
21 | {{{
22 | }}}
23 |
24 | Package=<3>
25 | {{{
26 | }}}
27 |
28 | ###############################################################################
29 |
30 |
--------------------------------------------------------------------------------
/src/M68k/sim68360/decode.cpp:
--------------------------------------------------------------------------------
1 | #include "M68k/sim68360/cpu32.hpp"
2 |
3 | cpu32::DecodeEntry cpu32::ourDecodeTable[] = {
4 | #include "M68k/sim68360/DecodeTable.hpp"
5 | };
6 |
7 | cpu32::ExecutionPointer *cpu32::ourDecodeCacheTable = nullptr;
8 |
9 | cpu32::ExecutionPointer cpu32::DecodeInstruction(int opcode) {
10 | // Check to see if this opcode needs to be decoded
11 | if (ourDecodeCacheTable[opcode] == 0) {
12 | // Decode the opcode using a linear search (slow :-{ )
13 | for (size_t s = 0; s < (sizeof(ourDecodeTable) / sizeof(DecodeEntry)); ++s) {
14 | if ((opcode & ourDecodeTable[s].mask) == ourDecodeTable[s].signature) {
15 | ourDecodeCacheTable[opcode] = ourDecodeTable[s].execute;
16 | }
17 | }
18 |
19 | // If not found then it's an invalid instruction
20 | if (ourDecodeCacheTable[opcode] == 0)
21 | ourDecodeCacheTable[opcode] = &cpu32::ExecuteInvalid;
22 | }
23 | return ourDecodeCacheTable[opcode];
24 | }
25 |
--------------------------------------------------------------------------------
/src/M68k/sim68360/main.cpp:
--------------------------------------------------------------------------------
1 | // Instantiates all of the objects and starts the user interface command parser.
2 |
3 | #include
4 |
5 | #include "Framework/Interface.hpp"
6 | #include "M68k/sim68360/cpu32.hpp"
7 | #include "M68k/devices/DeviceRegistry.hpp"
8 | #include "M68k/loader/Loader.hpp"
9 |
10 | int main() {
11 | auto processor = std::unique_ptr(new cpu32);
12 | auto loader = std::unique_ptr(new Loader(*processor));
13 | auto registry = std::unique_ptr(new DeviceRegistry);
14 |
15 | Interface interface(*processor, *registry, *loader);
16 | interface.CommandLoop();
17 |
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/src/M68k/sim68360/sim68360.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 5.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "sim68360"=.\sim68360.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | }}}
15 |
16 | ###############################################################################
17 |
18 | Global:
19 |
20 | Package=<5>
21 | {{{
22 | }}}
23 |
24 | Package=<3>
25 | {{{
26 | }}}
27 |
28 | ###############################################################################
29 |
30 |
--------------------------------------------------------------------------------
/src/Makefile.BSD:
--------------------------------------------------------------------------------
1 | PREFIX?= /usr/local
2 | BINDIR:= $(PREFIX)/bin
3 | LIBDIR:= $(PREFIX)/lib/bsvc
4 |
5 | CC?= egcc
6 | CXX?= eg++
7 | CFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c11
8 | CXXFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c++11
9 | O:= o
10 |
11 | WISH?= wish8.5
12 | AR:= ar
13 | RANLIB:= ranlib
14 | RM:= rm
15 | INSTALL:= install
16 | STRIP:= strip
17 | MKDIR:= mkdir
18 |
19 | MKDEP:= env CC=$(CC) sh mkdep.sh
20 |
21 | include GNUMakefile.common
22 |
--------------------------------------------------------------------------------
/src/Makefile.Linux:
--------------------------------------------------------------------------------
1 | PREFIX?= /usr/local
2 | BINDIR:= $(PREFIX)/bin
3 | LIBDIR:= $(PREFIX)/lib/bsvc
4 |
5 | CC?= gcc
6 | CXX?= g++
7 | O:= o
8 | CFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c11
9 | CXXFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c++11
10 |
11 | WISH?= wish
12 | AR:= ar
13 | RANLIB:= ranlib
14 | RM:= rm
15 | INSTALL:= install
16 | STRIP:= strip
17 | MKDIR:= mkdir
18 |
19 | MKDEP:= env CC=$(CC) sh mkdep.sh
20 |
21 | include GNUMakefile.common
22 |
--------------------------------------------------------------------------------
/src/Makefile.OSX:
--------------------------------------------------------------------------------
1 | PREFIX?= /usr/local
2 | BINDIR:= $(PREFIX)/bin
3 | LIBDIR:= $(PREFIX)/lib/bsvc
4 |
5 | CC?= clang
6 | CXX?= clang++
7 | O:= o
8 | CFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c11
9 | CXXFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c++11
10 |
11 | WISH?= wish
12 | AR:= ar
13 | RANLIB:= ranlib
14 | RM:= rm
15 | INSTALL:= install
16 | STRIP:= strip
17 | MKDIR:= mkdir
18 |
19 | MKDEP:= env CC=$(CC) sh mkdep.sh
20 |
21 | include GNUMakefile.common
22 |
--------------------------------------------------------------------------------
/src/Makefile.Solaris:
--------------------------------------------------------------------------------
1 | PREFIX:= /opt/bsvc
2 | BINDIR:= $(PREFIX)/bin
3 | LIBDIR:= $(PREFIX)/lib/bsvc
4 | LDFLAGS:= -lsocket -lnsl
5 |
6 | CC?= cc
7 | CXX?= CC
8 | O:= o
9 | CFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c11
10 | CXXFLAGS?= -O -ansi -pedantic -Wall -Werror -std=c++11
11 |
12 | WISH?= wish
13 | AR:= ar
14 | RANLIB:= ranlib
15 | RM:= rm
16 | INSTALL:= install
17 | STRIP:= strip
18 | MKDIR:= mkdir
19 |
20 | MKDEP:= env CC=$(CC) sh mkdep.sh
21 |
22 | include GNUMakefile.common
23 |
--------------------------------------------------------------------------------
/src/Tools/xtermpipe.cpp:
--------------------------------------------------------------------------------
1 | // This simple program can be used with the Motorola M68681 DUART
2 | // to pipe input and output to an xterm.
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | int WaitForIO(int pipe_id) {
15 | fd_set readfds;
16 | fd_set writefds;
17 | fd_set exceptfds;
18 |
19 | FD_ZERO(&readfds);
20 | FD_ZERO(&writefds);
21 | FD_ZERO(&exceptfds);
22 |
23 | FD_SET(0, &readfds);
24 | FD_SET(pipe_id, &readfds);
25 |
26 | select(pipe_id + 1, &readfds, &writefds, &exceptfds, NULL);
27 |
28 | if (FD_ISSET(0, &readfds))
29 | return (0);
30 |
31 | return (1);
32 | }
33 |
34 | int main() {
35 | int read_id, write_id;
36 |
37 | if (system("stty -echo -echoe -echonl raw") < 0) {
38 | fprintf(stderr, "Can't set terminal mode. Failing.\n");
39 | exit(1);
40 | }
41 |
42 | read_id = 3;
43 | write_id = 4;
44 |
45 | for (;;) {
46 | if (WaitForIO(read_id)) {
47 | char c;
48 |
49 | if (read(read_id, &c, 1) != 1) {
50 | fprintf(stderr, "Read failed.\n");
51 | exit(1);
52 | }
53 | if (write(1, &c, 1) != 1) {
54 | fprintf(stderr, "Write failed.\n");
55 | exit(1);
56 | }
57 | } else {
58 | char c;
59 |
60 | if (read(0, &c, 1) != 1) {
61 | fprintf(stderr, "Read failed.\n");
62 | exit(1);
63 | }
64 | if (write(write_id, &c, 1) < 0) {
65 | fprintf(stderr, "Error on write.\n");
66 | exit(1);
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/Down.xbm:
--------------------------------------------------------------------------------
1 | #define Down_width 16
2 | #define Down_height 16
3 | static unsigned char Down_bits[] = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f,
5 | 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01,
6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
7 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/PageDown.xbm:
--------------------------------------------------------------------------------
1 | #define PageDown_width 16
2 | #define PageDown_height 16
3 | static unsigned char PageDown_bits[] = {
4 | 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f,
5 | 0xe0, 0x07, 0xde, 0x7b, 0xbe, 0x7d, 0x7c, 0x3e, 0xf8, 0x1f, 0xf0, 0x0f,
6 | 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00};
7 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/PageUp.xbm:
--------------------------------------------------------------------------------
1 | #define PageUp_width 16
2 | #define PageUp_height 16
3 | static unsigned char PageUp_bits[] = {
4 | 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f,
5 | 0x7c, 0x3e, 0xbe, 0x7d, 0xde, 0x7b, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f,
6 | 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00};
7 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/Up.xbm:
--------------------------------------------------------------------------------
1 | #define Up_width 16
2 | #define Up_height 16
3 | static unsigned char Up_bits[] = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03,
5 | 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f,
6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
7 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/bspin.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/src/UI/bitmaps/bspin.gif
--------------------------------------------------------------------------------
/src/UI/bitmaps/bsvc.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BSVC/bsvc/73b28cccc5cdbcde35cb43b430845d6b7d7bdfcf/src/UI/bitmaps/bsvc.gif
--------------------------------------------------------------------------------
/src/UI/bitmaps/bsvcicon.xbm:
--------------------------------------------------------------------------------
1 | #define bsvcicon_width 48
2 | #define bsvcicon_height 48
3 | static unsigned char bsvcicon_bits[] = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x55, 0x55, 0x55, 0x05,
9 | 0x40, 0x55, 0x55, 0x55, 0x55, 0x05, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
10 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
11 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
12 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
13 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xc0, 0x51, 0x1c, 0xa3, 0x0f,
14 | 0xf0, 0x9d, 0xce, 0xbe, 0x99, 0x0f, 0xf0, 0xbd, 0xde, 0xdd, 0xbd, 0x0f,
15 | 0xf0, 0x9d, 0xf9, 0xdd, 0xfe, 0x0f, 0xf0, 0xc1, 0xe3, 0xeb, 0xfe, 0x0f,
16 | 0xf0, 0xbd, 0xcf, 0xeb, 0xfe, 0x0f, 0xf0, 0xbd, 0xde, 0xe3, 0xbd, 0x0f,
17 | 0xf0, 0x9d, 0xcc, 0xf7, 0x99, 0x0f, 0xf0, 0xc0, 0xe2, 0xf7, 0xc3, 0x0f,
18 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
19 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
20 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
21 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f,
22 | 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x40, 0x55, 0x55, 0x55, 0x55, 0x05,
23 | 0x40, 0x55, 0x55, 0x55, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 | };
29 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/listicon.xbm:
--------------------------------------------------------------------------------
1 | #define listicon_width 48
2 | #define listicon_height 48
3 | static unsigned char listicon_bits[] = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6 | 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x02, 0x00, 0xc0, 0x00, 0x00,
7 | 0x00, 0x02, 0x00, 0x40, 0x01, 0x00, 0x00, 0x02, 0x00, 0x40, 0x02, 0x00,
8 | 0x00, 0x02, 0x00, 0x40, 0x04, 0x00, 0x00, 0xe2, 0xdd, 0x4b, 0x08, 0x00,
9 | 0x00, 0x02, 0x00, 0x40, 0x10, 0x00, 0x00, 0x62, 0x77, 0xdf, 0x3f, 0x00,
10 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0xe2, 0xdf, 0xef, 0x31, 0x00,
11 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0xe2, 0x77, 0x37, 0x30, 0x00,
12 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
13 | 0x00, 0xe2, 0xbb, 0xf7, 0x31, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
14 | 0x00, 0xe2, 0xee, 0xbd, 0x30, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
15 | 0x00, 0x62, 0x7b, 0xef, 0x31, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
16 | 0x00, 0xe2, 0xef, 0x7b, 0x30, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
17 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0xe2, 0xbd, 0xdb, 0x31, 0x00,
18 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0xa2, 0xef, 0x6e, 0x30, 0x00,
19 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0xe2, 0xf6, 0xbd, 0x30, 0x00,
20 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
21 | 0x00, 0xe2, 0xdf, 0xfb, 0x31, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
22 | 0x00, 0x62, 0xfb, 0x5f, 0x30, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
23 | 0x00, 0xe2, 0xdf, 0xbd, 0x31, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
24 | 0x00, 0x02, 0x00, 0x00, 0x30, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
25 | 0x00, 0xfe, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00,
26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
28 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/memicon.xbm:
--------------------------------------------------------------------------------
1 | #define memicon_width 48
2 | #define memicon_height 48
3 | static unsigned char memicon_bits[] = {
4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6 | 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x02, 0x00, 0xc0, 0x00, 0x00,
7 | 0x00, 0xda, 0xb6, 0x4d, 0x01, 0x00, 0x00, 0x02, 0x00, 0x40, 0x02, 0x00,
8 | 0x00, 0xda, 0xb6, 0x4d, 0x04, 0x00, 0x00, 0x02, 0x00, 0x40, 0x08, 0x00,
9 | 0x00, 0xda, 0xb6, 0x4d, 0x10, 0x00, 0x00, 0x02, 0x00, 0xc0, 0x3f, 0x00,
10 | 0x00, 0xda, 0xf0, 0x21, 0x30, 0x00, 0x00, 0x02, 0x0c, 0x06, 0x30, 0x00,
11 | 0x00, 0x5a, 0xe2, 0x08, 0x33, 0x00, 0x00, 0x02, 0x19, 0x13, 0x30, 0x00,
12 | 0x00, 0x9a, 0x04, 0x24, 0x33, 0x00, 0x00, 0x82, 0x02, 0x28, 0x30, 0x00,
13 | 0x00, 0x5a, 0xba, 0x4b, 0x33, 0x00, 0x00, 0x42, 0x89, 0x50, 0x30, 0x00,
14 | 0x00, 0x5a, 0xb9, 0x53, 0x33, 0x00, 0x00, 0x42, 0x89, 0x50, 0x30, 0x00,
15 | 0x00, 0x5a, 0x8a, 0x48, 0x33, 0x00, 0x00, 0x82, 0x02, 0x28, 0x30, 0x00,
16 | 0x00, 0x9a, 0x04, 0x24, 0x33, 0x00, 0x00, 0x02, 0x19, 0x33, 0x30, 0x00,
17 | 0x00, 0x5a, 0xe2, 0x58, 0x32, 0x00, 0x00, 0x02, 0x0c, 0x96, 0x30, 0x00,
18 | 0x00, 0xda, 0xf0, 0x21, 0x31, 0x00, 0x00, 0x02, 0x00, 0x40, 0x32, 0x00,
19 | 0x00, 0xda, 0xb6, 0x8d, 0x34, 0x00, 0x00, 0x02, 0x00, 0x00, 0x39, 0x00,
20 | 0x00, 0xda, 0xb6, 0x6d, 0x32, 0x00, 0x00, 0x02, 0x00, 0x00, 0x34, 0x00,
21 | 0x00, 0xda, 0xb6, 0x6d, 0x39, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
22 | 0x00, 0xda, 0xb6, 0x6d, 0x33, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
23 | 0x00, 0xda, 0xb6, 0x6d, 0x33, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
24 | 0x00, 0xda, 0xb6, 0x6d, 0x33, 0x00, 0x00, 0x02, 0x00, 0x00, 0x30, 0x00,
25 | 0x00, 0xfe, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00,
26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
28 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/wait.xbm:
--------------------------------------------------------------------------------
1 | #define wait_width 17
2 | #define wait_height 17
3 | #define wait_x_hot 8
4 | #define wait_y_hot 8
5 | static unsigned char wait_bits[] = {
6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10 | 0x00, 0x00, 0x00};
11 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/wait0.xbm:
--------------------------------------------------------------------------------
1 | #define wait0_width 17
2 | #define wait0_height 17
3 | #define wait0_x_hot 8
4 | #define wait0_y_hot 8
5 | static unsigned char wait0_bits[] = {
6 | 0xc0, 0x07, 0x00, 0xf0, 0x19, 0x00, 0xf8, 0x21, 0x00, 0xfc, 0x41, 0x00,
7 | 0xfe, 0x81, 0x00, 0xfe, 0x81, 0x00, 0xff, 0x01, 0x01, 0xff, 0x01, 0x01,
8 | 0xff, 0xff, 0x01, 0x01, 0xff, 0x01, 0x01, 0xff, 0x01, 0x02, 0xff, 0x00,
9 | 0x02, 0xff, 0x00, 0x04, 0x7f, 0x00, 0x08, 0x3f, 0x00, 0x30, 0x1f, 0x00,
10 | 0xc0, 0x07, 0x00};
11 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/wait1.xbm:
--------------------------------------------------------------------------------
1 | #define wait1_width 17
2 | #define wait1_height 17
3 | #define wait1_x_hot 8
4 | #define wait1_y_hot 8
5 | static unsigned char wait1_bits[] = {
6 | 0xc0, 0x07, 0x00, 0xf0, 0x1f, 0x00, 0xf8, 0x3f, 0x00, 0xfc, 0x7f, 0x00,
7 | 0xf2, 0x9f, 0x00, 0xe2, 0x8f, 0x00, 0xc1, 0x07, 0x01, 0x81, 0x03, 0x01,
8 | 0x01, 0x01, 0x01, 0x81, 0x03, 0x01, 0xc1, 0x07, 0x01, 0xe2, 0x8f, 0x00,
9 | 0xf2, 0x9f, 0x00, 0xfc, 0x7f, 0x00, 0xf8, 0x3f, 0x00, 0xf0, 0x1f, 0x00,
10 | 0xc0, 0x07, 0x00};
11 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/wait2.xbm:
--------------------------------------------------------------------------------
1 | #define wait2_width 17
2 | #define wait2_height 17
3 | #define wait2_x_hot 8
4 | #define wait2_y_hot 8
5 | static unsigned char wait2_bits[] = {
6 | 0xc0, 0x07, 0x00, 0x30, 0x1f, 0x00, 0x08, 0x3f, 0x00, 0x04, 0x7f, 0x00,
7 | 0x02, 0xff, 0x00, 0x02, 0xff, 0x00, 0x01, 0xff, 0x01, 0x01, 0xff, 0x01,
8 | 0xff, 0xff, 0x01, 0xff, 0x01, 0x01, 0xff, 0x01, 0x01, 0xfe, 0x81, 0x00,
9 | 0xfe, 0x81, 0x00, 0xfc, 0x41, 0x00, 0xf8, 0x21, 0x00, 0xf0, 0x19, 0x00,
10 | 0xc0, 0x07, 0x00};
11 |
--------------------------------------------------------------------------------
/src/UI/bitmaps/wait3.xbm:
--------------------------------------------------------------------------------
1 | #define wait3_width 17
2 | #define wait3_height 17
3 | #define wait3_x_hot 8
4 | #define wait3_y_hot 8
5 | static unsigned char wait3_bits[] = {
6 | 0xc0, 0x07, 0x00, 0x30, 0x18, 0x00, 0x08, 0x20, 0x00, 0x0c, 0x60, 0x00,
7 | 0x1e, 0xf0, 0x00, 0x3e, 0xf8, 0x00, 0x7f, 0xfc, 0x01, 0xff, 0xfe, 0x01,
8 | 0xff, 0xff, 0x01, 0xff, 0xfe, 0x01, 0x7f, 0xfc, 0x01, 0x3e, 0xf8, 0x00,
9 | 0x1e, 0xf0, 0x00, 0x0c, 0x60, 0x00, 0x08, 0x20, 0x00, 0x30, 0x18, 0x00,
10 | 0xc0, 0x07, 0x00};
11 |
--------------------------------------------------------------------------------
/src/UI/breakpt.tk:
--------------------------------------------------------------------------------
1 | # Breakpoints
2 |
3 | ###############################################################################
4 | # Refresh the list of breakpoints in the breakpoint dialog
5 | ###############################################################################
6 | proc Breakpoints:Refresh {} {
7 |
8 | PutLine "ListBreakpoints"
9 | .breakpoints.list.list delete 0 end
10 |
11 | foreach i [lsort -ascii [GetList]] {
12 | .breakpoints.list.list insert end "$i"
13 | }
14 | }
15 |
16 | ###############################################################################
17 | # Break Point manipulation
18 | ###############################################################################
19 | proc Breakpoints:Open {} {
20 |
21 | ## Put the application in modal mode
22 | set mode [GetApplicationMode]
23 | SetApplicationMode "ModalMode"
24 |
25 | ## Make sure the window is destroyed
26 | catch {destroy .breakpoints}
27 |
28 | ## Create frame for breakpoint dialog
29 | frame .breakpoints -relief ridge -borderwidth 4
30 |
31 | ## Create the list of break points
32 | frame .breakpoints.list
33 | scrollbar .breakpoints.list.scroll -relief raised \
34 | -command ".breakpoints.list.list yview" -takefocus 0
35 | listbox .breakpoints.list.list -relief raised \
36 | -yscroll ".breakpoints.list.scroll set" \
37 | -selectmode extended -width 16
38 | pack .breakpoints.list.scroll -side left -fill y
39 | pack .breakpoints.list.list -side left -fill both -expand 1
40 |
41 | ## Create the add entry box
42 | frame .breakpoints.add -relief raised -borderwidth 2
43 | entry .breakpoints.add.entry -relief sunken
44 | bind .breakpoints.add.entry {
45 | if {[regexp {^[0-9a-fA-F]*$} [.breakpoints.add.entry get]]} {
46 | PutLine "AddBreakpoint [.breakpoints.add.entry get]"
47 | .breakpoints.add.entry delete 0 end
48 | GetList
49 | Breakpoints:Refresh
50 | ProgramListing:RefreshBreakpoints
51 | }
52 | }
53 | label .breakpoints.add.label -text "Add:"
54 | pack .breakpoints.add.label -side left
55 | pack .breakpoints.add.entry -side left -fill x -expand 1
56 |
57 | button .breakpoints.remove -text "Remove" \
58 | -command {
59 | if {[llength [.breakpoints.list.list curselection]] != 0} {
60 | foreach i [.breakpoints.list.list curselection] {
61 | PutLine "DeleteBreakpoint [.breakpoints.list.list get $i]"
62 | GetList
63 | }
64 | Breakpoints:Refresh
65 | ProgramListing:RefreshBreakpoints
66 | }
67 | }
68 |
69 | button .breakpoints.dismiss -text "Dismiss" -command {destroy .breakpoints}
70 |
71 | pack .breakpoints.list -side top -expand 1 -fill both -padx 2 -pady 2
72 | pack .breakpoints.add -side top -fill x -expand 1 -padx 2 -pady 2
73 | pack .breakpoints.remove -side left -fill x -expand 1 -padx 2 -pady 2
74 | pack .breakpoints.dismiss -side left -fill x -expand 1 -padx 2 -pady 2
75 |
76 | update idletasks
77 | place .breakpoints -relx 0.5 -rely 0.5 -anchor center
78 |
79 | ## Set keyboard focus to the entry widget
80 | focus .breakpoints.add.entry
81 |
82 | ## Update breakpoint list
83 | Breakpoints:Refresh
84 |
85 | ## Wait for the dismiss to be pressed
86 | tkwait window .breakpoints
87 |
88 | ## Reset application mode
89 | SetApplicationMode $mode
90 | }
91 |
92 |
--------------------------------------------------------------------------------
/src/UI/bsvc.win:
--------------------------------------------------------------------------------
1 |
2 | *memoryViewer.text*Background: MistyRose2
3 | *memoryViewer.text*activeBackground: MistyRose1
4 | *memoryViewer.text*activeForeground: Black
5 | *memoryViewer.text.width: 55
6 | *memoryViewer.text.height: 18
7 |
8 | *memoryViewer.dumpDialog*Background: bisque1
9 | *memoryViewer.dumpDialog*activeBackground: bisque2
10 | *memoryViewer.dumpDialog*highlightBackground: bisque2
11 | *memoryViewer.dumpDialog*activeForeground: black
12 |
13 | *memoryViewer.changeMemory*Background: bisque1
14 | *memoryViewer.changeMemory*activeBackground: bisque2
15 | *memoryViewer.changeMemory*highlightBackground: bisque2
16 | *memoryViewer.changeMemory*activeForeground: black
17 |
18 | *memoryViewer.fillMemory*Background: bisque1
19 | *memoryViewer.fillMemory*activeBackground: bisque2
20 | *memoryViewer.fillMemory*highlightBackground: bisque2
21 | *memoryViewer.fillMemory*activeForeground: black
22 |
23 | *memoryViewer.register*Background: bisque1
24 | *memoryViewer.register*activeBackground: bisque2
25 | *memoryViewer.register*highlightBackground: bisque2
26 | *memoryViewer.register*activeForeground: black
27 |
28 | *programListing.pack.text.width: 80
29 | *programListing.pack.text.height: 18
30 |
31 | *breakpoints.list.list.geometry: 12x10
32 | *breakpoints.add.entry.width: 12
33 | *breakpoints*Background: bisque1
34 | *breakpoints*activeBackground: bisque2
35 | *breakpoints*highlightBackground: bisque2
36 | *breakpoints*activeForeground: black
37 |
38 | *alertDialog*Background: LightSteelBlue1
39 | *alertDialog*activeBackground: LightSteelBlue2
40 | *alertDialog*highlightBackground: LightSteelBlue2
41 | *alertDialog*activeForeground: LightSteelBlue4
42 |
43 | *entryDialog*Background: bisque1
44 | *entryDialog*activeBackground: bisque2
45 | *entryDialog*highlightBackground: bisque2
46 | *entryDialog*activeForeground: black
47 |
48 | *writeModeDialog*Background: bisque1
49 | *writeModeDialog*activeBackground: bisque2
50 | *writeModeDialog*highlightBackground: bisque2
51 | *writeModeDialog*activeForeground: black
52 |
53 | *about*Background: #d9d9d9
54 | *about*activeBackground: #e9e9e9
55 | *about*activeForeground: Black
56 |
57 | *license.pack.text.width: 80
58 | *license.pack.text.height: 22
59 |
60 | *systemResources.registers*Background: seashell2
61 | *systemResources.registers.popup*activeBackground: seashell1
62 | *systemResources.registers.popup*activeForeground: black
63 | *systemResources.registers.list.selectForeground: Black
64 |
65 | *systemResources.statistics*Background: honeydew3
66 | *systemResources.statistics.popup*activeBackground: honeydew1
67 | *systemResources.statistics.popup*activeForeground: black
68 | *systemResources.statistics.list.selectForeground: Black
69 |
70 | *systemControl*Background: LightPink1
71 | *systemControl*highlightBackground: LightPink2
72 | *systemControl*activeBackground: LightPink2
73 | *systemControl*activeForeground: Black
74 |
75 | *systemOutput*Background: snow3
76 | *systemOutput*activeBackground: snow2
77 | *systemOutput*activeForeground: black
78 | *systemOutput*selectForeground: black
79 | *systemOutput*selectBackground: SkyBlue
80 | *systemOutput.text.width: 56
81 | *systemOutput.text.height: 22
82 |
83 |
84 |
--------------------------------------------------------------------------------
/src/UI/license.tk:
--------------------------------------------------------------------------------
1 | #
2 | # license.tk - BSVC copyright information
3 | #
4 |
5 | ###############################################################################
6 | # Create and display the license information dialog
7 | ###############################################################################
8 | proc License:Open {} {
9 | global Program
10 |
11 | # Return if the dialog already exists
12 | if {[winfo exists .license] == 1} {
13 | wm deiconify .license
14 | return
15 | }
16 |
17 | ## Create the top level window
18 | toplevel .license
19 | wm title .license "License"
20 | wm iconname .license "License"
21 | wm minsize .license 80 20
22 |
23 | text .license.text -relief sunken -borderwidth 2 \
24 | -yscrollcommand ".license.scroll set" \
25 | -setgrid 1 -wrap word \
26 | -takefocus 0 -highlightthickness 0
27 | scrollbar .license.scroll -command ".license.text yview" \
28 | -takefocus 0 -highlightthickness 0
29 | button .license.dismiss -text "Dismiss" \
30 | -command "destroy .license"
31 |
32 | pack .license.dismiss -side bottom -fill x
33 | pack .license.scroll -side left -fill y
34 | pack .license.text -side left -fill both -expand 1
35 |
36 | ## Create a highlight tag
37 | .license.text tag configure Highlight \
38 | -font -*-helvetica-bold-r-normal--*-140-*-*-*-*-iso8859-* \
39 | -underline 1 -borderwidth 2 -foreground Red
40 |
41 | .license.text insert 0.0 "\nLicense Information and Copyright Notice\n"
42 | .license.text tag add Highlight "2.0" "2.0 lineend"
43 |
44 | ## Read in the copyright information
45 | set file [open $Program(HelpDir)/license {r}]
46 | set info [read $file]
47 | close $file
48 |
49 | .license.text insert end $info
50 | .license.text configure -state disabled
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/src/mkdeps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | CC=${CC:-gcc}
3 | dir=$1
4 | shift
5 | if [ "$dir" != "" ]
6 | then
7 | dir="$dir/"
8 | fi
9 | $CC -MM -MG "$@" | sed -e "s@\(.*\).o:@$dir\1.o $dir\1.d:@"
10 |
--------------------------------------------------------------------------------