Jump to content
  • entries
    36
  • comments
    18
  • views
    33,678

Memory Fill Routine


tschak909

469 views

After much deliberation, I finally managed to get the memory clear/fill function debugged.

 

;
; FILL PAGES MACRO 
;
; %1 = beginning page to fill
; %2 = number of pages to fill (should be - 1)
; %3 = byte to fill with (e.g. $00)
;
; $CC = 00 for top of page boundary
; $CD = page currently being filled
; $D5 = corresponding to ending page
;
	.MACRO CLRP
STCL	LDA %1
	STA $CD
	LDA #00
	STA $CC
	LDY #0
	LDA $CD
	ADC #%2
	STA $D5
CRLP	LDA %3
	DEY
	STA ($CC),Y
	BNE CRLP
	INC $CD
	LDA $CD
	CMP $D5
	BEQ CRLP
	BCC CRLP
	.ENDM

 

So, what do you guys think? How can I make this so that it can fill regions of memory that don't end on nice page boundaries? Should I need to do that?

 

-Thom

5 Comments


Recommended Comments

Well, no clue if you should need to do that... creating macros without any goal in mind seems to be rather odd actually...

 

The code as is would execute 512 cycles faster (per page!) though, if you'd move the CRLP label just one line down.

(Of course you should no longer trash the accu with "LDA $CD" for the next page, but rather use the X register for that check instead.)

Link to comment

Well, I was thinking there might BE a need to fill sections of memory that do not begin on page boundaries (the atari usually crams its screen memory not exactly on screen boundaries, for example.) or should I just override that and move screen memory elsewhere myself???

 

As for the routine, thanks for the tips.

 

-Thom

Link to comment
The code as is would execute 512 cycles faster (per page!) though, if you'd move the CRLP label just one line down.

(Of course you should no longer trash the accu with "LDA $CD" for the next page, but rather use the X register for that check instead.)

I'm pretty sure there's also no need for the two conditional branches if you swap the operands on the compare and load:

	LDA $D5
	CMP $CD
	BCS CRLP

Link to comment
The code as is would execute 512 cycles faster (per page!) though, if you'd move the CRLP label just one line down.

(Of course you should no longer trash the accu with "LDA $CD" for the next page, but rather use the X register for that check instead.)

I'm pretty sure there's also no need for the two conditional branches if you swap the operands on the compare and load:

	LDA $D5
	CMP $CD
	BCS CRLP

 

oh wow, why can you do that?

 

-Thom

Link to comment
The code as is would execute 512 cycles faster (per page!) though, if you'd move the CRLP label just one line down.

(Of course you should no longer trash the accu with "LDA $CD" for the next page, but rather use the X register for that check instead.)

I'm pretty sure there's also no need for the two conditional branches if you swap the operands on the compare and load:

	LDA $D5
	CMP $CD
	BCS CRLP

 

oh wow, why can you do that?

 

-Thom

The two compares in your routine amount to branch if $CD=$D5 or $CD<$D5. Combined, that's $CD<=$D5.

 

Mine is "branch if $D5>=$CD" which is exactly the same as $CD<=$D5 if you think about it.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...