Simple Hello World Example on the TMS9900
<- Back to the Main Contents & Basic TMS9900 Assembly Lessons

Introduction to the Hello World Series...
In this series we'll be looking at the basics of coding,compiling and runniing

Lesson H1 - Hello World on the TI-99
The Ti-99 screen is basically the same as the MSX1 - we need to write bytes to screen RAM to make characters visible... we'll learn how to code and compile a cartrige, and run it on the machine...

Lets look how!

See HelloWorld.asm


Beginning a Cartridge
We're going to start a cartridge...

First we need to turn 'Padding Off' - Padding is where the assembler automatically adds zero bytes automatically - it will make things difficult, so we'll turn it off.

We need to put a fixed header word 'AA01' - this defines the cartridge start...

Next we need a pointer to our program for the main menu - and a name of the program (LearnAsm.Net)

The fixed values here will work fine for all our programs
As well as the header - we need the start of our program...

First we turn of the interrupts with LIMI

Next we need to define some memory to use for our register r0 - r15 - we're using ram address 83C0h so the 16 two byte registers use up to 83FFh
We now have a menu item for our program!... when we select it, label ProgramStart will run!


Our cartridge only has a single program, the format can support more than one, but it's not something we'll look at here.

Setting up our screen.

When the computer starts, the screen is in character mode - and each byte of VRAM is a chacacter tile  (from VRAM address 0000h onwards)...

To select a WRITE address we add 4000h to this ... and write to address &8C02h... we write the L byte first 00h... then the high byte 40h

To allow for Newlines, we need to count how many horizontal characters we've printed - we use CursorX to do this - here we reset it to zero.



Printing a character to the screen

Ok, we need to print a character to the screen... once we've selected a vram address with port 8C02 - we can write bytes to the screen with VRAM address 8C00 - these will appear as characters ... but there's a problem!

Characters over 96 (60h) are lowercase - and our font doesn't have lower case characters... we solve this by comparing to 6000h (top byte 60h=96) - and add E000h - effectively subtracting 32 from the byte - converting to lowercase.

We add 1 to the byte in CursorX - as we've moved across the screen.

Using our PrintChar to print a string

We're going to write a simple string printing routine, it prints a 255 terminated string.

All we do is read in bytes from *R1 until we get to a 255, at which point we return... we print all other characters with our PrintChar routine
To print the string, just load R1 with the address of the string, and call the function

NOTE!: we need to make sure we're aligned on an EVEN byte for the rest of the program code - so we put 'Align 2' after our bytes .... note, if we'd left PADDING ON, we wouldn't need the 'Align 2'
This will show 'Hello World' to the screen


NewLine

We've counted how many characters we've printed to the screen - in order to start a NewLine, we just need to print spaces until we reach the end of the line (32 characters)

Building the ROM

We build our rom with Macro AS (ASW)

Here is the script I use...
We specify the source asm (%1 in my batch file)
We specify our CPU type as TMS9900
We specify to output a listing file - this is handy for debugging.
We tell the assembler to define a symbol 'BuildT99' (Some of my multiplaform programs use this)
We output a Build file prog.bld - but this needs converting before we can use it as a rom!


Once the build completes - we need to convert it to a binary


We can then start the ROM with our emulator (Classic99):



Monitor Tools
As an added bonus we can include the 'Monitor Tools' we developed in the multiplatform series.

These allow us to show the registers or parts of the Ram for testing and debugging purposes
This gives us 2 commands...
Monitor shows all the registers,
RamDump will show R5 bytes from address R4 to the screen
We can see the result onscreen.
We've got some basic screen routines, a memory dump and register dump... we can use these as 'building blocks' for making and testing something better.






 

View Options
Default Dark
Simple (Hide this menu)
Print Mode (white background)

Top Menu
***Main Menu***
Youtube channel
Patreon
Introduction to Assembly (Basics for absolute beginners)
Amazon Affiliate Link
AkuSprite Editor
ChibiTracker
Dec/Bin/Hex/Oct/Ascii Table

Alt Tech
Archive.org
Bitchute
Odysee
Rumble
DailyMotion
Please note: I wlll upload more content to these alt platforms based on the views they bring in

