| |
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.... |
| |
Conjuror
Registered: Aug 2004 Posts: 168 |
Slammer,
Great work! thanks. This will really help with more flexible code creation.
Nice to see the ternary operator in there too.
|
| |
McKrackeN
Registered: Feb 2011 Posts: 20 |
Hey ppl! I have a newbie question: is there a way to use constants inside a macro?
For instance, I need to be able to do something like this:
.const MyConst = $d012
.macro myMacro(val)
{
ldy #val
sty MyConst
}
But I get an error when compiling.
Thanks in advance! :) |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Constants are visible after you have defined them. So the example you give, will work if you declare your const before you use the macro:
:MyMacro($32) // This won't work
.const MyConst = $d012
:MyMacro($32) // This will work
.macro myMacro(val)
{
ldy #val
sty MyConst
}
However, labels can be seen in the whole scope so they can be used before they are declared:
:MyMacro($32) // This will work
.label MyLabel = $d012
.macro myMacro(val)
{
ldy #val
sty MyLabel
} |
| |
McKrackeN
Registered: Feb 2011 Posts: 20 |
Thanks for your help!
I think i'm declaring the constant before using the macro but i'm still getting the compiler error.
I have two separate files. One called system.asm and the other test.asm.
// System.asm
.const MyConst = $d012
.macro myMacro(val)
{
ldy #val
sty MyConst
}
Then in the test.asm:
// test.asm
.import source "system.asm"
// some code
:myMacro(0)
|
| |
Slammer
Registered: Feb 2004 Posts: 416 |
I Just tried it and it works fine here. My guess is that you define the macro+constant inside one scope and execute your macro outside the scope. Eg. if you start you system.asm file with a .filenamespace directive.
|
| |
McKrackeN
Registered: Feb 2011 Posts: 20 |
Yes!! That's it!! Thanks for your help and for this amazing compiler!! |
| |
TWW
Registered: Jul 2009 Posts: 542 |
How would I go about doing a:
.fill 256,invert(data.get(i))
i.e. invert the data filled into memory on the fly? |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Suppose by invert you mean exclusive or you can:
.fill 256,data.get(i)^$ff |
| |
chatGPZ
Registered: Dec 2001 Posts: 11168 |
i found this bug:
test1.asm:
.if (1 == 1) {
.import source "test2.asm"
}
test2.asm can be whatever (even empty file)
assembling results in the following error:
.if (1 == 1) {
.import source "test2.asm"
^
Error: Unknown import type 'source'
at line 3, column 5 in test1.asm
additional question: if there are labels defined in test2.asm, then how do i export them outside the scope of the if statement? (i find it really super useless and annoying that if statements have their own scope to be honest, it effectively prevents me from being able to use them properly :/)
eg i am used to do stuff like this:
.if testing = 1
screen = $0400
chars = $0800
.else
screen = $e400
chars = $e800
.endif
how do you do this in kickass? (assuming there are many more such labels, replacing them all by a function is really not an option)
|
| |
TWW
Registered: Jul 2009 Posts: 542 |
Yepp, that's exactly what I ment. Thanx Slammer! |
Previous - 1 | ... | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | ... | 61 - Next |