SMON

From C64-Wiki
Jump to navigationJump to search
SMON
Title Screen
Developer N. Mann, Dietrich Weineck
Company
Publisher Markt & Technik
Release 1985
Licence Full version
Platform C64, C128, VIC-20
Genre Machine Code Monitor
Operation Keyboard
Media Listing, Diskette
Language(s) Language:english
Information 64'er issue 02/1985

SMON is a simple machine code monitor for assembling and disassembling, which was firstly published as listing in the German computer magazine 64'er in 1984/85. Later SMON was republished in several publications of magazines like the special issues of 64'er from publisher Markt & Technik. Also an assembler course was published in the 64'er magazine: "Assembler ist keine Alchemie".

Starting[edit | edit source]

The monitor screen

The 4 Kbyte large, easy and simple assembler SMON is started by the command SYS 49152 (for versions at $C000). The startup screen's frame and border color is switched to blue, the writing color to cyan and the following lines appear:

  PC  SR AC XR YR SP   NV-BDIZC
;C000 B0 C2 00 00 EE   10110000

The first line names the CPU registers and the second shows their current content. The rightmost block shows the Status Register (SR) in binary notation with the corresponding flag names above.

The abbreviations in the register line means:

All numbers are shown and will be taken as hexadecimal!


Flags

The flags are (from high to low):[1]

