stardot / beebasm

A portable 6502 assembler with BBC Micro style syntax
http://www.retrosoftware.co.uk/wiki/index.php/BeebAsm
GNU General Public License v3.0
84 stars 26 forks source link

PowerPC OSX support #43

Open Doctorj128 opened 4 years ago

Doctorj128 commented 4 years ago

BeebAsm appears to build with no errors on my iMac G5 (OSX 10.5.8), but whenever I try to assemble something, the fans ramp up quite a bit and it hangs indefinitely

ZornsLemma commented 4 years ago

I don't have any experience with OSX or Macs of any description, but I'd have expected this to work.

Can you copy and paste the command you're using to run beebasm into this issue just in case there's something odd?

You could also do a debug build (add '-g' in both CXXFLAGS and LDFLAGS in the Makefile, I think) and see if that helps.

You could also try running a debug build under gdb. Just prefix the command with 'gdb --', e.g. 'gdb -- beebasm blah blah', then type 'run' at the gdb prompt. If it does the fan ramping up thing wait a bit, type CTRL-C to interrupt it and then type 'bt' to get a backtrace so we can see what it's doing when it's stuck. Please copy and paste any output here.

You could also try posting over on stardot; a lot more people will see it there and it's quite likely there'll be someone with PowerPC OSX experience. This thread is probably a good place: https://stardot.org.uk/forums/viewtopic.php?f=55&t=12199

Doctorj128 commented 4 years ago

The command I'm using is just beebasm -i helloworld.asm I've also tried with some other programs and they all have the same result; these programs assemble fine on my Windows 10 computer. The debug build appears to have had no affect. It just does the exact same thing. Trying gdb, BeebAsm didn't even start: https://pastebin.com/06B4VHGz

I'll probably post about it on Stardot tomorrow

ZornsLemma commented 4 years ago

Thanks for trying that anyway. Looking at the pastebin, I probably told you the wrong invocation for gdb - it says "Excess command line arguments ignored. (helloworld.asm)". You probably need to do "gdb --args beebasm -i helloworld.asm" instead. Sorry about that! Feel free to post the results of that here if you like and/or post to stardot; I'll be watching the thread there anyway.

Doctorj128 commented 4 years ago

Ah, that does seem to have worked. Here's the backtrace:

#0  0x909aea3c in _Unwind_GetIPInfo ()
#1  0x909aecd0 in _Unwind_GetIPInfo ()

Previous frame identical to this frame (gdb could not unwind past this frame)

Edit: I tried the exact same thing again but with a different result this time

#0  0x909b1950 in __register_frame ()
#1  0x909af0c8 in _Unwind_GetIPInfo ()
#2  0x909b0918 in _Unwind_RaiseException ()
#3  0x00248170 in __cxa_throw ()
#4  0x0001fdf8 in LineParser::GetValue ()
#5  0x0002097c in LineParser::EvaluateExpression ()
#6  0x00020f18 in LineParser::EvaluateExpressionAsInt ()
#7  0x00006e14 in LineParser::HandleAssembler ()
#8  0x00024020 in LineParser::Process ()
#9  0x0002b8dc in SourceCode::Process ()
#10 0x00030514 in SourceFile::Process ()
#11 0x00036994 in main ()
ZornsLemma commented 4 years ago

Thanks. That's weird, even if it's throwing an exception (which it probably shouldn't, since this is helloworld.asm and it assembles fine on other machines) you'd think it would just terminate the execution instead of hanging.

Please do post this on stardot when you get a chance, I think there will be some Mac users over there who can help. Maybe there's some obscure command line switch needed when compiling, though I really can't think why - as I say, beebasm is not particularly exotic code.

SteveFosdick commented 4 years ago

I don't have a Mac either, let alone a Power PC one. Looking at the backtrace it appears an exception is being thrown. As to why unwinding the stack gets stuck in a loop I wonder if this is because the stack has become corrupted? Is there an off-by-one issue that doesn't matter on Intel because of the way variables are aligned but causes stack corruption on Power PC?

Where is hello.asm from? I am wondering about non-ASCII characters in the input - sometimes office programs (including e-mail clients) "helpfully" convert standard ASCII punctuation into Unicode typographically correct punctuation and I am wondering about that as both the source of an exception and because UTF-8 strings can have a different number of bytes/characters.

Doctorj128 commented 4 years ago

helloworld.asm is just a simple hello world program I wrote. Here it is: helloworld.zip

ZornsLemma commented 4 years ago

Thanks for posting that - it looks absolutely fine to me, no top-bit set characters, and I've confirmed it assembles fine on my x86 Linux machine.

cardboardguru76 commented 3 years ago

Could be an endian issue. I believe OSX uses PowerPC in big-endian mode. And X86 is little-endian.

Doctorj128 commented 3 years ago

Could be an endian issue. I believe OSX uses PowerPC in big-endian mode. And X86 is little-endian.

That's what I had assumed, plus the 6502 is little-endian as well.