Home
CBM
  ASCII-X
  BASIC
    Disk Commands
    Enter RUN mode
    Program Format
    Secret Variables
    Variable Format
    Expressions
    Keywords
      (divide)
      (equal)
      (less)
      (minus)
      (more)
      (multiply)
      (plus)
      (power)
      Abs
      And
      Append
      Asc
      Atn
      Auto
      Backup
      Bank
      Begin
      Bend
      Bload
      Boot
      Box
      Bsave
      Bump
      Catalog
      Char
      Chr
      Circle
      Close
      Clr
      Cmd
      Collect
      Collision
      Color
      Concat
      Cont
      Copy
      Cos
      Data
      Dclear
      Dclose
      Dec
      Def
      Delete
      Dim
      Directory
      Dispose
      Dload
      Do
      Dopen
      Draw
      Ds
      Ds string
      Dsave
      Dverify
      El
      Else
      End
      Envelope
      Er
      Err
      Exit
      Exp
      Fast
      Fetch
      Filter
      Fn
      For
      Fre
      Get
      Get num
      Getkey
      Go
      Gosub
      Goto
      Graphic
      Gshape
      Header
      Help
      Hex
      If
      Input
      Input num
      Instr
      Int
      Joy
      Key
      Left
      Len
      Let
      List
      Load
      Locate
      Log
      Loop
      Mid
      Monitor
      Movspr
      New
      Next
      Not
      Off
      On
      Open
      Or
      Paint
      Peek
      Pen
      Pi
      Play
      Pointer
      Poke
      Pos
      Pot
      Print
      Print num
      Pudef
      Quit
      Rclr
      Rdot
      Read
      Record
      Rem
      Rename
      Renumber
      Restore
      Resume
      Return
      Rgr
      Right
      Rlum
      Rnd
      Rreg
      Rspcolor
      Rsppos
      Rsprite
      Run
      Rwindow
      Save
      Scale
      Scnclr
      Scratch
      Sgn
      Sin
      Sleep
      Slow
      Sound
      Spc
      Sprcolor
      Sprdef
      Sprite
      Sprsav
      Sqr
      Sshape
      St
      Stash
      Step
      Stop
      Str
      Swap
      Sys
      Tab
      Tan
      Tempo
      Then
      Ti
      Ti string
      To
      Trap
      Troff
      Tron
      Until
      Using
      Usr
      Val
      Verify
      Vol
      Wait
      While
      Width
      Window
      Xor
    Syntax
    Tokens
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
KeywordAbbreviationToken (hex)Version(s)Classification
MONITORM{Shift+O}FA3.5Command and Statement*
MONITORMO{Shift+N}FA7.0Command and Statement*

 
 Syntax  
MONITOR junk ]
 
ParametersTypeLegal Value(s)Default ValueNote(s)
junkanyanyIgnored
 
 
 Purpose 
State management.  Exit BASIC interpreter and enter the machine-language monitor.

 
 Remarks 
MONITOR is the BASIC command to enter the built-in machine-language (ML) monitor.  This will (usually) not invoke an add-on ML monitor which has been loaded into RAM or is stored in an external cartridge.  Bug: on the C128, entering the ML monitor by any means will most likely corrupt BASIC's DS and DS$ because the ML monitor uses the string descriptior of DS$ as a temporary work space when parsing entered commands.
 
Although MONITOR is only available in version 3.5 and 7.0, some other machines have a built-in ML monitor.  On the PETs with BASIC 4.0, SYS 4 might call up the built-in ML monitor.  On the CBM-II series (BASIC 4.7) using SYS 5 will often enter the built-in ML monitor.  On these machines, the SYS is jumping to an opcode which cause the ML monitor to be called due to a CPU "break" opcode.  However, there is no gaurantee a zero will be at the given address so strange things may happen.  This is why a MONITOR keyword is a good thing.
 
Older versions of BASIC don't have an ML-monitor in ROM.  For the C64 (maybe VIC-20 too), I recommend SuperMon by the late Jim Butterfield.  His ML monitor is nearly identical to the one in the C128 (BASIC v7.0), but does not allow a bank number (the C64/VIC-20 do not have multiple banks).
 
