Added example code

This commit is contained in:
2020-04-02 23:44:05 +02:00
parent 61d533eb17
commit 937e360bf0
5 changed files with 116 additions and 0 deletions

8
src/example/char_out.asm Normal file
View File

@@ -0,0 +1,8 @@
10;Outputs an "A" in the second column of the last row
20 ORG 100H ;Tell the assembler to start at addr. 0x100
30START: LD A,41H ;Load the letter "A" to register A
40 LD DE,301H ;Sets the row to 3 and the column to 1
50 CALL 8468H ;Calls the ```char_out``` function
60 RET ;Return
70 END ;Marks the end of the code for the assembler

29
src/example/char_out.md Normal file
View File

@@ -0,0 +1,29 @@
# ```char_out```
> Version: 1.0.20092.1 \
> Created by: Jali <jali@orca-central.de> \
> Last modified by: Jali <jali@orca-central.de>
## About
The ```char_out``` function is one of the built-in functions from the ROM.
It takes a character, and writes it onto the screen, at a specific location.
## Parameters
```char_out``` is called through address 0x8468. It takes three parameters:
- Register A holds the ASCII code of the character to print
- Register DE holds the position on the screen. D is a value between 0 and 3, representing
the row, while E has a value between 0-23, representing the column to print in.
## Example
```ASM
10;Outputs an "A" in the second column of the last row
20 ORG 100H ;Tell the assembler to start at addr. 0x100
30START: LD A,41H ;Load the letter "A" to register A
40 LD DE,301H ;Sets the row to 3 and the column to 1
50 CALL 8468H ;Calls the ```char_out``` function
60 RET ;Return
70 END ;Marks the end of the code for the assembler
```

10
src/example/str_out.asm Normal file
View File

@@ -0,0 +1,10 @@
10;output a string into the top left of the screen
20 ORG 0100H ;Start at addr 0x100
30START: LD HL,DATA ;Load the start address of the string
40 LD B,0DH ;The length of the string (max 255 chars)
50 LD DE,0H ;Start in the top left corner (D=0-3 -> row; E=0-23 column)
60 CALL 84CDH ;Call the str_out function in ROM
70 RET ;Return from call
80DATA: DB 'HELLO, WORLD!'
90 END ;End marker for the assembler

33
src/example/str_out.md Normal file
View File

@@ -0,0 +1,33 @@
# ```str_out```
> Version: 1.0.20092.1 \
> Created by: Jali <jali@orca-central.de> \
> Last modified by: Jali <jali@orca-central.de>
## About
The ```str_out``` function is one of the built-in functions from the ROM.
It takes a string of characters, and writes them onto the screen, at a specific location.
## Parameters
```str_out``` is called through address 0x84CD. It takes four parameters:
- Register HL holds the address of the string in memory
- Register B holds the length of the string. This restricts the maximum length to 255.
- Register DE holds the position on the screen. D is a value between 0 and 3, representing
the row, while E has a value between 0-23, representing the column to print in.
## Example
```ASM
10;output a string into the top left of the screen
20 ORG 0100H ;Start at addr 0x100
30START: LD HL,DATA ;Load the start address of the string
40 LD B,0DH ;The length of the string (max 255 chars)
50 LD DE,0H ;Start in the top left corner (D=0-3 -> row; E=0-23 column)
60 CALL 84CDH ;Call the str_out function in ROM
70 RET ;Return from call
80DATA: DB 'HELLO, WORLD!'
90 END ;End marker for the assembler
```