68
5-1
Assembly Language Programming
The Hitachi HD6303X CPU is incorporated into the ASCII Unit. Mnemonics used
are those found in the HD6303X operation manual.
Memory Area
Special memory space for assembly language programs must be reserved with
the MSET command. When programming in assembly language, you cannot
use the BASIC program area to store the assembly program. The MSET com-
mand will move an existing BASIC program to another part of memory.
There are two ways to write an assembly language program:
•
By using the monitor functions
•
By directly writing the program to the memory using the POKE statement in
BASIC.
In most cases the first method is quicker and easier, however, the second meth-
od can be used to create short programs consisting of only a few steps.
Assembly language programs can be written to and read from RAM using the S
and L commands, respectively. They can also be written to or read from the EE-
PROM by using the SAVE and LOAD commands, respectively.
Addresses &H0000 to &H1FFF and &H8000 to &HFFFF are reserved for the
ASCII Unit operating system and must not be altered by the user.
Note When it is necessary to load or save data using a peripheral device other than
the input terminal connected to port 1, follow the
peripheral data transfer proce-
dure described below.
1, 2, 3...
1.
Enter the command and key in a carriage return.
2.
Disconnect the input terminal from port 1 and connect the peripheral device.
3.
Press the START/STOP switch on the ASCII Unit to start data transfer.
4.
Reconnect the input terminal and key in CTRL+x.
An assembly language program can be called from BASIC with the USR func-
tion:
USR [<number>][<argument>]
Before the USR function can be used, the DEF USR statement must be ex-
ecuted to reserve space for the assembly routine. When the USR function is ex-
ecuted, it calls the specified assembly routine and passes it an argument defined
in the BASIC program.
Variables other than the argument specified by the USR function can also be
passed to the assembly language program by using the VARPTR function.
The following arguments are passed to the assembly program:
Accumulator A contents: type of <argument>
Index register X contents: address of <argument>
The RTS command should be the last command of the assembly routine; it re-
turns execution back to the BASIC program.
The value of the stack pointer must not be altered by the assembly routine.
Therefore, the data should be pushed on the stack at the beginning of the routine
and then pulled off before executing the RTS command.
The assembly routine must store any data needed by the BASIC program in the
same address as that of the argument(s) passed by the USR or VARPTR func-
tions. Any data passed back to the BASIC program must be of the same TYPE
as the USR or VARPTR Function argument(s).
Do not disable any interrupts in the assembly language program.
It is recommended that the assembly language program be saved on an exter-
nal storage device or in the EEPROM for safety.
Writing an Assembly
Program
The Assembly Language
Program
Assembly Language Programming
Section 5-1
Содержание C500-ASC04
Страница 1: ...C500 ASC04 ASCII Unit Operation Manual Revised February 2001 ...
Страница 5: ...iv ...
Страница 7: ...vi ...