MaxCoderz

for your 1 bit pleasure!

All times are UTC




Post new topic Reply to topic  [ 104 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7  Next
Author Message
 Post subject:
PostPosted: Fri 20 Jun, 2008 3:51 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Hm, that's one of the more novel error messages I've seen it generate. :\


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon 23 Jun, 2008 3:36 pm 
Offline
New Member
User avatar

Joined: Wed 23 Apr, 2008 12:52 am
Posts: 74
Location: Maine
So, how does one use brass? Is there a tutorial nestled somewhere in this thread or summat?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon 23 Jun, 2008 4:07 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
No tutorial, sorry.

If you use the installer, you should have some sample projects in your Documents directory (Documents\Brass Projects\Samples). If you open any of the .brassproj project files (double-click), hitting F6 should build them (F5 will run them). To debug you will need to copy ROMs into C:\Program Files\Brass\Debug\TI\ROMs (see ROMs.txt for information).

The easiest way to make new projects is to copy the sample directory, edit the .brassproj (it's just an XML file, any text editor will do) to the name of your program and work from that.

It's all a bit messy, but I don't have as much time to work on this (and everything else) as I'd like. :(

If you have any questions, I'd be glad to answer them!


Top
 Profile  
Reply with quote  
PostPosted: Mon 08 Sep, 2008 7:15 pm 
Offline
Extreme Poster
User avatar

Joined: Thu 17 May, 2007 4:49 pm
Posts: 395
Location: $4080
Soooooo, any news?

To make this post somewhat useful:


[hr]
^ I want this tag to work >_<


I'm trying to make a label generator that generates a new label after every invoke:
Code:
labelgenvar = 0
.macro GENERATE_LABEL(base, value)
    eval(strformat("{0}{1} = {2}", base, labelgenvar, value))
    labelgenvar += 1
.endmacro
Might not look useful in this state, but I have plans for something similar in my generic game engine project

The problem is that the above code doesn't seem to make the label since
Code:
GENERATE_LABEL("label",5)
.db label1
Gives me a "label 'label1' not found" error.

Is something like this already possible, if so, how? If not, could you make it possible?


[hr]
^ same here


Something else:
Code:
x=y
z=5
y=z
Fails with "label 'y' not found" however it is clear that there is only one possible value for x, y and z.

EDIT: of course, if you allow variables to be reassigned that would give a huge mess... Meh...
But I *really* need it in my api (idea courtesy of timendus):
api.inc wrote:
Code:
;apivars = statvars ; Damn forward referencing is broken :(
apivars_size = 18
;define variables here (*)

.include "api_routines.inc"
api_routines.inc wrote:
Code:
api_start
;...
smc_start
#ifdef APPLICATION
; Relocate these
$ = smc_reloc
#endif
;...
smc_end

#ifdef APPLICATION
smc_size = smc_end-smc_reloc+apivars_size
$ = smc_start+smc_size
apivars = smc_reloc+smc_size-apivars_size
#else
smc_size = smc_end-smc_start
apivars = $
.block apivars_size, 0
#endif

api_end


This gives an error in "api.inc": "label apivars not found", if I move (*) after the include then Brass3 complains about non-existent variables

Is there any way to get around this, am I missing something obvious or is there just no way?


[hr]
^ again...


And there is one more thing...
Code:
.dw x,y,z
; Seems to result in
.dw z,z,z

I haven't been able to test this one thoroughly (or verify that it is my fault and not Brass3's fault)


Top
 Profile  
Reply with quote  
PostPosted: Mon 08 Sep, 2008 9:10 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
driesguldolf wrote:
[hr]
^ I want this tag to work >_<
Doesn't appear to be possible with phpBB (needs start and end tags).

Quote:
I'm trying to make a label generator that generates a new label after every invoke:
Code:
labelgenvar = 0
.macro GENERATE_LABEL(base, value)
    eval(strformat("{0}{1} = {2}", base, labelgenvar, value))
    labelgenvar += 1
.endmacro
Might not look useful in this state, but I have plans for something similar in my generic game engine project

The problem is that the above code doesn't seem to make the label since
Code:
GENERATE_LABEL("label",5)
.db label1
Gives me a "label 'label1' not found" error.

Is something like this already possible, if so, how? If not, could you make it possible?
This does appear to be broken, not sure why (probably some eval-related problem). You could use a C# script:
Code:
private static int labelgenvar = 1;
public static void GENERATE_LABEL(Compiler compiler, string name, double value) {
   compiler.Labels.Add(new Label(compiler.Labels, new TokenisedSource.Token(compiler.Labels.ModuleGetFullLabelPath(name + labelgenvar)), true, value, compiler.Labels.ProgramCounter.Page, null));
   ++labelgenvar;
}
...if you need to. You would use it like this:

Code:
.GENERATE_LABEL "label", 5
.echoln label1 ; Outputs 5


Quote:
Something else:
Code:
x=y
z=5
y=z
Fails with "label 'y' not found" however it is clear that there is only one possible value for x, y and z.
You need to assign variables in order, like most other programming languages. z=5 \ y=z \ x=y works. :)

Quote:
And there is one more thing...
Code:
.dw x,y,z
; Seems to result in
.dw z,z,z

I haven't been able to test this one thoroughly (or verify that it is my fault and not Brass3's fault)
The values for .dw are calculated after the entire source file has been assembled. Thus:
Code:
x = 1 \ y = 2 \ z = 3
.db x,y,z
x = 4 \ y = 5 \ z = 6
...assembles as 4, 5, 6.

