Skip to content

Fix .asciiz string encoding for ecall5 instruction #25

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

Open
Maryam-Gamal opened this issue Apr 6, 2025 · 0 comments
Open

Fix .asciiz string encoding for ecall5 instruction #25

Maryam-Gamal opened this issue Apr 6, 2025 · 0 comments

Comments

@Maryam-Gamal
Copy link
Contributor

Bug Description:

The bug is in the .asciiz directive. When processing .asciiz strings, the original code incorrectly packs characters into 16-bit words, which causes problems when these strings are used with the ecall 5 instruction.


Example:

.text 

    .org    0 

main: 

    lui     a0, %hi(0x100) 

    ecall   5               # service 5 to print a string 

exit: 

    ecall   3 

    .data 

    .org    0x100 

 str:    

    .asciiz "hello world" 

Expected Behavior:

Each character in the .asciiz string should be stored as a separate byte .

Image

Image

Actual Behavior:

As shown in the screenshot of the bin file, characters are incorrectly packed, causing incorrect string representation.

Image

Image

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

No branches or pull requests

1 participant