Search found 7 matches

by pifu
Fri Dec 19, 2025 4:04 pm
Forum: Programming
Topic: Assemler - efficient alternative to self-modifying code?
Replies: 4
Views: 615

Re: Assemler - efficient alternative to self-modifying code?

drogon wrote:
One way to make something that's normally ROMmable is to copy it to RAM - if you can spare a few bytes in ZP then it would work just fine
You right! So I just need to move the JMP() instruction to 3 bytes in ZP and jump there from my first routine... Easy :o
Many thanks!
by pifu
Fri Dec 19, 2025 2:04 pm
Forum: Programming
Topic: Assemler - efficient alternative to self-modifying code?
Replies: 4
Views: 615

Assemler - efficient alternative to self-modifying code?

Hi,
I need to assemble a double-indirect jump. I solved it with self-modifying code:

;SWITCH:
;A:X (lo:hi) = adr, OFS:OFS+1 (lo:hi) = ofs
;jump to address stored in MEM[adr+ofs]:MEM[adr+ofs+1]

SWITCH CLC
ADC OFS ;A <- lo(adr + ofs)
STA @jmp + 1 ;save it as JMP() arg, lo
TXA
ADC OFS + 1 ;A ...
by pifu
Thu Nov 06, 2025 8:50 am
Forum: Programming
Topic: [Commodore] Calculate VIC-II byte address of a given point
Replies: 1
Views: 637

[Commodore] Calculate VIC-II byte address of a given point

Hello,
I searched around for a compact routine for calculating the VIC-II byte address of a point, given its (x, y) coordinates. As you know, the VIC-II has a weird addressing, i.e. the bitmap addressing in 320x200 graphic mode is not linear: the very first 8 addresses refer to the 8x8-pixel block ...
by pifu
Tue May 23, 2017 9:25 am
Forum: Programming
Topic: escape from nested subroutines
Replies: 5
Views: 2738

Re: escape from nested subroutines

BTW, I'm coding an interpreter for executing OCaml bytecode on a 6510-based hw (i.e., the C64; but it should be easily generalized).
The interpreter, as you can imagine, makes heavy use of a stack: not only for math, but also for function calls, exception frames, and so on. Some detail of the ...
by pifu
Mon May 22, 2017 8:11 am
Forum: Programming
Topic: escape from nested subroutines
Replies: 5
Views: 2738

Re: escape from nested subroutines

Thank you.
Yes, CPU_STACK_PTR is not used elsewhere. The RTS at the end of main_loop must return to a BASIC program.
---
BTW: I think I'll study your 6502 STACK Treatise...
by pifu
Mon May 22, 2017 7:32 am
Forum: Programming
Topic: escape from nested subroutines
Replies: 5
Views: 2738

escape from nested subroutines

Hi all,
I need a way to escape from any level of nested subroutines and get back to the first caller level (somewhat like an exception handler), ensuring that its last RTS will be handled correctly.
Neither the main loop nor the subroutines make explicit use of the stack (i.e., it is used only by ...
by pifu
Thu May 04, 2017 12:25 pm
Forum: Programming
Topic: [porting] [languages] Ocaml bytecode interpreter
Replies: 1
Views: 900

[porting] [languages] Ocaml bytecode interpreter

crossposted on Lemon64 General forum

Hi all,
maybe some of you will have heard something about OCaml , a multi-paradigm programming language with a lot of nice features.
Well, I'm trying to write a runtime system in order to execute the OCaml bytecode on the C64. :shock:
After a look of OCapic ...