DeFalco
DeFalco

Reputation: 23

Why is this example Assembly code that is trying to create a data record which is the address of another data record generating an error?

This question regards code from the book "Learn to Program with Assembly" by Jonathan Bartlett. The code in question is on page 96 and is called persondatanamepointer.s. The context is that the author is giving an example of how text can be stored as part of a data record by using pointers (the record itself in this case is a person's name and data such as weight, age, shoe size etc.). Below is the code (trimmed down to a single record for readability):

.section .data

.globl people, numpeople
numpeople:
     .quad (endpeople - people)/PERSON_RECORD_SIZE
people:
     .quad $gkcname, 200, 10, 2, 74, 20
endpeople:

gkcname:
     .ascii "Gilbert Keith Chester\0"

.globl NAME_PTR_OFFSET, WEIGHT_OFFSET, SHOE_OFFSET
.globl HAIR_OFFSET, HEIGHT_OFFSET, AGE_OFFSET
.equ NAME_PTR_OFFSET, 0
.equ WEIGHT_OFFSET, 8
.equ SHOE_OFFSET, 16
.equ HAIR_OFFSET, 24
.equ HEIGHT_OFFSET, 32
.equ AGE_OFFSET, 40

.globl PERSON_RECORD_SIZE
.equ PERSON_RECORD_SIZE, 48

This code assembles, however, trying to link it I get the error:

persondatanamepointer.o: In function `people':
(.data+0x8): undefined reference to `$gkcname'

I'm only beginning with Assembly, so I don't have enough experience to understand: what's wrong?

Upvotes: 2

Views: 30

Answers (0)

Related Questions