* Although MONITOR may be used as a statement in a program, it clears the secret variable "Run Mode" so if you return to BASIC, the program will normally not continue.  You might be able to change some secret variables while in the ML monitor so the program would continue, but this would be very machine-specific.  Using the SYS method to enter the ML monitor might allow the BASIC program to continue, but the CPU stack pointer would need to be fixed due to the data pushed by the "break" opcode.
 
On any machine with an ML monitor, weather it is a built-in or installed by the user, the monitor will normally be called up automatically with the word BREAK or similar along with a display of registers if the CPU ever executes a BRK opcode (byte value 0).  On machines without an ML monitor, this will cause BASIC to soft-reset (like pressing STOP + Restore).
 
Below is a short list of commands available in the ML monitor.  The most important one for BASIC users is X.  Type this character and press RETURN to get back to BASIC.  Several of the commands are not available on the 4.x series of the ML-monitor or may work a bit differently.  In particular, they generally require an address to be entered as a 4-digit hexadecimal number (i.e., leading zeros are required).  On the otherhand, the C128 (v7.0) allows (does not require) a 5-digit hexadecimal number.  In these cases, the first digit is the BANK number and the remaining four digits are the normal 16-bit address.
 
In all the ML monitors, the default input of numbers is hexadecimal.  In version 7.0 and with SuperMon, you may also use a decimal value by prefixing the number with a + or use a binary value with a prefix of % or an octal value with a prefix of @.  You can also prefix a number with $ for hexadecimal, but because that is the default radix it is normally not needed.  The one exception is the number conversion feature: enter only a number with a prefix (i.e., no command) and the number will be listed in all forms (binary, octal, decimal, hexadecimal).  This is nice because no CBM BASIC has a BINARY function, and many versions of BASIC don't have the DEC and HEX$ functions either.  I don't know why you'd need octal, but there it is anyway!  See examples.
 
In all the ML monitors, spacing is often critical due to very simple parsing.  I will not go into the details of any of the ML commands because they are outside the scope of BASIC.  I will say if there is an error in your command, the ML monitor simply prints a question mark (?).  You will have to figure out the cause of the error.
 
Read "disk" error/status channel:
deviceNumber ]
 
List "disk" directory:
deviceNumber ] ,$ [ parameters ]
 
Send "disk" command:
deviceNumber ] , command
 
Set CPU registers:
PC [ P [ A [ X [ Y [ S ] ] ] ] ]
 
Enter byte(s) into memory:
addressStart byte ] ...
 
Assemble a 6502 instruction:
A address opcode [ operand [ , register ] ]
 
Compare bytes in memory:
C sourceStart sourceEnd compareStart
 
Disassemble memory:
D addressStart [ addressEnd ]
 
Fill memory:
addressStart addressEnd fillByte
 
GOTO an ML program (JMP):
addressStart
 
Hunt (search) for byte(s) in memory:
addressStart addressEnd wantByte [ , wantByte ] ...
 
GOSUB an ML program (JSR):
addressStart
 
Load a "file" (filename may only be omitted with cassette):
L [ "filename" [ , deviceNumber [ , loadAddress ] ] ]
 
Display a range memory:
addressStart [ addressEnd ]
 
Display CPU registers:
R
 
Save a "file" (limitAddress = endAddress + 1):
"filename",deviceNumber,startAddress,limitAddress
 
Transfer (copy) bytes from a range in memory to another location:
sourceStart sourceEnd copyStart
 
Verify memory with a "file" (filename may only be omitted with cassette):
V [ "filename" [ , deviceNumber [ , loadAddress ] ] ]
 
Exit the ML monitor (return to BASIC):
X
 
 
Examples:
MONITOR YOUR ENEMIES OR SUFFER

MONITOR
    PC  SR AC XR YR SP
; FB000 00 FF FF FF F8
$400               list the hexadecimal value '400' in every radix
 $0400 
 +1024 
 &2000 
 %10000000000
+400               list the decimal value '400' in every radix
 $0190 
 +400 
 &620 
 %110010000
X                  return to BASIC
READY.
 
 
 Compare With 
 
 Contrast With 
 See Also 

© H2Obsession, 2014, 2015