| |
cadaver
Registered: Feb 2002 Posts: 1154 |
Do you analyze page crossings / try to eliminate them?
Particularly in a game context, where code isn't easily separated into hot paths + data can be spread out in a manner that is not conductive to page-aligning everything cleanly?
As for the methods, I personally do that by symbol table analysis + a customizable simple emulator for runtime detection & counting ( https://github.com/cadaver/oldschoolengine2 ) |
|
... 28 posts hidden. Click here to view all posts.... |
| |
Frostbyte
Registered: Aug 2003 Posts: 174 |
Fucking "you cannot edit this post".
A build option would be very nice though as the above litters the code a bit and you need to remember to put the checks in place yourself. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11146 |
An option to warn at all page crossings wouldn't be terribly useful for most non trivial programs - you'd just drown in warnings :) |
| |
Frostbyte
Registered: Aug 2003 Posts: 174 |
Quote: An option to warn at all page crossings wouldn't be terribly useful for most non trivial programs - you'd just drown in warnings :)
Not useful for most scenarios, agreed - that's why it'd be a build option. Enable it when you need it. :) |
| |
cadaver
Registered: Feb 2002 Posts: 1154 |
Nice macro approach!
I also try to put the already ready or "least modified" code to the beginning, though it's made harder when I insist on stupid things like falling through to main loop from some long-winded initialization :) |
| |
trident
Registered: May 2002 Posts: 76 |
i use kickassembler and a set of macros that look like this:
loop:
// some code
bne_page(loop)
that trigger an error (or warning / assert) if that bne crosses a page boundary.
inside the bne_page() macro is the same type of macro magic that frostbyte posted.
sometimes you want a page boundary to be crossed (typically when doing really tightly timed rastercode). for this usecase there is a second set of macros:
loop:
// some code that intentionally crosses a page boundary
bne_different_page(loop) |
| |
Peiselulli
Registered: Oct 2006 Posts: 81 |
ACME macros:
!macro check_same_page_start {
!set page_check_page_addr = * & $ff00
}
!macro check_same_page_end {
!if (page_check_page_addr != ( * & $ff00)) {
!error "not the same page"
}
}
I place this macros around the interesting code (stable or highly optimized) |
| |
JackAsser
Registered: Jun 2002 Posts: 1990 |
Quote: Hmm interesting. This motivated me to look at KickAssembler docs, seems that there is no automagic option to warn/error about page crossings at compile time, but for branches there is a suggestion to do it manually like so:
beq label1
.errorif (>*) != (>label1), "Branch crosses a page!"
nop // some code to branch over
nop
label1:
Thus I suppose the above could also be used for tables:
table1:
nop // some table data
nop
.errorif (>*) != (>table1), "Table crosses a page!"
A build option
That's exactly how I do it for critical sections such as a clock slide.
I generally don't align data or code if I don't have to, hence the error hints to me when I must to. (to save space generally). |
| |
ws
Registered: Apr 2012 Posts: 229 |
Cool solutions here!
Actually, i never thought about that before, because CBMprgStudio warns automatically on compile that branches or commands cross page boundaries. But tables i always aligned manually until now and observed behavior in RAM by monitoring with ICU64/Retrodebugger. |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1381 |
While we're swapping notes, this is what I use in ca65 to fail compilation if somethings no longer on the same page as the address passed in:
.macro assert_same_page label_
.assert >(label_) = >(*), error, "Page crossing detected!"
.endmacro
Then here's an example clock slide:
sta :+ +1
: bcc :-
assert_same_page(:+)
.byte $80,$80,$80,$80
.byte $80,$80,$80,$04,$ea
:
I do like Trident's bxx_page/bxx_different_page concept mind - I might have to steal that :) |
| |
tlr
Registered: Sep 2003 Posts: 1724 |
I too approve of tridents solution. It is a nice complement, well worth stealing. :)
For a long time I used these macros in dasm: MAC START_SAMEPAGE
_SAMEPAGE_MARKER SET .
_SAMEPAGE_NAME SET {0}
ENDM
MAC END_SAMEPAGE
IF >_SAMEPAGE_MARKER != >.
IF _SAMEPAGE_NAME!=""
ERROR "[SAMEPAGE] Page crossing not allowed! (",_SAMEPAGE_NAME,"@",_SAMEPAGE_MARKER,"-",.,")"
ELSE
ERROR "[SAMEPAGE] Page crossing not allowed! (",_SAMEPAGE_MARKER,"-",.,")"
ENDIF
ELSE
IF _SAMEPAGE_NAME!=""
INFO "[SAMEPAGE] successful SAMEPAGE. (",_SAMEPAGE_NAME,"@",_SAMEPAGE_MARKER,"-",.,")"
ELSE
INFO "[SAMEPAGE] successful SAMEPAGE. (",_SAMEPAGE_MARKER,"-",.,")"
ENDIF
ENDIF
ENDM Note the capitals on pseudo ops. I don't do that anymore. :)
These can be used with START_SAMEPAGE <name> and END_SAMEPAGE to get a nice visual on what is happening. INFO: [SAMEPAGE] successful SAMEPAGE. ( get_byte @ $5d8 - $5dd ) Nowadays I've switched to assembler provided pseudo ops. |
Previous - 1 | 2 | 3 | 4 - Next |