Fun with strange bugs!

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Rahsennor
Posts: 475
Joined: Thu Aug 20, 2015 3:09 am

Re: Fun with strange bugs!

Post by Rahsennor » Thu Oct 04, 2018 1:40 am

Oziphantom wrote:I've been stung by this soooo many times, I got the assembler dev to add a warning to the assembler for me. Never again!
Gilbert wrote:Yeah. I think missing #s is a very common mistake in 6502 assembly in general, and it's sometimes hard to spot, in which in some cases the stuff still work most of the time(such as what I once encountered in my short demo).
I've been thinking of writing my own assembler, since I can't seem to find one picky enough to stop me doing dumb stuff. Maybe I should start a thread for common bugs I should make it look out for?
Oziphantom wrote:

Code: Select all

{
  int SomeVar = something
  bunch of code here
}

int thing = SomeVar + otherThing.
:shock:

How did that compile. Why did that compile. Who wrote that compiler!?
Bregalad wrote:I'm glad someone finally agrees with me on this.
Me too! We should start a C-haters club.

I kid. Though in all seriousness, I think the reason it's so popular is that every major OS is written in it. Thus anyone wanting to write code for any popular platform has to deal with it at some level. And anyone who writes an OS in anything else is forced to provide compatibility or fade into obscurity.

I've looked at loads of other programming languages in search of an alternative, but they all have one thing in common: they're not freestanding. They've all got great big libraries full of exception handling, garbage collection and Shinki knows what else that they haul around everywhere. The only people who are interested in freestanding programming languages are the OS devs, and they're all using stuff like C, because everyone uses C for OS development. It's a vicious cycle.

I've been trying to break the cycle - for me at least - by coming up with a freestanding language that's safer/stricter than C, but I'm a self-taught high school dropout. What would I know.

Oziphantom
Posts: 825
Joined: Tue Feb 07, 2017 2:03 am

Re: Fun with strange bugs!

Post by Oziphantom » Thu Oct 04, 2018 2:03 am

Rahsennor wrote:
Oziphantom wrote:I've been stung by this soooo many times, I got the assembler dev to add a warning to the assembler for me. Never again!
Gilbert wrote:Yeah. I think missing #s is a very common mistake in 6502 assembly in general, and it's sometimes hard to spot, in which in some cases the stuff still work most of the time(such as what I once encountered in my short demo).
I've been thinking of writing my own assembler, since I can't seem to find one picky enough to stop me doing dumb stuff. Maybe I should start a thread for common bugs I should make it look out for?
http://tass64.sourceforge.net/ see the diagnostic and warning areas at the end
constant result, possibly changeable to 'lda'
could be shorter by using 'xxx' instead
could be simpler by using 'xxx' instead
immediate addressing mode suggested
independent result, possibly changeable to 'lda'
label defined instead of variable multiplication for compatibility
possible jmp ($xxff) bug
possibly redundant as ...
possibly redundant if last 'jsr' is changed to 'jmp'
possibly redundant indexing with a constant value
duplicate definition
shadow definition
symbol is defined in an upper scope as well and is used ambiguously

Rahsennor wrote:
Oziphantom wrote:

Code: Select all

{
  int SomeVar = something
  bunch of code here
}

int thing = SomeVar + otherThing.
:shock:

How did that compile. Why did that compile. Who wrote that compiler!?
I don't know, or that either. NDAs forbid me from saying which compiler, and where we got it from, but lets just say for a very large and popular console.
Rahsennor wrote:
Bregalad wrote:I'm glad someone finally agrees with me on this.
Me too! We should start a C-haters club.

I kid. Though in all seriousness, I think the reason it's so popular is that every major OS is written in it. Thus anyone wanting to write code for any popular platform has to deal with it at some level. And anyone who writes an OS in anything else is forced to provide compatibility or fade into obscurity.

I've looked at loads of other programming languages in search of an alternative, but they all have one thing in common: they're not freestanding. They've all got great big libraries full of exception handling, garbage collection and Shinki knows what else that they haul around everywhere. The only people who are interested in freestanding programming languages are the OS devs, and they're all using stuff like C, because everyone uses C for OS development. It's a vicious cycle.

