Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Pointers

Peter Tillema edited this page Nov 26, 2018 · 2 revisions

Pointers can be difficult for newcomers to programming to understand, but once you understand how to properly use them, they are an incredibly powerful tool to have in your programming toolbox.

Pointers allow you to read and write data to your calculator's RAM and archive, giving you the ability to modify almost anything in your calculator's memory. You can use their ability to cheat a high score on Calcuzap, or to simply edit the name of a program.

But before we tell you how to use them, a warning: If you're not careful with pointers and write the wrong data to the wrong address in memory, you not only risk freezing your calculator, but there is a chance of you corrupting data, breaking the OS, or worse (although unlikely), permanently damaging your calculator. Be cautious and be sure you know what you're doing when messing with pointers. Once again, if possible, use an emulator.

We'll begin with a prerequisite, memory addresses. Every single byte of RAM and flash (archive) has a number bound to it, known as a memory address. If you want to read or write from a specific byte, you need to know it's memory address. If you treat a variable as a memory address, you then have a pointer. Here is an example:

15958016→A
*{A}→SEC

In the example above, we stored the number 15958016 into A, then we used *{A} to read one byte from the memory address that A points to, 15958016, and stored the read value into the variable SEC. 15958016 is the memory address for a byte of memory that is part of the real-time clock. Reading from this value gives you the current second. When you want to read from a memory address, there are four main ways to do so:

ICE syntax Explanation
{VAL} Reads a word (3-byte) value from location VAL.
***{VAL} Reads a word (3-byte) value from location VAL.
**{VAL} Reads a 2-byte value from location VAL.
*{VAL} Reads a 1-byte value from location VAL.

The first two are exactly the same, the first is just easier to remember while the other makes it more clear that you are reading a 3-byte value. VAL can be an expression, a variable, or a constant (you can even put pointers inside of pointers). You may recognize these from the lists section, because when you are reading from a list, you are reading from it's memory address plus an offset.

As for uses of pointers, if you find some other documentation, you can find memory addresses that give you useful information you could use in your programs, like the date or time. Some documentation can be found on this wiki. That page contains links to different ports on the TI 84+ CE, just note that you can only access (from ICE) the ones that are memory mapped.

Here is a page with ports for the real-time clock in the 84+ CE. Near the top of the page it says Memory-mapped address: F30000, this means that you can read from these ports as if they were memory by using the F30000 address range. Below you find a list of specific ports. If you wanted to read the current hour count, that page lists it as port 8008. You simply modify the memory mapped address to get F30008. Before you can use this in a pointer, you need to convert it from hexadecimal. Luckily, ICE has a modifier just for that, the scientific E. With this, you should now be able to read the current hour and store it into, for example, A, like this:

{|EF30008→A}

Now you can use that hour however you wish to in your program.

Clone this wiki locally