| |
Slammer
Registered: Feb 2004 Posts: 416 |
Kick Assembler Thread 2
The previous thread took a little long to load, so this is a new fresh one.. |
|
... 592 posts hidden. Click here to view all posts.... |
| |
algorithm
Registered: May 2002 Posts: 702 |
Quote: Nice one.. Btw. There is an error directive so you can fail if the number of chars exceeds 256.
The below tool can be used to pack a full screen image (or many images) to 256 chars. non-lossy if there are less than 256 unique 8x8 blocks. Lossy if more.
CSAM V3
|
| |
tlr
Registered: Sep 2003 Posts: 1737 |
Maybe this has been discussed before but:
If I do this...
.const str = "TESTING"
text:
.fill str.size(), str.charAt(i) & $3f ...or this...
.const str = "TESTING"
.function to_scr(c) {
.return c & $3f
}
text:
.fill str.size(), to_scr(str.charAt(i)) ... Kick Assembler 3.18 fails to recognize the '&' operator.
however this works:
.const str = "TESTING"
text:
.fill str.size(), $3f & str.charAt(i)
My guess that this is a problem with implicit casting of chars, no?
It took a while to figure out. I'd prefer if both ways of ordering worked or if it was at least documented... ;) |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Good question.
Kick Assembler works with objects, just like object oriented languages like C++, C# and java. Each class of objects has
assigned a set of functions and operators. Eg. a String object has a charAt function, but the number function hasn't.
The & operator is placed on the number object and not on the char object (See documentation).
When you write:.var a = 'x' & 1 The & operator is called on the char object. But it isn't defined so you will get an error.
But this work: .var b = 1 & 'x' The & operator is called on the number object which cast the char object parameter to a number value and performs the and operation.
Guess it would be nice if we could explicitly typecast objects - That will probably be in the next release. Until then you can make a dirty typecast to convert chars into numbers like this: .var a = [0+'x'] & 1
EDIT: So yes, it is a issue of casting cos how should the assembler know that we meant the & operator on the number object and the perform the cast to a number? Theoretically, we could have defined an & operator on the String value that appended two strings - should we then implicitly cast to a number or to a string (or to a third value). So the assembler cant decide this and gives an error.
|
| |
JackAsser
Registered: Jun 2002 Posts: 1997 |
@Slammer: The simple solution would be (as in Java) to treat chars as a kind of number, hence the &-operator would exist on char-objects aswell. I.e. simply allow the &-operator on char-objects. Or let char-class be a subclass of the more general number-class.
Regarding &-operator on strings to concatenate => fine, since string != char. "foo"&"bar" == "foobar" vs 'x'&'y' == 0xSomething. Right? |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Making the char class a subclass of the number class is absolutly a possibility. Im a bit defensive about these things since its easy to implement features with unwanted side effects you cant get rid of cos of backward compatibility.
In java 'o'+'k'=218 but 'o'+'k'="ok" seems more logical, so taking the java approach may also lead to surprises (In this example you can consider the char a subclass of a string).
|
| |
tlr
Registered: Sep 2003 Posts: 1737 |
Quote: Making the char class a subclass of the number class is absolutly a possibility. Im a bit defensive about these things since its easy to implement features with unwanted side effects you cant get rid of cos of backward compatibility.
In java 'o'+'k'=218 but 'o'+'k'="ok" seems more logical, so taking the java approach may also lead to surprises (In this example you can consider the char a subclass of a string).
Actually for someone (me) who has programmed assembly and C a lot I think 'o'+'k' = 218 is much more logical.
It's pretty common to do LDA #'<char>' and things like that so we should be quite used to seeing it as a number.
Explicit casting instead of 0+'<char>' would be acceptable but the above would be better IMO.
Can it be done with "<string>" + '<char>' still working? |
| |
JackAsser
Registered: Jun 2002 Posts: 1997 |
Quote: Making the char class a subclass of the number class is absolutly a possibility. Im a bit defensive about these things since its easy to implement features with unwanted side effects you cant get rid of cos of backward compatibility.
In java 'o'+'k'=218 but 'o'+'k'="ok" seems more logical, so taking the java approach may also lead to surprises (In this example you can consider the char a subclass of a string).
Imo if you wish to include the more logical approach ('o'+'k'="ok") then do it via some specific concatenate operator, like the dot (.) in PHP. Let +-*/&| always be arithmetical imho, to keep things more clean and predictable.
Having char as a subclass of string sounds just weird actually. It's more like a string is composed by chars which might be a subclass of a number or not.
But then again... :) It's your assembler and your decision and I don't even use it, although I'm deeply impressed by it so keep up the good work! :D |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Jackasser: For java strings the '+' operator is used for append, so it would counter intuitive to use another operator here for chars, and ind java 'o'+"k"= "ok" (char+string appending).
The string subclassing example was just point out that a char can be viewed as a string of length 1 as well as a number. If you write print('x') you would expect the string "x" as output and not the string "120", so in some respect it is a string and in other cases its a number.
However, I guess the number class is probably the most dominant one (it has more useful methods) so i guess that the primary object of inheritance. (So I actually agree with you, but just dont wan't to rush into an implementation with unwanted sideeffects)
|
| |
Angel of Death
Registered: Apr 2008 Posts: 210 |
Call me n00b, call me blind, call me stupid, whatever. But where were the executables of kick assembler again?
(can't find them on the designated spot)
Because Java just isn't my thing... |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Hi,
The exe version ain't supported anymore. Dependend on which os you use, java might already be installed which means the only difference between the exe version and the java version is that you have to write java -jar KickAss.jar mySource instead of KickAss.exe mySource Usually people set this up in some kind of configuration (scripfile or editor command), so it aint that much of a difference.
Also check out Pantaloons KickVice.exe (KickVice)
Btw. I made a few improvements on LCP.. V3.19 should be out soon.
|
Previous - 1 | ... | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ... | 61 - Next |