Probably not what you wanted to hear, but it may explain what's going on...


Top
 Profile  
Reply with quote  
PostPosted: Tue 09 Sep, 2008 12:22 am 
Offline
Extreme Poster
User avatar

Joined: Thu 17 May, 2007 4:49 pm
Posts: 395
Location: $4080
Thanks for the explanation but,

About the tags, that wasn't really the point. I just want more tags to work with :P. SimpleMachinesForum has a lot more (strike trough, tables, horizontal rule, etc.)

About the .dw case, could you explain these?
http://img300.imageshack.us/img300/7278/crap1we1.png
http://img296.imageshack.us/img296/2919/crap2yk5.png
Only the 2nd is correct.

http://img228.imageshack.us/img228/2761/crap3ru7.png
Neither of the pointers are correct.
EDIT: Meh, I mislooked, only the 2nd is correct.


Last edited by driesguldolf on Tue 09 Sep, 2008 8:42 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue 09 Sep, 2008 2:32 am 
Offline
Regular Member
User avatar

Joined: Wed 18 Oct, 2006 7:34 pm
Posts: 112
Location: The ex-planet Pluto
You should be checking for "label0", since the counter starts at 0 and increases *after* the label is generated.

_________________
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)


Top
 Profile  
Reply with quote  
PostPosted: Tue 09 Sep, 2008 7:32 am 
Offline
Extreme Poster
User avatar

Joined: Thu 17 May, 2007 4:49 pm
Posts: 395
Location: $4080
calc84maniac wrote:
You should be checking for "label0", since the counter starts at 0 and increases *after* the label is generated.

Oh, lol. Unfortunately it doesn't work with label0 either.
Writing the generated label to the console indeed gives "label0" so there's no mistake that one is correct.


Top
 Profile  
Reply with quote  
PostPosted: Tue 09 Sep, 2008 11:14 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
The way labels are handled and expressions are parsed is pretty lousy (eg labels can only be strings or doubles and when parsing expressions any unknown terms generate temporary labels which can confuse the assembler).

I'm glad you haven't asked about structs or array[index] type syntax as those are even more horribly broken. :( I'd very much like to rewrite this part of the assembler when I have time, with a more sensible parser and using full .NET objects as labels (which wouldn't break existing code as the assembler syntax would remain much the same, just would actually work).

