| |
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.... |
| |
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! |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Something like this?...
.var length = end - start
start:
nop
end:
.print "length:" + length
|
| |
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! |
| |
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.
|
| |
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 |
| |
tlr
Registered: Sep 2003 Posts: 1736 |
Quoting SlammerNo, 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? |
| |
Pantaloon
Registered: Aug 2003 Posts: 124 |
ohh, i didnt know of the importonce, lovely!!! |
| |
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 :-)
|
| |
tlr
Registered: Sep 2003 Posts: 1736 |
Quoting SlammerTlr: 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.
|
| |
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 |