sd-8516_assembly_language_part_ii
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sd-8516_assembly_language_part_ii [2026/02/14 02:49] – appledog | sd-8516_assembly_language_part_ii [2026/02/14 03:02] (current) – appledog | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| * Lessons 0-7: [[SD-8516 Assembly Language]] | * Lessons 0-7: [[SD-8516 Assembly Language]] | ||
| * Lessons 8-15: This page. | * Lessons 8-15: This page. | ||
| - | * [[SD-8516 Assembly Language Appendix]] | ||
| == Introduction to Part II | == Introduction to Part II | ||
| Line 208: | Line 207: | ||
| POP B | POP B | ||
| RET | RET | ||
| + | |||
| + | |||
| + | == Lesson 11: Debugging Techniques | ||
| + | There are several ways you can debug programs in SDA assembly. | ||
| + | |||
| + | === SED/CLD | ||
| + | In research or development builds, inserting SED will turn on trace debugging and you will be able to see what the CPU is executing. However, for release or community edition builds debugging has been turned off for speed. Therefore if you are interested in debugging your code and the console messages are not helping, you can use the following to help analyze and debug your code: | ||
| + | |||
| + | === INT 05h IO_PUTNUM | ||
| + | IO_PUTNUM is a CAM/IL function that prints a number (in b) to the screen: | ||
| + | |||
| + | LDB #10 ; print a number in b (0-65535) | ||
| + | | ||
| + | LDAH $63 ; IO_PUTNUM | ||
| + | INT $05 | ||
| + | |||
| + | === INT 05h IO_PRINT_STR | ||
| + | Similarly, IO_PRINT_STR will print a string followed by a newline. | ||
| + | |||
| + | LDBLX @hello_world | ||
| + | LDAH $66 ; IO_PRINT_STR | ||
| + | INT $05 | ||
| + | | ||
| + | LDAH $64 ; IO_NEWLINE | ||
| + | INT $05 | ||
| + | RET | ||
| + | | ||
| + | hello_world: | ||
| + | .bytes "Hello World!", | ||
| + | |||
| + | |||
| + | This will allow you to print a string. | ||
| + | |||
| + | === INT 10h print string | ||
| + | The interface for the above is based on the KERNAL BIOS interface from INT 10h. | ||
| + | |||
| + | LDAH $26 ; | ||
| + | LDBLX @hello_world | ||
| + | INT 0x10 | ||
| + | |||
| + | Note: The assembler will place a #13 (CR, hex $0D) inside the string if you type \n. However, if you are dealing with strings on your own you must handle this yourself. For this you can use the set cursor position call (INT 10h, AH=22h) or the CR and LF and scroll functions (1Ah, 1Bh and 1Ch, respectively). | ||
| + | |||
| + | You can also just call IO_NEWLINE from INT 05h, which calls **'' | ||
| + | |||
| + | === INT 10h print char | ||
| + | LDAH 0x24 ; AH=24h: Write character at cursor (teletype) | ||
| + | LDAL 0x41 ; ascii 65 ' | ||
| + | INT 0x10 | ||
| + | |||
| + | The KERNAL BIOS also has functions to put characters on the screen in mode 1 (40x25 TTY). The first one is "print char". It is accessible via INT 10h AH=24h as above. | ||
| + | |||
| + | |||
| + | === INT 19h memdump | ||
| + | Let's say you want to examine memory; for example to print some data in memory. You can use INT 0x19: | ||
| + | |||
| + | LDAH #7 ; Memory dump function | ||
| + | LDCL #2 ; Two rows (16 bytes) | ||
| + | INT 0x19 ; System services library | ||
| + | HALT | ||
| + | |||
| + | This looks something like: | ||
| + | |||
| + | 000000: 00 00 00 00 00 00 00 00 | ........ | ||
| + | 000008: 00 00 00 00 00 00 00 00 | ........ | ||
| + | |||
| + | |||
sd-8516_assembly_language_part_ii.1771037364.txt.gz · Last modified: by appledog
