Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Kick Assembler Thread 2
2009-07-21 17:20
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....
 
2016-09-02 12:20
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
2016-09-02 16:47
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
2016-09-02 17:22
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.
2016-09-03 15:46
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")
2016-09-03 18:32
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.
2016-10-19 04:32
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(^^).
2016-10-19 07:44
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).
2016-10-21 19:37
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 ?
2016-10-22 16:46
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 ?
2016-10-22 18:18
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Tom/TRS
Yodelking/Defiers
Lazycow
Bones99
neoman/titan
CyberBrain/NoName
K-reator/CMS/F4CG
(x)deejay
Guests online: 124
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Lobo  (9.7)
4 Mikael  (9.7)
5 Archmage  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.061 sec.