
-------------------------------------------------------------------------------

                                  S.I.M.

                        System-Independent Monitor
                          Release 4, Version 1.81

                  Copyright © 1990-1993 by Stefan Walter
                            ALL RIGHTS RESERVED

-------------------------------------------------------------------------------



				CONTENTS
				========


1.	Introduction
====================

	1.1		SIM v1.81
	1.2		Disclaimer


2.	Getting Started with SIM
================================

	2.1		What is SIM?
	2.2		Requirements and Limitations
	2.3		Commodores Guidelines for 'Banging the Hardware'
	2.4		Configurating SIM
	2.5		The SIM Binary
	2.6		Display Usage
	2.6		Keyboard Usage
	2.7		Mouse Support


3.	Command Window Usage
============================

	3.1		Editing functions
	3.2		Command Line Buildup and Execution
	3.3		Command List Explanations
	3.4		Memory Display and Related Commands
		3.4.1		Hexdump
		3.4.2		Asciidump
		3.4.3		Disassemble
		3.4.4		Copperlist
		3.4.5		Print Text
		3.4.6		Bitplane View
		3.4.7		Hear Memory
	3.5		Memory Editition Commands
		3.5.1		Edit Memory
		3.5.2		Assemble
		3.5.3		Transfer Memory
		3.5.4		Occupy Memory



4.	Debugger Window
=======================

5.	Assembler and Calculator
================================

        5.1     Assembler Usage 
        5.2     Calculator Usage
        5.3     Data Lines
        5.4     Disassembly Search Pattern


6.	Safety Features
=======================

	6.1	Warnings
	6.2	Selfprotection
	6.3	The External Interrupt Handler


7.	Advanced Features
=========================

	7.1	When SIM Fails...


8.	Appendixes
=========================

        8.1     Bibliography
        8.2     Acknowledgements	
        8.3     Registered Users
        8.4     Contacting Me...




*******************************************************************************
	1.	Introduction
*******************************************************************************




1.1	SIM v1.81
=================


Congratulations! You have just obtained a copy of the fourth release of SIM,
a hardware oriented, high performance 680x0/688xx monitor and debugger for
the Commodore Amiga.

SIM is distributed under the concept of shareware. In other words, you are
allowed to get a copy of it and to give it to anybody else. If you find this
program good and if you keep using it, I would appreciate if you send me
a contribution. For 15$ you will be registered and you will recieve support,
in case of errors you may find, you will obtain a fixed version, and you
get the next major release of the program.



1.2	Disclaimer
==================


This program is provided "as is" without warranty of any kind. The entire
risk of using it is to the user himself. In no event I (the author) will
be liable for direct or indirect damage, loss of data or criminal actions
done due to the use of this program. If you do not agree with this, you
may not use SIM.




*******************************************************************************
	2.	Getting started with SIM
*******************************************************************************




2.1	What is SIM?
====================


SIM is a very powerful debugger and monitor.  It was designed to work under
all   circumstances  and  especially  to  supervise  rather  unconventional
programs  which  do  not  make  much  use  of  the  operating  system or do
completely  disable  it  for  a  more  or  less long period of time.  It is
intended  for  people  who  need to debug games, demonstration programs and
even  other  operating  systems  on  the  Amiga.   It  fully  supports  the
68000-68040 processor range, the 68881/2 FPU and the 68851 MMU.

SIM  works below the operating system and does not interact with any of its
facilities  or  routines.   It  disposes  of  ways to enable you relatively
comfortable  debugging of any piece of machine language.  Be it a task list
manipulating  routine,  an interrupt or direct access on hardware like disk
drives  or  the  blitter,  routines you can't trace with an ordinary system
based  debugger.   There  are practically no limits,  you can invoke SIM at
any moment and it will pop up and work properly.

SIM will do as less changes to the software and hardware (RAM, custom/cia
registers) as it can. When you exit SIM, it will try to leave everything the
way it was when SIM was started. SIM does neiter use blitter nor copper,
so any 'interrupted' program can continue to run with no defects due to
a call to SIM.

SIM will be very useful for you if you need to debug programs belonging in
the cathegories described above. If you only need to debug 'ordinary'
programs with no critical or nonmultitasking routines, you are better served
with a full system debugger. There are plenty of good debuggers of that
kind available, also in the Public Domain.



2.2	Requirements and Limitations
====================================


SIM currently has certain problems with all kinds of graphic cards. Its
display will only appear on a monitor connected to the RGB port of the
Amiga.

To  use  SIM  efficiently,  detailed  knowledge of the AMIGAs hardware, the
MC680x0  processors, their coprocessors and assembly language is ABSOLUTELY
neccessary.   If  you  lack this knowledge, get Commodores 'Amiga Technical
Reference Series' and Motorolas documentations of the 68000 family.



2.3	Commodores Guidelines for 'Banging the Hardware'
========================================================


