Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Z80 Assembly/Hello World

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

In this section you will make a program to display "Hello, World!" on the screen. Writing the Program Make a new text file in Notepad and type in 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 ld (CURCOL),a ld (CURROW),a ld hl,text B_CALL(_PutS) ret text: .db "Hello, World!",0 .end end The tabbed lines need to be tabbed! Save this file as myprog.z80 into your "Programs" subfolder. Compiling the Program Compiling essentially means translating text code into code that a machine can read. To compile your program myprog.z80 first open a Command Prompt (Start > Run... > command in Win9x, or Start > Run... > cmd in WinNT). 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. frame|none|Screenshot The finished program should be located in your "Programs" folder as myprog.8xp. Testing the Program 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 Program 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 variable. So now the variable a=0. The next two lines load that number into the cursor row and column. 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 variable. 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.