Z80 Content
***Z80 Tutorial List***
Learn Z80 Assembly (2021)
Learn Z80 Assembly (old)
Hello World
Simple Samples
Advanced Series
Multiplatform Series
Platform Specific Series
ChibiAkumas Series
Grime Z80
Z80 Downloads
Z80 Cheatsheet
Sources.7z
DevTools kit
Z80 Platforms
Amstrad CPC
Elan Enterprise
Gameboy & Gameboy Color
Master System & GameGear
MSX & MSX2
Sam Coupe
TI-83
ZX Spectrum
Spectrum NEXT
Camputers Lynx

6502 Content
***6502 Tutorial List***
Learn 6502 Assembly
Advanced Series
Platform Specific Series
Hello World Series
Simple Samples
Grime 6502
6502 Downloads
6502 Cheatsheet
Sources.7z
DevTools kit
6502 Platforms
Apple IIe
Atari 800 and 5200
Atari Lynx
BBC Micro
Commodore 64
Commodore PET
Commander x16
Super Nintendo (SNES)
Nintendo NES / Famicom
PC Engine (Turbografx-16)
Vic 20

68000 Content
***68000 Tutorial List***
Learn 68000 Assembly
Hello World Series
Platform Specific Series
Simple Samples
Grime 68000
68000 Downloads
68000 Cheatsheet
Sources.7z
DevTools kit
68000 Platforms
Amiga 500
Atari ST
Neo Geo
Sega Genesis / Mega Drive
Sinclair QL
X68000 (Sharp x68k)

8086 Content
Learn 8086 Assembly
Platform Specific Series
Hello World Series
Simple Samples
8086 Downloads
8086 Cheatsheet
Sources.7z
DevTools kit
8086 Platforms
Wonderswan
MsDos

ARM Content
Learn ARM Assembly
Learn ARM Thumb Assembly
Platform Specific Series
Hello World
Simple Samples
ARM Downloads
ARM Cheatsheet
Sources.7z
DevTools kit
ARM Platforms
Gameboy Advance
Nintendo DS
Risc Os

Risc-V Content
Learn Risc-V Assembly
Risc-V Downloads
Risc-V Cheatsheet
Sources.7z
DevTools kit

MIPS Content
Learn Risc-V Assembly
Platform Specific Series
Hello World
Simple Samples
MIPS Downloads
MIPS Cheatsheet
Sources.7z
DevTools kit
MIPS Platforms
Playstation
N64

PDP-11 Content
Learn PDP-11 Assembly
Platform Specific Series
Simple Samples
PDP-11 Downloads
PDP-11 Cheatsheet
Sources.7z
DevTools kit
PDP-11 Platforms
PDP-11
UKNC

TMS9900 Content
Learn TMS9900 Assembly
Platform Specific Series
Hello World
TMS9900 Downloads
TMS9900 Cheatsheet
Sources.7z
DevTools kit
TMS9900 Platforms
Ti 99

6809 Content
Learn 6809 Assembly
Learn 6309 Assembly
Platform Specific Series
Hello World Series
Simple Samples
6809 Downloads
6809/6309 Cheatsheet
Sources.7z
DevTools kit
6809 Platforms
Dragon 32/Tandy Coco
Fujitsu FM7
TRS-80 Coco 3
Vectrex

65816 Content
Learn 65816 Assembly
Hello World
Simple Samples
65816 Downloads
65816 Cheatsheet
Sources.7z
DevTools kit
65816 Platforms
SNES

eZ80 Content
Learn eZ80 Assembly
Platform Specific Series
eZ80 Downloads
eZ80 Cheatsheet
Sources.7z
DevTools kit
eZ80 Platforms
Ti84 PCE

IBM370 Content
Learn IBM370 Assembly
Simple Samples
IBM370 Downloads
IBM370 Cheatsheet
Sources.7z
DevTools kit

Super-H Content
Learn SH2 Assembly
Hello World Series
Simple Samples
SH2 Downloads
SH2 Cheatsheet
Sources.7z
DevTools kit
SH2 Platforms
32x
Saturn

PowerPC Content
Learn PowerPC Assembly
Hello World Series
Simple Samples
PowerPC Downloads
PowerPC Cheatsheet
Sources.7z
DevTools kit
PowerPC Platforms
Gamecube

Work in Progress
ChibiAndroids

Misc bits
Ruby programming









Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!



































































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!



































































































Buy my Assembly programming book
on Amazon in Print or Kindle!


Buy my Assembly programming book





Available worldwide!
Search 'ChibiAkumas' on
your local Amazon website!
Click here for more info!