Bits:  76543210 
Flags: NV-BDIZC
  • Bit 7: N (negative flag) - used by mathematical operations with values greater than $7F (127), corresponds to bit 7, the sign bit
  • Bit 6: V (overflow flag) - signals an overflow of a signed arithmetic operation (with two's complement values)
  • Bit 5: - (not used) - always 1
  • Bit 4: B (break flag) - indicates an interrupt caused by a BRK command
  • Bit 3: D (decimal flag) - if set mathematical operations will be calculated in decimal mode
  • Bit 2: I (interrupt flag) - set if IRQ handling is suppressed
  • Bit 1: Z (zero flag) - set if the result of an operation becomes zero
  • Bit 0: C (carry flag) - is set appropriate on mathematical operations if their results would leave the $00 - $FF (0 - 255) range or is used for shifting and rotating operations

For more details see Processor Status Register.

Commands[edit | edit source]

Several commands (D, K, M) have a common keyboard control:

  • RETURN  key or any other key except the SPACE key: continues or stops the display process.
  • SPACE  key: step forward one line.
  • RUN/STOP  key: exit the display mode.


SMON supports the following commands [2] in Standard Mode and Disk Monitor Mode:

Standard Mode[edit | edit source]

A xxxx - Assemble

Assemble Code starting at xxxx. It is possible to use markers (a simple form of symbolic labels) in the form Mxx. A single "F" finishes the assembly. Single data bytes may be inserted with a leading dot, e.g. .2C

B xxxx yyyy - BASIC Data

Create BASIC DATA lines for the memory contents from xxxx to yyyy. Note: Line-numbers start with 32000 (defined in ($C087/$C088). The maximal length of a created BASIC line is usually 80 character (the maximal length that can be edited with the C64 BASIC editor). If you want shorter lines (e.g. 72 characters, that are usually the limit for emails and news-postings) set $C9AE to the desired length -7 (e.g. 65 for 72 characters).

C xxxx yyyy zzzz aaaa bbbb - Convert Program

The memory block from xxxx to yyyy is moved to zzzz. All absolute addresses in the code between aaaa and bbbb that pointed into the moved range are adjusted. Commonly used to insert a code sequence at address xxxx moving the old code to zzzz covering a program spanning from aaaa to bbbb. New code may be inserted into the range from xxxx to zzzz-1.

D xxxx (yyyy) - Disassemble

Disassemble the program starting at xxxx (and ending at yyyy) - continuous by pushing SPACE  key, stopping with RUN/STOP  key. Changes to the code are possible by overwriting the opcodes and pushing the RETURN  key.

F aa bb cc ..., xxxx yyyy - Find Bytes

Find all occurrences of the byte sequence aa bb cc ... in the memory range xxxx to yyyy. It is possible to specify some nibbles of the search pattern as don't-care by using the wildcard '*'. Note: Unlike most other SMON commands the Find commands are very picky about their syntax. There must be no space between the command name and the arguments given (exception: the Find Byte command requires exactly one space), and a comma before the range.

FAaaaa, xxxx yyyy - Find absolute Address

Find all references to the absolute address aaaa within the memory range xxxx to yyyy. Note that there is no space between FA and aaaa.

FRaaaa, xxxx yyyy - Find Relative

Find branch statements that points to address aaaa within the memory range xxxx to yyyy. Note that there is no space between FR and aaaa.

FTxxxx yyyy - Find Table

Find all tables in the memory range xxxx to yyyy. SMON defines a table as any information, that can not be disassembled.

FZaa, xxxx yyyy - Find Zero-Page

Find all references to the zero-page address aa within the memory range xxxx to yyyy. Note that there is no space between FZ and aa.

FIaa, xxxx yyyy - Find Immediate

Find all statements in the memory range from xxxx to yyyy, that use aa as immediate operand. Note that there is no space between FI and aa.

G (xxxx) - Go

Execute the machine program at xxxx or the current PC. If the code ends with RTS, SMON is terminated. To jump back to SMON after the code is executed, the program must end with BRK.

I xx - I/O Device

Select the I/O device for Load and Save. Common values for xx are 01 for tape or 08 to 0B for floppy devices.

K xxxx (yyyy) - Inspect (in German Kontrolle)

Display the memory contents from xxxx to yyyy as ASCII characters. Changes are possible by overwriting the characters.

L"filename" (xxxx) - Load

Load a file from the standard I/O device (see command I - I/O Device) at the standard address or xxxx. Note that there is no space between the command and the filename.

M xxxx (yyyy) - Memory Dump

Display the memory contents from xxxx to yyyy as hex values and ASCII characters. Changes are possible by overwriting the given hex values.

O xxxx yyyy zz - Occupy

Fill the memory range xxxx to yyyy with the value zz.

P xx - Printer

Select the device number for the printer. Valid values for xx are 04 and 05. To send the output of a command to the printer, that command name has to be written in upper case.

R - Register

Display the contents of the CPU registers. Changes are possible by overwriting the values.

S("filename" xxxx yyyy) - Save

Save the memory contents from xxxx to yyyy to a file. If the file has been loaded using the command L then the parameters for save are optional. Note that there is no space between the command and a given filename.

TW (xxxx) - Trace Walk

Execute the code at xxxx (or current PC) in single-step mode. After every executed command, the contents of the registers is displayed and the system is halted until a key is pressed, abort by pressing RUN/STOP  . Subroutines can be executed in real time by pressing J .

TB xxxx yy - Trace Break

A break-point is set at address xxxx. When the code is later executed with Trace Quick (see below) the execution will be switched to single-step mode when the break-point is reached for the (yy+1)th time.

TQ (xxxx) - Trace Quick

Execute the code at xxxx (or current PC if omitted) in real time. When a break-point is encountered the execution is switched to single-step mode (see TW - Trace Walk).

TS xxxx (yyyy) - Trace Stop

Executes the code at xxxx in real time. Execution stops as soon the program reaches yyyy (works only in RAM!).

V xxxx yyyy zzzz aaaa bbbb - moVe addresses

All references to absolute addresses in the code between from aaaa and bbbb which are pointing into the range xxxx to yyyy are adjusted to the range starting at zzzz.

W xxxx yyyy zzzz - Write

Copy the memory contents between xxxx and yyyy to zzzz. No address or other transformations are performed. Works correctly even if source and destination range overlap.

= xxxx yyyy - Check Equality

The memory ranges starting at xxxx and yyyy are compared for equality. The address of the first different byte is displayed.

X - Exit SMON

Also changes back frame and background colors to the standard C64 ones (not the previous colors). Entering SMON again is possible with the proper SYS command (e.g. SYS 49152 for a version at $C000 ).


  • # num - Convert Decimal
    The decimal number num is converted to hexadecimal notation. If num is a 8 bit number, than the binary form is also displayed.
  • $ xxxx - Convert Hexadecimal
    The hexadecimal number xxxx is converted to decimal notation. If xxxx is a 8 bit number, than the binary form is also displayed.
  • % xxxxxxxx - Convert Binary
    The (8 Bit!) binary number xxxxxxxx is converted to decimal and hexadecimal notation.
  • ? xxxx + yyyy - Hexadecimal Addition or Subtraction
    Two 16 bit hexadecimal numbers are added or subtracted.


Disk Monitor Mode[edit | edit source]

The SMON disk monitor...
  • Z - Start the disk monitor - screen border changes to color yellow.
    SMON features a built in disk monitor for floppy disk #8. To avoid confusion in terms of command names, the disk monitor must be explicitly started and terminated. While SMON is in disk monitor mode, only the following commands are available.
    Note: It is not possible to examine a device other than a real or truly emulated floppy disk (i.e. not a folder of a emulation host's hard disk or a tape) mounted on drive #8.
  • R (tt ss) - Read Sector
    Read track tt sector ss into memory. If tt and ss are missing the next logical (not physical!) sector is read.
  • W (tt ss) - Write Sector
    Write track tt sector ss to disk. If tt and ss are missing the parameters from the last Read Sector command are used.
  • M - Memory Dump
    Display the disk sector in memory on the screen. The SHIFT  keys can be used to interrupt/continue the display process.
  • @ - Floppy Error Status
    Displays the current floppy error message. If no error occurred, than no message is printed, i.e. the message 00, OK,00,00 is suppressed.
  • X - Exit the disk monitor, back to SMON's normal mode - screen border color is set to blue.


Links[edit | edit source]

WP-W11.png Wikipedia: Smon Language German

References[edit | edit source]

  1. Magic Disk 64: "Assembler-Kurs Teil 3"; issue 03/1990 Language German
  2. http://www.infinite-loop.at/Power64/Documentation/Power64-ReadMe/07-BuiltIn_Programs.html SMON commands at Power64-Emulator