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....
 
2012-12-04 11:15
chatGPZ

Registered: Dec 2001
Posts: 11114
Quote:
this does not work with labels & I dont feel like wrapping everything with blocks of .define and .if. What am I missing?

generally kickass does NOT have a preprocessor as you know from other assemblers, the .if stuff works fundamentally different. i find this very annoying myself, it often requires quite fucked up (and typing intensive) workarounds to do a whole lot of things i am used to from other environments.
2012-12-04 11:17
raven
Account closed

Registered: Jan 2002
Posts: 137
Hi Cruzer

I'm doing this (just an example):

.if (DEBUG == 1) {
.const SomeVar1 = $4000
.const SomeVar2 = $4800
} else {
.const SomeVar1 = $5000
.const SomeVar2 = $5800
}

Problem is, the consts are not seen outside the if/else scope, without also using .define.
And what about labels, how do I make them seen outside?


2012-12-04 11:20
chatGPZ

Registered: Dec 2001
Posts: 11114
you cant - fucked up workarounds are needed as i said (and be sure you only have two possibilites as in your example - if you have three or more things become *really* fucking ugly =P)

one that works for two is to write it like this (yes its annoying)

blabla = DEBUG == 1 ? $1234 : $5678
2012-12-04 12:29
Cruzer

Registered: Dec 2001
Posts: 1048
How about this:
.var SomeVar1 = 0
.var SomeVar2 = 0
.if (DEBUG == 1) {
	.eval SomeVar1 = $4000
	.eval SomeVar2 = $4800
} else {
	.eval SomeVar1 = $5000
	.eval SomeVar2 = $5800
}
Unless there's something consts can that vars can't.
2012-12-04 18:29
Cruzer

Registered: Dec 2001
Posts: 1048
Making a label visible outside requires a workaround like this:
.var label = 0
.if (true) {
label2:	nop
	.eval label = label2
}
	jmp label
Doesn't work if you wanna access it before though, which I gotta agree is quite annoying.
2012-12-04 23:05
Slammer

Registered: Feb 2004
Posts: 416
Can you give me some 'real world' examples. I see two roads:

1. Create the possibility of multiple var declarations in the same var to ease the declarations outside the scope. Eg: .var a,b,c,d

2. Create some preparse commands, but I'm afraid to confuse people by having (Almost) the same functionality twice so I will need some code that shows how big the need are.
2012-12-05 08:07
Frantic

Registered: Mar 2003
Posts: 1627
What about adding something kind of handling of scope levels? ...such as being able to define lables with global scope within a sub-scope, as well as making a variable visible in its parent scope(s).
.if (CONDITION1) {
	.if (CONDITION2) {
		.var @0SomeVar1 = $4000 ;Make visible in global scope
		.var @-1SomeVar2 = $4800 ;Make visible in parent scope
		.var @-2SomeVar3 = $5000 ;Make visible in two levels of parent scope
	} else {
		.var @0SomeVar1 = $8000 ;Make visible in global scope
		.var @-1SomeVar2 = $8800 ;Make visible in parent scope
		.var @-2SomeVar3 = $9000 ;Make visible in two levels of parent scope 
	}
	.var @0SomeVar4 = SomeVar2*2
}

More or less this is how it works in a few other assemblers I have tried. ..and it also resembles common keywords in all sorts of languages like putting the "global" keyword in front of variable declarations within a scope (e.g. "global int SomeVar = 0x04800;".
2012-12-05 18:54
Slammer

Registered: Feb 2004
Posts: 416
Frantic, That is a possibility. The notation is a bit cryptic but i will do the job.
2012-12-05 22:12
Cruzer

Registered: Dec 2001
Posts: 1048
I still don't get why people wanna declare vars inside if-blocks. Can't they just assign them? Of course it requires more typing to declare them before, but as Slammer suggested, it might help if you could declare multiple vars in one statement. I don't think this is worth introducing a new notation for.

Accessing labels inside if-blocks I can see the need for, although it's very seldom that I have actually needed it. But it would be nice to be able to use them like any other local labels inside blocks:
block:
.if (true) {
	label: nop
}
jmp block.label
Of course there should be an error if the if-condition is false, but that would be like any other reference to a non-existing label I guess.
2012-12-06 06:13
Slammer

Registered: Feb 2004
Posts: 416
Yes. Examples is important to see whats nice or not. If xyz.myvar does the job then making hashtables implement this kind of notation is a nice solution.
.var opt = Hashtable()
.if(something)
   .eval opt.myvar = 1234
else
   .eval opt.myvar = 6789

jmp opt.myvar

It depends on the context in which the variables are used.
Previous - 1 | ... | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | ... | 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
JCH/Vibrants
Doc Snyder/ONS
rambo/Therapy/ Resou..
cobbpg
Guests online: 113
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 Memento Mori  (9.6)
10 Bromance  (9.5)
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 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (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 Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Lobo  (9.7)
4 Mikael  (9.7)
5 Archmage  (9.7)

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