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

Label folding including local labels #147

Open
Bippym opened this issue Mar 15, 2021 · 7 comments
Open

Label folding including local labels #147

Bippym opened this issue Mar 15, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@Bippym
Copy link

Bippym commented Mar 15, 2021

When folding routines it would be useful if the local routines are folded too. If I have the following

SetPalette:

                lea        myimage,a1                                         ; Image into a1 again to search for the palette	
.loop           cmp.l      #"CMAP",(a1)                                       ; Looking for the colormap
                beq        .found                                             ; Have we found the colormap
                addq       #2,a1                                              ; Not found, move on :)
                bra.s      .loop
	
.found          addq       #8,a1                                              ; Jump over the header

                move.l     #SCREEN_DEPTH<<2-1,d7                              ; Number of colours in the image
	
                clr.l      d4
                clr.l      d3
                clr.l      d2
                clr.l      d1

When folding "SetPalette:" I want it to also fold ".loop" and ".found" and they wont be visible. Otherwise I endup with this

^SetPalette
^.loop
^found

@prb28 prb28 self-assigned this Mar 15, 2021
@prb28 prb28 added the enhancement New feature or request label Mar 15, 2021
@prb28
Copy link
Owner

prb28 commented Mar 15, 2021

Looks like a good way to do it, but I'm not sure that it is a common way to organize/use labels.
It may be more suitable to detect the subroutines to fold it.

@Bippym
Copy link
Author

Bippym commented Apr 14, 2021

This is how the QT framework seems to fold subroutines. It makes sense (to me at least) to hide the local/sub-routines when folding the parent.

@prb28
Copy link
Owner

prb28 commented Apr 15, 2021

I agree to fold subroutines inside the main label is interesting.
The question is : is it a common way to name a subroutine stating with a ".", and the main without ?
I've seen code written in a different way.
So how to know if it is a sub or a main label ?

@geijer
Copy link

geijer commented Apr 16, 2021

If the label starts with a ".", in most assemblers that is treated as a local variable (you can have several "." labels named the same as long as they have a non "." label between them). But lots of code exists that don't use it.

So I would say that "." labels is a good starting point.

I would also like a "special" comment syntax for folding, or both ;)

;region Optional text that shows at the folded place
Subroutine
        move.l #"DUMM",(a0)+
        move.l #"MY C",(a0)+
        move.l #"ODE"<<8,(a0)+
;region Nested region
waitformouse
        btst.b #6,$bfe001
        bne.b
;endregion
        rts
;endregion

@prb28
Copy link
Owner

prb28 commented Apr 17, 2021

Maybe something configurable with regexp, like:

  • main section start regexp: "^[A-Za-z:-_]+$"
  • sub section start regexp: "^.[A-Za-z:-_]+.*$"
  • sub section end regexp or new sub section found: "^\srts\s$"
  • main section end regexp or new main section found: ""
    It would work with the comments too.

@geijer
Copy link

geijer commented Apr 19, 2021

Hmm, several of my sections ends with a jump to another subroutine like:

    jsr (_LVOEnable,a6)
    rts

I usally optimize that to:

    jmp (_LVOEnable,a6)

You should at least add rte.

I think I would prefere a separate keyword for folding but it is worth a test :)

@prb28
Copy link
Owner

prb28 commented Apr 19, 2021

In you case that would be:

  • main section start regexp: "^;region .*$"
  • main section end regexp or new main section found: "^;endregion .*$"

With a test to deal with the nested regions.

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

3 participants