I've been trying to break the cycle - for me at least - by coming up with a freestanding language that's safer/stricter than C, but I'm a self-taught high school dropout. What would I know.
Commodore once wrote an OS in BCPL this was not looked on favorably and the switch to ASM and C was a massive improvement loved by all. The thing is you need something like C so you can actually hit a memory location, the higher level languages are great but when you need to do INT 5 they are kind of lost at sea.

User avatar
za909
Posts: 207
Joined: Fri Jan 24, 2014 9:05 am
Location: Hungary

Re: Fun with strange bugs!

Post by za909 » Thu Oct 04, 2018 3:26 am

It just happens too often that you accidentally end up using zero page memory access instead of an immediate value. Had the 6502 assembly language been originally developed to require you to prefix both immedate values and memory accesses, this kind of mistake would slip through much less often.

Whenever I find an instance of this happening during my debugging process, I get the urge for an ultimate facepalm.

User avatar
Banshaku
Posts: 2334
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Re: Fun with strange bugs!

Post by Banshaku » Thu Oct 04, 2018 6:43 pm

@Rahsennor

The reason I like C (to some degree) it that in the dos days, it was a lot of fun to use that and allowed to access the hardware instead of using asm. With Turbo C, you could even add inline asm so it was quite useful. I did use Quick Basic 4.5 or TP 7 but TC was the one I had the most fond memories.

Didn't do any OS programming though. Still, I guess this may be why I like the C syntax. Doesn't mean I like Java though :lol:

@Oziphantom

That's a nasty one :lol: Sometime it's not because it's from a big company that it means there is no bug ^^;;

@Gilbert

Loom.. Fond memory of that too under dos. I remember using that with my new "non continuous read" cd-rom on my 286 with 1 meg of ram!... ^^;;

@za909

I think ca65 had some < to let it know it was some zero page value (many of Shiru's example had that) but it was causing all kind of warning in 2.17 so I just removed them.

calima
Posts: 1125
Joined: Tue Oct 06, 2015 10:16 am

Re: Fun with strange bugs!

Post by calima » Fri Oct 05, 2018 2:13 am

That's one thing turning me off from official console dev. Having to use their (crappy) compiler, in their (crappy) IDE, and most probably on (ewwww) Windows too. I doubt any of them would be amenable to taking a binary from a homebrew toolchain, even if it was compliant with every spec.

User avatar
Bregalad
Posts: 7879
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Fun with strange bugs!

Post by Bregalad » Fri Oct 05, 2018 2:31 am

what are you calling its concurrents? B? or Comal?
Me too! We should start a C-haters club.
[...]
I've been trying to break the cycle - for me at least - by coming up with a freestanding language that's safer/stricter than C, but I'm a self-taught high school dropout. What would I know.
The direct concurents to C was Pascal, and then Ada (which was itself largely inspired by pascal). Both are stricter and safer.
Higher level languages with automatic memory management are not direct concurrents as they do not have the same purpose.

Celius
Posts: 2157
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Re: Fun with strange bugs!

Post by Celius » Fri Oct 05, 2018 1:59 pm

tokumaru wrote:I can tell you that I'm way too obsessed about coding mistakes to just roll back and carry on when something seemingly unrelated breaks! Whenever that happens to me, I spend as much time as it takes to figure out *exactly* what went wrong, otherwise something even more sinister may end up happening in the future...
I am the same way. I don't accept not knowing why something works or doesn't work, especially considering that I have direct access to the individual instructions being read by the processor, and can set breakpoints to see the status of registers at basically every moment in time. The chances that the instructions aren't being interpreted by the emulator correctly are extremely slim, so it's a coding mistake almost 100% of the time.

The only time I've used a solution where I didn't understand why it fixed my problem was with a PHP script I was writing for a website. In the script, I called a MySQL routine and tried to then use the same "connection" to execute a MySQL query afterwards. The call to the routine would work, but I kept getting errors right when trying to run the second query. I would remove the call to the routine, and the second query would work. I would replace the call to the routine with another query, and both would work. I could not figure it out, and based on my research, it really looked like I should have been able to do that. My solution was to use two different "connections" to the database (one for the call to the routine, and another for the query), and it started working. I never understood why I had to do that, and it still bothers me today!

User avatar
Banshaku
Posts: 2334
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Re: Fun with strange bugs!

Post by Banshaku » Fri Oct 05, 2018 9:36 pm

@Celius

Hey, long time no see :D

Post Reply