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....
 
2023-07-11 03:06
Martin Piper

Registered: Nov 2007
Posts: 634
Since I modified Acme to add python scripting support and exhaustive forward label resolution (it retries passes until all labels are defined consistent values) I prefer that assembler. :)
2023-07-11 17:41
Frantic

Registered: Mar 2003
Posts: 1627
Quote: Since I modified Acme to add python scripting support and exhaustive forward label resolution (it retries passes until all labels are defined consistent values) I prefer that assembler. :)

Where is that version of ACME available, if anywhere?
2023-07-12 09:32
Martin Piper

Registered: Nov 2007
Posts: 634
Quote: Where is that version of ACME available, if anywhere?

Win binaries: https://github.com/martinpiper/ACME/tree/master/Release

Tests:
https://github.com/martinpiper/ACME/blob/master/features/CheckF..
https://github.com/martinpiper/ACME/blob/master/features/CheckP..

https://github.com/martinpiper/ACME/blob/master/TestPython.a#L17

Source in same repo.
2023-08-09 17:56
Frostbyte

Registered: Aug 2003
Posts: 166
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?
2023-08-09 18:54
trident

Registered: May 2002
Posts: 74
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: 166
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: 416
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: 416
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: 166
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: 166
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?)
Previous - 1 | ... | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 - 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
Quetzal/Chrome
Exile/Anubis
kbs/Pht/Lxt
Sentinel/Excess/TREX
Mr. Spock/T'Pau
Ghost/Quantum
Guests online: 123
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 Logo Graphicians
1 Sander  (10)
2 Facet  (9.7)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

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