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 - Removal of unused code?
2019-02-05 15:04
Taskmaster
Account closed

Registered: Feb 2018
Posts: 22
Kick Assembler - Removal of unused code?

I'm trying out Kick Assembler and I'm wondering if it has a feature I used a lot in my own assemblers over the years.

I like to collect useful subroutines and keep them in an external ASM file that I include at the top of my code. Is there a way that I can do that BUT have the assembler not compile code that I don't actually call?

I hate to eat the memory space for stuff that I won't be calling in that specific app.

How do you guys handle this sort of thing? Am I over engineering? :)
 
... 20 posts hidden. Click here to view all posts....
 
2019-02-06 19:58
Frantic

Registered: Mar 2003
Posts: 1648
That is already described in the first post?
2019-02-06 20:06
Taskmaster
Account closed

Registered: Feb 2018
Posts: 22
To be fair, we sort of switched topics ... or side stepped, anyway.

But currently what I'm looking to do is use the Kick scripting language, or something else, to generate code.

This would allow me to write some generic wrapper macros that would auto-write the boilerplate necessary for the technique that Digger was sharing.
2019-02-06 23:29
Digger

Registered: Mar 2005
Posts: 437
Here's slightly "abstracted out" and cleaner version, using some tips from Slammer:
https://pastebin.com/print/cZqgdv7C

What remains is to figure out:
1) the ways of passing params to these lib code, a good write-up here: https://maciejmalecki.github.io/blog/macro-hosted-subroutines
2) what's the best way to utilise macro's variables
2019-02-07 00:54
Taskmaster
Account closed

Registered: Feb 2018
Posts: 22
Wow, this got a lot deeper than I was expecting ... thanks for the replies, everyone, it's been informative!
2019-02-08 10:48
Taskmaster
Account closed

Registered: Feb 2018
Posts: 22
So, to underscore what I wanted to do here in the end ... I wanted some way to boilerplate the code that Digger inspired above.

LONG STORY SHORT, I WANT TO USE THE SCRIPTING LANGUAGE TO GENERATE CODE THAT THEN GETS COMPILED AS IF I HAD TYPED IT.

Code like this gives me what I want, in terms of conditional compilation and I love it:

NOTE : SUBSYS_MasterAddr is defined elsewhere.

.var GFX_HideROMCharSet_Addr = 0

.macro GFX_HideROMCharSet()
{
	.if( GFX_HideROMCharSet_Addr == 0 )
	{
		.var save_pc = *
		* = GFX_HideROMCharSet_Addr = SUBSYS_MasterAddr
		{
			lda #$37
			sta $01
			cli

			rts
		}

		.eval SUBSYS_MasterAddr = *
		* = save_pc
	}

	jsr GFX_HideROMCharSet_Addr
}


The trouble is, this is all the code that I actually need:

			lda #$37
			sta $01
			cli


All the rest is boilerplate cruft. So I wanted a way, in Kick Assembler, to generically insert that code for me. But I need some sort of text replacement ability before compilation begins. It FEELS like it should be possible. So something like:

ProcStart(GFX_HideROMCharSet)
{
	lda #$37
	sta $01
	cli
}
ProcEnd(GFX_HideROMCharSet)


"ProcStart" and "ProcEnd" take the name I provide it and drop it into the assigned slots in the code templates and away we go. So, everywhere you see a [ARG_HERE] ...

-----------------------
ProcStart
-----------------------
.var [ARG_HERE]_Addr = 0

.macro [ARG_HERE]()
{
	.if( [ARG_HERE]_Addr == 0 )
	{
		.var save_pc = *
		* = [ARG_HERE]_Addr = SUBSYS_MasterAddr
		{


-----------------------
ProcEnd
-----------------------
			rts
		}

		.eval SUBSYS_MasterAddr = *
		* = save_pc
	}

	jsr [ARG_HERE]_Addr
}


This feels like it SHOULD be scriptable ... is it?
2019-02-08 16:25
Digger

Registered: Mar 2005
Posts: 437
Check my pastebin code above :)
2019-02-08 16:35
Taskmaster
Account closed

Registered: Feb 2018
Posts: 22
I saw that, thanks!

And that is a way to get where I'm going but I'm now wondering about the more generic question ...

Is there a way to write code with the Kick scripting language so that it dynamically creates source that will be compiled in later passes?

I know you can use FOR loops with VARs and modify operand arguments, but ... is there any way to emit straight text or strings?

Like, if I have:

.var myCmd = "lda #0"

Can I get that "lda #0" line emitted to the source code somehow?
2019-02-08 18:45
Digger

Registered: Mar 2005
Posts: 437
Why would you like to do it?
I often use JS to generate the KickAss code that later gets compiled, but that's useful usually for speed code, for example for texture lookups.
2019-02-08 19:11
Oswald

Registered: Apr 2002
Posts: 5094
	* = $1000
	
changebackr	.proc	
	sta $d020
	rts
	.pend

	jmp * 


result in memory:

.C:1000 4C 00 10 JMP $1000

	* = $1000
	
changebackr	.proc	
	sta $d020
	rts
	.pend

	jsr changebackr
	jmp *


result in memory:

.C:1000 8D 20 D0 STA $D020
.C:1003 60 RTS
.C:1004 20 00 10 JSR .changebackr
.C:1007 4C 07 10 JMP $1007


also macros do what you want in your post #1, they only get compiled into memory when you use them.

	* = $1000
	
changebackgr	.macro
	lda #\1
	sta $d020
	.endm

	#changebackgr 0
	jmp *


result in memory:

.C:1000 A9 00 LDA #$00
.C:1002 8D 20 D0 STA $D020
.C:1005 4C 05 10 JMP $1005
2019-02-08 21:12
Compyx

Registered: Jan 2005
Posts: 631
That looks like 64tass code. The topic is about Kickassembler.
Previous - 1 | 2 | 3 - 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
iAN CooG/HVSC
Martinland
Nordischsound/Hokuto..
zscs
tlr
ΛΛdZ
Doc Snyder/ONS
Brataccas/HF
Nuckhead/Backbone So..
Freeze/Blazon
Dano/Padua
Chesser/Blazon
REBEL 1/HF
Guests online: 125
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

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