Assembly is polluting my brain

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
pnoyes
Posts: 35
Joined: 15 Mar 2016

Assembly is polluting my brain

Post by pnoyes »

I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?
User avatar
BigEd
Posts: 11467
Joined: 11 Dec 2008
Location: England
Contact:

Re: Assembly is polluting my brain

Post by BigEd »

Hee hee. It might be a bit like switching keyboards - sometimes I use a US style keymapping and sometimes a UK one. There's a moment of adjustment as the punctuation comes out wrong, and then the fingers and the brain adust themselves.
User avatar
BigDumbDinosaur
Posts: 9431
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Assembly is polluting my brain

Post by BigDumbDinosaur »

pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?
Interesting that the compiler didn't issue a diagnostic with the semicolon at the start of the line. Which compiler is this?
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigDumbDinosaur
Posts: 9431
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Assembly is polluting my brain

Post by BigDumbDinosaur »

BigEd wrote:
Hee hee. It might be a bit like switching keyboards - sometimes I use a US style keymapping and sometimes a UK one. There's a moment of adjustment as the punctuation comes out wrong, and then the fingers and the brain adust themselves.
That used to happen to me back in the days of programming Commodore computers. I'd be on a C-128 for a while and then switch over to a PC. Most of the QWERTY keys were the same, but punctuation and other symbols were in different locations. In particular, a colon on a C-128 keyboard is an unSHIFTed character, but is a SHIFTed character on a standard PC keyboard (as well as on an ASCII terminal keyboard). That caused me no end of grief. :evil:

Incidentally, it is C that is causing brain pollution, not assembly language. :D
x86?  We ain't got no x86.  We don't NEED no stinking x86!
rwiker
Posts: 294
Joined: 03 Mar 2011

Re: Assembly is polluting my brain

Post by rwiker »

BigDumbDinosaur wrote:
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?
Interesting that the compiler didn't issue a diagnostic with the semicolon at the start of the line. Which compiler is this?
Why should a C compiler complain about a semicolon at the start of a line? Keep in mind that the canonical string copy routine in C is something like

Code: Select all

void strcpy(char *d, char *s) {
 while (*d++ = *s++) 
    ;
}
Bregalad
Posts: 149
Joined: 27 Mar 2010
Location: Chexbres, VD, Switzerland
Contact:

Re: Assembly is polluting my brain

Post by Bregalad »

pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?
Don't you use syntax colouring? Pretty much every editor uses them nowadays.
User avatar
BigEd
Posts: 11467
Joined: 11 Dec 2008
Location: England
Contact:

Re: Assembly is polluting my brain

Post by BigEd »

(Personally I never liked colour in my editor. I suppose like a lot of things it's a matter of personal preference.)
User avatar
GARTHWILSON
Posts: 8777
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Assembly is polluting my brain

Post by GARTHWILSON »

Same here. I don't use or like the color.
Quote:
Incidentally, it is C that is causing brain pollution, not assembly language. :D
+1
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Bregalad
Posts: 149
Joined: 27 Mar 2010
Location: Chexbres, VD, Switzerland
Contact:

Re: Assembly is polluting my brain

Post by Bregalad »

I do no see any advantage of NOT using syntax colouring. Using them avoids very stupid errors like that. I also use it when coding in assembly.
Quote:
Incidentally, it is C that is causing brain pollution, not assembly language. :D
+2 :)
Tor
Posts: 597
Joined: 10 Apr 2011
Location: Norway/Japan

Re: Assembly is polluting my brain

Post by Tor »

I dislike colours in terminal windows (b/c they always clash with the background I use), but I use colours in the editor. But obviously I use my own setup for the colours, not the default one. For that, it works very well.
As for C.. well, compared to those sqrt-solving Basic programs posted here a while ago, C is light years cleaner! :)
User avatar
pnoyes
Posts: 35
Joined: 15 Mar 2016

Re: Assembly is polluting my brain

Post by pnoyes »

Bregalad wrote:
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?
Don't you use syntax colouring? Pretty much every editor uses them nowadays.
I do use syntax highlighting. I don't know why I didn't recognize that the lines of code didn't gray out. Perhaps because there were no other comments in the vicinity.
User avatar
BigDumbDinosaur
Posts: 9431
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Assembly is polluting my brain

Post by BigDumbDinosaur »

rwiker wrote:
BigDumbDinosaur wrote:
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?
Interesting that the compiler didn't issue a diagnostic with the semicolon at the start of the line. Which compiler is this?
Why should a C compiler complain about a semicolon at the start of a line? Keep in mind that the canonical string copy routine in C is something like

Code: Select all

void strcpy(char *d, char *s) {
 while (*d++ = *s++) 
    ;
}
The semicolon in the middle of the strcpy while loop works because it is on an otherwise blank line, which automatically makes it the terminating character.
Last edited by BigDumbDinosaur on Thu Apr 14, 2016 7:45 pm, edited 1 time in total.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigDumbDinosaur
Posts: 9431
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Assembly is polluting my brain

Post by BigDumbDinosaur »

BigEd wrote:
(Personally I never liked colour in my editor. I suppose like a lot of things it's a matter of personal preference.)
I use a limited amount of color, the color choices being ones that stay out of where my vision messes up. Some color combinations, such as blue with green, are hard for me to read. Even worse are colors on top of a white back ground. :( The below image is about as colorful as I get.
editorscreen.jpg
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11467
Joined: 11 Dec 2008
Location: England
Contact:

Re: Assembly is polluting my brain

Post by BigEd »

I like more constant contrast than that - for me, the green looks good but the red is too dark. Of course this is very much in the area of personal preference.

For the C question, C allows null statements, which may help explain why there's no error in mistakenly trying to comment out a block with semicolons.
User avatar
BigDumbDinosaur
Posts: 9431
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Assembly is polluting my brain

Post by BigDumbDinosaur »

BigEd wrote:
I like more constant contrast than that - for me, the green looks good but the red is too dark. Of course this is very much in the area of personal preference.
My office is not brightly lit unless I turn on the overhead lights, so I generally don't use high screen intensity levels. Also, the low end of the visible light spectrum looks brighter to me than the upper end, so I dial down red to some extent. However, the red in the JPEG I posted is darker than in actuality.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
Post Reply