diff --git a/content/notes/6809.md b/content/notes/6809.md index 0b0815384..0e099a459 100644 --- a/content/notes/6809.md +++ b/content/notes/6809.md @@ -40,7 +40,42 @@ other instructions set flags too # Input/Output ![screen](https://i.imgur.com/IEiGKtj.png) +The screen always displays whatever is in the "screens memory location" which is $0400 +``` 6809 assembly +lda #'H' ; load the character (indicated by '') into the a register +sta $0400 ; store the contents of the a register in memory at location $0400 +``` + +## printing a whole string + +``` +message: + .byte "HELLO WORLD", 0 + +START: + ldy #message ; load + bsr puts ; branch to the "puts" subroutine + rts ; return + +; Routine: PUTS +; Pass the address of the string in Y +; +screen EQU $0400 ; start of screen + +PUTS: + pshs a,x,y ; save a, x, and y ; store the contents of the a, x, and y registers so they are not overwritten + ldx #screen ; start of screen ; load the hex value of the memory location of the screen ($0400) into the x register +more: + lda 0,y+ ; current char -> A ; load + cmpa #$00 ; was it a zero? + beq done ; if it was 0 then return + sta 0,x+ ; write + bra more ; repeat +done: + puls a,x,y ; restore a, x, y + rts ; return from this routine +``` # Hello World