| |
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.. |
|
... 590 posts hidden. Click here to view all posts.... |
| |
Scan
Registered: Dec 2015 Posts: 110 |
You don't need to move it to a new line, you can also use ; to separate the statements:
.var ZP = $02
.const FetchDataVector = ZP ; .eval ZP+=2
|
| |
Digger
Registered: Mar 2005 Posts: 421 |
Tru dat. But you can do this and it works without eval, since it evaluates post expression.
.var zp = $c0
.const screen = zp++
.const vOffset = zp+=2
.const vScrollText = zp+=2
|
| |
TWW
Registered: Jul 2009 Posts: 541 |
You guys are so clever 8-D
I seriously should drag my ass to a (c0py)party so I can start handing out those beers...
Now only question remains is the string issue above. |
| |
Agemixer
Registered: Dec 2002 Posts: 38 |
TWW, please check my example (dated 2015-03-27 earlier in this thread) for string conversion.
The basic idea for conversing kickass strings to ascii/petscii/whatever, is some macro like this:
.function pet2asc(p) { .eval p = [ p>$40? p+=$80 : p ] .return [ p<$20? p^$40 : p ] } // character conversion from Kickass text to c64 ascii
.macro asctxt(str) { .fill str.size(), pet2asc(str.charAt(i)) }
.macro asctxtCR(str) { :asctxt(str) .byte $0d } // With carriage return
After having these, you can define your text like:
:asctxt("Hello World!")
:asctxtCR("") // just a carriage return (byte $0d)
:asctxt("The quick brown fox ")
:asctxtCR("jumps over the lazy dog") |
| |
Digger
Registered: Mar 2005 Posts: 421 |
Another useful macro (hope @Slammer will add that natively soon) that converts hex string to bytes super useful for color tables.
.macro stringToBytes(string) {
.for (var i = 0; i < string.size(); i++) {
.var char = string.charAt(i).number()
.var value = char >= $30 ? char - $30 : char + 9
.byte value
}
}
Example:
stringToBytes("f582900000000000")
Can be surely written even shorter, but I didn't care. |
| |
TWW
Registered: Jul 2009 Posts: 541 |
Math Question:
Say I have a number: -161230 and do the following:
.var number = -161230
.var HighOrder = floor(abs(number/10000)) // Gives 16
.var MediumOrder = floor([abs(number/10000)-floor(abs(number/10000))]*100) // Gives 12
.var LowOrder = (abs(number/100)) // Gives 1612,3
.eval LowOrder = floor(abs(number/100)) // Gives 1612
.eval LowOrder = [(abs(number/100)) - floor(abs(number/100))]*100 // Gives 29,99999999999545
In my head this should give 30,0
Or shouldn't it?
EDIT: I can use round as a workaround(^^). |
| |
soci
Registered: Sep 2003 Posts: 473 |
That's how binary floating point works. This special case would have worked with decimal floating point.
In short floating point numbers need to be handled carefully and yes, that round() will be needed.
Btw. this sort of calculation should have been done with modulo and division using integer arithmetic only. And preferably unsigned to not get "surprising" results for negative numbers (implementation specific). |
| |
xIII
Registered: Nov 2008 Posts: 210 |
just a fast question:
if I use -> .word 100,100
the result in Vice is -> 64,80,64,00
I was expecting -> 64,00,64,00 ?
if I use .word $012c
I get -> 2c 80
expecting: 2c 01 ? |
| |
xIII
Registered: Nov 2008 Posts: 210 |
Quote: just a fast question:
if I use -> .word 100,100
the result in Vice is -> 64,80,64,00
I was expecting -> 64,00,64,00 ?
if I use .word $012c
I get -> 2c 80
expecting: 2c 01 ?
anyone ? |
| |
lA-sTYLe
Registered: Sep 2003 Posts: 63 |
no idea why, nor used to Kickass,
but how about .byte $2c,$01 ? |
Previous - 1 | ... | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 - Next |