eris2010

Documentation: http://frombelow.net/projects/eris2010/
Clone: git clone https://git.frombelow.net/eris2010.git
Log | Files | Refs | README | LICENSE

os.inc (2136B)


      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_SPPED 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 	BOOT_EMBEDDED = false
     31 	;; Set start addresses for program and
     32 	;; zero page variables
     33 	* = os.rom_zero_page_end
     34 	.dsection zero_page
     35         * = start_address
     36 .else
     37 	BOOT_EMBEDDED = true
     38 .endif
     39 
     40 .include "io.inc"
     41 .include "ds.inc"
     42 .include "sd.inc"
     43 .include "term.inc"	
     44 	
     45 ;;; -----------------------------------
     46 ;;; 
     47 ;;; Miscellaneous utility functions
     48 ;;; 
     49 ;;; -----------------------------------
     50 
     51 mem .namespace 
     52 
     53 SET_BITS .macro
     54 	lda \1
     55 	ora \2
     56 	sta \1
     57 	.endm
     58 
     59 CLEAR_BITS .macro
     60 	lda \1
     61 	and ~\2
     62 	sta \1
     63 	.endm
     64 
     65 TOGGLE_BITS .macro
     66 	lda \1
     67 	eor \2
     68 	sta \1
     69 	.endm
     70 	
     71 ;;; STORE_WORD(word,dst)
     72 ;;;   Store word at dst
     73 ;;;   Input:
     74 ;;;     word
     75 ;;;   Output:
     76 ;;;     -
     77 ;;;   Changes:
     78 ;;;     a, dst
     79 STORE_WORD	.macro
     80         lda #<\1
     81         sta \2
     82         lda #>\1
     83         sta \2+1
     84 	.endm
     85 
     86 
     87 COPY_WORD_IMMEDIATE:	.macro
     88 	lda #<\1
     89 	sta \2
     90 	lda #>\1
     91 	sta \2+1
     92 	.endm
     93 
     94 	;; Copy macro for absolute and indirect addressing modes
     95 COPY_WORD_ABSOLUTE_INDIRECT:	.macro
     96 	lda \1
     97 	sta \2
     98 	ldy #$01
     99 	lda \1,y
    100 	sta \2,y
    101 	.endm
    102 
    103 SUB_WORD:	.macro
    104 	lda \1
    105 	sec
    106 	sbc #<\2
    107 	sta \1
    108 	lda \1+1
    109 	sbc #>\2
    110 	sta \1+1
    111 	.endm
    112 
    113 ADD_WORD:	.macro
    114 	lda \1
    115 	clc
    116 	adc #<\2
    117 	sta \1
    118 	lda \1+1
    119 	adc #>\2
    120 	sta \1+1
    121 	.endm
    122 
    123 .endn