If you've written programs in hex code before on the TI-83+ and TI-84+, you may be pretty confused when trying to write hex codes for the CE. The processor is very different! But don't be afraid, it's still pretty similar.
Here's a "Hello, world!" program you can type into your calc and run.
Asm84CEPrgm 218EA8D1 CDC00702 CDF00702 C9 48656C6C6F2C20776F726C642100
How does it work?
Well, the main difference between the Z80 processor in older TI-84+ calcs and the eZ80 processor in the TI-84+CE is that it has something called ADL mode added, short for "address and data long" mode which allows for registers and memory addresses to use 24 bit values rather than the previous 16 bit.
Most of the two-byte registers like the HL register, BC, DE, and others only hold two-bytes of data in the Z80 processor, they are 16-bit. That means their maximum unsigned value is (2^16)-1, or 65,535. However, in the eZ80 processor, they can hold 24 bits, raising their maximum value to 16,777,215.
Because of this, sometimes the registers are referred to as HLU, BCU, and DEU, where the U represents the Upper byte (which can't be accessed directly).
Most of the hex codes are pretty similar. However, the big difference is when dealing with data and memory, most of them now require three bytes of data instead of two.
Let's break the code down.
"21" is your general "ld hl, x", or, "load something into the HL register" instruction.
I have three bytes after it representing the three bytes to load into it. Specifically, it is the address of my "Hello, world!" string.
"CD" is the "call" instruction.
The TI-84+CE no longer uses BCALLs (or rst 28h) for the built-in subroutines anymore. You simply call them using the CALL instruction. In this case, the address following it, "0207C0", is the address of the _PutS instruction, which prints a string to the screen. It gets the string from the address stored in the HL register.
This is also a call, but 0207F0 is the "_NewLine" instruction.
Return instruction. Again, the instructions are very similar.
The "Hello, world!" string. This is located at memory address D1A88E. Which is why I loaded that value into the HL register.
How did I know it is located at D1A88E?
Because userMem (where your program starts) is located at D1A881. There are 13 bytes in my program prior to the string. So 0D1A881h + 13 = 0D1A88E.
How did I know the instructions for "ld hl,x" and "call x"? See the official documentation on the eZ80 processor (pages 375-381).
How did I know the memory address for userMem, PutS, and NewLine? See the TI-84+CE include file.
If you're wondering why I reversed all the addresses, look up Endianness! Both the Z80 and eZ80 processors are little Endian. Meaning you reverse the byte order in cases like this.
Hope this helps! C:
Also, here's the another hex code to fill the screen pink!
See if you can figure out how it works.
Asm84CEPrgm 21BFFB00 22C02AD0 21000000 113F0100 0600 0EEF CD201202 C9