6800     EXORsim

EXORsim - Introduction to MDOS

Home page
Change Log
News
Usage
MDOS Intro
MDOS Commands
MDOS Tech. info

Source code
Download

Introduction to MDOS

This is one way to write an assembly language "Hello, World!" program:

1. Use EDITM to create the assembly language source file:

=EDITM
EDITM RELEASE 3.10
COPYRIGHT BY MOTOROLA 1978
READY
?BUILD HELLO
HELLO   .SA:0 CREATED
0010  NAM HELLO         Sets module name
0020  TTL HELLO         Sets title on listing
0030  OPT REL,G,S       options: rel for relocatable, g to expand fcc
0040  PSCT              Program section
0050 START LDX #PROMPT  Point to string
0060  SCALL .DSPLY      Display string
0070  SCALL .MDENT      Return to MDOS
0080 PROMPT FCC "HELLO, WORLD!"
0090  FCB 13            Carriage return terminates string
0100  BSZ 80            Allocate space for stack
0110  END START         Label after END is entry point
0120   
?RESE N                 Eliminate line numbers
READY
?LIST
 NAM HELLO
 TTL HELLO
 OPT REL,G
 PSCT
START LDX #PROMPT
 SCALL .DSPLY    
 SCALL .MDENT
PROMPT FCC "HELLO, WORLD!"
 FCB 13   
 BSZ 80   
 END START
?Q
SAVE IN HELLO1  .SA:0 (Y/N)?Y
READY
?Q
=

2. Assemble, including EQU.SA file. Note that there is no include directive, so header files like EQU.SA have to be specified on the command line.

=RASM EQU,HELLO1;LO=HELLO1
...490 lines from the EQU.SA file...
00491                         NAM    HELLO
00492                         TTL    HELLO
00493                         OPT    REL,G
00494P 0000                   PSCT
00495P 0000 CE 0007  P START  LDX    #PROMPT
00496P 0003                   SCALL  .DSPLY
00497P 0005                   SCALL  .MDENT
00498P 0007    48    A PROMPT FCC    "HELLO, WORLD!"
     P 0008    45    A
     P 0009    4C    A
     P 000A    4C    A
     P 000B    4F    A
     P 000C    2C    A
     P 000D    20    A
     P 000E    57    A
     P 000F    4F    A
     P 0010    52    A
     P 0011    4C    A
     P 0012    44    A
     P 0013    21    A
00499P 0014    0D    A        FCB    13
00500P 0015    0050  A        BSZ    80
00501          0000  P        END    START
TOTAL ERRORS 00000--00000
=

3. Link

=RLOAD
MDOS LINKING LOADER REV F3.P0
COPYRIGHT BY MOTOROLA 1977
?IF=T			Gives name of temporary file for second pass
?BASE			Set base addresses for MDOS
?IDON			Enable display of module name information
?LOAD=HELLO		Load object file, first pass
  HELLO   
?OBJA=HELLO		Give name of output file, start second pass
  HELLO   
?MAPF			Show map file
  NO UNDEFINED SYMBOLS
MAP
 S SIZE  STR  END COMN
 B 0000 0020 0020 0000		<-- Base section, for code below $100
 C 0000 2000 2000 0000		<-- Common section
 D 0000 2000 2000 0000		<-- Data section
 P 0065 2000 2064 0000		<-- The code is here, in program section
MODULE NAME BSCT DSCT PSCT
  HELLO     0020 2000 2000
?EXIT			Exit RLOAD
=

4. Load and run

=LOAD HELLO;G
HELLO, WORLD!

5. Rename it to a command file

=NAME HELLO.LO .CM

6. Now just type the command:

=HELLO
HELLO, WORLD!
=

You should likely modify EQU.SA to suppress its listing.

Add:
* INCLUDING MDOS EQUATE FILE
* LISTING OFF...
	OPT NOLIST	At the beginning.
Add:
	OPT LIST	At the end.
* ...LISTING ON

Hello World with modules:

1. Create a MAIN module:

=EDITM
EDITM RELEASE 3.10
COPYRIGHT BY MOTOROLA 1978
READY
?BUILD MAIN
MAIN    .SA:0 CREATED
0010  NAM MAIN
0020  TTL MAIN
0030  OPT REL
0040  OPT G
0050  OPT S
0060  PSCT
0070  XREF DOIT
0080 START JSR DOIT
0090  SCALL .MDENT
0100  BSZ 80
0110  END START
0120 
?RESE N
READY
?LIST
 NAM MAIN
 TTL MAIN
 OPT REL
 OPT G
 OPT S
 PSCT
 XREF DOIT
START JSR DOIT
 SCALL .MDENT
 BSZ 80
 END START
?Q
SAVE IN MAIN    .SA:0 (Y/N)?Y
READY
?Q
=

2. Modify HELLO module so that it's a subroutine:

=EDITM
EDITM RELEASE 3.10
COPYRIGHT BY MOTOROLA 1978
READY
?LOAD HELLO
RESEQUENCE NEEDED
READY
?RESE
READY
?LIST
0010  NAM HELLO
0020  TTL HELLO
0030  OPT REL
0040  OPT G
0050  OPT S
0060  PSCT
0070 FRED JMP FRED
0080 START LDX #PROMPT
0090  SCALL .DSPLY
0100  SCALL .MDENT
0110 PROMPT FCC "HELLO, WORLD!"
0120  FCB 13
0130  BSZ 80
0140  END START
?0100  RTS
?0080 DOIT LDX #PROMPT
?0140  END
?0055  XDEF DOIT
?LIST
0010  NAM HELLO
0020  TTL HELLO
0030  OPT REL
0040  OPT G
0050  OPT S
0055  XDEF DOIT
0060  PSCT
0070 FRED JMP FRED
0080 DOIT LDX #PROMPT
0090  SCALL .DSPLY
0100  RTS
0110 PROMPT FCC "HELLO, WORLD!"
0120  FCB 13
0130  BSZ 80
0140  END
?0130
DELETED
?RESE N
READY
?Q
SAVE IN HELLO   .SA:0 (Y/N)?Y
READY
?Q

3. Link them

=RLOAD
MDOS LINKING LOADER REV F3.P0
COPYRIGHT BY MOTOROLA 1977
?IF=T
?BASE
?IDON
?LOAD=HELLO
  HELLO   
?LOAD=MAIN
  MAIN    
?OBJA=HELLO
  HELLO   
  MAIN    
?MAPF
  NO UNDEFINED SYMBOLS
MAP
 S SIZE  STR  END COMN
 B 0000 0020 0020 0000
 C 0000 2000 2000 0000
 D 0000 2000 2000 0000
 P 006C 2000 206B 0000
MODULE NAME BSCT DSCT PSCT
  HELLO     0020 2000 2000
  MAIN      0020 2000 2017
DEFINED SYMBOLS
 NAME  S  STR  NAME  S  STR  NAME  S  STR  NAME  S  STR  NAME  S  STR 
DOIT   P 2003 
?EXIT
=

4. Try it

=LOAD HELLO;G
HELLO, WORLD!
=

I think the start addess is the label on END of the last module. I don't think this label can refer to an XREF- it's got to be in the module.

MDOS EDITORS

There are three:

EDIT

Invoke as follows: EDIT input-file,output-file

This is a much simplified TECO clone. TECO is like a screen editor, but without the screen. Instead you have to use your imagination to remember where the cursor is.

An important concept to understand for TECO-like editors is that they allow you to edit large files, but only within a small in-memory buffer window at a time, and without any kind of software or hardware based virtual memory system. The window makes one pass through the file, then you must exit and re-enter the editor.

Two commands facilitate this. Use A to append 255 lines from the beginning of the input file into the buffer. When you are done editing use P to move lines from the buffer to the output file. Now that there is space free for more lines, you can use the A command again to get more lines.

The P command allows you to move lines from any part of the edit buffer to the output file. This can sometimes be useful as a kind of cut and paste feature, but usually you will want to append lines between the cursor and the beginning of the buffer to the end of the output file, so you need to use something like -500P$$ (copy lines starting 500 lines back to the cursor and append to output file).

EDIT commands:

$ means hit ESC key. It is possible to give several commands before hitting the final ESC.

[-]nnP$$
Remove lines from the buffer and append them to the output file.
A$$
Bring in 255 lines from the file and append them to the buffer (you need to do this before you can do any editing).
Itext$$
Insert text at current position.
E$$
Move remaining lines from buffer and input file to output file and exit.
[-]nnM$$
Move forward by nn characters
[-]nnD$$
Delete characters
Ntext$$
Search forward for text. This command automatically runs the A and P commands to bring more text into the editor until the string is found. If the search fails, you need to exit the editor because all of the text will have been written out.
B$$
Go to beginning of buffer
Z$4
Go to end of buffer
K$$
Delete to end of current line including CR
-T$$
Type from beginning of previous line to current position
-1T$$
Type from beginning of previous line to current position
T$$
Type to end of current line
1T$$
Type to end of current line
0T$$
Type from beginning of current line to cursor
0TT$$
Type entire current line
Stext$$
Search forward for text. If not found, leave cursor at same position.
Ctext$replace$
Search forward for string and replace it.
Ctext$$
Search forward for string and delete it.
[-]nnL$$
Move cursor forward [-]nn lines

