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

Address Region Size #123

Closed
65816 opened this issue Nov 27, 2021 · 3 comments
Closed

Address Region Size #123

65816 opened this issue Nov 27, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@65816
Copy link

65816 commented Nov 27, 2021

A possible feature request.

Assign an address region size to a label

or

When editing a data operand allow addition or subtraction.

I have this block of code:

MOVE1           .dd2  BLOCK1          ;source address
                .dd2  $6800           ;destination address
                .dd2  $051c           ;number of bytes to copy
MOVE2           .dd2  BLOCK3          ;source address
                .dd2  $1000           ;destination address
                .dd2  $016b           ;number of bytes to copy
MOVE3           .dd2  BLOCK2          ;source address
                .dd2  $1800           ;destination address
                .dd2  $03ae           ;number of bytes to copy

The size of each block is referenced by number of bytes to copy comment. The block size can also be computed by the following:

MOVE1 bytes to be copied: block2 - block1 - 1
MOVE2 bytes to be copied: block4 - block3 (block4 is a label after block3 region ending)
MOVE3 bytes to be copied: block3 - block2

If I adjust MOVE3 bytes to be copy value to BLOCK3, 6502bench computes the offset.

MOVE3           .dd2  BLOCK2          ;source address
                .dd2  $1800           ;destination address
                .dd2  BLOCK3-$26ff    ;number of bytes to copy

To this, maybe

MOVE3           .dd2  BLOCK2          ;source address
                .dd2  $1800           ;destination address
                .dd2  BLOCK3-BLOCK2    ;number of bytes to copy

or

MOVE3           .dd2  BLOCK2          ;source address
                .dd2  $1800           ;destination address
                .dd2  BLOCK3_SIZE    ;number of bytes to copy
@65816
Copy link
Author

65816 commented Nov 27, 2021

BLOCK1: 21E2
BLOCK2: 26FF
BLOCK3: 2AAD
BLOCK4: 2C18

@fadden fadden added the enhancement New feature or request label Nov 27, 2021
@fadden
Copy link
Owner

fadden commented Nov 27, 2021

This is currently in the "to do" list:

  • Support expressions.
    • Start with simple expressions, such as ORing of multiple constants or defining an offset as the difference between two symbols.
    • Add "define offset table" that takes a base address and creates 8-bit or 16-bit offsets to symbols.
    • Allow arbitrary expressions in places that currently accept symbols (instruction and data operands). This is straightforward to manage within SourceGen, but can be difficult to generate for all cross-assemblers if the complexity gets too high.

The situation comes up fairly often, e.g. the byte count in the first tutorial would be best expressed as the difference between two labels. I think of it has a step in the direction of general expression handling... it's much simpler than support for arbitrary expressions, but it handles what is probably the most common use case.

One quirk of address region sizes is that, thinking in terms of how the source code would be written, you'd want to subtract the value of a label that is placed after the region from the label at the start of a region. So we might need to define post-labels to go with the pre-labels.

@fadden
Copy link
Owner

fadden commented Jan 23, 2022

Moved to TO DO list.

@fadden fadden closed this as completed Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants