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

[Genesis core] CDL missing table jump data #2588

Open
g0me3 opened this issue Jan 20, 2021 · 6 comments
Open

[Genesis core] CDL missing table jump data #2588

g0me3 opened this issue Jan 20, 2021 · 6 comments
Assignees
Labels
Core: Genplus-gx Sega Genesis / Mega Drive core Tool: Code–Data Logger

Comments

@g0me3
Copy link
Contributor

g0me3 commented Jan 20, 2021

Example. Game Toejam & Earl 2 (U)
here MOVE.W OFF(PC,D0.L),D0 logged as code
this opcode fetches one of the offsets in the table below
no table entries logged as data
so this one particular data fetch is missing from CDL (maybe there are others but this one I see for sure just now).

ROM:00023290 D080                                add.l   d0,d0           ; *c
ROM:00023292 303B 0806                           move.w  off_2329A(pc,d0.l),d0 ; *c
ROM:00023296 4EFB 0002                           jmp     off_2329A(pc,d0.w) ; *c
ROM:00023296                     ; ---------------------------------------------------------------------------
ROM:0002329A 0018                off_2329A:      dc.w sub_232B2-2-$23298 
ROM:0002329C 0034                                dc.w sub_232CE-2-$23298
ROM:0002329E 05C6                                dc.w sub_23860-2-$23298
ROM:000232A0 012A                                dc.w sub_233C4-2-$23298
ROM:000232A2 03C4                                dc.w sub_2365E-2-$23298
ROM:000232A4 028A                                dc.w sub_23524-2-$23298
ROM:000232A6 05C6                                dc.w sub_23860-2-$23298
ROM:000232A8 0474                                dc.w sub_2370E-2-$23298
ROM:000232AA 0512                                dc.w sub_237AC-2-$23298
ROM:000232AC 05C6                                dc.w sub_23860-2-$23298
ROM:000232AE 05C6                                dc.w sub_23860-2-$23298
ROM:000232B0 05A0                                dc.w sub_2383A-2-$23298
ROM:000232B2                     ; =============== S U B R O U T I N E =======================================
ROM:000232B2                     sub_232B2:   
ROM:000232B2 4A6A 000A                           tst.w   $A(a2)          ; *c
ROM:000232B6 6B00 05D2                           bmi.w   sub_2388A       ; *c
ROM:000232BA 08EA 0007 004B                      bset    #7,$4B(a2)      ; *c
ROM:000232C0 4A6A 000A                           tst.w   $A(a2)          ; *c
ROM:000232C4 6600 05C4                           bne.w   sub_2388A       ; *c
ROM:000232C8 08EA 0004 004B                      bset    #4,$4B(a2)      ; *c
@g0me3 g0me3 changed the title [Genesis core] CDL missing table jump data tables [Genesis core] CDL missing table jump data Jan 20, 2021
@nattthebear nattthebear added the Core: Genplus-gx Sega Genesis / Mega Drive core label Jan 20, 2021
@nattthebear nattthebear self-assigned this Jan 20, 2021
@g0me3
Copy link
Contributor Author

g0me3 commented Jan 20, 2021

ok, checked the core, all PC relative data instructions uses direct memory read handlers, they has no CDL code. so this for sure affects all PC relative instructions.

@nattthebear
Copy link
Contributor

It will probably be a bit before I get to this. Are we saying that the genesis core (right now) doesn't support the D in CDL at all? move is just a plain data read, after all. Or is this something specific to the addressing mode?

@g0me3
Copy link
Contributor Author

g0me3 commented Jan 20, 2021

No.
Currently, gensx core does data logging in functions for regular data fetch: m68ki_read_*_fc
But all PC relative instructions uses m68ki_read_pcrel_X -> m68k_read_pcrelative_X functions which are just immediare memory fetches, without any data logging -> m68k_read_immediate_X
For this core there is no difference between opcodes for load immediate operands and opcodes that fetches the data using the relative PC offset, which is causes they are not logged as data as in any other addressing methods.

@g0me3
Copy link
Contributor Author

g0me3 commented Jan 20, 2021

MOVEQ XX,REG - fetches data operand at PC + 1
MOVEW OFS(PC,REG),REG - the same but data operand is at PC + REG + OFS
first one does not need to set data log flags, but the secod one need it
same for all other opcodes with PC relative addressing mode.

@nattthebear
Copy link
Contributor

Got it. I wonder if this bears any similarity to #1760; if immediate/pc relative fetches occur very commonly in real code, then this might have an unacceptable speed loss for normal use. We'll see.

@g0me3
Copy link
Contributor Author

g0me3 commented Jan 20, 2021

we need to separate immediate operand fetches from PC relative addressing first i think.
PC relative operands are not so frequent, mostly used for switch-case constructions.
the regular data fetches are much more frequent and there is no significant loss in speed with them just now.

when I find any code that heavily abuses pc relative operands I will test if for sure, but doubt I can spot the difference on any current pc ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core: Genplus-gx Sega Genesis / Mega Drive core Tool: Code–Data Logger
Projects
None yet
Development

No branches or pull requests

3 participants