log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- Archive Edition 27:2 reviewed (News:)
- WROCC May 2024 meeting - Gerph talks games (News:)
- Drag'n'Drop 13i3 edition reviewed (News:1)
- Wakefield Show 2024 in Pictures (News:5)
- April 2024 News Summary (News:2)
- RISC OS 5.30 arrives (News:2)
- Upgrading your RISC OS system to 5.30 (News:2)
- WROCC May 2024 meeting on wednesday - Gerph talks games (News:)
- uniprint upgraded to 4.50 (News:)
- PhotoDesk 3.23 released (News:)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
The Icon Bar: General: ARM Assembler in BBC Basic - HELP!
 
  ARM Assembler in BBC Basic - HELP!
  johnbeamer (04:23 14/12/2012)
  Stoppers (08:25 14/12/2012)
    johnbeamer (09:20 14/12/2012)
      VincceH (10:15 14/12/2012)
        johnbeamer (10:27 14/12/2012)
          not_ginger_matt (10:52 14/12/2012)
          apdl (10:53 14/12/2012)
            johnbeamer (11:07 14/12/2012)
              johnbeamer (18:00 14/12/2012)
  PaulV (01:11 16/12/2012)
    johnbeamer (17:09 16/12/2012)
    johnbeamer (17:31 16/12/2012)
      Raeddie (18:45 16/12/2012)
        Raeddie (19:25 16/12/2012)
      PaulV (19:50 16/12/2012)
        johnbeamer (12:36 17/12/2012)
          PaulV (14:10 17/12/2012)
            johnbeamer (15:27 17/12/2012)
              PaulV (16:11 17/12/2012)
                johnbeamer (17:05 17/12/2012)
              Raeddie (17:09 17/12/2012)
                PaulV (17:38 17/12/2012)
                johnbeamer (17:38 17/12/2012)
                  Raeddie (18:08 17/12/2012)
                    johnbeamer (03:41 18/12/2012)
                      PaulV (09:42 18/12/2012)
                        swirlythingy (11:39 18/12/2012)
                          PaulV (12:49 18/12/2012)
                            johnbeamer (05:25 19/12/2012)
 
John Beamer Message #121659, posted by johnbeamer at 04:23, 14/12/2012
Member
Posts: 21
Hello

I am doing some programming in ARM Assembler through BBC Basic - trying to relearn some lost skills from a few years back.

Anyway, I've built a couple of programs - mostly little games (Pong, Snake etc ...). The problem is that after I've coded half the program I get an error message "BAD IMMEDIATE CONSTANT"

Now normally one gets this message when you initialise a register with an inappropriate value. However, in both my programs it seems as though this happens when I run out of memory.

I'll be adding a new section to the code and then after compiling i get the BAD IMMEDIATE CONSTANT error message. When I delete the old code and add a NOP instruction (mov r0,r0) I get the same error. When I delete a different line it works.

Really strange but seems a function of running out of memory. I have tried to allocate more memory at the start to the program but it doesn't seem to work.

Any bright ideas of what is going on -- this is very frustrating!!

Thanks John
  ^[ Log in to reply ]
 
Simon Willcocks Message #121660, posted by Stoppers at 08:25, 14/12/2012, in reply to message #121659
Member
Posts: 302
The problem is that after I've coded half the program I get an error message "BAD IMMEDIATE CONSTANT"
Have you allocated enough memory for the code in the DIM?

Do you perform two passes with different OPT values, so that forward jumps are calculated correctly? (Do you have the assembler output to the screen while assembling, so you can see the exact instruction causing the problem?)

Do you think the Programming forum might have been a better place? smile
  ^[ Log in to reply ]
 
John Beamer Message #121662, posted by johnbeamer at 09:20, 14/12/2012, in reply to message #121660
Member
Posts: 21
Yeah - i changed the DIM size and it made no difference.

If you allocate insufficient memory you get a different error message: Internal Error: Abort on Data Transfer [ADDRESS]

Yes - I use two-pass assembly with OPT so that is working.

The weird thing is that there is no specific instruction causing the error. It is something to do with length of code / memory allocated. I can put a ton of no-op instructions in to trigger the BAD IMMEDIATE CONSTANT error. That is why the DIM suggestion is logical but doesn't appear to be the answer.

By the way, if helpful I am running Red Squirrel, RISC OS 3.7 ... not sure if that is causing the issue but could be.

And yeah, should be in programming. Sorry.
  ^[ Log in to reply ]
 
VinceH Message #121663, posted by VincceH at 10:15, 14/12/2012, in reply to message #121662
VincceH
Lowering the tone since the dawn of time

Posts: 1600
It's been a long time since I did anything in ARM, rather than C, but from what I remember, because the instruction itself takes up however many bits, you're only left with a limited space for the constant.

