base:clearing_a_section_of_memory
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:clearing_a_section_of_memory [2015-04-17 04:30] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Clearing a Section of Memory ====== | ||
+ | from 6502 Software Gourmet Guide & Cookbook | ||
+ | When setting up a program for entering data or storing the results of a calculation, | ||
+ | |||
+ | An alternative subroutine which, when called, will clear as many locations in a table area as defined by the calling program. The routine listed below will fill up to 256 memory locations with zeros. The calling routine must store the lowest address of the table in TOPNT on page zero. Also, the X index register must contain the binary count of the number of locations to be cleared. CLRMEM is the start of the subroutine. The accumulator and the X index register will be equal to zero upon returning. | ||
+ | |||
+ | TOPNT is a successive pair of memory locations set up on page zero. It will be used as storage for a temporary pointer. The low portion of the address stored in TOPNT is stored in the lower addressed byte and the page portion is stored in the next higher byte. | ||
+ | < | ||
+ | CLRMEM | ||
+ | TAY ; | ||
+ | CLRM1 STA (TOPNT), | ||
+ | INY ; | ||
+ | DEX ; | ||
+ | BNE CLRM1 ;Not zero, continue checking | ||
+ | RTS ; | ||
+ | </ | ||
+ | |||
+ | Mickael Pointier suggests an alternative method that saves one free register and runs a bit faster since you no longer have to increment one of the registers: | ||
+ | < | ||
+ | CLRMEM | ||
+ | CLRM1 | ||
+ | STA (TOPNT), | ||
+ | BNE CLRM1 ;Not zero, continue checking | ||
+ | RTS ; | ||
+ | </ |
base/clearing_a_section_of_memory.txt · Last modified: 2015-04-17 04:30 by 127.0.0.1