| |
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.... |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
My guess is that you do like this:
-----------main.asm---------------
.import source "file1.asm"
.import source "file2.asm"
.var myNumber=42
-----------file1.asm---------------
lda #myNumber
This will not work since the variable is declared after file1.asm is included, so the variable is used before it is declared.
There are two solutions:
1. Define your vars before the import statements
2. Define your vars as labels (this will cost you an extra pass when assembling since the value first will be ready in pass two, but you probably don't care about this)
The following should work:-----------main.asm---------------
.import source "file1.asm"
.import source "file2.asm"
.label myNumber=42
-----------file1.asm---------------
lda #myNumber |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Or import globals.asm as the first file in main.asm, that way it doesn't need to be imported into all the other files. |
| |
Mace
Registered: May 2002 Posts: 1799 |
There is no way to incorporate binary data as ASCII in the source with KickAss, is there?
Something like BASE64? |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
You can write a decode macro that does it. Something like:
.var base64Str = "sfkjfsjdfisjhfijsifjsdkjfskdjf";
:Base64Decode(base64Str)
.marcro Base64Decode(str) {
// for all chars in str look up value in decode table and make a .byte directive to output the data
} I'm curious, how is this useful? |
| |
Mace
Registered: May 2002 Posts: 1799 |
So I could post on forums a source that includes binary data, without having to type all bytes with .byte. :-)
It's not that I really NEED it, but I was just wondering. |
| |
Conjuror
Registered: Aug 2004 Posts: 168 |
I have a question about scoping. Is there anyway to access variables within a scope block, such as:
lda #$03
sta scroller.rowCount + 1
scroller: {
rowCount:
ldx #$03
...
rts
}
note: example only
Otherwise I'd have to expose the entire 'function' and its labels/variables to the rest of the program. Yes I am a JAVA programmer :D
Steve |
| |
Mace
Registered: May 2002 Posts: 1799 |
@ Conjuror: yes, check pages 18 and 34 of the manual.
Also, you could place your label inside the scope better, so that it points to the address itself instead of having to do calculations outside the scope. |
| |
Conjuror
Registered: Aug 2004 Posts: 168 |
Thanks Mace, thats just embarrassing. I was very tired today. |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
As Mace said, it is supported. Another example of 'auto namespacing' is when you put a label before a macro execution. This will enable you to access the labels inside the macro which is quite useful. |
| |
Mace
Registered: May 2002 Posts: 1799 |
Quote:Another example of 'auto namespacing' is when you put a label before a macro execution. Blimey, I needed that! Thanks :-) |
Previous - 1 | ... | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ... | 61 - Next |