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-01 21:38
TWW

Registered: Jul 2009
Posts: 541
Hmm another thing I saw now was that I get an error when compiling my code after updating Kickass (was using old version):

    .var ZP                    = $02
    .const FetchDataVector     = ZP .eval ZP+=2


Have to move the ".eval ZP+=2" to a new line but it used to assemble just fine. Will make my ZP variable declarations a lot more messy ^^
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: 420
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: 420
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: 472
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: 209
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: 209
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 ?
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
Exile/Anubis
Cobra/Samar
t0m3000/ibex-crew
Matt
Guests online: 300
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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