Go to advanced search

by RichardRussell
Wed Aug 04, 2021 8:50 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

Though I was able to diff and patch my version with no conflicts Really you don't want to be using patched versions of BBC.h , bbmain.c , bbexec.c or bbeval.c . That's why I'm keen to discover the best solution for the link00 misalignment, so I can incorporate that fix and then you will be able to ...
by RichardRussell
Tue Aug 03, 2021 8:49 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

I don't think the Pico has an execute bit or even an MMU. From what I can tell there is no problem stuffing bits of executable code wherever one wants Oh, right, that's great. In that case we just need a Thumb assembler to incorporate into the BBC BASIC build instead of the (32-bit) ARM one. I wond...
by RichardRussell
Tue Aug 03, 2021 8:11 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

Do you think the BBC Basic interpreter will be faster or slower than micro Python? I've not the slightest idea, especially given the processor architecture. It's only a couple of days ago that you said you weren't concerned about performance, because one can always use the assembler when it's not g...
by RichardRussell
Tue Aug 03, 2021 8:21 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

That might work. Could you try it sometime, since (if it works) it's a simpler and more elegant solution than looping through the individual bytes. is it correct to assume the contents of BBCSDL/lib should be copied to szLibrary? Yes, although if you look at the contents of any of the console mode ...
by RichardRussell
Mon Aug 02, 2021 10:04 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

The moral of this story seems to be unaligned global symbols from an assembler file confuse the C optimizer. Since GCC generates standard (e.g. Elf format) object modules, it must be intended that you can link its output with modules generated by other tools. They could be an assembler, a different...
by RichardRussell
Mon Aug 02, 2021 12:00 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

Try this, it passes all my tests here but of course I've had no opportunity to see if it fixes the alignment issue:
BBCSDL_alignfix.zip
(47.86 KiB) Downloaded 9 times
by RichardRussell
Mon Aug 02, 2021 8:06 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

This indicates it's time for unaligned macro madness. I'm making progress. I have bbmain.c hopefully fixed and bbexec.c edited to use the macros - but it's failing my regression tests. It must be something silly but I'm having trouble finding it; watch this space. Unless and until I give up, it wou...
by RichardRussell
Sun Aug 01, 2021 5:26 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

before I got everything worked out I discovered that the current binary for the Pico was not crashing but the characters weren't making their way to the correct buffer Not wishing to be pessimistic, but it seems probable that the reason it's not crashing is simply that until the character input iss...
by RichardRussell
Sun Aug 01, 2021 4:20 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

I fear there are going to be casts to other aligned types, not just int , that are affected I reckon there are at least five aligned data types potentially affected: int , unsigned int , unsigned short , void* and signed char* . I've briefly experimented with this helper to handle them; it works as...
by RichardRussell
Sun Aug 01, 2021 10:52 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

GCC help says: If unaligned access is enabled then the preprocessor symbol "__ARM_FEATURE_UNALIGNED" is also defined. Yes, although it doesn't explicitly say that this tells you whether the CPU can natively handle unaligned accesses itself in hardware. The documentation of other compilers...
by RichardRussell
Sun Aug 01, 2021 9:19 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

This suggests that all I need to do is search the code for all casts to int and replace them with suitable calls to memcpy. I fear there are going to be casts to other aligned types, not just int , that are affected and will probably increase the total considerably. Then there will be casts from po...
by RichardRussell
Sun Aug 01, 2021 9:10 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

