70 RTS

80 ]

90 P%=demo

100 END

Line 20 reserves 10 memory locations to hold the machine code version of the

program. P% at line 30 is used to indicate to the computer the first memory

location to be used for the machine code program.

The brackets at lines 40 and 80 indicate the beginning and end of the assembly

language section of the program. The short program from line 50 to 70 prints

the letter C on the screen. If you run the program you will see the following:

E71

E71 A9 43 LDA #67

E73 20 EE FF JSR &FFEE

E76 60 RTS

The computer has used the assembler to translate the assembly language

instructions into machine code. The numbers in the left-most column are the

hexadecimal memory locations where the machine code is stored. Each

remaining hexadecimal number on the line is the equivalent of one assembly

language instruction.

Notice that running the program has only translated the assembly language

into machine code, and does not run the machine code program itself. To

actually execute the machine code, type:

CALL P%

CALL is a statement to the computer to execute a piece of machine code. It is

followed by the memory location at which the execution of the machine code is

to begin. You should find that the computer prints the letter C.

Once an assembly language program has been translated by the assembler, the

machine code program can be run independently. If you use NEW, the original

program is removed but the machine code remains in memory, as you can

prove by typing CALL P% again. The section of memory containing the machine

code can be saved on its own and used again without any need for the original

program containing the assembly language instructions.

The facility for mixing BASIC and assembly language instructions is a

powerful one, but any further discussion on the subject is outside the scope of

this guide.

C 67