comparison src/memory.s @ 136:e49bd0493baf

Checkpoint updates to immediate mode program editing and some memory handling
author William Astle <lost@l-w.ca>
date Fri, 12 Jul 2024 23:29:45 -0600
parents 3a4cb89a419c
children
comparison
equal deleted inserted replaced
135:3a4cb89a419c 136:e49bd0493baf
50 sta ,x+ ; save new byte in insert location 50 sta ,x+ ; save new byte in insert location
51 leau 1,u ; move to next source byte 51 leau 1,u ; move to next source byte
52 leay -1,y ; done all source bytes? 52 leay -1,y ; done all source bytes?
53 bne mem_insert3 ; brif not 53 bne mem_insert3 ; brif not
54 puls d,x,pc ; clean up stack and return 54 puls d,x,pc ; clean up stack and return
55 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56 ; Block copy routines. There are two routines here. One for moving a block upward in memory and one for moving the block
57 ; downward in memory. Which one is used doesn't matter if the source and destination do not overlap. However, if the
58 ; source and destination do overlap, the direction that needs to be used depends on whether the source is after or
59 ; before the destination. There are three entry points below. One is a general block copy, one is for moving upward
60 ; and one is for moving downward. All entry points have the same input conditions.
61 ;
62 ; Entry:
63 ; X: Destination pointer
64 ; U: Source pointer
65 ; Y: Length of the block to copy
66 ;
67 ; General copy. This just dispatches either mem_copyup or mem_copydn based on whether the source is before or after
68 ; the destination.
69 mem_copy pshs u ; save source address for compare
70 cmpx ,s++ ; is the destination below or above?
71 blo mem_copydn ; brif destination is below the source - we're copying downward
72 ; fall through ; we're copying upward here
73 ; Copy Y bytes from (U) to (X), working from the top down
74 mem_copyup tfr y,d ; need to move pointers to the end of the block
75 leax d,x
76 leau d,u
77 mem_copyup0 lda ,-u ; copy a byte upward
78 sta ,-x
79 leay -1,y ; done yet?
80 bne mem_copyup0
81 rts
82 ; Copy Y bytes from (U) to (X), working from bottom up
83 mem_copydn lda ,u+ ; copy a byte downward
84 sta ,x+
85 leay -1,y ; done yet?
86 bne mem_copydn ; brif not
87 mem_checkptr0 rts
88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
89 ; Check for D bytes of free memory
90 mem_checkd addd freestart ; add to current start of free memory
91 ; fall through to test the resulting pointer
92 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
93 ; Check if the address in D is within the free memory area allowing for a buffer for the system stack.
94 mem_checkptr addd #stackheadroom ; add in the stack buffer space to the pointer
95 sts ,--s ; get the current stack pointer somewhere
96 cmpd ,s++ ; did the pointer run into the stack pointer?
97 blo mem_checkptr0 ; brif not - no error
98 OMERROR ldb #err_om ; raise an OM error
99 jmp ERROR
55 *pragmapop list 100 *pragmapop list