-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding more stuff to global * copy large mem backward sub added * update README.md --------- Co-authored-by: Maciej Małecki <[email protected]>
- Loading branch information
1 parent
53acb79
commit 0385f54
Showing
4 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2017-2023 c64lib | ||
* Copyright (c) 2017-2023 Maciej Małecki | ||
* | ||
* 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. | ||
*/ | ||
#import "../invoke.asm" | ||
#import "../mem.asm" | ||
#import "../math.asm" | ||
|
||
/* | ||
* Copies block of memory backward. Both source and target memory block can overlap as long as target | ||
* block is located lower than source block. | ||
* | ||
* IN: | ||
* Stack WORD - source address | ||
* Stack WORD - target address | ||
* Stack WORD - size | ||
* MOD: A, X | ||
*/ | ||
.namespace c64lib { | ||
copyLargeMemBackward: { | ||
|
||
invokeStackBegin(returnPtr) | ||
pullParamW(copyCounter) | ||
pullParamW(staNext) | ||
pullParamW(ldaNext) | ||
|
||
// addMem16(copyCounter, staNext) | ||
// addMem16(copyCounter, ldaNext) | ||
copyNextPage: | ||
ldx #0 | ||
copyNext: | ||
lda ldaNext:$ffff, x | ||
sta staNext:$ffff, x | ||
dec16(copyCounter) | ||
cmp16(0, copyCounter) | ||
beq end | ||
inx | ||
cpx #0 | ||
bne copyNext | ||
add16(256, ldaNext) | ||
add16(256, staNext) | ||
jmp copyNextPage | ||
end: | ||
|
||
invokeStackEnd(returnPtr) | ||
rts | ||
// local vars | ||
returnPtr: .word 0 | ||
copyCounter: .word 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2017-2023 c64lib | ||
* Copyright (c) 2017-2023 Maciej Małecki | ||
* | ||
* 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. | ||
*/ | ||
#import "64spec/lib/64spec.asm" | ||
#import "../lib/invoke-global.asm" | ||
|
||
|
||
sfspec: init_spec() | ||
|
||
describe("copyLargeMemBackward") | ||
|
||
it("copies 7 bytes forward non overlapping"); { | ||
c64lib_pushParamW(dataToBeMoved) | ||
c64lib_pushParamW(targetLocation) | ||
c64lib_pushParamW(7) | ||
jsr copyLargeMemForward | ||
|
||
assert_bytes_equal 7: targetLocation: dataToBeMoved | ||
} | ||
|
||
it("copies 260 bytes forward non overlapping"); { | ||
c64lib_pushParamW(largeDataToBeMoved) | ||
c64lib_pushParamW(largeTargetLocation) | ||
c64lib_pushParamW(260) | ||
jsr copyLargeMemForward | ||
|
||
assert_bytes_equal 19: largeTargetLocation: largeDataToBeMoved | ||
} | ||
|
||
finish_spec() | ||
|
||
* = * "Data" | ||
copyLargeMemForward: | ||
#import "../lib/sub/copy-large-mem-forward.asm" | ||
dataToBeMoved: .text "foo bar" | ||
targetLocation: .text " " | ||
|
||
largeDataToBeMoved: .fill 260, 127.5 + sin(toRadians(i*360/256)) | ||
largeTargetLocation: .fill 260, 0 |