BeebAsm

handy tools that can assist in the development of new software
SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Tue Mar 20, 2018 8:17 pm

I've merged those changes to get rid of the link-time warnings into proposed-updates.

Prime
Posts: 2858
Joined: Mon Jun 01, 2009 12:52 am
Contact:

Re: BeebAsm

Post by Prime » Sun Mar 25, 2018 8:44 pm

Something I'd currently find useful, would be the ability to specify an output folder for the SAVE command on the command line.

So you could do something like

Code: Select all

mkdir beeb
mkdir elk
mkdir master

beebasm somecode.asm -DMACHINE=0 -OD=beeb
beebasm somecode.asm -DMACHINE=1 -OD=elk
beebasm somecode.asm -DMACHINE=2 -OD=master
For example, I know this can be done with an if inside the asm file, but this gets tedious for more than a couple of output dirs, and more than a couple of asm files. Also it allows you to move things around in the filesystem without having to manually edit each and every asm file to point at the new folder.

If it can currently do this, I don't know the correct syntax for it.......

Also what is the currently worked upon branch of the source as I'd like to test the updates.....

Cheers.

Phill.

User avatar
Rich Talbot-Watkins
Posts: 1592
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: BeebAsm

Post by Rich Talbot-Watkins » Sun Mar 25, 2018 8:54 pm

That needn't be a BeebAsm feature - you could just do something like:

Code: Select all

mkdir beeb
mkdir elk
mkdir master

beebasm somecode.asm -DMACHINE=0 && move output.ssd beeb
beebasm somecode.asm -DMACHINE=1 && move output.ssd elk
beebasm somecode.asm -DMACHINE=2 && move output.ssd master
...I think?

(or substitute mv for move in Unix-type environments)

User avatar
ctr
Posts: 230
Joined: Wed Jul 16, 2014 3:53 pm
Contact:

Re: BeebAsm

Post by ctr » Sun Mar 25, 2018 9:04 pm

Prime wrote:Also what is the currently worked upon branch of the source as I'd like to test the updates.....
https://github.com/stardot/beebasm/tree ... ed-updates

Note that the EXE isn't quite up-to-date. It does include all the new features.

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Sun Mar 25, 2018 9:48 pm

Rich Talbot-Watkins wrote:That needn't be a BeebAsm feature - you could just do something like:

Code: Select all

mkdir beeb
mkdir elk
mkdir master

beebasm somecode.asm -DMACHINE=0 && move output.ssd beeb
beebasm somecode.asm -DMACHINE=1 && move output.ssd elk
beebasm somecode.asm -DMACHINE=2 && move output.ssd master
...I think?

(or substitute mv for move in Unix-type environments)
You could also probably do something like:

Code: Select all

mkdir beeb
mkdir elk
mkdir master
(cd beeb; beebasm -i ../somecode.asm -D MACHINE=0)
(cd elk; beebasm -i ../somecode.asm -D MACHINE=1)
(cd master; beebasm -i ../somecode.asm -D MACHINE=2)
Incidentally, note that you must have a space between -D and the variable to define.

I guess it would also be possible to handle this by adding support for string variables. You could then do:

Code: Select all

beebasm -i somecode.asm -D MACHINE=0 -D 'OUTPUTDIR$=beeb/'
and have the souce code contain:

Code: Select all

SAVE OUTPUTDIR$+"foo", start,end
That is probably quite a bit of implementation effort though, and may not fit will with the existing internals.

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Sun Mar 25, 2018 10:05 pm

Can't you just run in the directory you want to output to?
You might need to add ../ to the paths used for includes.

User avatar
Rich Talbot-Watkins
Posts: 1592
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: BeebAsm

Post by Rich Talbot-Watkins » Sun Mar 25, 2018 10:28 pm

It would probably INCLUDE/INCBIN from the wrong place though. I originally planned on making them relative to the file being assembled, but it was a bit of a pain to do and I never got round to it. It'd need to maintain the base directory (everything up to the final slash) and pass that to subsequent INCLUDEs.

Edit: as tricky already said.

Prime
Posts: 2858
Joined: Mon Jun 01, 2009 12:52 am
Contact:

Re: BeebAsm

Post by Prime » Mon Mar 26, 2018 9:52 am

