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....
 
2010-05-22 01:08
TWW

Registered: Jul 2009
Posts: 542
Oswald/Pantalon:

I was thinking more in the lines of modifications of labels inside scopes / loops. Not Self Modifying speedcode or lookup-tables.

So to rephrase;

can I do something like:


.for (y=0;y<5;y++) {

.label mylabel+toIntString(y)

//Do something

}

and get the assembler to generate 5 labels (mylabel1 to mylabel 5) for my 5 Do something routines?
2010-05-22 10:55
Pantaloon

Registered: Aug 2003
Posts: 124
well, thats now how kickassembler works, just store the programCounter in a list and use it that way, its the same as working with labels just a different syntax really. instead of doing something mylabel you do something mylabels(labelindex).
2010-05-22 13:00
TWW

Registered: Jul 2009
Posts: 542
Alright I see now.

Thanx.

-TWW
2010-06-17 19:34
Pantaloon

Registered: Aug 2003
Posts: 124
Slammer:

can you add something like .ifdefined(myvar) , it would be very useful to check if a variable has been declared when using alot of small source files.

and i found a bug, if you use the .import directive inside an if statement it doesnt compile.

ie.

.if (LINK == true)
{
.import source "MySourceFile.s"
}

-P
2010-06-18 16:52
Slammer

Registered: Feb 2004
Posts: 416
Some kind of ifdefined is already on the todo-list - I'll prioritize it a bit higher.

Right now the development is on a hold i'm afraid. I have to replace my old development computer.
2010-06-18 19:19
Pantaloon

Registered: Aug 2003
Posts: 124
nice!, hope you get a new computer soon :)
2010-06-29 17:52
TWW

Registered: Jul 2009
Posts: 542
I know even before posting that this question will sound weird but here goes;


Can I create a macro/pseudocommand which will compile differently depending on arguments passed?


f.ex.

ex #1:

A routine changes the code it produces based on arguments passed. Like a multiply routine which choosed 8 bit or 16 bit multiply depending on which arguments the macro/pseudo is called with.

ex #2:

A joystick routine called with port as a parameter simply returns the joystick status in A or something BUT if an aditional parameter like acceleration is passed the routine "changes" into different produced code which handles acceleration this aswell (somehow^^)...

TWW/Creators
2010-06-29 21:59
Slammer

Registered: Feb 2004
Posts: 416
Yes you can. Use the if command or modify arguments to change the behavior. Here are a couple of examples from my own library (increasing complexity).

Example 1. I got two versions of a move macro, one that is fast and a general one for moving a lot of data. Dependent of the number of bytes to be moved i select one of the two:
.macro Move(source, target, size) {
	.if (size <= $1000) :FastMove(source,target,size)
	else                :GeneralMove(source,target,size)
}

.macro FastMove(source, target, size) {
…..
}

.macro GeneralMove(source, target, size) {
...
}

Example 2. I got a 8/16 bit library that gives me amiga/pc like pseudo commands. Below is an example of an 8 bit adc command. You con give it 3 arguments it adds the first two and place the result in the third argument (eg: :add #3 ; table1,x ; result). But you can also leave out the third argument and then the result is placed in the second (eg: :add #3 ; score)
.pseudocommand adc arg1;arg2;tar {
	.if (tar.getType()==AT_NONE) .eval tar=arg2
	lda arg2
	adc arg1
	sta tar
}

Example 3. Now lets take the 16bit version of the adc command which is a bit harder since the highbyte of each argument should be treated different dependent on the mode of the arguments (absolute, immediate, zeropage, etc). Eg if you have an immediate argument like #$1234 the the lowbyte is 34 and the highbyte is 12, but if you have an absolute like $1000 then the lowbyte is in $1000 and the highbyte is in $1001. To take care of this we define a nextArguent function and use it as show below.
.pseudocommand adc16 arg1 ; arg2 ; tar {
	.if (tar.getType()==AT_NONE) .eval tar=arg2
	lda arg2
	adc arg1
	sta tar
	lda _16bit_nextArgument(arg2)
	adc _16bit_nextArgument(arg1)
	sta _16bit_nextArgument(tar)
}

.function _16bit_nextArgument(arg) {
	.if (arg.getType()==AT_IMMEDIATE) .return CmdArgument(arg.getType(),>arg.getValue())
	.return CmdArgument(arg.getType(),arg.getValue()+1)
}

// the above macro is use like this:
:add16 #$2800 ; $1000
:add16 screen ; offset ; zpPointer


2010-06-30 06:37
TWW

Registered: Jul 2009
Posts: 542
Awesome.

Seriously, Thanx for such a cool tool!

TWW/Creators
2010-06-30 13:33
Mace

Registered: May 2002
Posts: 1799
Hmm, 'nested' macros... interesting and simple, yet I never thought of it :-)
Previous - 1 | ... | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ... | 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
E$G/hOKUtO fOrcE
Sentinel/Excess/TREX
Murphy/Exceed
algorithm
Jammer
El Jefe/Slackers^sidD
grennouille
wil
acrouzet/G★P
Starfox
Guests online: 88
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 Uncensored  (9.6)
7 Comaland 100%  (9.6)
8 No Bounds  (9.6)
9 Aliens in Wonderland  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Birth of a Flower  (9.5)
9 Morph  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Offence  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Talent  (9.6)
4 Facet  (9.6)
5 Mermaid  (9.6)

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