Accessing the hardware registers of the Amiga directly has been allowed
by Commodore until the AA chipset was introduced. Now, to enssure
compatibility of programs to new Amiga models and chip sets, accessing
the hardware, especially the registers concerning display, is strictly
prohibited for normal programs.

SIM however needs to access those registers directly since its concept was
*not* to use any functions of the OS. Therefore SIM will work on all
existing Amigas but it is not guaranted to work on whatever comes after
the A4000. In any case, an update of SIM which will be capable of
handling any possible new chipset will be released as soon as new Amiga
models are on the market. 



2.4	Configuring SIM
=======================



2.5	The SIM Binary
======================


SIM is not an executable. It has no hunk structure and hence cannot simply be
started from CLI or Workbench. It is a simple file containing fully PC
relative code that needs no relocation. It can be located somewhere in the
memory or included in any program that needs a built-in debugger while
developing and just has to be invoked when needed. The advantages and
possibilities of this concept are discused in a later chapter. SIM keeps
its own dataspace within itself, so it is currently not possible to locate
SIM in ROM/EPROM or in otherwise write protected memory.



2.6	Display Usage
=====================


SIM builds up a one plane high resolution display, either interlaced or not.
When you use PAL it has 640x256/512 pixels, in NTSC mode 640x200/400. Expressed
in characters this means 80x32/64 for PAL, 80x25/50 for NTSC. SIM contains a
full ASCII charset, which, by default, is the same as Kickstart 2.04 topaz 80.

The display is seperated into three parts:

The head line. It contains the program title, the entry reason and a signal
field for warnings. It is also used for input of options and data used
by certain shortcuts, and for keyboard restoring when leaving SIM.

The  command  and debugger window.  The command window serves for execution
of  commands,  the  debugger  window to display the register set and one or
multiple  areas  of  memory.   What is in the command window is stored when
exiting SIM and available again when invoking SIM again.

The bottom line. It contains a field for status and error messages and the
startaddresses of SIM in memory, the plane, the backup for it and the work
memory.



2.7	Keyboard Usage
======================


SIM contains two complete keymaps for unqualified, shifted, alternated and
shifted & alternated keys, one custom that can be selected when configuring
SIM and one US. The keymaps are adapted one-on-one from the international
keymaps distributed by Commodore on the Workbench disk except that there
is no 'dead-key' support. The user can toggle between US and custom keymap
using the <AMIGA+SHIFT+k> shortcut.