I'll try to take a closer look at it soon. :|


Top
 Profile  
Reply with quote  
PostPosted: Tue 16 Sep, 2008 10:50 am 
Offline
Extreme Poster
User avatar

Joined: Thu 17 May, 2007 4:49 pm
Posts: 395
Location: $4080
Hmm, I've been thinking about a way to handle such forward referencing without breaking backwards compatibility :P

During the first phase (where macro processing happens):
Generate a list with the footprints a label when you encounter one, a footprint are the labels of which the value of this label is dependent of.
Now either:
1) The label has not yet been registered: Mark the label as "Forward reference enabled"
2) The label has already been registered: Mark it as "No forward reference allowed" (since "forward referencing" basically means a label has a universal value throughout the source, a redefinition will make the label ambiguous, instead this label will be treated as #defines)

Now before the second phase starts we're going to solve the label values:
First delete all labels who are marked as "No forward reference allowed" (these will be re-calculated during the 2nd phase).
Next create a new list of labels, these will hold the solved labels.

While the last iteration solved at least one label do:
For each label check if all the labels its value depends on is calculated (ie, the labels are found in the solved labels list), if so calculate its value and add it to the list of solved labels.
Repeat.

If there are still unsolved labels this means that there was a circular definition: Like "a=b\ b=a"

Now start the 2nd phase, using the solved labels list.


That should do the trick, what do you think?


Top
 Profile  
Reply with quote  
PostPosted: Tue 16 Sep, 2008 12:00 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
A nice idea, but there is only a single pass (stuff that needs to output data based on labels that may be defined in the future registers a delegate which is invoked at the end of the pass to insert the correct values). eg ".dw somelabel" says "reserve 2 bytes for me", and at the end of the pass the assembler invokes the delegate to retrieve the proper byte[2]. Macro preprocessing is done as statements are read in from the file in the same pass.


Top
 Profile  
Reply with quote  
PostPosted: Tue 16 Sep, 2008 2:47 pm 
Offline
Extreme Poster
User avatar

Joined: Thu 17 May, 2007 4:49 pm
Posts: 395
Location: $4080
Ah yes, that complicates matters...

Also, I just saw that the algorithm doesn't work when "forward ref enabled" labels are defined in terms of "no forward ref allowed" labels...

I'll see if I can find a way around it :)


Top
 Profile  
Reply with quote  
PostPosted: Tue 16 Sep, 2008 3:40 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
I still stand by my original point; the expression parsing bit and handling of labels needs to be completely rewritten. The expression parser relies on each and every label in an expression already existing (even x in x=1 has to exist beforehand, so there's lots of fudging around creating potentional temporary labels), which causes all sorts of issues. It would be much nicer to just have a label reference that may - or may not - have a value, and that value is only extracted at the last minute when it's actually needed.

Allowing for full .NET objects with properties and methods makes logical sense (see how PowerShell handles this for example). There's all sorts of hackery involved with labels either being strings or numbers (including the fun feature that 'a'+1 is 'a1', not 'b' as you may expect, you need to do 'a'*1+1) as well as creating constants (values that can't be changed). Again, proper .NET objects with conversion operators and member properties would help alleviate most of these problems.


Top
 Profile  
Reply with quote  
PostPosted: Wed 17 Sep, 2008 9:09 am 
Offline
Extreme Poster
User avatar

Joined: Thu 17 May, 2007 4:49 pm
Posts: 395
Location: $4080
Yeah, but that's independent of labels who allow forward referencing. I really want 'em :mad:


Top
 Profile  
Reply with quote  
PostPosted: Wed 17 Sep, 2008 10:17 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Well, the source is available. ;) (I kid, I wouldn't wish that monstrosity on my worst enemy). :(


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 104 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB ® Forum Software © phpBB Group | DVGFX2 by: Matt