08.04.2013 Views

Your Commodore - Commodore Is Awesome

Your Commodore - Commodore Is Awesome

Your Commodore - Commodore Is Awesome

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

computer think that you have typed<br />

LOAD FILE,8,1 so it will go off to the<br />

disk drive and LOAD the program<br />

called file. There is one carriage return<br />

left in the keyboard buffer. The cursor<br />

is now over the keyword RUN and<br />

when the RETURN is executed the<br />

computer thinks you have typed RUN.<br />

Simple isn't it?<br />

If you are confused read the<br />

explanation again and play around<br />

with the program in FIGURE 2.<br />

Quite often you will come across a<br />

program which when the loader for it<br />

is RUN, proceeds to POKE itself into<br />

the same memory locations as the<br />

loader program. This of course will not<br />

work. In order to overcome this<br />

problem you have to move the start of<br />

Basic so that the Loader program and<br />

the machine code will be at two<br />

different memory locations. Memory<br />

locations 43 and 44 (45 and 46 on the<br />

CI 28) hold the start of Basic. Location<br />

43 holds the low byte off the address<br />

and location 44 holds the high byte.<br />

The following formulae can be used to<br />

work out the numbers to be POKED<br />

into the relevant memory locations:<br />

LOW BYTE = ADDRESS - 256* INT<br />

(ADDRESS/256)<br />

HIGH BYTE = INT (ADDRESS/<br />

256)<br />

Where address is the memory location<br />

where you want Basic to start<br />

One further point worth raising is<br />

that the memory location before the<br />

start of Basic should always contain a<br />

zero. For example if you had moved<br />

Basic to memory location 2000,<br />

location 1999 should be POK Ed with a<br />

zero. <strong>Commodore</strong> 128 owners have an<br />

advantage over C64 owners when it<br />

comes to SAVEing a prograrn, they<br />

have a machine code SAVE instruction<br />

in Basic 7.0 as well as the one in<br />

the monitor. C64 owners have to resort<br />

to POKEing into memory yet again.<br />

We have already said that locations<br />

43 and 44 hold the start of Bask.<br />

Memory locations 45 and 46(47 and 48<br />

on the CI 28) hold the memory address<br />

of' the end of Basic. Whenever a SAVE<br />

is performed the computer looks at<br />

these memory loca-tions to see what<br />

area of memory it should SAVE to<br />

whatever device you are using. If you<br />

POKE these memory locations with<br />

the start address and end address of<br />

your machine code program you will<br />

be able to SAVE your code. The<br />

C64 AND C12811<br />

memory locations should be POKEd<br />

with the following values:<br />

43 low byte of start address<br />

44 high byte of start address<br />

45 low byte of end address<br />

46 high byte of end address<br />

The formulae already given can be<br />

used to work out the numbers to be<br />

POKE&<br />

Of course, since you have moved<br />

Basic, you will not be able to list any<br />

programs in Basic memory until you<br />

reset the memory locations to their<br />

original values.<br />

One more problem that you may<br />

come across is the fact that the<br />

machine code program to be turned<br />

into DATA statements sits at the same<br />

memory location as the Data Maker<br />

Data Maker C64<br />

PROGRAM: DATAMAKER-C64<br />

Please read 'LISTINGS'<br />

before entering program.<br />

10 10 81,-145 :LN-70 :SA-4915<br />

2<br />

F9 20 FOR L-0 TO BL:CX-0:FOR D-<br />

O TO 15<br />

9F 30 READ A:IF A>255THENPRINT"<br />

NUMBER TO LARGE":1.N*(1,*10S<br />

TOP<br />

28 40 CX-CX-PA:POKE<br />

NEXT D<br />

A9 50 READ AilF A>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!