Download 68K User`s Manual

Transcript
SK*DOS User's Manual
000070 AOOF
000072 66C8
000074 609E
DC
BNE.S
BRA
}00003C
}000014
FDELET
ERROR
OPEN
DELETE THE FILE
ON ERROR
OPEN FILE AGAIN
*
* TEXT STRINGS
000076 2E
000077 04
000078 5448 4154 2046
OOOOAF 04
OOOOBO 4152 4520 594F
0000D1 04
PROMPT
ASKDEL
ASKSUR
*
DC.B
DC.B
DC.B
" "
DC.B
DC.B
DC.B
4
"THAT FILE ALREADY EXISTS
DO YOU WISH TO DELETE IT? "
4
"ARE YOU SURE YOU REALLY WANT TO? "
4
END
BUILD
...
which causes PICTEST to signal an error even though there is
none. (PICTEST, explained later in the manual, is used to check
a program to make sure it is position independent.)
NOTE to non - assembly language users:
The assembly language examples in this chapter are intended only as guides for those users who intend to write their
own assembly language programs. If you wish to try them out,
proceed as follows: (1) Type the command EDLIN SAMPLE to
edit a sample file. (2) When EDLIN returns with a # prompt,
give it the I command to start inserting text. (3) Enter the LIST
program (the tirst program in this chapter). Examine the listing
to note that the first line of the program begins with an asterisk;
type in only the material to the right of that column. For example,
begin the first line with * LIST ... ; begin the 7th line with
FCBERR EQU ... (4) When you finish typing in the program,
enter a # at the beginning of a new line, and then use the S
command to exit EDLIN. (5) Give the command ASM SAMPLE to assemble the sample from assembly language to machine
language. You will now see that the assembler added all of the
machine language code which you did not type in. (6) Assuming
there are no errors (correct the program if there are), then give
the command SAMPLE SAMPLE. The computer will then use
the SAMPLE.COM file generated by the assembler to print out
the SAMPLE. TXT file you typed. SAMPLE.COM does exactly
the same thing as the LIST command supplied with SK*DOS,
except that it does not have the 'help' feature.
Although it is not immediately obvious from the above
examples, all user-written programs must be written in position
- independent code (although see the description of the binary
file format in Chapter 13 for possible exceptions.) To write
position - independent programs for 68xxx processors, generally
follow the following rules:
1. Do not use JMP and JSR instructions - use BRA and
BSR instead. In general, there should be no JMPs or JSRs in
your programs at all.
2. Refer to variables within your program using PC-relative addressing. For example, the instruction MOVE.B NUMBER(PC),D4 would move the quantity NUMBER into D4, but
the (PC) tells the assembler to use PC-relative addressing. Unfortunately, the 68xxx does not allow PC-relative addressing as
a destination; that is, the instruction MOVE.B D4,NUMBER(PC) is illegal. Hence this instruction has to be replaced by
a two-instruction sequence such as
LEA NUMBER(PC),A5
MOVE. B D4, (A5)
While this adds an extra instruction evelY time you store to
a local variable, we suggest that you avoid the alternative
shortcut of setting one address register to point to your data area
and then doing all stores relative to that register. Although this
makes your program a bit shorter and faster, it generates code
12-4