os.inc (2085B)
1 ;;; -*- asm -*- 2 3 ;;; Copyright 2021 Gerd Beuster (gerd@frombelow.net). This is free 4 ;;; software under the GNU GPL v3 license or any later version. See 5 ;;; COPYING in the root directory for details. 6 7 ;;; This file may be included from os.asm or from 8 ;;; some userland program. 9 ;;; We use the definition of CLOCK_SPEED in os.asm to 10 ;;; check if we are compiling in the context of a userland 11 ;;; program. 12 .weak 13 CLOCK_SPEED = 0 14 .endweak 15 .if CLOCK_SPEED == 0 16 .if SYMON 17 filename_addition = "_symon" 18 start_address = $0300 19 .else 20 filename_addition = "" 21 start_address = $0200 22 .endif 23 os: .binclude "os" .. filename_addition .. ".l" 24 io: .binclude "io" .. filename_addition .. ".l" 25 ds: .binclude "ds" .. filename_addition .. ".l" 26 sd: .binclude "sd" .. filename_addition .. ".l" 27 lfsr: .binclude "lfsr" .. filename_addition .. ".l" 28 via: .binclude "via" .. filename_addition .. ".l" 29 term: .binclude "term" .. filename_addition .. ".l" 30 ;; Set start addresses for program and 31 ;; zero page variables 32 * = os.rom_zero_page_end 33 .dsection zero_page 34 * = start_address 35 .endif 36 37 .include "io.inc" 38 .include "ds.inc" 39 .include "sd.inc" 40 .include "term.inc" 41 42 ;;; ----------------------------------- 43 ;;; 44 ;;; Miscellaneous utility functions 45 ;;; 46 ;;; ----------------------------------- 47 48 mem .namespace 49 50 SET_BITS .macro 51 lda \1 52 ora \2 53 sta \1 54 .endm 55 56 CLEAR_BITS .macro 57 lda \1 58 and ~\2 59 sta \1 60 .endm 61 62 TOGGLE_BITS .macro 63 lda \1 64 eor \2 65 sta \1 66 .endm 67 68 ;;; STORE_WORD(word,dst) 69 ;;; Store word at dst 70 ;;; Input: 71 ;;; word 72 ;;; Output: 73 ;;; - 74 ;;; Changes: 75 ;;; a, dst 76 STORE_WORD .macro 77 lda #<\1 78 sta \2 79 lda #>\1 80 sta \2+1 81 .endm 82 83 84 COPY_WORD_IMMEDIATE: .macro 85 lda #<\1 86 sta \2 87 lda #>\1 88 sta \2+1 89 .endm 90 91 ;; Copy macro for absolute and indirect addressing modes 92 COPY_WORD_ABSOLUTE_INDIRECT: .macro 93 lda \1 94 sta \2 95 ldy #$01 96 lda \1,y 97 sta \2,y 98 .endm 99 100 SUB_WORD: .macro 101 lda \1 102 sec 103 sbc #<\2 104 sta \1 105 lda \1+1 106 sbc #>\2 107 sta \1+1 108 .endm 109 110 ADD_WORD: .macro 111 lda \1 112 clc 113 adc #<\2 114 sta \1 115 lda \1+1 116 adc #>\2 117 sta \1+1 118 .endm 119 120 .endn