From sjudd at ffd2.com Mon May 1 20:50:47 2006 From: sjudd at ffd2.com (Steve Judd) Date: Mon, 1 May 2006 19:50:47 -0600 (MDT) Subject: [Slackers] xlang ascii put patch In-Reply-To: <20060501034514.V27604@artificial-stupidity.net> References: <20060423165758.L27604@artificial-stupidity.net> <20060424020030.O27604@artificial-stupidity.net> <20060430005659.T27604@artificial-stupidity.net> <20060501034514.V27604@artificial-stupidity.net> Message-ID: > > Be sure the PUT the file "core.ext.s" at the top of the code. Note that, > > this way, if you have several modules which use the core routines the > > routines are only included once. Using PUT, the routines would be > > included multiple times. > > Interestingly, this also fails in the same place - but jumping to a differnet > bogus address ($97fa instead). I threw the whole lot up at Yeah, I'll bet. This bug, combined with your other bugs (I mean, it's not as if they're MY bugs), has opened a huge can of worms. I'm amazed that programs like spred worked at all; it's like they exactly missed calling the things that mattered. Anyways, that's why there's no update yet; I have to re-figure out how a whole bunch of stuff works. Take pride in your ability to sow mayhem! But... hopefully soon. -S From jaymz at artificial-stupidity.net Tue May 2 01:48:24 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Tue, 2 May 2006 16:48:24 +1000 Subject: [Slackers] xlang ascii put patch In-Reply-To: ; from sjudd@ffd2.com on Mon, May 01, 2006 at 07:50:47PM -0600 References: <20060423165758.L27604@artificial-stupidity.net> <20060424020030.O27604@artificial-stupidity.net> <20060430005659.T27604@artificial-stupidity.net> <20060501034514.V27604@artificial-stupidity.net> Message-ID: <20060502164823.W27604@artificial-stupidity.net> On Mon, May 01, 2006 at 07:50:47PM -0600, Steve Judd wrote: > > > Be sure the PUT the file "core.ext.s" at the top of the code. Note that, > > > this way, if you have several modules which use the core routines the > > > routines are only included once. Using PUT, the routines would be > > > included multiple times. > > > > Interestingly, this also fails in the same place - but jumping to a differnet > > bogus address ($97fa instead). I threw the whole lot up at > > Yeah, I'll bet. This bug, combined with your other bugs (I mean, it's not > as if they're MY bugs), has opened a huge can of worms. I'm amazed that > programs like spred worked at all; it's like they exactly missed calling > the things that mattered. > > Anyways, that's why there's no update yet; I have to re-figure out how a > whole bunch of stuff works. Take pride in your ability to sow mayhem! Whee, fun bugs are the best type! Good luck with the fixoring... I look forward to testing that version :) --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From jaymz at artificial-stupidity.net Mon May 15 07:53:35 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Mon, 15 May 2006 22:53:35 +1000 Subject: [Slackers] Just another bug report - this time in sirius :) Message-ID: <20060515225335.F44046@artificial-stupidity.net> I found an interesting bug in the assembler part while writing a script to auto port six/style's net library (so i can compile it into a library.. I was previously usinh magervalp's one compiled to $c000, but porting from cc65 was too hard :-p). Anyhow, the following construct: txt "nETirq kILLED.",13,0 will error with "invalid number", while: txt "nETirq kILLED.",13,00 will compile :). It seems to hate single digit numbers, le sigh. --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From sjudd at ffd2.com Mon May 15 13:54:43 2006 From: sjudd at ffd2.com (Steve Judd) Date: Mon, 15 May 2006 12:54:43 -0600 (MDT) Subject: [Slackers] Just another bug report - this time in sirius :) In-Reply-To: <20060515225335.F44046@artificial-stupidity.net> References: <20060515225335.F44046@artificial-stupidity.net> Message-ID: Hey Jaymz, On Mon, 15 May 2006, Jaymz Julian wrote: > txt "nETirq kILLED.",13,0 > > will error with "invalid number", while: > > txt "nETirq kILLED.",13,00 I think the rule is that only hex digits are allowed by TXT -- meaning two-byte hex numbers. I do not remember the reasons for this, but it probably just uses the HEX routine, which definitely requires two digits, for doing things like hex 0102040810204080 Since you probably intended a CR above, the way to do it is txt 'blah',0d,00 or txt 'blah' dfb 13,0 (note that DFB just uses numbers, i.e. no digit restrictions and they can be decimal, hex, or binary). Sorry for the lack of contact -- been really busy, but I'm working on Slang again. -S From jaymz at artificial-stupidity.net Mon May 15 19:13:52 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Tue, 16 May 2006 10:13:52 +1000 Subject: [Slackers] Just another bug report - this time in sirius :) In-Reply-To: ; from sjudd@ffd2.com on Mon, May 15, 2006 at 12:54:43PM -0600 References: <20060515225335.F44046@artificial-stupidity.net> Message-ID: <20060516101351.G44046@artificial-stupidity.net> On Mon, May 15, 2006 at 12:54:43PM -0600, Steve Judd wrote: > Hey Jaymz, > > On Mon, 15 May 2006, Jaymz Julian wrote: > > > txt "nETirq kILLED.",13,0 > > > > will error with "invalid number", while: > > > > txt "nETirq kILLED.",13,00 > > I think the rule is that only hex digits are allowed by TXT -- meaning > two-byte hex numbers. I do not remember the reasons for this, but it > probably just uses the HEX routine, which definitely requires two digits, > for doing things like Hrm, it seems that way. Didn't this strike you as a little silly when you implemented it, making txt this big special case for numbers? :) > Since you probably intended a CR above, the way to do it is > > txt 'blah',0d,00 > > or > > txt 'blah' > dfb 13,0 I think I'm just going to have to write code to convert all of the data into long strings of numbers... it's going to be easier than splitting, i suspect. --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From sjudd at ffd2.com Sat May 20 10:39:48 2006 From: sjudd at ffd2.com (Steve Judd) Date: Sat, 20 May 2006 09:39:48 -0600 (MDT) Subject: [Slackers] Just another bug report - this time in sirius :) In-Reply-To: <20060516101351.G44046@artificial-stupidity.net> References: <20060515225335.F44046@artificial-stupidity.net> <20060516101351.G44046@artificial-stupidity.net> Message-ID: Yo Jaymz, > Hrm, it seems that way. Didn't this strike you as a little silly when you > implemented it, making txt this big special case for numbers? :) If I could remember back that far... nah. I'm sure I did it to maintain compatibility with Merlin (and hence my old source codes). In fact, I checked the Merlin manual and it said that alternate syntaxes are txt 'blah',050d00 i.e. commas not required, which is cool for strings. Doesn't look like I did that though, ah well. Usually I just use dfb after txt for anything other than 0d or 00, I guess. > I think I'm just going to have to write code to convert all of the data into > long strings of numbers... it's going to be easier than splitting, i suspect. What's the issue here? (Like, what needs to be converted?) cu, -S From jaymz at artificial-stupidity.net Sat May 20 11:32:34 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Sun, 21 May 2006 02:32:34 +1000 Subject: [Slackers] Just another bug report - this time in sirius :) In-Reply-To: ; from sjudd@ffd2.com on Sat, May 20, 2006 at 09:39:48AM -0600 References: <20060515225335.F44046@artificial-stupidity.net> <20060516101351.G44046@artificial-stupidity.net> Message-ID: <20060521023233.C47003@artificial-stupidity.net> On Sat, May 20, 2006 at 09:39:48AM -0600, Steve Judd wrote: > What's the issue here? (Like, what needs to be converted?) Six's tcp stack is full fo code like: db.b 13,0,"text",13,0 and various. Seriously, it's easier for me to machine convert that most likely. I'm away for a week now, btw, so i'll be pretty non=responsive. Damn work shit. -jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From sjudd at ffd2.com Sun May 21 09:30:36 2006 From: sjudd at ffd2.com (Steve Judd) Date: Sun, 21 May 2006 08:30:36 -0600 (MDT) Subject: [Slackers] Just another bug report - this time in sirius :) In-Reply-To: <20060521023233.C47003@artificial-stupidity.net> References: <20060515225335.F44046@artificial-stupidity.net> <20060516101351.G44046@artificial-stupidity.net> <20060521023233.C47003@artificial-stupidity.net> Message-ID: > Six's tcp stack is full fo code like: > > db.b 13,0,"text",13,0 > and various. Seriously, it's easier for me to machine convert that > most likely. Yeah, a little perl would fix that up quickly; another option might be to create a new keyword called "db" which parsed everything out. Which is cool, but probably more work than a simple script. > I'm away for a week now, btw, so i'll be pretty non=responsive. Damn > work shit. Bummer. I have fixed the earlier bugs and may actually have a new beta for a change. cu, -S From sjudd at ffd2.com Mon May 29 13:19:59 2006 From: sjudd at ffd2.com (Steve Judd) Date: Mon, 29 May 2006 12:19:59 -0600 (MDT) Subject: [Slackers] New slangb1.20 up Message-ID: Hola dewdz, Okay, new slang beta up: http://www.ffd2.com/fridge/slang/slang120.zip This hopefully fixes the earlier bugs, doesn't add any new bugs, and will never need any more updates ever. This is a pretty big update, such that I ran out of memory again and have moved slangdef from $a800 to $aa00. One new thing is allowing pointers to arrays to be passed to subroutines -- like, an easy way to pass arrays to subroutines: ubyte ^t1(16,16) ... test(t1) sub test(ubyte ^arr(16,16)) arr(2,3)=1 endsub I've also updated functions to allow for multiple arguments. Previously, functions were like sin(x) -- one argument in parenthesis. I've also added a way for users to add new commands, called userdef. Userdef works exactly the same as slangdef: you put "userdef" at the top of the file, then you can define new keywords, functions, eval operators, and assignment operators. You then compile this file and save somewhere. You then use this file by either 1) Editing the "config.s" file to add "user "filename"" (SCPU) 2) Using "-u filename" from xlang. Or will, once I add to xlang! With this method: - can add commands without editing slangdef - compiling is much faster - much easier for me to implement (much less error prone, etc.)! I am starting to document userdef/slangdef and will send stuff in another post. NOTE: I have not updated xlang yet. I will do so in the near future. If someone motivated (Jaymz) wants to try it out, the strategy is: load in slangdef useraddr is stored in $aa0a/b load file to useraddr, set $aa0c to 1 1st two bytes of userdef file should be same as $aa0a/b addr Otherwise I'll add this in in the near future. cu, -S From sjudd at ffd2.com Mon May 29 13:22:31 2006 From: sjudd at ffd2.com (Steve Judd) Date: Mon, 29 May 2006 12:22:31 -0600 (MDT) Subject: [Slackers] Userdef/Slangdef Message-ID: I am starting to document userdef/slangdef. Here's what I have so far. Not too useful, but what the heck. Feel free to make comments, etc. -S -- Slangdef/Userdef reference manual SLJ 5/22/06 Slangdef and Userdef is the mechanism for adding new commands to Slang. "Commands" consist of - keywords (for/next), - functions (sin/cos), - eval operators (a+b), - assignment operators (a=1), and - variable types (byte, int, float). A userdef file allows all but the variable types. By editing these files, or creating new files, new commands and even new languages may be implemented. If you're feeling brave, you can even use the newly defined commands in a new slangdef/userdef file and bootstrap into oblivion. This document describes the slangdef format and commands, and how to program the compiler. The discussion begins with a brief overview of the BASIC interpreter, which gives a fair amount of insight into designing a generic compiler. Next, since Slang is built on top of the Sirius assembler the basic assembler design is discussed, along with the relevant data structures. The different aspects of Slang are then discussed in detail. Finally, a list of the various compiler commands is given along with a (brief) description of the command. 1.0 BASIC Interpreter 2.0 Sirius assembler 3.0 Slang components 3.1 eval 3.2 subs 3.3 ... 4.0 Slangdef commands 1.0 BASIC Interpreter (don't knock it!) --------------------- The BASIC interpreter contains most of the components needed for a compiler, such as a parser and an expression evaluator. The difference is that it runs pre-defined routines instead of emitting code. Thus the interpreter routines are not particularly useful for a compiler but they do give a lot of insight. The BASIC interpreter starts by checking for a keyword, and if it's not a keyword then it must be an assignment (an implied LET) like "a=1". If it's an assignment, then the right hand side expression is evaluated, and the final value is stored to the left hand side variable. The routine which does this is EVAL. EVAL deals with up to two arguments at a time, in FAC1 and FAC2: - read left argument - check for operator; if found, - read right argument - call operator, result->fac1 - store result in left hand side variable when done If parenthesis are encountered everything is pushed onto the stack, and EVAL is called to evaluate the new expression. For keywords, the interpreter uses a keyword lookup table. If it's a keyword, the code jumps to the corresponding address in the table. Most keywords then call routines like EVAL to do their thing. That is, the BASIC interpreter may be thought of as a kernel, containing generic routines to parse text, evaluate expressions, and so forth, for use by individual commands. This is what allows new BASIC keywords to be added, and you could add an entirely different set of commands just by replacing the table. And that's about it. A compiler is very similar. The simple rule of keyword vs. assignment pretty much holds: - check for keyword - if not keyword, check for variable (regular, subroutine, etc.) - (Slang: if not variable, check for assembly). An expression evaluator works along the same lines as EVAL, above, with one key difference: - emit code to read left argument - check for operator; if found, - emit code to read right argument - emit code to execute operator - emit code to store result That is, it doesn't perform an operation, it _emits code_ to perform an operation, e.g. ; dest = var1+var2 lda var1 clc adc var2 sta dest The final, very important, point has to do with the "generic routine" aspect of the BASIC interpreter. A command, such as a keyword, simply calls these generic routines to perform a set of actions. This is how Slang is organized, as a set of generic routines that may be called by keywords. As with BASIC, Slang looks to a keyword table for valid commands. Slangdef allows you to define this table, in effect changing the language by changing the table. The same thing holds for operators and functions. When combined with a useful set of generic routines, this allows the language to be reconfigured on the fly. 2.0 Sirius Assembler -------------------- A line of 6502 assembly looks like LABEL OPCODE ARG so an assembler has it pretty easy: - Check 1st column; if a char, then read in label and assign address - Read opcode (look up in table) and call - For opcodes which can take an arg, read in argument - Output appropriate opcode/arg code. The first step is to read labels. A typical assembler uses two passes. On the first pass we read in the label and assign its address; on the second pass we use that address to output the correct code. That is, the first pass is to compute and assign addresses, the second is to output code. In Sirius, labels ("variables") are stored in a table called VARTAB. This table has a simple format: name type addr | | | | | 3 bytes | 1 byte, high bit set n bytes All names are converted to lower-case, and so have no characters with the high bit set. The "type" byte ends the name and says what type of label this is, such as type = $ff normal label $fe EQUated label $fd label EQUated to normal label and so forth. (The different types here are needed for the linker to work correctly.) Finally, a three-byte address follows. Simple and effective for 6502. The next step is to read in the opcode, and call the appropriate routine. In Sirius, each opcode routine does its own work. That is, it will call (if needed) the routine to read in an argument, determine if the argument is valid, and emit appropriate code. The READARG routine reads in arguments. An "argument" in this case may consist of numbers, labels, and address mode syntax characters, for example ($fe),y ADDR+1,x The job of READARG is to parse expressions like the above into something usable by the opcode routines. In Sirius, the result is a data structure called ARG1. From the code: * * Argument types: * 0 = no arg 1 = immediate 2 = absolute * 3 = abs,x 4 = abs,y 5 = abs,s * 6 = abs,abs * 7 = (zp) 8 = (zp),y 9 = (zp,x) * 10 = (zp,s),y 11= [zp] 12 = [zp],y * ARGLEN DFB 00 ARGOFF DFB 00 ;Argument offset ARGTYPE DFB 00 ;Argument type (abs, zp, etc.) ARG1 DFB 0,0,0,0 ;Main argument DFB 0,0 ;padding for PCODE The actual, numerical address is stored in ARG1. ARGLEN contains the argument length, e.g. 1, 2, or 3 bytes. ARGOFF is used for statements like lda #>$1234 For this case, ARG1 will equal $1234, but ARGOFF will be 1 (as will ARGLEN). Finally, ARGTYPE is used to indicate what type of addressing mode will be used. (ARGMODE would have been a better name, but such is life.) The statement above would have ARGTYPE=1 (immediate mode). Once an argument has been read in the opcode routine can output code. The Slang routines are all built on top of this foundation. The same code to check for labels/opcodes is used to check for Slang keywords. The same code, with slight modification, is used to read in Slang variables and expressions, and the same VARTAB is used to store variables. Most importantly, the Slang routines call the opcode routines directly to output code. That is, if Slang wants to emit code like lda var1 it will set up ARG1 and then call the LDA opcode routine. This turns out to have all sorts of advantages. One final thing, as an aside. The assembler error routine comes in at the end of the line; that is, the main loop looks like - read label - read opcode, call - read rest of line (comments, etc.) - check for error, if not then loop This works because the assembler reads in one opcode at a time. This doesn't work so well for Slang, which can encounter multiple errors while reading in a line. The problem is that I didn't figure this out until later in the development; most Slang commands generate an error when the error occurs, but a few things implemented early on will generate errors using the old system. So if you see a strange error, that seems removed from the actual error -- that's why! 3.0 Slang components 3.1 eval 3.2 subs 3.3 ... 4.0 Slangdef commands From sjudd at ffd2.com Mon May 29 20:16:15 2006 From: sjudd at ffd2.com (Steve Judd) Date: Mon, 29 May 2006 19:16:15 -0600 (MDT) Subject: [Slackers] A bug! Aiiiggggghhhh! Message-ID: Looks like sub asm is broken. Again. After fixing it. Twice. -S From jaymz at artificial-stupidity.net Mon May 29 20:34:09 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Tue, 30 May 2006 11:34:09 +1000 Subject: [Slackers] A bug! Aiiiggggghhhh! In-Reply-To: ; from sjudd@ffd2.com on Mon, May 29, 2006 at 07:16:15PM -0600 References: Message-ID: <20060530113409.C87965@artificial-stupidity.net> On Mon, May 29, 2006 at 07:16:15PM -0600, Steve Judd wrote: > Looks like sub asm is broken. Again. After fixing it. Twice. D'oh! I will try the new version later today, in any case. Thanks! --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From jaymz at artificial-stupidity.net Mon May 29 22:59:13 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Tue, 30 May 2006 13:59:13 +1000 Subject: [Slackers] New slangb1.20 up In-Reply-To: ; from sjudd@ffd2.com on Mon, May 29, 2006 at 12:19:59PM -0600 References: Message-ID: <20060530135912.D87965@artificial-stupidity.net> On Mon, May 29, 2006 at 12:19:59PM -0600, Steve Judd wrote: > Hola dewdz, > > Okay, new slang beta up: > > http://www.ffd2.com/fridge/slang/slang120.zip Hrm, sadly I can't get this to output validly linked code - the jsr into no mans land still appears at the multiply point :(. But I find myself wondering if I need a new version of core.l As an aside, I draw note to the following output - is this right? :0000 01 02 04 08 ubyte faceBitsMapping(4)={1 2 4 8] :0000 0e 0d 0b 07 ubyte ifaceBitsMapping(4)={14 13 11 7] :0000 00 28 50 byte lyneMap(3)={0 40 80] :0000 :0000 01 01 02 02 :0004 04 04 08 08 :0008 10 10 20 20 :000c 40 40 80 80 ubyte bitTable(16)={ 1 1 2 2 4 4 8 8 16 16 32 32 64 64 128 128 ] :0000 fe fe fd fd :0004 fb fb f7 f7 :0008 ef ef df df :000c bf bf 7f 7f ubyte ibitTable(16)={ 254 254 253 253 251 251 247 247 239 239 223 223 191 191 127 127 ] :0000 00 0b 0c 0f :0004 0f 0c 0b 00 ubyte starColours(8)={ 0 $b $c $f $f $c $b $0 ] Note how the counter resets to zero each line! Btw, are you aware that code has gotten bigger - I assume this is a feature, but I mention it in case it was not intended. Having to rebranch everything :) It's a lot of code, though, for: :21bc ae 9a 34 bd :21c0 e1 29 85 02 :21c4 bd fb 29 85 :21c8 03 ad 99 34 :21cc 18 65 02 85 :21d0 02 90 02 e6 :21d4 03 ad 9b 34 :21d8 a0 00 91 02 screen(y,x)=v :21dc ae 9a 34 bd :21e0 15 2a 85 02 :21e4 bd 2f 2a 85 :21e8 03 ad 99 34 :21ec 18 65 02 85 :21f0 02 90 02 e6 :21f4 03 a9 01 a0 :21f8 00 91 02 colour(y,x)=1 In any case, I will look at that more closely once I deal with the not being able to link problem. I am really reluctant, though, to unlink everything, since the linker is a very attractive feature to me. --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From sjudd at ffd2.com Tue May 30 14:27:38 2006 From: sjudd at ffd2.com (Steve Judd) Date: Tue, 30 May 2006 13:27:38 -0600 (MDT) Subject: [Slackers] New slangb1.20 up In-Reply-To: <20060530135912.D87965@artificial-stupidity.net> References: <20060530135912.D87965@artificial-stupidity.net> Message-ID: Hey Jaymz, > Hrm, sadly I can't get this to output validly linked code - the jsr into no > mans land still appears at the multiply point :(. But I find myself wondering > if I need a new version of core.l Ah, sorry, should have included that. Try this one: http://www.ffd2.com/fridge/slang/coretest.zip I just recompiled CORE.I.S and used that. There's also a stupid demo program in there to make sure it's not doing JSR 0000 anymore. > As an aside, I draw note to the following output - is this right? > > :0000 01 02 04 08 ubyte faceBitsMapping(4)={1 2 4 8] > :0000 0e 0d 0b 07 ubyte ifaceBitsMapping(4)={14 13 11 7] Yeah, no problem. The compiler is outputting numbers directly into the variable space, then resets the counter. I think I can fix it so that the printed output looks better. > Btw, are you aware that code has gotten bigger - I assume this is a feature, > but I mention it in case it was not intended. Having to rebranch everything :) Shouldn't be, except for things which failed earlier (like the array bugs you found -- that should generate more code now). > It's a lot of code, though, for: > > :21bc ae 9a 34 bd > :21c0 e1 29 85 02 > :21c4 bd fb 29 85 > :21c8 03 ad 99 34 > :21cc 18 65 02 85 > :21d0 02 90 02 e6 > :21d4 03 ad 9b 34 > :21d8 a0 00 91 02 screen(y,x)=v This looks OK. The above code is ldx $349a ;y lda $29e1,x ;table lo sta $02 lda $29fb,x ;table hi sta $03 lda $3499 ;x clc adc $02 sta $02 bcc +2 inc $03 lda $349b ;v ldy #00 sta ($02),y which is correct. Note that array statements like this will recompute the address every time. To get around this, to make code more efficient, the options are pointers and asm. Personally, I think the above is really nice 2D array code :). Whew! No new bugs (yet). cu, -S From jaymz at artificial-stupidity.net Tue May 30 18:52:37 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Wed, 31 May 2006 09:52:37 +1000 Subject: [Slackers] New slangb1.20 up In-Reply-To: ; from sjudd@ffd2.com on Tue, May 30, 2006 at 01:27:38PM -0600 References: <20060530135912.D87965@artificial-stupidity.net> Message-ID: <20060531095237.E87965@artificial-stupidity.net> On Tue, May 30, 2006 at 01:27:38PM -0600, Steve Judd wrote: > This looks OK. The above code is > > ldx $349a ;y > lda $29e1,x ;table lo > sta $02 > lda $29fb,x ;table hi > sta $03 > lda $3499 ;x > clc > adc $02 > sta $02 > bcc +2 > inc $03 > lda $349b ;v > ldy #00 > sta ($02),y > > which is correct. Note that array statements like this will recompute the > address every time. To get around this, to make code more efficient, the > options are pointers and asm. > > Personally, I think the above is really nice 2D array code :). I agree - although, didn't it at one point detect the case where the final element size is <256 (as in screen :)), and instead of doing a 16bit add, just doing sta (zp),y? In a lot of very common cases that'd be a LOT faster :). I forget if array code gen is in slangdef of in the compiler, and i'm not at home right now to check - but i thought i'd mention this before i forget will try the new core when i get home. thanks! --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From sjudd at ffd2.com Tue May 30 21:58:10 2006 From: sjudd at ffd2.com (Steve Judd) Date: Tue, 30 May 2006 20:58:10 -0600 (MDT) Subject: [Slackers] New slangb1.20 up In-Reply-To: <20060531095237.E87965@artificial-stupidity.net> References: <20060530135912.D87965@artificial-stupidity.net> <20060531095237.E87965@artificial-stupidity.net> Message-ID: Hola Jaymz, On Wed, 31 May 2006, Jaymz Julian wrote: > I agree - although, didn't it at one point detect the case where the final > element size is <256 (as in screen :)), and instead of doing a 16bit add, just > doing sta (zp),y? In a lot of very common cases that'd be a LOT faster :). I think the rule is that if the last element is an immediate number, and there are <256 elements, it will load it directly. That is, screen(y,3)=v will ldy #3. On those things I had some reason for doing it -- some special cases that could come up, etc. Or maybe I don't have a way of deciding if Eval evaluated just one argument. But now that you bring it up, I'll have a look in there and see if it can be made sweet. (The danger is that I overlook some special case that was apparent a year or two ago, and break things.) And yeah, I agree, it can make a big difference. -S From jaymz at artificial-stupidity.net Wed May 31 05:24:22 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Wed, 31 May 2006 20:24:22 +1000 Subject: [Slackers] New slangb1.20 up In-Reply-To: ; from sjudd@ffd2.com on Tue, May 30, 2006 at 08:58:10PM -0600 References: <20060530135912.D87965@artificial-stupidity.net> <20060531095237.E87965@artificial-stupidity.net> Message-ID: <20060531202422.F87965@artificial-stupidity.net> On Tue, May 30, 2006 at 08:58:10PM -0600, Steve Judd wrote: > Hola Jaymz, > > On Wed, 31 May 2006, Jaymz Julian wrote: > > > I agree - although, didn't it at one point detect the case where the final > > element size is <256 (as in screen :)), and instead of doing a 16bit add, just > > doing sta (zp),y? In a lot of very common cases that'd be a LOT faster :). > > I think the rule is that if the last element is an immediate number, and > there are <256 elements, it will load it directly. That is, > > screen(y,3)=v > > will ldy #3. On those things I had some reason for doing it -- some > special cases that could come up, etc. Or maybe I don't have a way of > deciding if Eval evaluated just one argument. But now that you bring it > up, I'll have a look in there and see if it can be made sweet. (The > danger is that I overlook some special case that was apparent a year or > two ago, and break things.) The thing is, if there is only 8bits of elements, then the behaviour of going over the end of that array should be undefined anyhow - so it's okay, in that case, to wrap at >256, imnsho - and indeed you do this at least on short single dimension arrays, so I see no reason not to do that generally. --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From jaymz at artificial-stupidity.net Wed May 31 06:10:01 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Wed, 31 May 2006 21:10:01 +1000 Subject: [Slackers] New slangb1.20 up In-Reply-To: ; from sjudd@ffd2.com on Tue, May 30, 2006 at 01:27:38PM -0600 References: <20060530135912.D87965@artificial-stupidity.net> Message-ID: <20060531211001.G87965@artificial-stupidity.net> On Tue, May 30, 2006 at 01:27:38PM -0600, Steve Judd wrote: > Hey Jaymz, > > > Hrm, sadly I can't get this to output validly linked code - the jsr into no > > mans land still appears at the multiply point :(. But I find myself wondering > > if I need a new version of core.l > > Ah, sorry, should have included that. Try this one: > > http://www.ffd2.com/fridge/slang/coretest.zip > > I just recompiled CORE.I.S and used that. There's also a stupid demo > program in there to make sure it's not doing JSR 0000 anymore. No go. Same result exactly: .C:5b72 A9 00 LDA #$00 .C:5b74 8D 91 74 STA $7491 .C:5b77 A9 00 LDA #$00 .C:5b79 8D 92 74 STA $7492 .C:5b7c A9 0A LDA #$0A .C:5b7e CD 91 74 CMP $7491 .C:5b81 A9 00 LDA #$00 .C:5b83 ED 92 74 SBC $7492 .C:5b86 30 4A BMI $5BD2 .C:5b88 AE 91 74 LDX $7491 .C:5b8b BD CC 71 LDA $71CC,X .C:5b8e 85 02 STA $02 .C:5b90 AD 91 74 LDA $7491 .C:5b93 85 69 STA $69 .C:5b95 AD 92 74 LDA $7492 .C:5b98 85 6A STA $6A .C:5b9a A9 18 LDA #$18 .C:5b9c 85 6B STA $6B .C:5b9e A9 00 LDA #$00 .C:5ba0 85 6C STA $6C .C:5ba2 20 94 96 JSR $9694 <----- right here .C:5ba5 18 CLC .C:5ba6 A5 69 LDA $69 .C:5ba8 69 0D ADC #$0D .C:5baa 8D 00 10 STA $1000 .C:5bad A5 6A LDA $6A .C:5baf 69 00 ADC #$00 .C:5bb1 18 CLC from the slang compiler output: :1b72 sub initTables() :1b72 SetZpTemp mainZp :1b72 int x :1b72 ubyte y :1b72 a9 00 8d 91 :1b76 34 a9 00 8d :1b7a 92 34 a9 0a :1b7e cd 91 34 a9 :1b82 00 ed 92 34 :1b86 30 4a for+ x=0:(mazeWidth-1) :1b88 ae 91 34 bd :1b8c cc 31 85 02 :1b90 ad 91 34 85 :1b94 69 ad 92 34 :1b98 85 6a a9 18 :1b9c 85 6b a9 00 :1ba0 85 6c 20 72 <-- the '20 72 1b' here corrisponds to the '20 94 96' above, after linking... :1ba4 1b 18 a5 69 :1ba8 69 0d 8d 00 :1bac 10 a5 6a 69 :1bb0 00 18 8d 01 :1bb4 10 ad 00 10 :1bb8 69 1f a6 02 :1bbc 9d d7 31 ad :1bc0 01 10 69 00 :1bc4 9d d8 31 xtable(x)=x*24+13+31 :1bc7 ee 91 34 d0 :1bcb 03 ee 92 34 :1bcf 4c 7c 1b endfor I have no idea, btw, what is causing this :). Note that 'mazeWidth' above is an equ, btw. I don't remember if slang optimizes that out or not :). I zipped the code, btw, that generates this and put it at http://dspaudio.com/~jaymz/wor-broken.zip. All of this with the latest beta, and the new core.l. --jj -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From sjudd at ffd2.com Wed May 31 08:42:15 2006 From: sjudd at ffd2.com (Steve Judd) Date: Wed, 31 May 2006 07:42:15 -0600 (MDT) Subject: [Slackers] New slangb1.20 up In-Reply-To: <20060531211001.G87965@artificial-stupidity.net> References: <20060530135912.D87965@artificial-stupidity.net> <20060531211001.G87965@artificial-stupidity.net> Message-ID: Hey Jaymz, I wasn't able to build-wor.sh -- missing sprite.inc file. I wanted to compile it to see what's going on, but maybe the following would be good enough: > .C:5b9e A9 00 LDA #$00 > .C:5ba0 85 6C STA $6C > .C:5ba2 20 94 96 JSR $9694 <----- right here Can you show me the code at $9694 as well? Alternatively, can you show the output of the linker (I'd like to see what address core.l is being linked to). Also, I assume you re-compiled the wor program before linking? Thanks, -S P.S. The way a REL file works is fairly straightforward. The idea is to make a relocatable module. This is done by compiling the code (to 0000), and including some additional info with the file to tell the linker how to fix up addresses. The only addresses which matter are labels (regular, not EQUates). There are three types of labels which matter: regular labels, ENT labels, and EXT labels. For regular labels -- say, JSR Blah or LDA table1,x -- what's assembled in the file is the label _offset_ from the beginning of the code (because the code is assembled to 0000). At link time, the linker simply loads in the REL module to some address, and adds that address to the offset already in the code. So for regular labels in a REL file you'll see them assembled as an offset from the beginning of the code, and there will be an entry associated with it at the end of the code (all those bytes output after the code is done assembling). ENT labels work the same, except there is an additional entry in the link tables at the end of the code, containing the label name and its offset. EXT labels -- like core routines such as multiplication -- don't need any offset information. The label value is resolved at link time. All the linker needs to know is the address to store the value at. So at the end of the REL file, you should see an entry like core]mult16 offset where "offset" is the address $1ba2 in the code you printed. From sjudd at ffd2.com Wed May 31 13:00:08 2006 From: sjudd at ffd2.com (Steve Judd) Date: Wed, 31 May 2006 12:00:08 -0600 (MDT) Subject: [Slackers] REL/Linker files Message-ID: Hmmm, that last explanation was pretty bad. I'd like a do-over. REL/Linker file structure: A REL file is a RELocatable module containing both code and information for relocating the code. Consider a statement like lda LABEL,x ;or jsr LABEL, etc. There are four cases of interest for LABEL: Case 1: EQUated label (e.g. LABEL = $C000). Nothing needs to be done, since the value is absolute, not relative. Case 2: LABEL is contained within the module. At link time, we need to store the actual value in the code. To do so, we need two pieces of information: - The location of LABEL in the "lda LABEL,x" statement (the location to fix up at link time) - The offset of LABEL within the module (the address). At link time, the module is loaded to some address ADDR. The linker then computes the correct label value as ADDR+Offset, and stores this correct value at the appropriate location. In a REL file, the offset is stored in the location (e.g. lda OFFSET,x above), and a two-byte address is stored at the end of the file to indicate locations within the file that need fixing. Case 3: LABEL is an ENT value. Because the label is within the code we still need to do case 2 above, but in addition the label needs to be stored in the REL file along with its offset, for use by other programs. Case 4: LABEL is an EXT value. In this case a dummy value is assembled into the file, and the variable and its location are stored within the REL file. At link time, after the linker has computed all the correct ENT labels it can store the proper EXT values. Example: REL blah equ $ff var1 ext start ent lda blah ; lda $ff sta var1 ; sta $xxxx jsr test ; jsr $0009 test = org+9 rts ; rts test inc $d020 ; inc $d020 rts ; rts table at end of code: ; 06 00 relative address to be fixed ; start 00 00 ENT labels (name and offset) ; var1 03 00 EXT labels (name and fix offset) Note: There are several exceptions to the above rules, such as lda #>label and so forth, and with Slang it's more complicated for things like arrays. But the above gives the idea of what a REL file looks like. Full details are in the linker source code. One final detail: the REL file structure goes like code offset table two bytes: size of offset table ENT table two bytes: size of ent table EXT table two bytes: size of ext table two byte ID Using this structure, the linker can load the file to the correct address and then work backwards from the end of the file to fix stuff up. Now You Know. -S P.S. This was all from memory but I think it's correct. From jaymz at artificial-stupidity.net Wed May 31 18:03:52 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Thu, 1 Jun 2006 09:03:52 +1000 Subject: [Slackers] New slangb1.20 up In-Reply-To: ; from sjudd@ffd2.com on Wed, May 31, 2006 at 07:42:15AM -0600 References: <20060530135912.D87965@artificial-stupidity.net> <20060531211001.G87965@artificial-stupidity.net> Message-ID: <20060601090352.I87965@artificial-stupidity.net> On Wed, May 31, 2006 at 07:42:15AM -0600, Steve Judd wrote: > Hey Jaymz, > > I wasn't able to build-wor.sh -- missing sprite.inc file. I wanted to > compile it to see what's going on, but maybe the following would be good > enough: > > > .C:5b9e A9 00 LDA #$00 > > .C:5ba0 85 6C STA $6C > > .C:5ba2 20 94 96 JSR $9694 <----- right here > > Can you show me the code at $9694 as well? Alternatively, can you show > the output of the linker (I'd like to see what address core.l is being > linked to). ooops. http://dspaudio.com/~jaymz/sprite.inc :) $9694 is a world of $00,$00,$00,$00,$00,$00 :). Output: ^_^*jaymz ~/c64/asm/slang$ ./xlang wor.link -o wor.prg Loading (petscii) bin/rom-a000.prg... $00a000-$00c000 Loading (petscii) bin/rom-e000.prg... $00e000-$010000 Loading (petscii) bin/CHARROM-D000.PRG... $00d000-$00dfff Loading (petscii) bin/ZP0000-03FF.PRG... $000000-$0003ff Loading (petscii) bin/SLANGDEF.O... $00aa00-$00c2ad Loading (petscii) bin/SLANG1.3.O... $000801-$00a8a7 Loading (ascii) wor.link... $040000-$040029 Compiling... Loading (petscii) wor.l... $020000-$024c78 $4000 addext: addent: fixloc:Loading (petscii) sprite.l... $0236f9-$023c1a $76f9 addext: addent: fixloc:Loading (petscii) core.l... $023a64-$024079 $7a64 addext: addent: fixloc: resolving externals... assembly sucessful -- 15712 bytes $4000-$7d5f ORG=$4000, CODEEND=$7d60 Saving wor.prg... $4000-$7d60 > Also, I assume you re-compiled the wor program before linking? yep :) -- -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net From sjudd at ffd2.com Wed May 31 21:49:46 2006 From: sjudd at ffd2.com (Steve Judd) Date: Wed, 31 May 2006 20:49:46 -0600 (MDT) Subject: [Slackers] New slangb1.20 up In-Reply-To: <20060601090352.I87965@artificial-stupidity.net> References: <20060530135912.D87965@artificial-stupidity.net> <20060531211001.G87965@artificial-stupidity.net> <20060601090352.I87965@artificial-stupidity.net> Message-ID: Yeah, ok, obviously another bug. Rats! Thought I had that one fixed... -S From jaymz at artificial-stupidity.net Wed May 31 22:04:25 2006 From: jaymz at artificial-stupidity.net (Jaymz Julian) Date: Thu, 1 Jun 2006 13:04:25 +1000 Subject: [Slackers] New slangb1.20 up In-Reply-To: ; from sjudd@ffd2.com on Mon, May 29, 2006 at 12:19:59PM -0600 References: Message-ID: <20060601130424.K87965@artificial-stupidity.net> On Mon, May 29, 2006 at 12:19:59PM -0600, Steve Judd wrote: > NOTE: I have not updated xlang yet. I will do so in the near future. If > someone motivated (Jaymz) wants to try it out, the strategy is: > > load in slangdef > useraddr is stored in $aa0a/b > load file to useraddr, set $aa0c to 1 > 1st two bytes of userdef file should be same as $aa0a/b addr > > Otherwise I'll add this in in the near future. I'll get to this on the weekend, but meanwhile, does this mean that there can only be one userdef? Given that, is put allowed in userdef files? --jj -- Jaymz Julian - Coder, Visionary, Fat Ass. "Hannibal is a serial killer. He only likes to kill and eat people. Very few people have `I want to be killed and eaten' on their cards, so Hannibal is out of a job." - http://cards.sf.net