Programming with Ophis
<<< Previous | The basics | Next >>>

# Writing the actual code

Now that we have our header information, let's actually write the "Hello world" program. It's pretty short—a simple loop that steps through a hardcoded array until it reaches a 0 or outputs 256 characters. It then returns control to BASIC with an `RTS` statement.

Each character in the array is passed as an argument to a subroutine at memory location $FFD2. This is part of the Commodore 64's BIOS software, which its development documentation calls the KERNAL. Location $FFD2 prints out the character corresponding to the character code in the accumulator.

            ldx #0
    loop:   lda hello, x
            beq done
            jsr $ffd2
            inx
            bne loop
    done:   rts

    hello:  .byte "HELLO, WORLD!", 0

The complete, final source is available in the tutor1.oph file.

<<< Previous | Home | Next >>>
Related commands and options | Up | Assembling the code