Commodore 128 Programmer's Reference Manual page 192

Hide thumbs Also See for 128:
Table of Contents

Advertisement

182
COMMODORE 128
Li
Now that you know about addressing modes, types of instructions and opcodes, you
LJ
need to know how to actually enter machine language instructions into the Commodore
128 memory. The C128 offers three methods of inputting instructions so that they may
p
be operated on by the microprocessor. You can enter machine language instructions by:
\ j
1.
Using the built-in machine language monitor (available in C128 mode only).
2.
POKEing the translated decimal opcode values into memory with a BASIC
| j
program (C128 and C64 modes).
^
3.
Using an additional software program called an assembler.
All three methods have advantages and disadvantages. For instance, the built-in
IJ
machine language monitor is easy to use and allows you to program in machine
language without any additional aids such as an assembler. It makes merging BASIC
and machine language easy. In addition, you can save machine language programs as
j j
binary files with the monitor SAVE command. Since you are already working in an
^
object code, there is no need to compile from source code into an object code, as is
necessary with an assembler.
| I
Though these are powerful features, the monitor does not allow the use of symbolic
\j
operand names or commented code. The monitor produces executable (object) code;
hence, no source files are produced. The resulting coded program contains actual
j \
(absolute) address references, whereas an assembler source code file allows the use of
j
symbolic addresses and arguments as well as comments. When you display a machine
language program in the monitor, you do not have the luxury of comments or symbolic
address variables, so you really have to know what you are looking for when reading
j J
other people's code. On the other hand, an assembler source file must be compiled into
U
executable object code, then used often with an additional program called a loader. This
requires three steps, whereas the monitor's machine language is ready to run as soon as
T i
you finish writing the program.
M
The second method, POKEing translated decimal opcode data into memory with a
BASIC program, is an alternative usually implemented only when the first two options
are not available. This is the case if you have no assembler and are writing a machine
f
language routine in Commodore 64 mode, which does not make the built-in monitor
^
available to you. However, it is sometimes handy to POKE small routines from
BASIC if the application program you are writing is more suited for BASIC and you
"i {
need the speed of machine language for only a small portion of the program (though for
<J
the most part, this method is tedious, bulky and time-consuming). Use it only if you
have no alternative, since once it is POKED into memory, you cannot display a listing
; ,
of the machine language routine as in the monitor or the assembler.
j
This chapter explains how to enter machine language programs in the first two
methods described above. The third method, using an assembler, requires an additional
software package similar to the Commodore 64 Assembler Development System. For
] j
specific details on how to enter machine language programs with the assembler, refer to
LJ
the manual that is packed with the assembler software package you buy.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents