Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM assembler version of lpeek and lpoke #33

Merged
merged 9 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(assembler
src/llvm/fileio.s
src/llvm/dirent.s)
src/llvm/dirent.s
src/llvm/memory_asm.s)

set(objects
src/conio.c
Expand Down Expand Up @@ -67,8 +68,8 @@ set(CLANG_WARNINGS
-Wpedantic # warn if non-standard C/C++ is used
-Wlanguage-extension-token
)
add_compile_options(-mcpu=mos65c02 -Os ${CLANG_WARNINGS})
target_compile_options(mega65libc PRIVATE -mcpu=mos65c02 -Os ${CLANG_WARNINGS})
add_compile_options(-mcpu=mos65ce02 -Os ${CLANG_WARNINGS})
mlund marked this conversation as resolved.
Show resolved Hide resolved
target_compile_options(mega65libc PRIVATE -mcpu=mos65ce02 -Os ${CLANG_WARNINGS})

# install target
include(GNUInstallDirs)
Expand Down
35 changes: 35 additions & 0 deletions src/llvm/memory_asm.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.global lpeek, lpoke
.section .zeropage, "a", @nobits
tmp:
.ds.b 8

.section code,"a"
lpoke:
; 32-bit address (a, x, rc2, rc3)
sta tmp
stx tmp + 1
lda __rc2
sta tmp + 2
lda __rc3
sta tmp + 3
; 8-bit value (rc4)
lda __rc4
ldz #0
nop
sta (tmp),z
ldz #0
mlund marked this conversation as resolved.
Show resolved Hide resolved
rts
lpeek:
; 32-bit address (a, x, rc2, rc3)
sta tmp
stx tmp + 1
lda __rc2
sta tmp + 2
lda __rc3
sta tmp + 3
ldz #0
ldx #0
nop
lda (tmp), z
ldz #0
mlund marked this conversation as resolved.
Show resolved Hide resolved
rts
mlund marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 6 additions & 7 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,20 @@ unsigned char lpeek_debounced(long address)
return db1;
}

#ifndef __CC65__
// cc65 has specialized assembler versions of lpeek and lpoke
void lpoke(long address, unsigned char value)
{
dma_poke(address, value);
}
// cc65 and llvm have specialized assembler versions of lpeek and lpoke
#if !defined(__clang__) && !defined(__CC65__)
unsigned char lpeek(long address)
{
return dma_peek(address);
}
void lpoke(long address, unsigned char value)
{
dma_poke(address, value);
}
#endif

void dma_poke(long address, unsigned char value)
{

dmalist.option_0b = 0x0b;
dmalist.option_80 = 0x80;
dmalist.source_mb = 0x00; // dma_byte lives in 1st MB
Expand Down