Rich Talbot-Watkins wrote:It would probably INCLUDE/INCBIN from the wrong place though. I originally planned on making them relative to the file being assembled, but it was a bit of a pain to do and I never got round to it. It'd need to maintain the base directory (everything up to the final slash) and pass that to subsequent INCLUDEs.
I guess one thing that would be useful, would be being able to specify an include directory on the command line like gcc's -I and have the assembler search the current source file's directory followed by any -I directories

Cheers.

Phill.

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Mon Apr 30, 2018 7:58 pm

It's been fairly quiet here lately - I guess everyone's busily coding away with the new proposed-updates version of BeebAsm, right? :-)

I'm thinking it's probably time to call proposed-updates v1.09 and merge it to master. Any objections? I think all we need to do is add the release date into README.md and then merge. If someone else wants to do this then go ahead, otherwise I'll do it this coming weekend if no one objects first.

Cheers.

Steve

ETA: Is the Windows executable slightly out of date? I don't think it matters that much - as ctr says above, it has all the features - but if someone could rebuild it that would be nice.

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Mon Apr 30, 2018 8:44 pm

Consider this an early suggestion for the next release ;)
I sometimes find myself with code like:

Code: Select all

.function
{
	;; ...
.label
	;; ...
}
where I would like to jump to label from outside function.
What do people think about jsr function.label?
I would also like to export function.label when exporting symbols to use in beebem (as I described before).
I know .function isn't related to {}, but it could be considered if it is the address of the start of {}.
I would also find it useful to export some constants, although these are often of the form:

Code: Select all

.func : func_sub = func + 100
{
	;; ...
.sub
	;; ...
IF func_sub <> sub
	ERROR
ENDIF
}

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Mon Apr 30, 2018 9:48 pm

tricky wrote:I sometimes find myself with code like:

Code: Select all

.function
{
	;; ...
.label
	;; ...
}
where I would like to jump to label from outside function.
What do people think about jsr function.label?
I'm not saying this is a bad idea - I quite like it - but at the risk of stating the obvious, I think you can already achieve something similar (if not quite as good) by writing:

Code: Select all

.function
{
	;; ...
.^function.label
.label ;; this line is optional unless you want to able to just use '.label within this scope as shorthand
	;; ...
}
Though I haven't tested this, and maybe you can't use "." in a label, in which case you'd have to use "_" or similar.
tricky wrote:I would also find it useful to export some constants
I have wanted this on occasion myself, and I don't think there is any straightforward way to do it at the moment. A symbol defined with = is always restricted to the current scope and I don't think there's any way around that. Apart from not needing it *that* badly :-), what put me off trying to implement it was the question of syntax - 'export symbol'? 'symbol *= 42'? '*symbol = 42'? Something else?

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Tue May 01, 2018 7:00 am

Sorry, I had forgotten that was added.
I will add the export symbols with dots to there enclosing scope locally and see how it feels. I like having beebem showing the labels as I step and adjusting breakpoint and watch addresses automatically from one run to the next.

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Sat May 12, 2018 8:49 pm

Only a week later than promised: proposed-updates has been merged to master and tagged as v1.09: https://github.com/stardot/beebasm/releases/tag/v1.09 Thanks to everyone who helped out with this!

What's the next step? Should we do new development on the existing proposed-updates branch or create a new branch (called v1.10-proposed-updates?)? I don't personally have any immediate development planned, though there are plenty of good suggestions already, and I have some half-baked features knocking around in various threads which could in principle be tidied up and pulled into a release eventually, so I'd like to get this right.

User avatar
ctr
Posts: 230
Joined: Wed Jul 16, 2014 3:53 pm
Contact:

Re: BeebAsm

Post by ctr » Sun May 13, 2018 12:17 pm

No, thank you! That's brilliant.

I've committed a new Windows exe. We might as well carry on in proposed-updates, it's easier to type and you've tagged the release if anyone wants to go back to that particular version. Though I committed the exe to master so that would have to be merged back in to proposed-updates.

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Mon Apr 22, 2019 4:43 pm

I was browsing idly and noticed BeebAsm was listed on 6502.org's tools page, but pointing to RetroSoftware and Tom Seddon's repo: http://6502.org/tools/asm/

