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

Mem module. More...

Functions

macro c128lib_CopyFast (source, destination, count)
 This macro copies a block of memory from one location to another in a fast manner.
 
macro c128lib_CopyWithRelocation (source, destination)
 This macro copies a block of memory from one location to another using page relocation.
 
macro c128lib_CopyWithRelocationWithBank (source, sourceBank, destination, destinationBank)
 This macro copies a block of memory from one location to another using page relocation with bank selection.
 
macro c128lib_FillMemory (address, length, value)
 This macro fills memory with a specified value.
 
macro c128lib_Cmp16 (value, address)
 This macro compares a 16-bit value with a 16-bit memory location.
 
macro c128lib_Set16 (value, address)
 Fills two-byte located in memory address "mem" with byte "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

◆ c128lib_CopyFast()

macro c128lib_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: c128lib_CopyFast($C000, $C100, 256) // Copies 256 bytes from memory location $C000 to $C100
Since
1.0.0

◆ c128lib_CopyWithRelocation()

macro c128lib_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: c128lib_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.
Since
1.0.0

◆ c128lib_CopyWithRelocationWithBank()

macro c128lib_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.
Since
1.2.0

◆ c128lib_FillMemory()

macro c128lib_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 the screen memory.
[in]valueThe value to be filled on the screen.
Remarks
Registers .A and .X will be modified.
Flags N and Z will be affected.
Note
Usage: c128lib_FillMemory($0400, $E0) // Fills the screen starting from memory location $0400 with the value $E0
Since
1.0.0

◆ c128lib_Cmp16()

macro c128lib_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: c128lib_Cmp16($1234, $C000) // Compares the 16-bit value $1234 with the 16-bit memory location starting at $C000
Since
1.0.0

◆ c128lib_Set16()

macro c128lib_Set16 ( value ,
address  )

Fills two-byte located in memory address "mem" with byte "value".

Parameters
[in]valuevalue to set on specified address
[in]addressaddress to set
Remarks
Register .A will be modified.
Flags N and Z will be affected.
Since
1.0.0