[Feature request] Feature to ensure a certain piece of data is within aligned boundary
- Dominant language
- C++
- Stars
- 1.6k
- Forks
- 193
- Avg merge
- 22h 17m
- Merged PRs (30d)
- 26
Description
This is not really easy to implement, but I though I'd post it before I forget again so it's on the record as a feature request.
The feature requested is the ability to make sure that a certain piece of data (for example a table or a short piece of data to be copied) doesn't cross a page boundary. This would allow optimizations in many cases where 8 bit math can be used without checking overflow, and without the need for hard alignment to a page boundary, which imposes more restrictions on the alignment than necessary. Consider something like:
```
; A contains an index to the table.
ld D, HIGH(some_table)
add LOW(some_table) ; This is ok because we can assume the table won't cross a page boundary.
ld E,A
ld A, [DE]
; ....
BALIGN 8
some_table:
db xx, xx, xx, xx
ENDBALIGN
```
Or:
```
small_copy::
ld A,[DE]
ld [HL+],A
inc E ; This is ok because we can assume DE will not cross a page boundary.
dec B
jr nz,small_copy
ret
; ....
ld DE,some_data
call small_copy
; ....
BALIGN 8
some_data:
db xx, xx, xx, xx
ENDBALIGN
```
Contributor guide
Research direction
Start by reviewing the existing BALIGN and ENDBALIGN handling in the assembler and how data placement is represented. Trace how alignment constraints are validated, then determine where a no-page-crossing constraint could fit. Done means the requested data can be constrained not to cross a page boundary without requiring hard alignment, with coverage for the examples described here.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100