c128lib Base
Base macros for C128
Loading...
Searching...
No Matches
mem.asm File Reference

Mem module. More...

Functions

macro CopyFast (source, destination, count)
 This macro copies a block of memory from one location to another in a fast manner.
 
macro CopyWithRelocation (source, destination)
 This macro copies a block of memory from one location to another using page relocation.
 
macro CopyWithRelocationWithBank (source, sourceBank, destination, destinationBank)
 This macro copies a block of memory from one location to another using page relocation with bank selection.
 
macro FillMemory (address, length, value)
 This macro fills memory with a specified value.
 
macro Cmp16 (value, address)
 This macro compares a 16-bit value with a 16-bit memory location.
 
macro Set8 (value, address)
 

Variables

pseudocommand set8 value
 

Detailed Description

Mem module.

Simple macros for memory operations.

Author
Raffaele Intorcia raffa.nosp@m.ele..nosp@m.intor.nosp@m.cia@.nosp@m.gmail.nosp@m..com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Date
2024

Function Documentation

◆ CopyFast()

macro CopyFast ( source ,
destination ,
count  )

This macro copies a block of memory from one location to another in a fast manner.

It uses the 6502 assembly instructions 'lda' (load accumulator) and 'sta' (store accumulator) to perform the copy operation. This macro does not check for memory overlap between the source and destination. If the source and destination overlap, the behavior is undefined.

Parameters
[in]sourceThe starting address of the memory block to be copied.
[in]destinationThe starting address of the location where the memory block will be copied to.
[in]countThe number of bytes to be copied.
Remarks
Register .A will be modified.
Flags N and Z will be affected.
Note
Usage: CopyFast($C000, $C100, 256) // Copies 256 bytes from memory location $C000 to $C100
Use c128lib_CopyFast in mem-global.asm
Since
1.0.0

◆ CopyWithRelocation()

macro CopyWithRelocation ( source ,
destination  )

This macro copies a block of memory from one location to another using page relocation.

This macro also handles the page relocation of the memory block during the copy operation. It's slower than

See also
CopyFast but it uses much less memory, especially for large memory blocks copy.
Parameters
[in]sourceThe starting address of the memory block to be copied.
[in]destinationThe starting address of the location where the memory block will be copied to.
Remarks
Registers .A and .X will be modified.
Flags N and Z will be affected.
Zeropage location $FE will be used.
During copy, interrupts are disabled.
Note
Usage: CopyWithRelocation($C000, $C100) // Copies 256 bytes from memory location $C000 to $C100 with relocation
The number of bytes that can be copied is always 256.
Source and destination less significant byte should be $00. Any different value will be ignored.
Use c128lib_CopyWithRelocation in mem-global.asm
Since
1.0.0

◆ CopyWithRelocationWithBank()

macro CopyWithRelocationWithBank ( source ,
sourceBank ,
destination ,
destinationBank  )

This macro copies a block of memory from one location to another using page relocation with bank selection.

This macro also handles the page relocation of the memory block during the copy operation. It's slower than

See also
CopyFast but it uses much less memory, especially for large memory blocks copy. This version allows to specify the bank for source and destination memory locations.
Parameters
[in]sourceThe starting address of the memory block to be copied.
[in]sourceBankBank of the starting address.
[in]destinationThe starting address of the location where the memory block will be copied to.
[in]destinationBankBank of the destination address.
Remarks
Registers .A and .X will be modified.
Flags N and Z will be affected.
Zeropage location $FE will be used.
During copy, interrupts are disabled.
Note
The number of bytes that can be copied is always 256.
Source and destination less significant byte should be $00. Any different value will be ignored.
Use c128lib_CopyWithRelocationWithBank in mem-global.asm
Since
1.2.0

◆ FillMemory()

macro FillMemory ( address ,
length ,
value  )

This macro fills memory with a specified value.

This macro fills memory starting from the specified address with the given value.

Parameters
[in]addressThe starting address of memory.
[in]lengthThe memory length to be filled.
[in]valueThe value to be filled on memory.
Remarks
Registers .A and .X will be modified.
Flags N and Z will be affected.
Note
Usage: FillMemory($0400, 50, $E0) // Fills 50 bytes in memory starting from memory location $0400 with the value $E0
Use c128lib_FillMemory in mem-global.asm
Minimum length is set to 5 because it's not convenient to use this macro for lower values.
Since
1.0.0

◆ Cmp16()

macro Cmp16 ( value ,
address  )

This macro compares a 16-bit value with a 16-bit memory location.

The macro first compares the low byte of the value with the low byte of the memory location, and if they are equal, it then compares the high byte of the value with the high byte of the memory location.

Parameters
valueThe 16-bit value to be compared.
addressThe starting address of the 16-bit memory location to be compared with.
Returns
Flag C is set if value is greater than or equal to the value of the memory location, otherwise it is cleared.
Remarks
Register .A will be modified.
Flags N, Z and C will be affected.
Note
Usage: Cmp16($1234, $C000) // Compares the 16-bit value $1234 with the 16-bit memory location starting at $C000
Use c128lib_Cmp16 in mem-global.asm
Since
1.0.0

◆ Set8()

macro Set8 ( value ,
address  )

Variable Documentation

◆ value

pseudocommand set8 value