Using labels

Until now, we used some addresses in the memory to specify what we want to display. For example, we used mem a000 a0ff to show the beginning of the BASIC ROM. Like mine, your memory might not be perfect. Although I can memorize the one or the other address, I won't be able to memorize most addresses. Because of this, you can also specify some labels. These are just names you can give an address. Thus, you only have to remember the name, not the address.

One small but important note: All labels in the VICE monitor have to start with a dot ("."). The monitor needs it to distinguish labels from addresses (would BEEF be the address $BEEF, or the label BEEF?).

VICE already has a list of (some) labels for the C64 since some generations of the emulator. You can just load the list with the "load_labels" (ll) command. I won't get into details here now, but you can load this list with the following command:

(C:$e5d4) ll "c64mem.sym"
Warning: label(s) for address $a8a0 already exist.
Warning: label(s) for address $0007 already exist.
Warning: label(s) for address $0041 already exist.
(C:$e5d4)

Don't get irritated by the warnings. Just ignore them for now.

One of the defined labels in c64mem.sym is .zCHRGET. You can just show the data there by entering: mem .zCHRGET:

(C:$e5d4) m .zCHRGET .zCHRGOT
>C:0073  e6 7a d0 02  e6 7b ad                                .z...{.
(C:$007a)

So, you can see the memory bytes in between the labels .zCHRGET and .zCHRGOT. Let's have a look at the disassembly of the same area:

(C:$007a) d .zCHRGET .zCHRGOT
.C:0073   .zCHRGET:
.C:0073   E6 7A      INC $7A
.C:0075   D0 02      BNE .zCHRGOT
.C:0077   E6 7B      INC $7B
.C:0079   .zCHRGOT:
.C:0079   AD 00 08   LDA $0800
(C:$007c)

Compare it to the same output if no labels were given:

(C:$e5d1) d 0073 0079
.C:0073   E6 7A      INC $7A
.C:0075   D0 02      BNE $0079
.C:0077   E6 7B      INC $7B
.C:0079   AD 00 08   LDA $0800
(C:$007c)

You can clearly see that VICE outputs the name of a label if it exists (cf. addresses $0073 and $0079). Additionally, it replaces targets of commands with the label name if there is one (cf. at address $0075).

In the examples, you can clearly see that you can use labels whenever you have to enter an address in the monitor. This can be very convenient in some places.

Now, assume you want to add a label to a place. For example, the RESET routine we used in some older article does not have a label, as we can easily verify:

(C:$e534) d fce2
.C:fce2   A2 FF      LDX #$FF
.C:fce4   78         SEI
.C:fce5   9A         TXS
.C:fce6   D8         CLD
.C:fce7   20 02 FD   JSR $FD02
.C:fcea   D0 03      BNE $FCEF
(C:$fcec)

So, let's add the label named .RESET for $FCE2:

(C:$fcec) add_label fce2 .RESET
(C:$fcec)

We can use this label immediately:

(C:$fcec) d .RESET
.C:fce2   .RESET:
.C:fce2   A2 FF      LDX #$FF
.C:fce4   78         SEI
.C:fce5   9A         TXS
.C:fce6   D8         CLD
.C:fce7   20 02 FD   JSR $FD02
.C:fcea   D0 03      BNE $FCEF
(C:$fcec)

Ok, fine. Now, we don't like our label anymore, thus, we can delete it again (with delete_label, or dl):

(C:$fcec) delete_label .RESET
(C:$fcec)

We can easily verify that the delete worked:

(C:$fcec) d .RESET
ERROR -- Found an undefined label.
  d .RESET
    ^
(C:$fcec)

Another possibility to find out if we successfully deleted or added a label is to show the list of all labels with the command show_labels (or shl). This will output the full list of all labels known to the monitor.

If we have added some labels, we might want to preserve the list for later. We can do this by issuing the save_label (sl) command. As with load_label, we have to give a filename to this command:

(C:$fcec) save_labels "c64mem-test.sym"
Saving symbol table to `c64mem-test.sym'...
(C:$fcec)