Page 1 of 1

Post the fun code you found!

Posted: Tue Jan 22, 2013 2:21 am
by Godzil
As some already know, I'm playing with the disassembly of the various Jasmin ROM, and found some interesting assembly construction in the Jasmin ROM:

Code: Select all

LFE0D:  dey                                     ; FE0D 88                       .
        cpy     #$FF                            ; FE0E C0 FF                    ..
        beq     LFE1B                           ; FE10 F0 09                    ..
        lda     LFE63,y                         ; FE12 B9 63 FE                 .c.
        sta     L0400,y                         ; FE15 99 00 04                 ...
        clc                                     ; FE18 18                       .
        bcc     LFE0D                           ; FE19 90 F2                    ..
LFE1B:  lda     #$01                            ; FE1B A9 01                    ..
I hope that the T-DOS was better coded!

Re: Post the fun code you found!

Posted: Tue Jan 22, 2013 9:15 am
by Dbug
One reason I could see for the clc/bcc is to want to keep the code relocatable by using only relative branching.

Re: Post the fun code you found!

Posted: Thu Jan 24, 2013 11:38 pm
by Godzil
That's true that the 6502 does not have a BRA (Branch Always) like instruction, anyway, PIC was not really the in thing at the time, maybe the code was made by hand and not using an assembler, but personally, it's easier to provide the good address of an instruction than calculate the offset to apply for a Bxx intruction ;)

But anyway, I found this code funny, and I'm pretty sure that it is not optimal.

Re: Post the fun code you found!

Posted: Fri Jan 25, 2013 10:14 pm
by Dbug
Well, I had to use this kind of weird thing for the boot sector of the Defence-Force demos.

Typically if both the Atmos and the Telestrat have a Microdisc system, they don't load the boot sector at the same address in memory so any code that uses absolute addressing will just crash and burn.

Perhaps the Jasmin rom is doing similar things?

Re: Post the fun code you found!

Posted: Sun Jan 27, 2013 12:46 am
by Godzil
I don't know if this code is move elsewhere, but it's one of the first thing the ROM does, so it should not move around in RAM.