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: 425
Kick Assembler Thread 2

The previous thread took a little long to load, so this is a new fresh one..
 
... 594 posts hidden. Click here to view all posts....
 
2023-08-09 18:54
trident

Registered: May 2002
Posts: 101
Quote: I have a small problem, and I don't know if Kick Assembler has a way to provide the solution.

What I think I'd need is dynamic labels - that is, labels that are created and named dynamically at compile time.

In my macro, i'm generating code based on some input data, and I'd need labels within that code (in positions and numbers I don't know of yet at the time of generating the code). Then I'm generating another code block that would refer to those generated labels.

E.g. first bit of macro creates code with label1, label2, label3 etc.

Second bit of macro creates code that updates the values at the aforementioned labels.

As far as I can see this is not possible, at least with the usual labels that seem to be always hard-coded? Any other ideas how to do something like this?


Instead of using a bunch of labels, you can create a list to keep track of the addresses, and then use that list to reach them. Like this:

.var ldas = List()

.macro the_macro_that_creates_the_code() {
.eval ldas.add(* + 1)
lda #0
sta $d020
}

Then, further down in the code:

.macro the_macro_that_refers_to_the_created_code() {
.for (var i = 0; i < ldas.size(); i++) {
lda colors + i,x
sta ldas.get(i)
}
}
2023-08-09 21:51
Frostbyte

Registered: Aug 2003
Posts: 184
Quote: Instead of using a bunch of labels, you can create a list to keep track of the addresses, and then use that list to reach them. Like this:

.var ldas = List()

.macro the_macro_that_creates_the_code() {
.eval ldas.add(* + 1)
lda #0
sta $d020
}

Then, further down in the code:

.macro the_macro_that_refers_to_the_created_code() {
.for (var i = 0; i < ldas.size(); i++) {
lda colors + i,x
sta ldas.get(i)
}
}


Ahhh of course, brilliant! Thank you! I haven't tried it yet, but I can already see it solves my problem. :)
2023-08-09 22:35
Slammer

Registered: Feb 2004
Posts: 425
This is probably one of the most asked questions. There are different ways to handle these kind of cases one of them is shown by Trident. Let me point you to another feature that solves it quite nicely.

Normally, when you want label1, label2, etc. the labels are inside a loop, like:
	spriteLoop: .for (var i=0; i<8; i++) {
		lda data: #0    // <- Fancy inbetween label declaration so you dont need +1
		sta $07f8+i
	}

You can now use the 'spriteLoop' label to access the 'data' labels of the different iterations of the loop like this:
	lda #0
	sta spriteLoop[0].data  // Sprite 0   
	sta spriteLoop[1].data  // Sprite 1   
	sta spriteLoop[2].data  // Sprite 2
	...   

	// Or simply .for (var i=0; i<8; i++) sta spriteLoop[i].data

If you want to do a table with the addresses, simply:
	addrTable: .fill  8, <spriteLoop[i].data  

You can access the labels of an executed macros by putting a label in front of the execution, just like we did with the .for loop.
2023-08-09 22:40
Slammer

Registered: Feb 2004
Posts: 425
With regards to the dicussion earlier in the thread. Several years ago I moved the main feedback/support channel of Kick Assembler to the following facebook group:

https://www.facebook.com/groups/RetroAssembler

This was to ensure a forum were the discussion where not interupted by other things. You are welcome to join regardless of which assembler you are using.

(Please notice that I do not visit this CSDb thread often).
2023-08-10 12:49
Frostbyte

Registered: Aug 2003
Posts: 184
Quote: With regards to the dicussion earlier in the thread. Several years ago I moved the main feedback/support channel of Kick Assembler to the following facebook group:

https://www.facebook.com/groups/RetroAssembler

This was to ensure a forum were the discussion where not interupted by other things. You are welcome to join regardless of which assembler you are using.

(Please notice that I do not visit this CSDb thread often).


Yesterday I sent a request to join that group, but it's still pending. :)
2023-08-10 12:54
Frostbyte

Registered: Aug 2003
Posts: 184
Quote: This is probably one of the most asked questions. There are different ways to handle these kind of cases one of them is shown by Trident. Let me point you to another feature that solves it quite nicely.

Normally, when you want label1, label2, etc. the labels are inside a loop, like:
	spriteLoop: .for (var i=0; i<8; i++) {
		lda data: #0    // <- Fancy inbetween label declaration so you dont need +1
		sta $07f8+i
	}

You can now use the 'spriteLoop' label to access the 'data' labels of the different iterations of the loop like this:
	lda #0
	sta spriteLoop[0].data  // Sprite 0   
	sta spriteLoop[1].data  // Sprite 1   
	sta spriteLoop[2].data  // Sprite 2
	...   

	// Or simply .for (var i=0; i<8; i++) sta spriteLoop[i].data

If you want to do a table with the addresses, simply:
	addrTable: .fill  8, <spriteLoop[i].data  

You can access the labels of an executed macros by putting a label in front of the execution, just like we did with the .for loop.


Nice! As in my scenario I don't know how many labels I'll end up with, I suppose in the second loop I could also iterate while i < spriteLoop.size()? (in other words, compiler considers spriteLoop as an array or list?)
2024-05-11 13:28
mutetus

Registered: Dec 2020
Posts: 13
I'm having a small problem (ka 5.25). So, this works:
.var filename = "textfile.txt"
.import binary filename

But .import text filename doesn't work and it doesn't even tell me what the problem is. Any way around this?
2024-05-12 13:33
Maxlide

Registered: Apr 2003
Posts: 33
Huhm.
When using a string literal instead of a variable it works.
.import text "textfile.txt"

But why .import binary is working fine with a variable and .import text is not... Well, very odd!
2025-04-15 08:29
TWW

Registered: Jul 2009
Posts: 548
KickAss has the possibility to create tables with Lo/Hi byte pointers as follows:

Table:
    .lohifill 4, List().add($00a0, $01b0, $02c0, $03d0).get(mod(i,16))


Then the LoByte table and HiByte table can be accessed as follows:

    ldx #whatever
    lda Table.lo,x
    sta $fb
    lda Table.hi,x
    sta $fc


The lengt of the table does not matter, as the .lo/.hi affixes will point to the correct memory location for the tables.

------------------

Now to the question;

Is there a way to know if an address or pointer such as this 'Table' pointer is passed to a pseudocommand (i.e. that it has 2 pointers attached to it or however the internals of this works), and is there a way to easily derive the .lo/.hi addresses within said pseudo?

Reason for the question is because I would like to do this instead of the above example of use:

    ldx #whatever
    mov16 Table,x : $fb
2025-04-16 23:48
Slammer

Registered: Feb 2004
Posts: 425
I know why you want it, since I have also been in a situation where it would be handy. But currently you cannot do that. If you wanna support it you could make a dedicated command like this (Not tested):

	.pseudocommand movlh lo : hi : tar {
		lda lo
		sta tar
		lda hi
		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)
	}

	usage:	
	movlh table.lo,x : table.hi,x : $fb



The types you can give currently are the normal mnemonic modes (abs, immediate, absx, etc). But there are other situations where extra types are useful. For instance being able to give regA, regX and regY as arguments to a pseudocommand is very usful for e.g. telling the command to leave the result in register A instead of a memory address. So i might extend the pseudocommand arguments in the future. (NB you can achieve regA, regX and regY by being a little creative, but a dedicated argumenttype is nicer)
Previous - 1 | ... | 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
Mr. Mouse/XeNTaX/G*P
cba
zzarko/Avatar
hedning/G★P
TheRyk/MYD!
dstar/Fairlight
ciccior2003/HF
Acidchild/Padua
Kimono
Guests online: 107
Top Demos
1 Signal Carnival  (9.7)
2 Next Level  (9.7)
3 13:37  (9.7)
4 Codeboys & Endians  (9.7)
5 Coma Light 13  (9.6)
6 Mojo  (9.6)
7 Edge of Disgrace  (9.6)
8 The Trip  (9.6)
9 In Surgery  (9.6)
10 Uncensored  (9.6)
Top onefile Demos
1 Nine  (9.8)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Dawnfall V1.1  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 TRSAC, Gabber & Pebe..  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Censor Design  (9.2)
5 Triad  (9.2)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

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