Shall I drop them a mail asking them to update the link to the stardot github page (https://github.com/stardot/beebasm)? That in turns has a link to this forum so I don't think we need 6502.org to point directly here, but if anyone feels differently let me know.

User avatar
BigEd
Posts: 2971
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: BeebAsm

Post by BigEd » Mon Apr 22, 2019 4:52 pm

I've just updated it... I think I notice that the wiki, linked to from the repo, doesn't link back to the repo, or the github issues, or have any recent changes listed. Perhaps a good time for a wiki update?

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Mon Apr 22, 2019 10:54 pm

Great, thanks for doing that!

My inclination is to delete everything on the wiki page from "Command line options" (inclusive) down to the end, though retaining the "Demo" section as it has a nice screenshot. :-) This would avoid duplicating too much of the information from the README.md on github and creating maintenance burden while leaving the wiki page with some information. I could then look at updating the rest of the page with the newer version.

How does this sound to everyone?

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Sun Mar 29, 2020 5:51 pm

I have just written the code to export the labels in the format that I suggested, so that they can be loaded into the latest beebem and used for debugging.
It seems to work quite well, I had to make automatic labels for scope that doesn't start at a label and for labels inside a for loop:

Code: Select all

.fun
{
.start
  NOP
.end
}
will give: .fun=0, .fun.start=0 and .fun.end=1

Code: Select all

.fun
{
  NOP
  for i, 3, 5
  {
    NOP
.mid
  }
  next
}
Will give: .fun=0, .fun._i_3.mid=2, .fun._i_4.mid=3 and .fun._i_5.mid=4

Code: Select all

.fun
{
  NOP
  {
    NOP
.mid
  }
  NOP
  {
    NOP
.mid
  }
}
Will give: .fun=0, .fun._1.mid=2 and .fun._2.mid=4
_N means N scopes since the enclosing scope started.
I just did these by hand, so I might have made a mistake, but I can't find any problems whit the generated ones.

I agree that for a few cases, the .^label can be used to achieve what I wanted for assembling and I do occasionally use .* but when debugging, all labels might be wanted, even those nested in scopes.
This is completely separate from the -d labels and doesn't affect assembling at all.

Would anyone be interested in the code?

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Fri Apr 17, 2020 2:37 pm

tricky wrote:
Sun Mar 29, 2020 5:51 pm
Would anyone be interested in the code?
Hi tricky,

I only just noticed this post, sorry - I can't believe more people weren't jumping on it, but yes, I'd love to see this code, thanks! And I agree that it makes sense to have all the labels exported for debugging, scopes and scope jumping for me are about controlling the accessibility of labels in the code (so I can have a dozen 'loop' labels sprinkled around and so forth) - in the debugger I want to see everything and the dot path style names you have seem like a good solution.

Does b-em support this format yet, do you know? But I'd like to see the code regardless...

Cheers.

Steve

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Fri Apr 17, 2020 4:46 pm

The current beebem beta supports loading the labels, but the dots in the name have no significance, which is fine.
I've added -dd to dump the extended labels (original was and still is -d).
This version also has a -writes N which will set the (NN) access counter on the .SSD if you are writing one (default 0, as before).
I wrote it to interfere as little as possible with the current code, so it does duplicate some code and could be written more efficiently.
Let me know what you think.
Sorry, I don't do Git, so its all or a manual patch list ;)
Attachments
beebasm_src.zip
(66.58 KiB) Downloaded 6 times

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Sat Apr 18, 2020 1:37 pm

Thanks tricky, I'll take a look at it. Do you mind if I push it up to my github repo? That way it will be easier for people to see the code, try it out, discuss it, track any changes we make to it, etc.

Cheers.

Steve

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Sat Apr 18, 2020 1:41 pm

Sure, if it was Perforce I would have submitted for review through swarm, but I'm happy for anyone to take my code, as long as they don't then try to sell it (not expecting that here, just mentioning it in passing).
Its only me been testing it (well, using it really) so it hasn't had much testing.

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Sat Apr 18, 2020 1:57 pm

Thanks tricky. I've extracted the -writes change to start with and pushed it up to a separate branch here: https://github.com/ZornsLemma/beebasm/t ... cky-writes The code seemed to default the number of writes to -1 (=255) so I've tweaked that, but otherwise this is unaltered. I've created an enhancement issue on the main stardot repository so we don't forget to merge this eventually.

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Sat Apr 18, 2020 2:17 pm

I'm having trouble getting -dd to work - it just outputs an empty list. Can you please double check you've sent the right code? It looks to me as though the problem is that:
  • SymbolTable::Dump() is dumping out the contents of label_list
  • SymbolTable::AddLabel() is the only place which puts things into label_list
  • but AddLabel() is never called anywhere

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Sat Apr 18, 2020 3:10 pm

