It is currently Mon Jun 26, 2017 11:58 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Tue Apr 04, 2017 10:07 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9757
Location: Rio de Janeiro - Brazil
Yeah, I miss ASM6's label system after switching to ca65. Local labels are nice, but you still have to worry about uniqueness between non-local labels. Anonymous labels are also great, but having to count labels when referencing them is not editing-friendly, since you need to change multiple references when you add/remove anonymous labels to/from an area that already uses them.

ASM6's temporary labels are free to use like anonymous labels, but they're named, so easier to reference and more readable. The only drawback is that they can only be referenced from one direction (for obvious reasons), so I have found myself in situations where I had to awkwardly use 2 labels to mark a spot:

Code:
  jmp +MyLabel
  (...)
+MyLabel:
-MyLabel:
  (...)
  jmp -MyLabel

I guess that the ideal solution for me would be if you could specify the direction in the reference, while still being able to name the labels freely. Kinda like this:

Code:
  jmp ?MyLabel+
  (...)
?MyLabel:
  (...)
  jmp ?MyLabel-
  jmp ?MyLabel+
  (...)
?MyLabel:

I'm using "?" to identify this type of label in this example, but I'm not sure this would be the best character to use for real.


Top
 Profile  
 
PostPosted: Tue Apr 04, 2017 4:12 pm 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 590
Location: Sweden
unregistered wrote:
Why does a local label have a longer range than a nameless lable? Local lables and nameless lables both assemble the same way... at least I think so. A bne + and a bne @ both assemble to two bytes. I bet Loopy (asm6 creator) would have made nameless labels work the same as local labels. Please help me to understand what I'm missing Pokun, thanks for helping me! :D :)

edit: + labels don't have to have numbers in them; that is very helpful for me too... the less numbers I have to look at on the screen makes programming assembly easier for me. :)

Maybe range was a bad word. I mean nameless labels are more limited because you can only refer to them in one direction and also you have to count labels from the reference. And also like Tokumaru said, they get in the way when you need to edit the routine because you might have to change multiple nameless labels. For this reason I usually mostly use them for smaller routines when I just want to do really short jumps or branches.

I agree with you about using numbers being pretty stale. But the few times I do is when there are not a lot of them, so @loop1, @loop2 and @loop3 is still OK I think. Other times I'd give them unique names within the routine like @init_loop, @read_loop or @whatever_loop and such. I like label names that are easy to pronounce, somewhat short and descriptive, and I never had problem of thinking of unique descriptive names for either global or local labels (I've still never done a complete large project though).

I sometimes use local labels just to describe a part of code, even though I never refer to it with a jump or branch. Because with the highlighting I made local labels gets a different highlighting color than comments and global labels, they will stand out more and look pretty. An example is the @up label in my input handler I posted earlier in this thread. It's never referred to in the code, it's just there to be consistent with the other local labels and to be descriptive.


Top
 Profile  
 
PostPosted: Tue Apr 04, 2017 4:26 pm 
Offline

Joined: Wed Nov 30, 2016 4:45 pm
Posts: 62
Location: Southern California
Does ASM6 really require labels to be on their own line, with nothing following on the same line??

_________________
http://WilsonMinesCo.com/ lots of 6502 resources


Top
 Profile  
 
PostPosted: Tue Apr 04, 2017 5:04 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1601
Location: DIGDUG
Quote:
Does ASM6 really require labels to be on their own line, with nothing following on the same line??


Why would you think so?

Why would this be a problem, if it were true?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Apr 04, 2017 5:59 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9757
Location: Rio de Janeiro - Brazil
Garth wrote:
Does ASM6 really require labels to be on their own line, with nothing following on the same line??

I don't​ think so, since you can use .dsb, .dsw, etc. to create variables, for example:

Code:
MyVariable: .dsb 2

And you can also use temporary label like this:

Code:
- lda MyVariable
  beq -


Top
 Profile  
 
PostPosted: Tue Apr 04, 2017 10:27 pm 
Offline

Joined: Wed Nov 30, 2016 4:45 pm
Posts: 62
Location: Southern California
Thanks. I just ask because ASM6 is not one of the several assemblers I've used, but it seem that everyone using it puts labels on their own lines, increasing the number of lines required to write your code, and adding sometimes-undesirable breaks.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources


Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 1:37 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 590
Location: Sweden
Labels don't require their own lines in asm6 and unlike ca65 even the colon is optional.

I mostly use a new line because otherwise I would be really limited on the label length. And since I use only two spaces for indention for opcodes it wouldn't really be possible to have more than one character labels (like for a "+" or "-" label) if they didn't have their own lines. This do indeed sometimes leave undesired breaks, but it's often possible to avoid and the benefits greatly outnumbers the drawbacks IMHO.

