| |
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.... |
| |
Agemixer
Registered: Dec 2002 Posts: 38 |
Hi,
I'm still new to kickassembler and found this thread - in need to continue with the question about conditional assembly.. But it's not exactly the same. I needed something like this to remove some debug code from the final product (simplified example):
.label DEBUG_MODE=1
.if (DEBUG_MODE==1) // debug mode
{
lda #$00
sta $d020
MODIFY_THIS:
lda #$00
sta $d020
}
lda #$00 // normal or debug mode
sta $d020
.if (DEBUG_MODE==1) // debug mode
{
inc MODIFY_THIS+1
}
rts
..which gives "Error: Unknown symbol 'MODIFY_THIS'"
So i needed to pull all labels like MODIFY_THIS out of .if, to get it compiled:
.if (DEBUG_MODE==1) // debug mode
{
lda #$00
sta $d020
}
MODIFY_THIS:
.if (DEBUG_MODE==1) // debug mode
{
lda #$00
sta $d020
}
lda #$00 // normal or debug mode
sta $d020
.if (DEBUG_MODE==1) // debug mode
{
inc MODIFY_THIS+1
}
rts
Are there any better way of doing similiar conditional assembly such like this? I don't even know which order kickass parses the asmfile, but this is just strange. Is that the same scope issue in question? I got a plenty of SMC labels like Something=*-1 so my code looks like ANYTHING else but CLEAN because of this :)
How you would create that kind of label touching code? I spent just several hours just because of this... |
| |
Pantaloon
Registered: Aug 2003 Posts: 124 |
To my knowledge the labels are limited to it's scope.
One way of doing the thing you want could be this.
.label DEBUG_MODE=1
.var MODIFY_PTR = 0
.if (DEBUG_MODE==1) // debug mode
{
lda #$00
sta $d020
.eval MODIFY_PTR = *
lda #$00
sta $d020
}
lda #$00 // normal or debug mode
sta $d020
.if (DEBUG_MODE==1) // debug mode
{
inc MODIFY_PTR+1
}
rts |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
seems overcomplicated.. how about:
lda #debug_mode
sta $d020
or:
if debug_mode
inc $d020
else
sta $d020
etc. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11111 |
Quote:Are there any better way of doing similiar conditional assembly such like this?
use an assembler that properly supports scoping. |
| |
Pantaloon
Registered: Aug 2003 Posts: 124 |
i was waiting for that comment from Groepaz :) |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
I guess Groepaz is the kind of person who goes down to the store to buy a tool so he can cook an egg. The clerk sells him a frying pan and the next day he comes back complaining that the pan is a terrible pot and that he can't get the egg hard-boild!
Groepaz: I think you mean an assembler that does not support scoping, not an assembler that supports scoping properly. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11111 |
i mean exactly what i said. and no, "not the right tool for the job" does not apply here at all. hardly any other assembler is broken like this. |
| |
soci
Registered: Sep 2003 Posts: 473 |
Works as designed, it seems. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11111 |
i am not doubting that at all :) |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
"I got a plenty of SMC labels like Something=*-1 so my code looks like ANYTHING else but CLEAN because of this :)
How you would create that kind of label touching code? I spent just several hours just because of this..."
I guess its a matter of habit what's comfortable & clean to you. I usually do this:
smod lda #$00
sta $d020
inc smod+1
this keeps the label and the instruction on the same line *-x wont fuck up, since you cant insert extra instruction inbetween, furthermure its obvious where the label points no *+ fucking, and one label is enough to reach lo/hi / instruction.
if the branch is really close then just:
inc $d020
jmp *-3
lda #$03
adc $02
sta $02
bcc *+3
inc $03
but I only use it in very simple cases like this. if you insert an instruction and forget to update the * you're fucked. |
Previous - 1 | ... | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | ... | 61 - Next |