Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Basic data management

2010-06-09

If you want to do this on a real Commodore 128, you will need a blank floppy disk, and if you are doing this from an emulator, you will need a blank floppy image. I have created a blank d64 image from the Vice emulator. To do that, click File, Attach disk image, and Drive 8 to display the Attach disk image dialog. There, type in a filename, click Create image, and finally click Attach.

You can make sure that your disk is correctly attached by typing DIRECTORY. This is what you should see:

To create a blank area of memory, enter the machine code monitor and fill a memory area with the value zero. Type:

MONITOR

F 1000 1100 0

To ensure that memory now is blank, type M 1000. Type X to leave the machine code monitor. Note that the monitor is using the hexadecimal, so the area that we have blanked out is from address 4096 to address 4352.

From the Basic parser (that is, outside the machine code monitor) the POKE command is used to set a byte and the PEEK function is used to get a byte. Commodore Basic uses the decimal number system but is equipped with functions to convert between the systems.

So, to set a byte at position 4096 (in this case, the value 5) type:

POKE 4096, 5

To read the same byte, type:

PRINT PEEK(4096)

Also, you can enter the monitor and type M 1000. This is what you should see:

The C128 has built in commands for saving memory to disk and loading memory to disk. Let’s say that we want to save our byte and some following bytes, use the BSAVE command (Binary Save). This will save 4 bytes to a file called TEST.DAT, where the first byte is our value 5. The second argument is the device (B0 is device 8), the third argument is the address range (the character P must occur before the number).

BSAVE "TEST.DAT", B0, P4096 TO P4100

Type DIRECTORY to make sure the file is located there.

To load this file, use BLOAD (Binary Load). This is a test you can do.

Type PRINT PEEK(4110) to ensure address 4110 is empty. Load the file into the address 4110 by typing:

BLOAD "TEST.DAT", B0, P4110

Type PRINT PEEK(4110) again to see that it now holds the value 5, as loaded from the file.

Categories: Geeky

Tags: C128

Leave a Reply

Your email address will not be published. Required fields are marked *



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips