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.
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.
Assuming x is a variable or parameter, then
x denotes the value of the variable&x denotes the address of the variableAssuming y is also a variable or parameter, then
&x-&y denotes the number of bytes between the
address of x and the address of y.Assuming x is a local variable or a parameter:
&x-D denotes the number of bytes between where the
stack point (D) points to and the first byte of
xAssuming x is a pointer (note that x can be
complex):
*x denotes what x points to.
Assuming x is a structure (note that x
itself can be complex):
&x.m1 - &x denotes the number of bytes between
the address of member m1 of structure x and
the first byte of structure x.Assuming x is a pointer to a structure (note that
x itself can be complex):
&x->m1 - x denotes the number of bytes between
the address of member m1 pointed to by x and
the structure pointed to by x.Use == instead of = to denote equality.
This is because = means assignment, not equality. For
example:
ldi a,XYZ // a == &XYZNote that this is just an example to illustrate how to
express that register a has the address of
XYZ.