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

Assembler error with sequence .if .db .endif #88

Closed
dennowiggle opened this issue Nov 7, 2024 · 4 comments
Closed

Assembler error with sequence .if .db .endif #88

dennowiggle opened this issue Nov 7, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@dennowiggle
Copy link

dennowiggle commented Nov 7, 2024

If there is a .db within an .if to .endif block then the byte data is placed in the executable code even when the .if condition is false.

Test Code

    .assume adl=1
    .org $000000

    ld      hl, 0x112233

.if 0

    ld      hl, 0x445566
    
    .db     "\r\nHL = ", 0

    ld      hl, 0x778899
    
.endif

    ld      hl, 0xAABBCC

Listing File
This is the listing file that is created with the -l compile option. It can be seen byte data is added at address range 0x000004 to 0x00000B.

PC     Output      Line

040000             0001      .assume adl=1
040000             0002      .org $000000
000000             0003  
000000 21 33 22 11 0004      ld      hl, 0x112233
000004             0005  
000004             0006  .if 0
000004             0007  
000004             0008      ld      hl, 0x445566
000004             0009  
000004 0D 0A 48 4C 0010      .db     "\r\nHL = ", 0
       20 3D 20 00 
00000C             0011  
00000C             0012      ld      hl, 0x778899
00000C             0013  
00000C             0014  .endif
00000C             0015  
00000C 21 CC BB AA 0016      ld      hl, 0xAABBCC
000010             0017  
000010             0018  
@envenomator envenomator added the bug Something isn't working label Nov 7, 2024
@envenomator envenomator self-assigned this Nov 7, 2024
@envenomator
Copy link
Owner

envenomator commented Nov 7, 2024

Fixed for all types of data/blk data statements. I'll need to revisit which additional directives may benefit from also respecting if/else/endif.

@dennowiggle
Copy link
Author

Thank you, that was quick!

Confirmed that the issue with the code I was compiling is resolved.

@envenomator
Copy link
Owner

Thanks for bringing this up; this reminds me to also add in per file stacked if/else/endif, so something like
.if 1
.include "1.s"
.else
.include "2.s"
.endif

will become possible, while any if/else/endif statements within the included files will also still work and the caller source file will retain the if state upon returning from the include.
I'd then be able to bring this functionality over to incbin and include that in v1.10

@envenomator
Copy link
Owner

Fixed in release v1.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants