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....
 
2012-02-19 13:27
chatGPZ

Registered: Dec 2001
Posts: 11110
i found this bug:

test1.asm:

.if (1 == 1) {
    .import source "test2.asm"
}


test2.asm can be whatever (even empty file)

assembling results in the following error:

.if (1 == 1) {
    .import source "test2.asm"
    ^

Error: Unknown import type 'source'
at line 3, column 5 in test1.asm


additional question: if there are labels defined in test2.asm, then how do i export them outside the scope of the if statement? (i find it really super useless and annoying that if statements have their own scope to be honest, it effectively prevents me from being able to use them properly :/)

eg i am used to do stuff like this:

.if testing = 1
screen = $0400
chars = $0800
.else
screen = $e400
chars = $e800
.endif


how do you do this in kickass? (assuming there are many more such labels, replacing them all by a function is really not an option)
2012-02-19 16:13
TWW

Registered: Jul 2009
Posts: 541
Yepp, that's exactly what I ment. Thanx Slammer!
2012-02-19 16:24
Slammer

Registered: Feb 2004
Posts: 416
I see your problem. You can't use the .import source directive this way, it can't be nested inside a .for or an .if. The reason is that the .import source directive is evaluated in a pre parse that collects pseudocommands, macros, functions, etc so you can use them in the evaluation, but the error message is wrong. Should be something like 'Cant use an import source directive here'.

If you are importing libraries and only want to import them once, then use the .importonce directive instead.

btw. booleans are implemented so you can do: .if (true) { ..}

----

About labels/Constants/Variables:

Constants: Is defined like '.const myConst=25' and can only be accessed after they are defined. Constants can't change values.

Variables: Is defined like '.var myVar=true' and works like constants. The only difference is that you can change the value of a variable. e.g.: '.eval myVar=false'

Labels: Is defined like 'myLabel1:' or '.label myLabel2="HelloWorld" and can be accessed before they are declared (Note that they don't necessarily have to be numbers). Labels can't change values.

Now back to your question. To do a test setup like the one you describe you can do it in two ways. The first way defines your constants in a really compact way:

   // Define Mode
   .const TEST = true

   // Define Data
   .const screen = TEST ? $0400 : $e400 
   .const chars = TEST ? $0800 : $e800

Another way, that keeps the test setup more separated from the normal setup, is to define the datafields as variables and assign them insides ifs:
   // Define Mode
   .const TEST = true

   // Define Data
   .var screen .var chars 
   .if (TEST) {
	.eval screen = $0400 
	.eval chars = $0800 
   } else {
	.eval screen = $e400 
	.eval chars = $e800 
   }
2012-02-19 17:47
chatGPZ

Registered: Dec 2001
Posts: 11110
Quote:
I see your problem. You can't use the .import source directive this way, it can't be nested inside a .for or an .if. The reason is that the .import source directive is evaluated in a pre parse that collects pseudocommands, macros, functions, etc so you can use them in the evaluation, but the error message is wrong. Should be something like 'Cant use an import source directive here'.
If you are importing libraries and only want to import them once, then use the .importonce directive instead.

urks :( i am selectively including other sourcefiles there, depending on some other settings (ie, its not an include-guard). bummer, that will be tricky to solve :/
2012-02-20 20:36
Slammer

Registered: Feb 2004
Posts: 416
I once considered making a set preprocessing commands so you could do things like this, but I guess it will be really confusing to have two if commands, two var commands, etc. And I guess the .importonce directive covers 99% of the needs.

Dependent on how complex you includes are, there might be a hack. Since normal directives aren't evaluated during the preprossing pass, you can't create normal .var's or .const's to use in the '.import source' directive.. However, you can give variables to the assembler by the command line and use these as the include filename. Create an empty file to include, if you don't want to include anything..

Eg:
  --- Commandline ---
  java -jar KickAss.jar mySource.asm :loader="irqloader.asm" 

  --- mySource.asm ----
  .import source cmdLineVars.get("loader")


NB. Its only the .import source directive that is effects by this issue. Other imports can be placed inside if's
2012-03-12 11:28
Norrland

Registered: Aug 2011
Posts: 14
I'm trying to convert from 64tass-religion to KickAss-religion. When using 64tass, I've been using command line option -L alot. From 64tass docs:
Quote:

-L <file> List into <file>
Dumps source code and compiled code into file. Useful for debugging code, it's much easier to identify the code in memory within the source files.
Example

64tass -L list.txt a.asm
*=$1000
ldx #0
loop dex
bne loop
rts

result (list.txt):

;6502/65C02/65816/CPU64/DTV Turbo Assembler V1.4x listing file of "a.asm"
;done on Fri Dec 9 19:08:55 2005

.1000    a2 00          ldx #$00                ldx #0
.1002    ca             dex             loop    dex
.1003    d0 fd          bne $1002               bne loop
.1005    60             rts                     rts

;****** end of code


I can't seem to find a similar command line option in Kick Assembler docs. Does that exists?
2012-03-13 15:46
Cruzer

Registered: Dec 2001
Posts: 1048
@H Macaroni: Seems like a cool feature, but no, you can't do that in KickAss. What I usually do is simply to print out the address of the point I wanna inspect in the monitor like this:

.print "here: " + toHexString(*)
2012-03-13 20:44
Slammer

Registered: Feb 2004
Posts: 416
If i where you, I would export a vice symbol file (option -vicesymbols) and see your code in the vice monitor (including your labels).

There actually is a secret option a bit like the one you want, but with a much higher detail level so I won't recommend it for debugging programs in general (I use it for debugging the assembler). However, It might be interesting for people who wants a sneak peak of whats going on while assembling. The option is -parsetree which shows the state between each pass. The output looks like this:
rasterbar.asm 45:4             :       #NAsmCmd(ldy, EAsmArg(EVarRef(rasterColor)))
rasterbar.asm 46:4             :       #NAsmCmd(cpy, EAsmArg(EConst(!255.0)))
rasterbar.asm 47:4             :       #NAsmCmd(beq, EAsmArg(EVarRef(o1)))
rasterbar.asm 48:4             :       #NAsmCmd(lda, EAsmArg(EConst(!53266.0)))
rasterbar.asm 49:4             :       #NAsmCmd(cmp, EAsmArg(EConst(!53266.0)))
rasterbar.asm 50:4             :       #NAsmCmd(beq, EAsmArg(EObjFuncCall(-,EPcRef(),EConst(!3.0))))
rasterbar.asm 51:4             :       #NAsmCmd(sty, EAsmArg(EConst(!53280.0)))
rasterbar.asm 52:4             :       #NAsmCmd(inx, EAsmArg())
rasterbar.asm 53:4             :       #NAsmCmd(jmp, EAsmArg(EVarRef(l1)))


Beware, It easily gets complicated and is not supported in any way (Originally only intended for me to read). However, if you are really interested whats going on in line 50, you might be able to tell.

2012-03-13 23:51
Norrland

Registered: Aug 2011
Posts: 14
Thanks for the answers, I'll try them.
2012-04-17 21:20
Mace

Registered: May 2002
Posts: 1799
Why do I get an error (Uknown function) on the - in [max-min] in de code below?
Using KickAss v3.25.

.pseudocommand sinData min;max;freq {
	.var amp = 0
	.eval amp = [max-min]/2
	.fill 256, amp + amp * sin(toRadians(i*[360*freq]/256))
	}

.pc = $1000
	:sinData 0;255;1
Previous - 1 | ... | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | ... | 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
DeMOSic/HF^MS^BCC^LSD
TheRyk/MYD!
Alakran_64
Mike
syntaxerror
kbs/Pht/Lxt
Thunder.Bird/HF/MYD!..
josepzin/Nautilus
Guests online: 146
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 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (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 Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

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