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

Add a dp declaration to add Pascal Strings #241

Open
Cthutu opened this issue Sep 17, 2024 · 1 comment
Open

Add a dp declaration to add Pascal Strings #241

Cthutu opened this issue Sep 17, 2024 · 1 comment

Comments

@Cthutu
Copy link

Cthutu commented Sep 17, 2024

Feature overview

I am trying to add strings in my assembly where the first byte is the count of characters in the strings (i.e. Pascal strings). This is really common and often more useful than null-terminated strings.

I propose a new keyword dp that declares a pascal strings. It would concatenate all entries on the line, count the number of bytes they take and emit that count first. Thereafter, it acts like a db declaration.

The count would be stored as a byte so lengths greater than 255 are not allowed. Empty strings should be allowed though.

Examples

    dp "Hello"          ; Equivalent to: db 5,"Hello"
    dp "Foo","Bar"   ; Equivalent to: db 6,"Foo","Bar"
@ped7g
Copy link
Collaborator

ped7g commented Sep 17, 2024

possible implementation idea:
add internal invincible labels (like macro 0> but not listed) to mark start/end of the emitted block so the length byte can be calculated in final pass (even for non-device mode).

note to myself: review which other issues are similar to this, there were multiple attempts for "length of something" directives, usually running into similar implementation problems, doing the internal labels in some general way could maybe solve more of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants