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..
 
... 592 posts hidden. Click here to view all posts....
 
2016-09-01 21:29
TWW

Registered: Jul 2009
Posts: 541
I saw I asked this thing like 4 years ago and surely found some work-around back then but that is several HD crashes ago and perhaps there are updates I didn't catch.

Strings:

I am making a string for a cartridge header but it contains some RVRS ON characters and stuff. The question is how do I avoid doing this hack:

.const CartridgeName = "C64GS C" // Maximum 32 bytes.
.text CartridgeName
.byte $61,$72,$74,$72,$69,$64,$67,$65

Basically what I would like to do is to append the constant with the bytes as added data to the string. This again to allow me to fill in the surplus available characters without having to cheat:

.fill 32-CartridgeName.size()-8,0

So what I would like to do is:

.const CartridgeName = "C64GS C"+hexBytes($61,$72,$74,$72,$69,$64,$67,$65)
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: 422
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: 422
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: 474
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 ?
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
MWR/Visdom
š˜š—”š—š/FairLight
celticdesign/Gā˜…P/M..
grasstust/Hoaxers
Wayne/Art Ravers
jmin
ArturoDente
Didi/Laxity
Guests online: 105
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.7)
6 No Bounds  (9.6)
7 Aliens in Wonderland  (9.6)
8 Comaland 100%  (9.6)
9 Uncensored  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Happy Birthday Dr.J  (9.7)
2 Layers  (9.6)
3 It's More Fun to Com..  (9.6)
4 Cubic Dream  (9.6)
5 Party Elk 2  (9.6)
6 Copper Booze  (9.6)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Rainbow Connection  (9.5)
9 Dawnfall V1.1  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 SHAPE  (9.3)
Top Original Suppliers
1 Black Beard  (9.7)
2 Derbyshire Ram  (9.5)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Jazzcat  (8.6)

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