Commodore 128 Programmer's Reference Manual page 135

Hide thumbs Also See for 128:
Table of Contents

Advertisement

MACHINE LANGUAGE ON THE COMMODORE 128
125
n
Programs such as those used in arcade games cannot operate in the relatively slow
speed of BASIC, so they are written in machine language. Other instances dictate the
j"l
use of machine language simply because those programming operations are handled
r i
better than in a high-level language like BASIC. But some programming functions such
as string operations are easier in BASIC than in machine language. In these cases,
n
BASIC and machine language can be used together. You can find information on how to
\ |
mix machine language with BASIC in Chapter 7.
Inside your computer is a perpetually running program called the operating
system. The operating system program controls every function of your computer. It
i i
performs functions at lightning speeds you are not even aware of.
1 !
The operating system program is written entirely in machine language and is
stored in a portion of the computer called the Kernal ROM. (Chapter 13 describes how
f"j
to take advantage of the machine language programs within the Kernal, and how to use
/ j
parts of the operating system in your own machine-language programs.)
Though machine language programming may seem more complicated and difficult
p
than BASIC at first, think back to when you didn't know BASIC or your first
I j
programming language. That seemed difficult at first, too. If you learned BASIC or
another programming language, you can learn machine language. Although it's a good
idea to learn a higher-level language such as BASIC before you start machine language,
P
it's not absolutely necessary.
WHAT DOES MACHINE LANGUAGE
LOOK LIKE?
Chapter 2 describes the C128 BASIC 7.0 language. Most statements in BASIC start
with a BASIC verb or keyword, followed by an operand. The BASIC keywords
resemble English verbs. The operands are variables, or constants, that are part of an
expression. For example, A + B = 2, is an expression where A, B, and 2 are operands
in the expression. Machine-language instructions are similar, though they have a uniform
format. Here's the format for an 8502 symbolic machine language instruction as it
appears in the C128 Machine Language Monitor:
OP-CODE FIELD
OPERAND FIELD
OPERATION CODE (OP-CODE) FIELD
The first part of a machine-language instruction is called the operation code or op-code.
The op-code is comparable to a BASIC verb, in that it is the part of the instruction that
performs an action. A machine language op-code is also referred to in an assembly
language as a mnemonic. All 8502 (6502) machine language assembler mnemonics are
three-letter abbreviations for the functions they perform. For example, the first and most
common instruction you will learn is LDA, which stands for LoaD the Accumulator.
This chapter defines all of the mnemonics.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents