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..
 
... 592 posts hidden. Click here to view all posts....
 
2011-09-27 14:39
TWW

Registered: Jul 2009
Posts: 542
Hey!


Is there a clever way to count the amount of bytes used in a routine within KickAss?

something like (creating an index table):

.pc = begin
CODE
.pc = end

.for (var i = 0 ; i < 128 ; i++) {
.byte <STUFF+[i*[end-begin]]
}

cheers!
2011-09-27 14:52
Cruzer

Registered: Dec 2001
Posts: 1048
Something like this?...

.var length = end - start
start:
    nop
end:
.print "length:" + length

2011-09-27 17:32
TWW

Registered: Jul 2009
Posts: 542
Quote: Something like this?...

.var length = end - start
start:
    nop
end:
.print "length:" + length



Yepp, Exactly like that 8-D

Easier then I thought^^

Thanx!
2011-10-01 08:58
tlr

Registered: Sep 2003
Posts: 1736
Am I missing something here?

This works:
	.pc = $1000

.const TEST_ENABLE = true

.macro test(v) {
	.byte v
}

.if (TEST_ENABLE) {
	:test(2)
}


This doesn't:
	.pc = $1000

.const TEST_ENABLE = true

.if (TEST_ENABLE) {
.macro test(v) {
	.byte v
}
	:test(2)
}

(fails with "Error: Macro command 'test' not defined")

Seems pretty unintuitive to me, especially as the if is enabled by a constant.
2011-10-01 16:01
Slammer

Registered: Feb 2004
Posts: 416
No, it's just a bad error message. Macros can't be defined inside if statements. They are collected in a preparse which makes it possible to define macros after you use them (eg. macro definitions in the bottom of your sourcefile).

Why do you want to place it inside an if? I'm guessing you have made a libraryfile and only want to define the macro once in the case the library is imported sevaral times? If thats the case, place an .importonce directive in the top of your library-file. It works as the if you had placed an #ifndef, #define XYZ, #endif in C++:

--------- KickAss Library File: ---------
.importonce 
... your code

--------- C++ Library File: ---------
#ifndef __MYLIB__ 
#define __MYLIB__
... your code
#endif
2011-10-01 16:10
tlr

Registered: Sep 2003
Posts: 1736
Quoting Slammer
No, it's just a bad error message. Macros can't be defined inside if statements. They are collected in a preparse which makes it possible to define macros after you use them (eg. macro definitions in the bottom of your sourcefile).

Why do you want to place it inside an if? ...


The .if in this case is for conditional compile. In this case the macro only relates to the code within that code block. Then it makes sense to be able to define the macro close to the code that actually uses it.

As a side note, not being able to set constants in the global scope from within an .if (in the conditional compile use) is rather inconvenient.

Should I be using some other construct for conditional compile?
2011-10-01 17:46
Pantaloon

Registered: Aug 2003
Posts: 124
ohh, i didnt know of the importonce, lovely!!!
2011-10-02 09:34
Slammer

Registered: Feb 2004
Posts: 416
Tlr: Like in java, you can't reach a variable declared inside an if (or for). If you want to access it outside the scope of the if, then declare it outside of the scope and set it inside.

Panta: Thanks :-)

2011-10-02 14:32
tlr

Registered: Sep 2003
Posts: 1736
Quoting Slammer
Tlr: Like in java, you can't reach a variable declared inside an if (or for). If you want to access it outside the scope of the if, then declare it outside of the scope and set it inside.

Will give predeclaration a go.

What's causing the confusion is that there is no preprocessor style if.
Other assemblers usually treat both if's and macros in a preprocessor sense, often even using multiple passes to resolve conflicts.

This of course causes some other problems (like oscillations) which you solve in kick assembler with much stricter parsing rules.

I'll see if I can figure out a way to adapt my coding style to this difference.
2011-10-05 03:37
TWW

Registered: Jul 2009
Posts: 542
Feature Request:

Maybee this is a posibility already but here goes:

Allow Suffixes to Pseudocommands according to some fixed syntax.

Ex:

A multiply routine can be called with either:

:MUL_S <- for Signed Mul (suffix being the "_S")

or

:MUL_U for Unsigned (Suffix is "_U").

This is just an example and so is the syntax but it would allow you to put both these routines inside one file instead of two (there would ofcourse have to be some way to use these suffixes inside the pseudo to make descicions).


Another thing:

Did the ".IfDefined" feature requested by someone before see the day of light?


Cheers!
Previous - 1 | ... | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | ... | 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
Knight Rider/TREX
Krill/Plush
csabanw
TheRyk/MYD!
Guests online: 81
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Aliens in Wonderland  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Birth of a Flower  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Offence  (9.3)
Top Logo Graphicians
1 Sander  (9.9)
2 Facet  (9.5)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

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