One way to use EDIT defensively is to try to always keep the cursor at the beginning of the line. In this way, it is somewhat like a line editor, which at least requires a little less imagination to use without getting hopelessly lost.

A$$
Bring file in from disk
T$$
Show current line
L$$
Move to beginning of next line
-L$$
Move to beginning of previous line
K$$
Delete current line
Itext
$$
Insert line - remember to include carriage return.
E$$
Save and exit
Stext$$L-L$$
Find text and move to beginning of line
Ctext$repl$$L-L$$
Change text in current line and go back to beginning of line
L-L$$
Go to beginning of line
L-M$$
Go to end of line

Note: there is no "repeat previous search" that I could find.

Note: there is no way to abort your current edits (so make a backup file first)

E (EDITORM RESIDENT EDITOR)

This is a screen editor (for an ExorTERM 155) with a line editor mode. This was the only editor I used when I used MDOS professionally. I only used it in line mode, because we did not have an ExorTERM 155. Also, I think the version I used had been patched to always start in line mode.

Invoke the editor with: E FILENAME;S-N

Option S disables screen editor mode. Option -N disables automatic line numbering of new files.

If someone knows the control sequences for an ExorTERM 155, please send them to me. I'll add a translater to EXORSIM so that E can be used as a screen editor with ANSI terminal emulators.

Update! I have found the manual for the EXORterm 155 and have implemented an emulator for it so that now E can run in screen editor mode. Check it out:

E in CRT mode

E Editor commands:

These strings are in the commnad table: C, CHAN, D, DEL, DELE, DUPL, E, EX, EXTE, F, FIND, I, INSE, L, LIST, MERG, MOVE, N, NUMB, PRIN, QUIT, R, RANG, RESE, S, SAVE, SEAR, TAB, V, VERI, X, XTRA.

F
Go to top of file
F -1
Go back one line
F 1
Go forward one line
F /string/
Search for string starting at beginning of file
S /string/
Search for string starting at next line
S
Find next instance
C /old/new/
Replace old string with new one in current line
L
List entire file
L [-]NN
List one line relative to current line
L [-]NN-MM
List MM lines starting with line [-]NN relative to current line
QUIT
Save and exit
QUIT A
Abandon and exit
SAVE
Save file
DEL
Delete current line
DEL [-]NN
Delete line [-]NN, relative to current line
DEL [-]NN-MM
Delete range of lines
MOVE [-]NN-MM
Cut
XTRA
Paste
EX /string/
Append string to current line
RESE
Add line numbers, resequence
RESE N
Eliminate line numbers
MERG name
Insert file
I
Enter insert mode: Insert lines until you try to enter a blank line... except it does not seem to work. E is still in command mode after I type I.

EDITM

A "simple" line editor which requires you to use line numbers (because it has no notion of current line). Since no programming languages except BASIC expect line numbers, you have to "rese n" (delete them) before saving the file.

Documentation for this editor is incuded on some of the MDOS disk images on bitsavers.

EDITM commands:

BUILD <file>
Create a new file
LOAD <file> [N]
Load a file. N means no. line no.s in file.
LIST [NN[-MM]]
List a file. 9999 means list name too.
SAVE <file>
Save file
NNN <line>
Add a line
NNN
Modify a line
END,Q,QUIT,EXIT
Exit editor. Prompts for name.
C /XXX/YYY/
Change
C NN/XXX/YYY/
C NN-MM/XXX/YYY/
C NN-MM;KK/XXX/YYY/
KK is occurance. 'A' means all. _ in XXX or YYY is single character wild card.
A /XXX/
Append
A NN/XXX/
A NN-MM/XXX/
F /XXX/
Find
F NN/XXX/
F NN-MM/XXX/
F NN-MM;KK/XXX/
P
List to printer
P NN
P NN-MM
RSQ
Resequence
RESE
Resequence
RSQ MM
MM is starting
RSQ MM,NN
NN is increment
RSQ NLN
Remove record keys
M NN,MM
Move
M NN-MM,LL
M NN-MM,LL,KK
LL is new location, KK is new increment (def = 1)
DEL NN
Delete
DEL NN-MM
D NN,MM
Duplicate
D NN-MM,LL
LL is new location, KK is new increment
D NN-MM,LL,KK
B
Block mode (narrow to last range)
B OFF
MERGE file(nn-mm),ll
Merge file in.