Something like twelve bits, four of which are used to perform a shift on the other eight, so that they represent a different eitght bits of the full 32bit range?*

Which means you can easily use any constant between 0 and 255 (the four bit field is zero, so you can just use the number) - but if what you want is higher than that, it becomes more complicated.

* Assuming I've remembered correctly and it's a 4/8 split, four bits can only represent 0 to 15 (or sixteen levels of shift), so there must be a resolution of two bits to the level of shifting - so, for example, the first level of shift would mean only numbers that are multiples of four, and the second only numbers that are multiples of sixteen. But I could be misremembering completely, of course.
  ^[ Log in to reply ]
 
John Beamer Message #121664, posted by johnbeamer at 10:27, 14/12/2012, in reply to message #121663
Member
Posts: 21
VinceH -- that's absolutely right. However, in my program there is no constant > 255. Any I only get the BAD IMMEDIATE CONSTANT error message when the code reaches a certain length.

Really weird I know ... but I can put a series of No-Op instructions in the code to trigger the error.
  ^[ Log in to reply ]
 
Richard Wilson Message #121665, posted by not_ginger_matt at 10:52, 14/12/2012, in reply to message #121664
Member
Posts: 63
My guess is that you're trying to use an ADR instruction that's outside the addressable range. Adding the NOOPs will be moving the location you're addressing and thus cause the issue.
Try using an extension tool to give you ADRL macros.
  ^[ Log in to reply ]
 
David Holden Message #121666, posted by apdl at 10:53, 14/12/2012, in reply to message #121664
Member
Posts: 138
VinceH -- that's absolutely right. However, in my program there is no constant > 255. Any I only get the BAD IMMEDIATE CONSTANT error message when the code reaches a certain length.
Are you using ADR? If so the same logic applies as Vince described earlier. ie. if the address is byte aligned it must be within 256 bytes of the ADR mnemonic and if it's word aligned then only guaranteed if within 1K. If it's outside this range than you can still use ADR but to use it 'as is' you must make sure that the assembler can shift the offset to achieve the required offset.

As you say the problem only arises when your code gets bigger this is the most likely cause of your problem as the offsets will get bigger. If you don't want to faff about with an ARDL function then try moving some of the offsets closer rather than putting all your data at the end of the code.
  ^[ Log in to reply ]
 
John Beamer Message #121667, posted by johnbeamer at 11:07, 14/12/2012, in reply to message #121666
Member
Posts: 21
Are you using ADR? If so the same logic applies as Vince described earlier. ie. if the address is byte aligned it must be within 256 bytes of the ADR mnemonic and if it's word aligned then only guaranteed if within 1K. If it's outside this range than you can still use ADR but to use it 'as is' you must make sure that the assembler can shift the offset to achieve the required offset.
Yes I am ... sounds like that is the problem - thank you.

Is the only solution to put the data close to where it is used to minimise offsets? Or is there a way I can force the offsets so it can be shifted properly.?

Thanks again guys! This is great.

[Edited by johnbeamer at 15:18, 14/12/2012]
  ^[ Log in to reply ]
 
John Beamer Message #121668, posted by johnbeamer at 18:00, 14/12/2012, in reply to message #121667
Member
Posts: 21
Thanks again ... I've found the ARDL macro here:

http://www.heyrick.co.uk/assembler/pseudo.html
  ^[ Log in to reply ]
 
Paul Vernon Message #121669, posted by PaulV at 01:11, 16/12/2012, in reply to message #121659
Member
Posts: 135
I had exactly this problem last month and posted a similar thread on the RetroSoftware forum

http://www.retrosoftware.co.uk/forum/viewtopic.php?f=71&p=5960

I solved it by using !ExtBAS

http://icebird.org/tools.html

I'm using !ExtBAS2 on my A410/1

Essentially it uses RMFaster to load BASIC into RAM and then patches it to add in a load of extra compiler commands including ADRX, ADRW and ADRL.

I've stuck !ExtBAS in my Pre-Desktop folder so those extra commands are available all the time.

It works a treat and is worth installing for that and a whole host of other reasons too big grin

Paul
  ^[ Log in to reply ]
 
John Beamer Message #121673, posted by johnbeamer at 17:09, 16/12/2012, in reply to message #121669
Member
Posts: 21
Paul - thanks for the tip. I'll do that for sure

John
  ^[ Log in to reply ]
 
John Beamer Message #121674, posted by johnbeamer at 17:31, 16/12/2012, in reply to message #121669
Member
Posts: 21


I solved it by using !ExtBAS

I've stuck !ExtBAS in my Pre-Desktop folder so those extra commands are available all the time.

It works a treat and is worth installing for that and a whole host of other reasons too big grin
Paul

Sorry to be a pain but I am struggling to install it properly. I see from the other thread you had issues but mine I think are slightly different.

