-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[commodore] Implement KERNAL LOAD function as inline assembly (#373)
* Rewrite cbm_k_load w. inline asm * Add doxygen documentation * Remove empty line * Update doxygen documentation
- Loading branch information
Showing
4 changed files
with
55 additions
and
25 deletions.
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,31 @@ | ||
// Copyright 2024 LLVM-MOS Project | ||
// Licensed under the Apache License, Version 2.0 with LLVM Exceptions. | ||
// See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license | ||
// information. | ||
|
||
#include <stdint.h> | ||
|
||
// Helper to (dis)assemble a 16-bit integer | ||
typedef union { | ||
uint16_t value; | ||
struct { | ||
uint8_t lo, hi; | ||
}; | ||
} Word; | ||
|
||
void *cbm_k_load(const unsigned char flag, void *load_addr) { | ||
Word result; | ||
const Word addr = {.value = (uint16_t)(load_addr)}; | ||
|
||
__attribute__((leaf)) __asm__ volatile( | ||
" jsr __LOAD \n" | ||
" bcc 1f \n" // no error if carry clear | ||
" tax \n" // else get error code from A | ||
" ldy #0 \n" | ||
"1: \n" // no error | ||
: "=x"(result.lo), "=y"(result.hi) | ||
: "a"(flag), "x"(addr.lo), "y"(addr.hi) | ||
: "p"); | ||
|
||
return (void *)(result.value); | ||
} |
This file was deleted.
Oops, something went wrong.