Yes, I merged with the latest beebasm and seem to have lost AddLabel and somehow changed writes back to -1 - what have I done!

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Sat Apr 18, 2020 3:46 pm

Code: Select all

I think it is just putting AddLabel back in commands.cpp
/*************************************************************************************************/
/**
	LineParser::HandleDefineLabel()
*/
/*************************************************************************************************/
void LineParser::HandleDefineLabel()
{
. . .

Code: Select all

		else
		{
			// on the second pass, check that the label would be assigned the same value

			if ( SymbolTable::Instance().GetSymbol( fullSymbolName ) != ObjectCode::Instance().GetPC() )
			{
				throw AsmException_SyntaxError_SecondPassProblem( m_line, oldColumn );
			}

Code: Select all

			SymbolTable::Instance().AddLabel(symbolName);

Code: Select all

		}

		if ( GlobalData::Instance().ShouldOutputAsm() )
		{
			cout << "." << symbolName << endl;
		}
	}
	else
	{
		throw AsmException_SyntaxError_InvalidSymbolName( m_line, m_column );
	}
}

/*************************************************************************************************/
/**
	LineParser::HandleDefineComment()
*/
/*************************************************************************************************/

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Sat Apr 18, 2020 4:41 pm

Cheers, that seems to have fixed it. I've pushed this to my github repo here: https://github.com/ZornsLemma/beebasm/t ... bel-export

I've not done more with it than have a quick look over the -dd output on one of my projects, but it looks good. Am I right in thinking you'd normally use both -d and -dd together to get the full set of labels for debugging with?

I'd really like to be able to use these labels with b-em but I guess that's a separate issue. I don't plan on making any code changes until I've had a chance to try debugging with these labels, but I find myself wondering if it might be useful (as an option) to include the filename in these labels where they occur at the top level within a file - I have a big project which is made up of a dozen or so source files and each has a large scope enclosing the whole file.

I'll be interested to hear how other people get on with this - I'd have thought if you're already a user of both beebasm and the BeebEm debugger this should be something of a killer feature... (ETA: actually I guess you also have to be a heavy-ish user of scopes too, otherwise the existing -d option already had you covered.)

User avatar
tricky
Posts: 4218
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BeebAsm

Post by tricky » Sat Apr 18, 2020 4:59 pm

I only use -dd as it contains all labels.
I just left -d for backwards compatibility.
If each file already has a scope, you could add a label to each, or just before the include.
I would have thought that it would be easy to add them to b-em just by checking the address before printing the line, at least for single stepping.

SteveF
Posts: 563
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: BeebAsm

Post by SteveF » Sat Apr 18, 2020 5:34 pm

Good idea on the label before each scope; I will give that a try.

You're right that -dd does contain all labels, but global labels defined inside a scope via the '.*label' syntax appear in the output with their "fully qualified" name (e.g. '._1221.label'), which I think confused me. It might be better if the code were tweaked so labels like this didn't get the scope qualifiers added to them; I might have a look at implementing that eventually. Alternatively using both -d and -dd gives both the old and new style names for these symbols, which depending on how the debugger treats duplicates might be a solution.

But this is just me speculating; as I say, I haven't yet tried to use these debug symbols in anger.

fuzzel
Posts: 544
Joined: Sun Jan 02, 2005 1:16 pm
Location: Cullercoats, North Tyneside
Contact:

Re: BeebAsm

Post by fuzzel » Sun May 03, 2020 1:15 pm

I've run out of memory writing my assembly language game (I've used &1100 to &7BFF) and I've decided to use &600-&7FF to store an extra game procedure. My problem is that it has a couple of JSRs which loop to the main game itself. When I run Beebasm in DOS it compiles the entire code too quickly to see. How do I quickly find the absolute address of my procedures so I can refer to them in my new subroutine?
Ideally, there'd be a couple of lines in the ASM code which would print these out after the compiling has been done.

EXAMPLE:
SUBROUTINE (ADDITIONAL)
&600 JSR procl I need to know the address of procl
..
..
&730 JSR numberprinter I need to know the address of numberprinter
..
RTS

MAIN PROGRAM
&xxxx .procl
..
..
RTS
..
&yyyy .numberprinter
..
..
RTS

Post Reply

Return to “development tools”