To enter a character with ascii value from 0 to $1f, press <CTRL> and a
key with ascii value from $40 to $5f, i.e. <CTRL+[> for the ESC character.
To enter a character with ascii value from $80 to $9f, press <CTRL> and a
key with ascii value from $60 to $7f, i.e. <CTRL+{> for the CSI character.
Note that SIM makes a difference between <CTRL> keystrokes and function keys
that normally have assigned the same ASCII value. Entering <CTRL+J> is
a character and does not have the effect of pressing the <CR> key. This way
it is possible to include any CTRL chars in expressions.

Key repeat speed is 1/50th (PAL) or 1/60th (NTSC) of a second, key repeat
delay is 5/2 or 1/3 of a second. Both can't be modified.

The keypad is not used for movement, only for numeric input etc.



2.6	Mouse Support
=====================


SIM supports the mouse for different operations. It is not vital to have
the mouse connected, it is only used for features that enhance comfort.

The mouse pointer is a little arrow, smaller than the regular mouse
pointer.  SIM doesn't use a sprite for it but copies the pointer directly
in the plane.  Therefore it may flicker sometimes.  Speed is comparable to
setting 1 or 2 of the normal preferences.  Double click timeout is 1/2 of a
second.

The pointer automatically disappears as soon as you press a key or SIM is
busy doing output on the screen.




*******************************************************************************
	3.	Command Window
*******************************************************************************




3.1	Editing Functions
=========================


The command window is one of the two windows SIM has. It is used to execute
commands likely to a CLI window of Amiga DOS with the difference that it's
not line oriented but acts as a whole page. The cursor can also be moved up
and down, enabeling reuse of previous commands and output.

When typing, normally all text goes to the monitor window. SIM either uses
insert or overwrite mode, depending what the user selected with the shortcut
<AMIGA+,>, default is overwrite.

The command window is basically a text buffer. One can simply enter a
character at any position in it. If the cursor would go below the bottom of
the window by pressing <CR> in the bottom line, the entier buffer scrolls
one line up. There is also no line wrap, a command line starts at row 1 and
ends at row 80, the cursor will not switch to the next line when it reaches
the right margin. The contents of the command window are stored within SIM
and are available again at its next invocation.

For editition of command lines and cursor movement, the following basic
functions are assigned to function keys:

	- The cursor can be moved left and right by either pressing <Left>
	  or <Right>.

	- The cursor can be moved to left margin by pressing <SHIFT+Left>.

	- The cursor can be moved to the end of the text line, that means
	  to the space after the last char that is not a space in the line or
	  to the last char if the line is full, by pressing <SHIFT+Right>.

	- The cursor can be moved one line up or down by either pressing
	  <Up> or <Down>.

	- The cursor can be moved to the first or the last line in the
	  window by pressing either <SHIFT+Up> or <SHIFT+Down>

	- <DEL> deletes the character the cursor is on and shifts all chars
	  right of it one left and inserts a space at row 79.

	- <BS> moves cursor one left and deletes that char.

	- <SHIFT+DEL> inserts a space at the position of the cursor,
	  shifting all chars right of it one right.

	- <SHIFT+BS> replaces char on which the cursor is by a space
	  and moves cursor one left.

	- <ALT+DEL> will clear the visible part of the command window and
	  put the cursor in the left upper corner next to a period.

	- <ALT+BS> will clear the line in which the cursor is, put a period
	  in row 1 and the cursor in row 2.

	- <SHIFT+ESC> copies the last executed command line in the line of
	  the cursor.

	- <ALT+ESC> copies the line of the cursor in the command line
	  buffer. It can then be inserted anywhere with <SHIFT+ESC>.

	- <CR> will execute the commands in the line the cursor is in.

	- <SHIFT+CR> clears the part of the command line left of the
	  cursor and executes it.

	- <ALT+CR> executes only the first command of a command line and
          ignores the rest

Additionally to these, the following function keys also have a direct effect
on the window:

	- <HELP> activates the online help system.

	- <ALT+Up> goes one step back in command history and fills the
	  line of the cursor with the current history command string.

	- <ALT+Down> goes one step forth in command history. If there is
	  no newer command string, the line is cleared.

SIM remembers the last command lines executed. The last two shortcuts are
used to put an earlier executed command line back in the current line.

The mouse can be used to position the cursor by clicking on the place where
it must go. Snap functions described in a later chapter are also supported.



3.2	Command Line Buildup and Execution
==========================================


A commad line in general looks like this, where <command> is a command keyword
and <options> can be whatever:

	.<command> <options>:<command> <options...

Multiple commands can be executed in one event by seperating them with a ':'.
The period at the beginning of the line is not neccessary. A command can also
begin at any place in the line. Options do not need to be seperated from the
command by a space as long as the direct combination of the wanted command
and the beginning of the options does not form another, longer command name.

Multiple arguments in options are separated by spaces. If a command can
handle multiple options (like the calculate command), the different options
are seperated by a komma.

When starting execution of a command line, SIM remembers it in the command
line history, if the line that is executed is no reuse of an earlier command
line put back by the command history shortcuts.

When all commands of a command line have been executed, SIM checks the line
the cursor now is in. If there is a space or a semikolon in row 1, it clears
the line. Otherwise it lets it, puting the cursor in row 2 if there is a period
in row 1, in row two if there is another char in row 1.

There are several comands that can be repeated. This means that by pressing
<CR> in an empty line with no command in it, SIM will execute the last command
without arguments. This applies to all dump commands, trace commands and
certain others.

Commands are case sensitive. Rarely used or dangerous commands consist of
multiple characters or are upper case.



3.3	Command List Explanations
=================================


In the helppage and the explanations, the following abreviations are used for
options:

	- s	start address/seek
	- e	endaddress
	- a	address
	- t	destination 'target' address/track
	- i	assembly instruction(s)/fragments
	- d	data
	- c	text
	- n	decimal number
	- x	hexadecimal number
	- m	mask
	- r	register
	- p	plane/period
	- b	backup/buttons/block
	- ?	calculator expression
	- f	file
	- j	advanced options

Arguments in '[]' brackets are neccessary, leaving them away causes an
'argument missing' error and aborts command execution. Options in '()' are
optional and can be left out. Chars in '{}' brackets are optional and serve
as flags.

Because space in SIM is limited, the help pages tell only the basic syntax
of a command and its char sequence. The following list contains detailed
information about each command. Commands for similar purposes are
grouped together.



3.4	Memory Display and Related Commands
===========================================


All dump commands share the same syntax. They also all use the memory paging
and only display memory that is declared, use full charset if desired and
24 or 32 bit addresses.

All commands use the actual address if no start address is specified.
Refere to the appropriate section for details.



3.4.1	Hexdump
---------------

Usage:	m (s)(e)

	Displays the chosen clip of the memory as hexdump with asciidump,
	16 bytes per line. If editable dump is on, a colon is put
	at the start of the line, enabling editing the memory by changeing
	the dump and pressing <CR> in the changed line.

	Memory that is not defined and hence not readable is represented
	by asterixes in both hex- and asciidump. Asciidump uses the full
	charset if this is enabled.

	If the chosen area's length is not a multiple of 16, it is rounded
	up to the next multiple of 16.

		m [s][e]	Display hexdump from s to e.
		m [s]		Display 8 lines hexdump from s.
		m		Display 8 lines hexdump at actual address.

Example:

.m -20 !+37
:ffffffe0: **** **** **** **** **** **** **** ****  ;****************
:fffffff0: **** **** **** **** **** **** **** ****  ;****************
:00000000: 0000 0000 00c0 0276 00fc 0818 00fc 081a  ;.....À.v.ü...ü..
:00000010: 00fc 081c 00fc 081e 00fc 0820 00fc 0822  ;.ü..ü...ü. .ü."
.



3.4.2	Asciidump
-----------------

Usage:	a (s)(e)

	Displays the chosen area of the memory as asciidump, 64 bytes per
	line. If editable dump is on and full charset used, a '`' char is
	put at the start of the line, enabling editing the memory by
	changeing the dump and pressing <CR> in the changed line.

	Memory that is not defined and hence not readable is represented
	by asterixes. The entier charset is used if this is enabled, else
	CTRL chars are represented by a period.

	If the chosen area's length is not a multiple of 64, it is rounded
	up to the next multiple of 64.

		a [s][e]	Display asciidump from s to e.
		a [s]		Display 8 lines asciidump from s.
		a		Display 8 lines asciidump at actual address.

Example:

.a -80 80
 ffffff80: 'N.J.l..."*.ìp(j..N.NÖNq...............¬.......È...Ì...É...p...8 '
 ffffffc0: '...@...Î...h...Í...°...Ê...|...Ë...T...Ñ.&}³....?À............. '
 00000000: '.....À.v.ü...ü...ü..ü...ü. .ü.".ü...ü.&.ü.(.ü.*.ü.,.ü...ü.0.ü.2 '
 00000040: '.ü.4.ü.4.ü.4.ü.4.ü.4.ü.4.ü.4.ü.4.ü.4.ü...ü.â.ü...ü.l.ü.ú.ü.@.ü..'
.



3.4.3	Disassemble
-------------------

Usage:	d (s)(e)

	Displays the desired part of the memory as 680x0/688xx disassembly, one
	instruction per line. If an endaddress was given, the command ends
	as soon as after a line, the actual address is greater or equal to
	the endaddress. If no endaddress given, memory for 8 lines is
	disassembled. If editable dump is selected, a tilde is put at the
	start of a line enabeling to assemble to memory by changing an
	instruction in the dump and pressing <CR>.

	There are four possible dump forms, explained in the apropriate
	chapter. Instructions which are no pure 68000 code are marked
	with '?!'.

	Memory that is not defined and hence not readable is represented
	by asterixes in both disassembly and opcode.

		d [s][e]	Disassemble from s to e.
		d [s]		Disassemble 8 lines from s.
		d		Disassemble 8 lines at actual address.

Example:

.d -2 10
~fffffffe: ****  *
~00000000: 0000 >ori.b   #0,d0
~00000004: 00c0  dc.w    $c0
~00000006: 0276  andi.w  #$fc,$18(a6,d0.l)
~0000000c: 00fc *dc.w    $fc
~0000000e: 081a  btst    #4,(a2)+
~00000012: 081c  btst    #4,(a4)+
.



3.4.4	Copperlist
------------------

Usage:	l (s)(e)

	Displays the desired area area of memory as copperlist disassembly,
	one instruction per line.

	Memory that is not defined and hence not readable is represented
	by asterixes in both opcode and disassembly. Copperlist instructions
	that are not pure are marked with '?!'.

	If the chosen area's length is not a multiple of 4, it is rounded
	up to the next multiple of 4.

		l [s][e]	Display copperlist from s to e.
		l [s]		Display 8 lines copperlist from s.
		l		Display 8 lines copperlist at actual address.

Example:

.l -4
 fffffffc: ********  *
 00000000: 00000000  cmove   #$0000,$dff000
 00000004: 00c00276  cmove   #$0276,$dff0c0
 00000008: 00fc0818  cmove   #$0818,$dff0fc
 0000000c: 00fc081a  cmove   #$081a,$dff0fc
 00000010: 00fc081c  cmove   #$081c,$dff0fc
 00000014: 00fc081e  cmove   #$081e,$dff0fc
 00000018: 00fc0820  cmove   #$0820,$dff0fc
.



3.4.5	Print Text
------------------

Usage:	o (s)(e)

	Displays the desired area area of memory as text, likely to a text editor.
	There is no address header before each line. Lines longer than 80 chars
	are truncated. All CTRL chars cause a line feed except TAB which is
	interpreted as 8-spacing tabulator.

	Memory that is not defined and hence not readable is represented
	by asterixes. If the full charset is enabled, it will be used.

	This command mainly serves to display source codes somewhere in
	memory.

		o [s][e]	Display text from s to e.
		o [s]		Display 8 lines text from s.
		o		Display 8 lines text at actual address.

Example:

.o 201000
.
.
.
.
.
À.
v.
ü.
.



3.4.6	View Plane
------------------

Usage:	P (a)(n)

	Initiates the bitplane viewer. SIM will display memory starting
	at a given address as bitplane graphic with modulo in hires
	or lores. Either 240 or 184 lines are used for the graphics in
	black/white color, depending on PAL/NTSC mode. The bottom two
	text lines are used as a seperating bar and a status line indicating
	current start address, modulo and resolution.

	SIM uses the page memory managing and only displays parts of the
	addressing space containing memory. Undefined memory is zeroed
	and hence black.

	It is possible to look at the full range of memory, also at fast
	and expansion ram and rom.

	While the viewer is active, the following keys are used for its
	control:


	<ESC>		Terminates the command and continues execution
			of the current command line.

	<CR>		Toggles between hires and lores. Modulo is adjusted
			so the graphics shrink or expand in width but don't
			get mixed up.

	<BS>		Resets modulo to zero.

	<HELP>		Increases modulo by 2.

	<DEL>		Decreases modulo by 2.

	<SHIFT+HELP>	Increases modulo by 16.

	<SHIFT+DEL>	Decreases modulo by 16.

	<Up>		One line up. Decreases address by line length+modulo.

	<Down>		One line down. Increases address by line length+modulo.

	<Left>		One word left. Increases address by 2.

	<Right>		One word right. Decreases address by 2.

	<SHIFT+Up>	One page up. Decreases address by page length.

	<SHIFT+Down>	One page down. Increases address by page length.


	Modulo is limited to a range of $ffda to 3fd8 for lores, $ffb2 to
	$3db0 for hires display. Therefore line lengths range from 2 to
	$4000 bytes per line.

	The resolution used at termination will be used again when the comand
	is used next time.
 
		P [a][n]	View bitplane at a with modulo n.
		P [a]		View bitplane at a with same modulo.
		P 		View bitplane at actual address.

Example:

.P fc0000 28
.



3.4.7	Hear Memory
-------------------

Usage:	H [s][e](n)

	Sends memory as sample to audio chanel 0 with a given period.
	Volume is maximum by default. When no period is given for the
	first time, SIM will use 300. Else the last used period will
	be reused.

	The period can range from 80 to $7fff.

	While listening, The address where the sample words are currently
	taken from (aprox.) is displayed in the footer.

	The page memory managing is used and only defined memory is
	heard at. Undefined memory causes silence.

	By pressing CTRL, the command can be stopped.

		H [s][e][n]	Hear memory from s to e with period n.
		H [s][e]	Hear memory from s to e with same period.

Example:

.H 0 20000 80
.



3.5	Memory Editition Commands
=================================


Memory editition is severely controled. No changes in SIM itself, symbol
nodes or the workmem are allowed. An attempt to edit such memory either
causes an error or is not done.


3.4.1	Edit Memory
-------------------

Usage:	e (a)(d)

	The edit command can be used to change memory directly, allowing
	different data forms.

	Data is written using the page memory managing with the exception
	that only protection of memory is checked and the interrupt vectors
	and backup are mirrored. The pages themselves are ignored. You can
	also write to undefined memory. This enables to write to the custom
	registers which in most cases are not declared as readable.

	For an overview of data line buildup refere to the appropriate section.

	If this command is executed without datas, SIM will start a loop where
	it requests data to write to an address until no data are entered.
	Therefore it builds the next command line by itself which will look
	like 'e>xxxxxxx: '. You can leave the loop by pressing <CR> without
	entering a data line.

	If there is an error in the data line, it is displayed but the entier
	line is not written to memory.

	Datas are written as words if possible. This is neccessary to edit
	the custom registers which are not used by SIM.

	In the above described mode, SIM will recognize if the next command
	line already was a line built by the edit loop and only changes the
	address and leaves the actual data line untouched.

		e [a][d]	Write data d to address a.
		e [a]		Start editing at a.
		e		Start editing at the actual address.

Example:

.e 100
 e>00000100: 0011,?[4],'SIM!'
 e>0000010a:
.e 4 ?'DIE!'
.



3.4.2	Assemble
----------------


Usage:	n (a)(i)

	The assemble command can be used to directly assemble one or
	multiple instructions to an address.

	Data is written using the page memory managing with the exception
	that only protection of memory is checked and the interrupt vectors
	and backup are mirrored. The pages themselves are ignored. You can
	also assembly to undefined memory.

	If this command is executed without an instruction, SIM will start
	a loop where it requests instructions to assemble to an address until
	no more instructions are entered. Therefore it builds the next command
	line by itself which will look like 'n>xxxxxxx: '. You can leave the
	loop by pressing <CR> without entering an instruction.

	In the above described mode, SIM will recognize if the next command
	line already was a line built by the assemble loop and only changes the
	address and leaves the instructions untouched. That way you can
	enter an entier program and adjust the possible branch addresses
	by editing them, moving the cursor in the first line of the program
	and pressing <CR> until the last line is executed.

	Multiple instructions can be seperated by a komma.

	If an instruction is faulty, an error is printed and the entier
	line is not assembled to memory.

		n [a][i]	Assemble instructions i to address a
		n [a]		Start assembling at a.
		n		Start assembling at the actual address.

Example:

.n 100
 n>00000100: lea $200,a0, lea $300,a1, moveq #$3f,d0
 n>0000010a: move.l (a0)+,(a1)+
 n>0000010c: dbra d0,$10a
 n>00000110: rts
 n>00000112:
.



3.4.3	Transfer Memory
-----------------------


Usage:	T [s][e][t]

	The transfer command is used to copy around areas of memory.

	The page memory managing is used. Undefined areas in the destination
	are not written to, undefined areas in the source are read zero.
	If protected memory (symbol nodes, etc.) is in the destination
	area, an error occures.

	SIM either uses ascending or descending mode to copy, there will
	be no faults when copying overlaying areas.

		T [s][e][t]		Copy memory from s to e to t

Example:

.T fc0000 1000000 200000
.



3.4.4	Occupy Memory
---------------------


Usage:	O [s][e][d]

	This command is used to occupy an area of memory with a byte pattern.

	The page memory managing is used. Undefined areas in the destination
	are not written to. If protected memory (symbol nodes, etc.) is in the
	destination area, an error occures.

		O [s][e][d]		Occupy memory from s to e with d.


Example:

.O 0 80000 'KILL'
.


*******************************************************************************
	4.	Debugger Window
*******************************************************************************




*******************************************************************************
	5.	Assembler and Calculator
*******************************************************************************




5.1     Assembler Usage
=======================


SIM has a full 680x0/688xx assembler builtin which allows you to make changes
to programs while debugging. It supports the standard optimisations and
aliases used by most other assemblers:


	- ADDI and ADDA can be replaced by ADD. ADDX can also be replaced
	  by ADD if the effective addresses are address register indirect
	  with predecrement.

	- SUBI and SUBA can be replaced by SUB. SUBX can also be replaced
	  by SUB if the effective addresses are address register indirect
	  with predecrement.

	- CMP can be used instead of CMPA, CMPI and CMPM.

	- EOR, OR and AND can be used instead of EORI, ORI and ANDI.

	- Bcc and DBcc instructions and PC-relative effective addresses
	  use absolute addresses. It is possible to specify the offset
	  directly by puting a '+' or '-' sign in front (but note that
	  the offset is counted from start of instruction plus 2):

	        00060010:	bra	$60000
            or  00060010:	bra 	-$12

	- If no size is given, Bcc will be optimised to short if possible.

	- If no size given, memory direct effective addresses are optimised
	  to WORD if possible.

	- If no size given for an instruction, the default size is used
	  which in most cases is WORD.



The assembler will either assemble only instructions which can be executed by
the current CPU and coprocessors or all instructions, depending on whether or
not the full instruction set is enabled for disassembling/assembling.
 


5.2	Calculator Usage
========================


The calculator is one of the central functions of SIM, all numeric input
is handled by it. It disposes of mostly all operations and value
forms. The following operators are supported, sorted by priority
when evaluating the term:


	()	Brackets: Correspond to normal brackets. Number of opening
		and closing brackets must be the same.

	[]	Memory indirection: The result of the term in these brackets
		an address and the content of the memory at that address will
		be read.

		A size directly after the closing bracket will define if
		the value will be read as a BYTE, WORD or LONG and extended
		to LONG. I.e.: [4].l reads out AbsExecBase, [$dff002].w reads
		out the actual DMACON as a WORD.

	-	Prefix change: Changes a positive value to a negative and vice
		versa. I.e.: -5 is -5, -0 is 0, --6 is 6.

	~	Logical NOT: Inverts all 32 bits of the value. I.e.: ~5 is -6.

	.s	Sizing: Any value will be extended to LONG from the size
		specified. I.e.: $89.b is $ffffff89.

		The size of the result is used both for the assembler when
		using memory direct effective addresses and for data input
		for the memory edit command etc. If multiple sizing operations
		occure, the last sizing operation in the lowest bracket level
		defines the finial size of the result.

	*,/	Multiply and divide: Signed LONG multiplication and division.
      		I.e.: -$56*5 is fffffe52, 9/-3 is -3.

	\	Modulo: Signed LONG modulo. I.e.: 11\4 is 3.

	+,-	Addition and subtraction: LONG addition and subtraction.
		I.e.:	1000-9 is 991.

	<<	Shift left: Correspond to a multiplication with 2 to the nth
		power, whereas n is the numer of bits to be shifted.
		I.e.: $20<<8 is $2000.

	>>	Shift right: Corresponds to a division by 2 to the nth power,
		whereas n is the numer of bits to be shifted.
		I.e.: $2000>>8 is $20.

	&	Logical AND: LONG AND operation. I.e.: $1234&$ff00 is $1200.

	!	Logical EOR: LONG EOR operation. I.e.: $c1!$54 is $a5.

	|	Logical OR: LONG OR operation. I.e.: $1200|$34 is $1234.

	<>	Not equal: Result of this operation is -1 if values not equal,
		else 0. I.e.: 5<>6 is -1, 3<>3 is 0.

	=	Equal:  Result of this operation is -1 if values are equal,
		else 0. I.e.: 5=6 is 0, 3=3 is -1.

	<=,=<	Lower or same: Signed comparison, result is -1 if value left
		of operator is lower or the same than the right value.
		I.e.: 1<=1 is -1, 6<=5 is 0.

	=>,>=	Greater or equal: Signed comparison, result is -1 if value left
		of operator is greater or equal than the right value.
		I.e.: 2=>1 is -1, 0=>5 is 0.

	<	Less: Signed comparison, result is -1 if value left
		of operator is less than the right value.
		I.e.: 1<1 is 0, 0<5 is -1.

	>	Greater: Signed comparison, result is -1 if value left
		of operator is greater than the right value.
		I.e.: 2>1 is -1, 0>5 is 0.


As for the form of values, the following are supported:


	$x	Hexadecimal number: A number in hexadecimal form, consisting
		of max. 8 digits 0-9 and a-f. I.e.: $badcode1

	#x	Decimal number: A number in decimal form, consisting of
		digits 0-9. I.e.: #1992.

	%x	Binary number: A number in binary form, consisting of
		max. 32 digits 0 and 1. I.e.: %1010001011.

	',"	ASCII chars: A number consisting of max. 4 ASCII chars.
		The string must be introduced and ended with the same
		sign. If a ' must appear in a string introduced with
		', two ' following each other mark one '. The same is valid
		for the ". I.e.: "SIM!", 'DATA', 'it''s','''' , '"MC"'.

	!	Last result: Stands for the result of the last term
		calculated. I.e.: To display 16 bytes at $50000 one can
		enter the command 'm $50000 !+$10'.

	@	Actual address. Stands for the actual address used by dump
		commands and edit/assembly commands. I.e.: @-100.

	SIM	SIM start: The program and base address of SIM.

	D0-D7 ,A0-A7 ,PC ,SP ,SSP ,USP ,SR ,CCR, ISP, MSP, CAAR, CACR, VBR,
	SFC, DFC, TT0, AC0, ITT0, IACR0, TT1, AC1, ITT1, IACR1, DTT0, DACR0,
	DTT1, DACR1, MMUSR, ACUSR, PSR, PCSR, DRPH, DRPL, URP, CRPH, CRPL,
	SRPH, SRPL, SRP, TC, AC, CAL, VAL, SCC, BAC0-BAC7, BAD0-BAD7, FPCR,
	FPSR ,FPIAR, SEA, TEA, SX, TX, SIM and M0-M7
		CPU/FPU/MMU registers: The calculator can directly use the
		content of these registers. SSP is the supervisor stack pointer,
		USP the userstack pointer SP and A7 the actual stack pointer.
		M0-M7 are variables, M0-M3 are used as view start registers.
		Because the calculator can only handle operands within long-
		word bounds, it can only access either the first or second
		longword of the quadword sized SRP, CRP and DRP. Use CRPH,
		SRPH and DRPH for the high longword, CRPL, SRPL and DRPL for the
		low longword of the respective registers. The registers FP0-FP7
		cannot be accessed from the calculator.

		The registers support a special feature which allows to use
		the registers of a history entry. Add an underscore and the
                number of the history entry as a decimal number after the
                register name.

		I.e.: pc+10-d0, srph_4

	x',\x'	Symbols: Uses the symbol specified after the '\'. Any symbol
		can be abreviated by placing a "'". Refere to the chapter
		about symbols in general for detailed information.


A calculator term normally ends at a space, a colon, a semicolon,
a komma or a carriage return. If you have opened a bracket, you can have
spaces between operators and values, but ONLY then. Otherwise, the end of
the term will not be there where you wanted.

The calculator can work in decimal or hexadecimal mode. In decimal mode you
do not have to write the '#' before a decimal number, but for hexadecimal
numbers, the '$' is neccessary. In hexadecimal mode you do not have to write
the '$' before a hexadecimal number, but for decimal numbers, the '#' is
neccessary.

Hexadecimal mode is usually used to get addresses and hexadecimal numbers.
For the other cases decimal mode is used, also for the assembler.



5.3	Data Lines
==================



5.4	Disassembly Search Pattern
==================================




*******************************************************************************
	6.	Safety Features
*******************************************************************************




This version of SIM is much safer to use and smarter in detecting abnormal,
critical and fatal situations and errors than any previous version has been.
There are various built in safety features and a reliable warning system
which relieves the user from most basic checks.




6.1	Startup Checks
======================


When SIM is invoked, it does various checks on itself and on the configuration.
Most of these checks result in warnings, described in the next chapter. Three
of them in fact have other, direct results if they fail.

First SIM will test if SIM itself, the display, the backup for the display,
the work memory and the nodes of the external symbol list overlay somewhere.
Overlays are of course not allowed, i.e. having the display address pointing
somewhere in SIM would be fatal.

Then it tests if the display is within  graphic memory. Additionally it tests
if any given backup for the display is entierly within a memory page.

If any of these tests fail, SIM will not start up any further. It will disable
any display and set the background color to red and wait for you to press the
left mouse button. After you confirm this, SIM exits again.

Next it does a checksum over its main code. If it changed, SIM will start up,
but the text color will be set to red. If damage to SIM was little, you can
still use it, hoping that no accesses to any destroyed code or data is made.
Better would be to leave SIM and load a fresh copy.



6.1     Warnings
================


SIM disposes of a warning system for various critical happenings. If a
new warning is displayed, the screen color turns orange and a text is
printed in the header. When you have read the warning text, press <ESC>
to confirm.

In the top right corner, a flag field indicates what warnings occured
in the current call to SIM. If there are any, make sure that you dealt
with the problem before you leave SIM.



6.2	Selfprotection
======================


While SIM is active it prohibits write accesses to memory associated with
SIM. You cannot write to SIM itself, to any external symbol nodes or to
SIMs work memory. If no backup for the display is used, writing to the display
memory is also forbidden. Attempting to do so results in a 'protected memory'
error.

The only space in SIM you can write to is the SIM base, bytes 72-127.

Write attempts to any custom or CIA registers used by SIM while operating
are redirected to the corresponding backup or reentry entry in the SIM base.



6.3	The External Interrupt Handler
======================================


While SIM is working, the only interrupts allowed are vertical blanking
and CIA-A interrupts (and audio 0 while the 'H' command is executing). All
other interrupts are disabled.

The Amigas hardware allows external devices like harddisk controlers
or other hardware to generate interrupts. Depending on the implementation
of the hardware, it does not always suffice to acknowledge an interrupt
generated by such an external device by clearing a bit in the INTREQ
register. The interrupt server for that device may need to access hardware
registers of the device itself to do this, at addresses only it knows
about. Therefore SIM can't acknowledge to such an interrupt and would hang.

To prevent this, SIM catches any Level 2 and Level 3 interrupts that aren't
caused due to a keyboard event or a vertical blank. It will then automatically
exit, perform the interrupt handler and enter through the JSR entrance
afterwards.





*******************************************************************************
	7.	Advanced Features
*******************************************************************************




7.1	When not to Call SIM...
===============================


There are certain situations in which invoking SIM will cause damage or loss of
data. These situations however are very, very special. You will possibly never
get to call SIM in one of those. For completion and for the few users who will
have to deal with this, here is a list of when SIM shall not be invoked:


	1. Never call SIM in the interrupt level 2 before the interrupt
	   routine has read out the ICR register to know about what caused
	   the interrupt. If you do so, SIM will read out the ICR instead
	   of the interrupt. If the value is nonzero, SIM displays a warning.
	   It is your business then to pass the ICR value read by SIM to the
	   interrupt handler.

	2. Never call SIM in the keyboard interrupt before it has sent the
	   handshake to the keyboard hardware. If you do so, the keyboard will
	   loose synchronisation and miss one or more keystrokes which can
	   remotely lead to software failures.

	3. Never call SIM while doing serial data transfer. If you do so, SIM
	   will display a warning and the transfer is interrupted.

	4. Never call SIM in a disk IO routine which uses the DISKBYT register
	   instead of DMA. Doing so will either destroy the data on the disk
	   or the data read from it.



*******************************************************************************
	8.	Appendixes
*******************************************************************************




8.1     Bibliography
====================


8.2     Acknowledgements
========================



8.3	Registered Users
========================



8.4	Contacting Me...
========================


If you want to register or if you have bugreports, question, ideas, flames or
complaints (constructive criticism is always welcome), or if you just want
to contact me, write or send a letter to:

        Stefan Walter
        Finsterruetistr. 57
        8135 Langnau a./A.
        SWITZERLAND

Because snail mail is slow, you can also contact me by phone or by sending
a message to the electronic mail address below (If you call by phone, please
concider any possible time differences and don't wake me up in the night :).

        Phone:      Switzerland/(0)1/713-01-46
        Internet:   swalter@avalon.unizh.ch or
                    swalter@amiga.icu.net.ch	    
	  


-------------------------------------------------------------------------------
                                                     Stefan Walter, 14.Dec.1993

