In this section you will make a program to display "Hello, World" on the screen.
Writing the ProgramEdit
Make a new text file on NotePad and type the following text:
.NOLIST #define EQU .equ #define equ .equ #define END .end #define end .end #include "ti83plus.inc" .LIST .org 9D93h .db $BB,$6D ld a,0 ; load the value 0 to register a, the ''accumulator'' ld (CURCOL),a ; assign the contents of register a to memory address (CURCOL) in the RAM ld (CURROW),a ; assign the contents of register a to memory address (CURROW) in the RAM ld hl,text ; load the data in label "text" to register hl B_CALL(_PutS) ; calls a function in ti83plus.inc to print text B_CALL(_NewLine) ; calls a function in ti83plus.inc to insert a lnbreak (for legibility) ret ; returns from the program to the calc's OS text: .db "Hello, World",0 .end end
The tabbed lines need to be tabbed! Save this file as myprog.z80 into your "Programs" subfolder. Also, note that the command B_CALL() may need to be changed to bcall() depending on the contents of the includes file used during compiling. The compiler will record one error if the command (B_CALL or bcall) is different than the one defined in ti83plus.inc, though in the most popular editions of ti83plus.inc it is bcall - simply swapping one for the other may fix this.
Compiling the ProgramEdit
Compiling essentially means translating text code into code that a machine can read.
To compile your program myprog.z80 first open a Command Prompt (it should be in Accessories). You should be faced with a black window with some white text saying what folder you are in. The first step is to change the folder to your programs folder. To do this use the following commands:
- cd subfoldername (This will go to the subfolder that you tell it to.)
- cd .. (This will instantly go to the folder that holds the folder you are in.)
Afterwards, you need to type in:
- compile myprog
This should automatically compile myprog.z80 if you have followed all instructions correctly.
The finished program should be located in your "Programs" folder as myprog.8xp.
Testing the ProgramEdit
On your computer, open up the TI 83 Plus Flash Debugger to make a fake calculator for testing purposes. Click on the white paper icon to make a new fake calculator and choose the 83+ calculator. Then click on Load... RAM File and open your compiled program (myprog.8xp). Finally, click on the triangle-shaped play button to begin emulation. On the fake calculator, press [2nd]+[Catalog] to bring up the catalog and arrow down to Asm(. Press enter to insert the command into the screen and then select your program ([PRGM],[ENTER]). The screen on the calc should say Asm(prgmMYPROG). Now press enter, and "Hello World" should be displayed on the screen.
Always test your programs on the Flash Debugger before you use them on your real calculator because there is a large chance of your real calculator crashing.
Commands of the ProgramEdit
The only lines of importance now are the middle ones:
ld a,0 ld (CURCOL),a ld (CURROW),a ld hl,text B_CALL(_PutS) ret text: .db "Hello, World",0
When the calculator executes a program, it follows the commands line by line. The first line (ld a,0) loads zero into a, which is a commonly used register. So now register a = 0. The next two lines load that number into the cursor row and column sectors in the RAM. So now the cursor is located at 0,0 and the next text will be displayed at that location. The fourth line (ld hl,text), loads the location of .db "Hello... into hl, another register. B_Call(_PutS) takes the text that hl has specified and displays it at the current cursor location. Finally, ret tells the calculator to exit out of the program. You should now have a vague understanding of the functions of most of the lines in your first program.
This little program, however small, is far from optimal. ld a,0 can be replaced by xor a as long as you don't need to preserve the flags. XOR A (see ) inverts any bit that is 1, so basically it sets A to zero. This is not all, one can load CurCol and CurRow at once with ld (CurRow),hl , L will go into CurRow and H into CurCol.
ld hl,0 ld (CurRow),hl ld hl,text B_CALL(_PutS) ret text: .db "Hello, World",0