I learned to use 2 spaces for indentions from my programming teacher in C++ and continued to do so because it's fast, still easy to see and leaves more room for comments. I once used TABs instead of spaces, but they never look the same on different computers so I don't trust TABs anymore. I don't like inconsistent things.


Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 2:15 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9757
Location: Rio de Janeiro - Brazil
Pokun wrote:
I once used TABs instead of spaces, but they never look the same on different computers

They do if you use editors that let you pick the TAB size! :wink:


Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 2:35 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 590
Location: Sweden
But then you view it in an editor that isn't setup like that and tada it doesn't work. Sometimes TABs will be differently sized on different lines in the same editor even! Really? What's their problem?? All kinds of strange happenings seems to occur when using TABs, so I avoid them and they can't hurt me anymore. Zamamiro!


Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 2:43 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 528
Location: Gothenburg, Sweden
Whose idea was it anyway to make tabs dependent on environment? I get the benefits in layout programs like quark express and inDesign, and full-fledged word processors, but for notepad applications? That's useless compared to having a standardized indentation.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 9:59 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5321
Location: Canada
If you use tabs for left-side indentation only, you can avoid all problems to do with variations in the display of tab widths.

Use spaces instead of tabs for alignment within a row of text, and never try to align stuff vertically from different tab stops; start all rows that need to be vertically aligned at the same tab stop, then spaces after that.

Examples of common mistakes:
Code:
> = tab
. = space

>   don't>  do> this
>   do......do..this

>   dont(>  int.do,
>   >   >   int.this)

>   do(.int.do,
>   ....int.this)


If you make a rigorous habit of it, I find that variable tab stop sizes become a non-issue, and you can retain the advantages of tabs for indent this way. I don't like using spaces instead of tabs just because it means I have to deal with typing and deleting multiple spaces frequently. The editor can usually automate a lot of it, but if not using actual tabs there's always tons of cases where I still have to deal with all those spaces hanging around.

Of course, in a professional setting, or when working with someone else's code, I don't have a choice, I must adopt the prevailing style. If your editor lets you show whitespace characters, I find this is a big help for quickly identifying the style used. (Especially helpful if you can make the whitespace characters a pale colour against the white background.) Also, try to get an editor configurable for tabs vs spaces and different tab stop sizes, if you can.


Last edited by rainwarrior on Wed Apr 05, 2017 10:08 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 10:05 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 5846
Location: Seattle
The tab byte as a nonprinting symbol with meaning, rather than as a nonprinting symbol with constant width, is something I've found useful... and something that python programmers everywhere haven't (but I suspect would), because no more text editors agree on this interpretation than on tab width.

I use 22-character-wide tabs when writing assembly. If I had an editor that would automatically set the first two tab columns according to the width of assembly labels and mnemonics, that would be even better.

I've somehow managed to coax emacs's C-mode into using semantic tabs with spaces for alignment. (i.e.
if (foo &&
␣␣␣␣bar) {
tabstuff();
}
The cool thing about this is that it will render correctly regardless of what the tab width is set to.


Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 10:09 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5321
Location: Canada
FrankenGraphics wrote:
Whose idea was it anyway to make tabs dependent on environment? I get the benefits in layout programs like quark express and inDesign, and full-fledged word processors, but for notepad applications? That's useless compared to having a standardized indentation.

I think there was a tradition of 8 spaces coming from UNIX, but many others (e.g. Microsoft) thought this was too much and went with 4, and this resulted in an eternal schism, I guess.


Top
 Profile  
 
PostPosted: Wed Apr 05, 2017 10:35 am 
Offline

Joined: Wed Nov 30, 2016 4:45 pm
Posts: 62
Location: Southern California
I used the tab character a lot when memory and disc size were a lot more limited; but more recently I've set my editor's (MultiEdit) options to use spaces to bring me up to the next tab column when I press the tab key. It's more of a pain when you want to backspace over it, since you have to backspace varying numbers of times, but the reason I did it was that the tab character was making a mess of vertical alignment when I copy and paste source code into a web page or forum topic.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources


Top
 Profile  
 
PostPosted: Fri Apr 07, 2017 8:45 am 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 756
Location: cypress, texas
Garth wrote:
I used the tab character a lot when memory and disc size were a lot more limited; but more recently I've set my editor's (MultiEdit) options to use spaces to bring me up to the next tab column when I press the tab key. It's more of a pain when you want to backspace over it, since you have to backspace varying numbers of times, but the reason I did it was that the tab character was making a mess of vertical alignment when I copy and paste source code into a web page or forum topic.

Good point! To get around having to backspace varying number of times use Shift+Home then Delete. And I think CTRL+Left will allow you to move the cursor quickly to different words. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group