[Coco] Hello World part3
Roger Taylor
rtaylor at bayou.com
Wed Jan 21 16:00:11 EST 2004
Here's a very short Hello World example.
org 12000
msg fcc "HELLO WORLD OF ASSEMBLY"
fcb 13,0
start ldx #msg point to our message
p@ lda ,x+ get current ASCII character
beq x@ exit if it's the NULL-terminator
jsr [40962] print the character using stdout hook
bra p@ keep printing
x@ rts
end start
At 03:27 PM 1/21/2004 -0500, you wrote:
>It has been mentioned that assembly programming is not done in a vacuum.
>There is normally an operating system (OS) present and it make sense to
>use as many routines from the OS as possible in your own programs.
>
>Here is a version of Hello World that uses ROM routines. It will clear and
>print to the screen regardless of Coco3 text mode; 32, 40, 80. This type
>of coding requires a knowledge of the ROMs that can only be obtained from
>sources such as the Unravelled series of books. They can be found on the
>Internet with a good search engine.
>
>* HELLO WORLD USING ROM ROUTINES
>
>PRNSTR EQU $B99C ROM PRINT STRING ROUTINE
>CLRSCR EQU $A910 ROM CLEAR SCREEN
>CURPOS EQU $88 CURRENT SCREEN POSITION, LOW RES
>CRSLOC EQU $FE00 " " FOR HIGH RES
>SMODE EQU $E7 SCREEN MODE 0=32COL,1=40COL,2=80COL
>
> ORG $7000
>START JSR CLRSCR
> LDA SMODE FIND OUT WHICH TEXT SCREEN IS IN USE
> BNE HRES
> LDX #$4EA CENTER OF LOW RES SCREEN
> STX CURPOS
> BRA NEXT
>HRES LDX CRSLOC
> CMPA #1
> BEQ MRES
> LEAX 1670,X ABOUT CENTER OF 80 COL. SCREEN
> BRA NEXT
>MRES LEAX 824,X ABOUT CENTER OF 40 COL. SCREEN
>NEXT STX CRSLOC
> LEAX MESGE-1,PCR THE -1 IS NECESSARY
> JSR PRNSTR
>LOOP BRA LOOP
>
>MESGE FCC /Hello, World/
> FCB 0
>
> END START
>
>
>--
>Coco mailing list
>Coco at maltedmedia.com
>http://five.pairlist.net/mailman/listinfo/coco
----------
Roger Taylor
More information about the Coco
mailing list