Might be worth loosening the search slightly (most people write *(int*) with no space. Unfortunately I've developed some bad habits, one of which is adding spaces where they are not needed and can even obscure meaning. I think it's an over-enthusiasm for whitespace to reduce density, but it doesn't...
by RichardRussell
Sun Aug 01, 2021 3:22 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

I think we should draw this thread to a close now. It's clear that my BBC BASIC cannot run on a Pico without extensive modifications

Edit: These problems have evidently been overcome.
by RichardRussell
Sun Aug 01, 2021 3:03 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

But you have explicitly declared that p is an int * - that's what the cast does. I know, but to me alignment isn't a language issue. I've declared that p should be treated as a pointer to an int, not a pointer to an aligned int! But if that's the way it works in practice, isn't there a nicer soluti...
by RichardRussell
Sun Aug 01, 2021 2:27 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

But it will still do a single LDR instruction regardless because that's what you told it to do. I'm surprised that *(int *)p is "telling" the compiler to use an aligned load, when I have explicitly declared p as unaligned; are you sure that's the case? Where can I find that documented? If...
by RichardRussell
Sun Aug 01, 2021 2:11 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

My understanding is that the placement of link00 in system memory is a legacy consideration... No, it has nothing to do with that "legacy consideration". It's not one of the variables that needs to be at a fixed address (they are all aligned anyway). Indeed, as I've said several times, th...
by RichardRussell
Sun Aug 01, 2021 1:51 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

I have already tried explicitly enabling or disabling unaligned access and saw no difference with the write to link00 Please ignore the write to link00 , that is a red herring. The compiler is entitled to assume it is aligned (even though it's not), so it can't be used as a guide to whether the swi...
by RichardRussell
Sun Aug 01, 2021 1:40 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

See also __ARM_FEATURE_UNALIGNED -munaligned-access -mno-unaligned-access Enables (or disables) reading and writing of 16- and 32- bit values from addresses that are not 16- or 32- bit aligned. By default unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for ARMv8-M Baseline architect...
by RichardRussell
Sun Aug 01, 2021 1:14 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

I don't know how to tell the compiler something is not aligned. I thought that, in early versions of C at least, one could use __attribute__ ((packed)) with simple variables as well as with structures. But link00 is not the problem: the assignment can simply be omitted or a workaround using volatil...
by RichardRussell
Sat Jul 31, 2021 9:10 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

Is there a way to track down other alignment problems? Not really; as I said, my BBC BASIC makes extensive use of unaligned data structures (it was after all originally developed for the Z80 and then the x86, which do not care about alignment). The C code assumes that memory addressed by a void* or...
by RichardRussell
Sat Jul 31, 2021 1:08 pm
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

Kilograham has a bit perfect BBC emulator running on the Pico. I don't think BBC BASCI should be too much of a stretch from that. There's not much in common between a 6502 emulator and a BBC BASIC interpreter, certainly not enough to draw a conclusion about one from the other. Indeed even BBC BASIC...
by RichardRussell
Sat Jul 31, 2021 9:29 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

Looking forwards to seeing BBC Basic graphics examples on the Pico VGA/HDMI :D ejolson is attempting to port the Console Mode edition of BBC BASIC - no graphics or sound! That's not to say that, if successful, there might not be an attempt to incorporate them later but for the moment that's not the...
by RichardRussell
Sat Jul 31, 2021 9:18 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

I've pushed a fix for the link00 alignment fault (only bbmain.c is affected). link00 is the only global variable that I know for sure is unaligned, but if you get more faults let me know and I will investigate. You definitely do not want the --no_unaligned_access flag; I added it to the RPi makefile...
by RichardRussell
Sat Jul 31, 2021 7:13 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

After commenting "link00=0" out I now get the BBC Basic '>' prompt but the interpreter immediately crashes after that. Any clues what to do next would be appreciated. Assuming you have a debugger, what is the crash reporting as the cause? If it's another alignment error you could be in tr...
by RichardRussell
Sat Jul 31, 2021 7:00 am
Forum: Other programming languages
Topic: BBC BASIC on the Raspberry Pi Pico?
Replies: 69
Views: 1935

Re: BBC BASIC on the Raspberry Pi Pico?

I think I got rid of the threads with static unsigned char kbget (void) { unsigned char ch = 0 ; char c=getchar_timeout_us(100); if(c!=PICO_ERROR_TIMEOUT) ch=c; return ch ; } Does that look like a plausible solution? Yes, although do you need a non-zero timeout? Even 100μs could be a significant ti...

Go to advanced search