I'm trying to mix in a bit of inline assembly but I keep getting the error:
Error: Constant integer expression expected
I read the CC65 manual on inline assembly, and they even use examples of close to what I'm doing but it's not working.
Code: Select all
uint8_t lowByte = address & 0xFF; // Low byte (7:0) of the start address
uint8_t midByte = (address >> 8) & 0xFF; // Middle byte (15:8) of the start address
uint8_t highBit = (address >> 16) & 0x01; // High bit (16) of the start address
// Set the starting address of VRAM
__asm__("lda #%b", lowByte);
__asm__("sta $9F20");
__asm__("lda #%b", midByte);
__asm__("sta $9F21");
// Set the high bit of the address (17th bit) and set address increment
__asm__("lda #%b", highBit | 0x10);
__asm__("sta $9F22");
Code: Select all
static uint8_t lowByte; // Low byte (7:0) of the start address
static uint8_t midByte; // Middle byte (15:8) of the start address
static uint8_t highBit; // High bit (16) of the start address
// ... more code here
lowByte = address & 0xFF; // Low byte (7:0) of the start address
midByte = (address >> 8) & 0xFF; // Middle byte (15:8) of the start address
highBit = (address >> 16) & 0x01; // High bit (16) of the start address
// Set the starting address of VRAM
__asm__("lda %v", lowByte);
__asm__("sta $9F20");
__asm__("lda %v", midByte);
__asm__("sta $9F21");
// Set the high bit of the address (17th bit) and set address increment
__asm__("lda %v", highBit);
__asm__("ora #$10"); // Combine with bit 4 set for auto-increment
__asm__("sta $9F22");
I can also get it working using either #defines or typing in the values directly.
What does "Error: Constant integer expression expected" mean?