Module 0376: C notations to describe what is in a register

Tak Auyeung

1 What this is for?

This module describes a way to concisely describe what is in a register using a simplified (typeless) C notation. This notation is useful for commenting a program, but it is also useful in the final exam when a question asks for commenting.

2 Notations

2.1 Overall description

In C/C++, pointers are typed. This means that given

T *p, *q;

the expression p-q does not return the number of bytes, but rather the number of type T things between the two pointers.

In TTPASM, registers are not typed. As a result, given two pointers, x and y, the properly typecasted expression of (char*)x - (char*)y to compute the number of bytes between where x and y point to simplifies to x-y.

2.2 Variables and Parameters

Assuming x is a variable or parameter, then

Assuming y is also a variable or parameter, then

2.2.1 (Auto) local variables or parameter

Assuming x is a local variable or a parameter:

2.2.2 Dereference

Assuming x is a pointer (note that x can be complex):

*x denotes what x points to.

2.2.3 Structure and member

Assuming x is a structure (note that x itself can be complex):

Assuming x is a pointer to a structure (note that x itself can be complex):

Use == instead of = to denote equality. This is because = means assignment, not equality. For example:

   ldi   a,XYZ // a == &XYZ

Note that this is just an example to illustrate how to express that register a has the address of XYZ.