Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > Kick Assembler - Removal of unused code?
2019-02-05 15:04
Taskmaster

Registered: Feb 2018
Posts: 19
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: 1370
That is already described in the first post?
2019-02-06 20:06
Taskmaster

Registered: Feb 2018
Posts: 19
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: 313
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

Registered: Feb 2018
Posts: 19
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

Registered: Feb 2018
Posts: 19
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: 313
Check my pastebin code above :)
2019-02-08 16:35
Taskmaster

Registered: Feb 2018
Posts: 19
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: 313
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: 4365
	* = $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: 429
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
markus sinalco
Moloch/TRIAD
swasti
JCH/Vibrants
Compyx/Focus
0xDB/NOOP
Scan/House Designs
redcrab/G★P
Walt/Bonzai
Guests online: 78
Top Demos
1 Unboxed  (9.7)
2 Uncensored  (9.7)
3 Edge of Disgrace  (9.7)
4 Coma Light 13  (9.6)
5 Comaland 100%  (9.6)
6 The Shores of Reflec..  (9.6)
7 Lunatico  (9.6)
8 C=Bit 18  (9.6)
9 Wonderland XII  (9.5)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Smile to the Sky  (9.6)
2 Daah, Those Acid Pil..  (9.5)
3 Dawnfall V1.1  (9.4)
4 FMX Music Demo  (9.4)
5 Crystal Gazer  (9.4)
6 Rewind  (9.4)
7 Pandemoniac Part 2 o..  (9.4)
8 Official X2018 Report  (9.4)
9 Arok 20 Invitation  (9.4)
10 Party Horse  (9.3)
Top Groups
1 PriorArt  (9.7)
2 Performers  (9.5)
3 Oxyron  (9.5)
4 Booze Design  (9.4)
5 Censor Design  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.9)
2 Veto  (9.8)
3 Jailbird  (9.6)
4 Mirage  (9.6)
5 Mermaid  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2019
Page generated in: 0.058 sec.