I add the file (extbas2) on to the hard drive. Then unzip with !sparkFS. I can access the file - there are three files: !run, !extbasr03, !extbasr04

If I click on say extbasr03 it says 'cannot install patch routine'. This is with BASIC shut (note: when I say BASIC I mean edit).

Any ideas?

Also what editor are you using - is it ZAP or something else?

Thanks
John
  ^[ Log in to reply ]
 
Holger Palmroth Message #121675, posted by Raeddie at 18:45, 16/12/2012, in reply to message #121674
Member
Posts: 58
Which version do you use? v2.13 seems to be the most "recent" (12.5 years old). You have to pull it out of the Wayback Machine, though: http://web.archive.org/web/20100808074128/http://www.youmustbejoking.demon.co.uk/progs.utils.html#extbasicasm

In this archive you will find a folder named "ExtBas", which should went into "!Boot.Library". A simple "extbas" in the command line or an obey file then patches BASIC when needed.

(In theory, don't have my RISC OS 3.7 system powered on right now.)

[Edited by Raeddie at 19:05, 16/12/2012]

[Edited by Raeddie at 19:08, 16/12/2012]

[Edited by Raeddie at 19:11, 16/12/2012]
  ^[ Log in to reply ]
 
Holger Palmroth Message #121676, posted by Raeddie at 19:25, 16/12/2012, in reply to message #121675
Member
Posts: 58
I have no idea what's going on. The web.archive.org link multiplies itself anytime I try to edit my post and points anywhere else than I set it to. I have put ExtBas v2.13 on my small webspace: http://home.versanet.de/~palmroth/ExtBas.zip
  ^[ Log in to reply ]
 
Paul Vernon Message #121678, posted by PaulV at 19:50, 16/12/2012, in reply to message #121674
Member
Posts: 135
If I click on say extbasr03 it says 'cannot install patch routine'. This is with BASIC shut (note: when I say BASIC I mean edit).

Any ideas?
My problem was that the BASIC module was in use as a piece of BASIC code was running when I attempted to install the patch and it can't apply the patch with BASIC running. Using !Edit or not has no bearing on whether BASIC is in use.

Ideally, you should RMLoad the ExtBasRO3 module as soon as possible to ensure that no BASIC programs are running. That way, BASIC gets re-mapped into RAM and then can be patched with the extended module.

Try doing a *RMFaster BASIC. If that fails then you know you've got something written in BASIC running and the patch cannot be installed.

Paul
  ^[ Log in to reply ]
 
John Beamer Message #121680, posted by johnbeamer at 12:36, 17/12/2012, in reply to message #121678
Member
Posts: 21
Thanks guys - helpful. However, I'm still having trouble :-( Very, very annoying.

I now get filename .Messages.UK not recognised!! When I click on ExtBasRO3 or use RMLoad ...

I've checked BASIC isnt' running (with *RMFaster) ...

Might be something to do with the Red Squirrel emulator I am running ... any other ideas?

How do I know when the patch is working?

Can I just write an ADRL command and test that?

[Edited by johnbeamer at 12:49, 17/12/2012]
  ^[ Log in to reply ]
 
Paul Vernon Message #121681, posted by PaulV at 14:10, 17/12/2012, in reply to message #121680
Member
Posts: 135
I now get filename .Messages.UK not recognised!! When I click on ExtBasRO3 or use RMLoad ...
The Messages folder that was in the zip file along with the ExtBasRO3 file should be copied into the same folder that you have ExtBasRO3 residing in your system. That will fix your issue and everything should then work.

Paul

[Edited by PaulV at 14:11, 17/12/2012]
  ^[ Log in to reply ]
 
John Beamer Message #121682, posted by johnbeamer at 15:27, 17/12/2012, in reply to message #121681
Member
Posts: 21
Hi Paul

Tried that but still get the same issue. See the attached screenshot to see what I mean. You can see the folders I have and the RMLoad I use, and the error message.

See the attached screenshot to see what I mean

https://picasaweb.google.com/115772122876810810047/Archie#5822935626765351202

Sorry for being really stupid about all this. I am not really a RISC OS expert - my background was in 6502 assembly on the BBC and then on to PCs, just skirting past an A3020 that I still have!

Thanks
John
  ^[ Log in to reply ]
 
Paul Vernon Message #121683, posted by PaulV at 16:11, 17/12/2012, in reply to message #121682
Member
Posts: 135
Hi John,

What's in the Messages folder? The UK file appears to be in the wrong place and should be in the Messages folder...

Paul
  ^[ Log in to reply ]
 
John Beamer Message #121684, posted by johnbeamer at 17:05, 17/12/2012, in reply to message #121683
Member
Posts: 21
Another copy of the UK file. I have tried it with a copy in the Messages folder, without and both with and without !!

Johnh
  ^[ Log in to reply ]
 
Holger Palmroth Message #121685, posted by Raeddie at 17:09, 17/12/2012, in reply to message #121682
Member
Posts: 58
Double-click on the !Run file. This obey file sets a variable that points to the message file (the ExtBas module needs this variable to find it's messages) and starts the correct "ExtBasRO*" module.
  ^[ Log in to reply ]
 
Paul Vernon Message #121686, posted by PaulV at 17:38, 17/12/2012, in reply to message #121685
Member
Posts: 135
Double-click on the !Run file. This obey file sets a variable that points to the message file (the ExtBas module needs this variable to find it's messages) and starts the correct "ExtBasRO*" module.
... and if that doesn't work, try using version 1.74 (which is actually v1.76). That doesn't have the dependency on the Messages folder and also doesn't have the !Run file and RO4 version which if you're using an A3020 you don't need anyway.

Paul
  ^[ Log in to reply ]
 
John Beamer Message #121687, posted by johnbeamer at 17:38, 17/12/2012, in reply to message #121685
Member
Posts: 21
Great - I think that works. No error message and when I RMFaster BASIC it says not in ROM ... which is good.

I'll try and test it later tonight and hopefully all good.

Appreciate the help

John
  ^[ Log in to reply ]
 
Holger Palmroth Message #121688, posted by Raeddie at 18:08, 17/12/2012, in reply to message #121687
Member
Posts: 58
When everything works as expected, you could copy the complete "ExtBas" folder to "!Boot.Choices.Boot.PreDesk". BASIC will then be patched automatically at boot. (Just as Paul suggested some posts ago.)
  ^[ Log in to reply ]
 
John Beamer Message #121689, posted by johnbeamer at 03:41, 18/12/2012, in reply to message #121688
Member
Posts: 21
Thanks again -- got it working. And it also works during boot up. Thanks Holger and Paul - really appreciated.

By the way, can either of you recommend a good ASM editor. I've just been using EDIT but it isn't very good. I may install ZAP. Is that the best or is there another editor you'd recommend
  ^[ Log in to reply ]
 
Paul Vernon Message #121690, posted by PaulV at 09:42, 18/12/2012, in reply to message #121689
Member
Posts: 135
I use Zap. I did try StrongEd for a very short while and I didn't get on with it.

On RISC OS I think it's fair to say that StrongEd and Zap are the two main editors that people use and reading the forums I get the impression that people tend to favour one over the other as their personal favourite but there isn't one clear winner...

Try both and see which one you prefer. I use Eclipse as my development environment outside of RISC OS though and Zap is the most reminiscent of that I guess so that's probably why I prefer that over StrongEd as it seems more familiar.

Paul
  ^[ Log in to reply ]
 
Martin Bazley Message #121691, posted by swirlythingy at 11:39, 18/12/2012, in reply to message #121690

Posts: 460
Zap has been abandonware for some time (hence why it isn't included in the Raspberry Pi disc image - ROOL couldn't contact the developers), although it has been patched to run on modern hardware. StrongED (capital D, by the way) is still undergoing continuous development. You may wish to choose StrongED just for that reason, if you don't have any previous habits with either to maintain.

Oh, and Eclipse is a truly loathsome piece of glitchy, crashy bloatware which annoys you in every conceivable way it can, so that's another reason.
  ^[ Log in to reply ]
 
Paul Vernon Message #121692, posted by PaulV at 12:49, 18/12/2012, in reply to message #121691
Member
Posts: 135
Oh, and Eclipse is a truly loathsome piece of glitchy, crashy bloatware which annoys you in every conceivable way it can, so that's another reason.
It doesn't annoy me... Although I can see from your response, it does annoy you ;-).

I guess it depends on what you're using if for. I use it daily and yes, it's a memory hog but aside from that, I've never had a glitch or crash with Eclipse in over 7 years of usage but I do tend turn everything off that I don't need.

I guess it comes down to what 3rd party modules you install and how well they're written/interact with other modules as to how stable Eclipse is for you.

I tend to use Eclipse for Java, ColdFusion, and XML based development projects and have my IDE tailored very closely to my needs so I guess that's why I don't tend to see it crashing.

One thing definitely in its favour is that it behaves like a RISC OS app in so much as it installs itself into a single folder and you can move it from machine to machine without any hassle as I've done over the years keeping my configuration intact each time.

Anyhow, like I said originally, it's all down to personal preference.

Paul
  ^[ Log in to reply ]
 
John Beamer Message #121693, posted by johnbeamer at 05:25, 19/12/2012, in reply to message #121692
Member
Posts: 21
Thanks - I've tried both StongED and ZAP and preferred the look / feel of ZAP. I guess more similar to what I have been used to in the past.

Cheers
John
  ^[ Log in to reply ]
 

The Icon Bar: General: ARM Assembler in BBC Basic - HELP!