Please be advised that access to Atari Forum this coming Friday will be sporadic whilst the backend operating system and dependency upgrades are carried out.
Devpac 3: can I unwrap a loop that contains labels
Moderators: Zorro 2, Moderator Team
-
- Obsessive compulsive Atari behavior
- Posts: 144
- Joined: Fri Jan 07, 2005 5:59 pm
- Location: St John's, Canada
Devpac 3: can I unwrap a loop that contains labels
Here is some pseudo-code I'd like to unwrap:
MOVE.W #15,D0
doit:
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
.skip
DBF D0,doit
Can the macro processor in devpac automatically put an index
at the end of the labels so that I can do something like this ?
REPT 16
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
.skip
ENDR
The problem I have at this time is that the ".skip" label is duplicated
16 times. Is there any way I can tell devpac to replace ".skip" with
".skip01", ".skip02", .... "skip16" ?
doggyfred
MOVE.W #15,D0
doit:
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
.skip
DBF D0,doit
Can the macro processor in devpac automatically put an index
at the end of the labels so that I can do something like this ?
REPT 16
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
.skip
ENDR
The problem I have at this time is that the ".skip" label is duplicated
16 times. Is there any way I can tell devpac to replace ".skip" with
".skip01", ".skip02", .... "skip16" ?
doggyfred
-
- Fuji Shaped Bastard
- Posts: 2048
- Joined: Tue Sep 21, 2004 9:33 pm
- Location: Kent, UK
-
- Obsessive compulsive Atari behavior
- Posts: 144
- Joined: Fri Jan 07, 2005 5:59 pm
- Location: St John's, Canada
-
- Hardware Guru
- Posts: 4704
- Joined: Sat May 29, 2004 7:52 pm
This is not a good idea. You will need to change the offset each time you make changes in the code. And you might forget and your program might crash without knowing why. Or you might change optimization options in the assembler and the offset might also change.unseenmenace wrote:If you know the size of the branch then you should be able to use an offset in the branch command rather than a label and then the Repeat directive will work properly.
Devpac has a solution for generating unique labels automatically, using the "\@" syntax. It doesn't work for REPT blocks, but it does for macros. So just put the code to be repeated in a macro:
Code: Select all
yourmacro macro
bne .skip\@
nop
.skip\@
endm
rept 16
yourmacro
endr
-
- Fuji Shaped Bastard
- Posts: 2048
- Joined: Tue Sep 21, 2004 9:33 pm
- Location: Kent, UK
-
- Obsessive compulsive Atari behavior
- Posts: 144
- Joined: Fri Jan 07, 2005 5:59 pm
- Location: St John's, Canada
-
- Administrator
- Posts: 2310
- Joined: Tue May 21, 2002 12:44 pm
- Location: Grenoble (38) - France
Re: Devpac 3: can I unwrap a loop that contains labels
Hi mister doggyfred,doggyfred wrote:Here is some pseudo-code I'd like to unwrap:
MOVE.W #15,D0
doit:
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
.skip
DBF D0,doit
When I see the source on the top, I demand myself if the code seems right like that ?
Code: Select all
MOVE.W #15,D0
doit:
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
bra .exit
.skip:
sub.w #1,d0
bra doit
.exit:
-
- Administrator
- Posts: 2310
- Joined: Tue May 21, 2002 12:44 pm
- Location: Grenoble (38) - France
Well, I think too much on this little code and I propose to you (mister doggy), 2 other things :
1- Call label procedure :
2- memory/stack storage access :
Maybe I'm wrong !?!
1- Call label procedure :
Code: Select all
sample:
rept 16
bsr my_proc
endr
end:
clr.w -(a7)
trap #1
my_proc:
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
.skip:
rts
Code: Select all
text
init:
lea code,a0
move.w #$B27C,(a0)+ * CMP.W #0,D1
move.w #$0000,(a0)+ * adr/offset
move.w #$6600,(a0)+ * BNE skip
move.w #$0004,(a0)+ * adr/offset
move.w #$4E71,(a0)+ * nop
move.w #$4E75,(a0) * skip : rts
sample:
rept 16
bsr code
endr
end:
clr.w -(a7)
trap #1
bss
code: ds.w 6
end
-
- Obsessive compulsive Atari behavior
- Posts: 144
- Joined: Fri Jan 07, 2005 5:59 pm
- Location: St John's, Canada
Hi Zorro 2,
Your code:
That snippet does pretty much the same thing as my pseudo-code,
however you have 16 BSR in there, which is cycle consuming (use of
the stack in a sub call). I was looking to unwrap my loop to optimize speed.
The solution involving a macro is perfect in that regard.
Thanks,
Doggyfred
Your code:
Code: Select all
sample:
rept 16
bsr my_proc
endr
end:
clr.w -(a7)
trap #1
my_proc:
CMP.W #0,D1
BNE .skip
NOP ; (some useful code here)
.skip:
rts
however you have 16 BSR in there, which is cycle consuming (use of
the stack in a sub call). I was looking to unwrap my loop to optimize speed.
The solution involving a macro is perfect in that regard.
Thanks,
Doggyfred
-
- Atari God
- Posts: 1317
- Joined: Sat Dec 28, 2002 4:49 pm
You could use a code generator too:doggyfred wrote:Hi Zorro 2,
Your code:That snippet does pretty much the same thing as my pseudo-code,Code: Select all
sample: rept 16 bsr my_proc endr end: clr.w -(a7) trap #1 my_proc: CMP.W #0,D1 BNE .skip NOP ; (some useful code here) .skip: rts
however you have 16 BSR in there, which is cycle consuming (use of
the stack in a sub call). I was looking to unwrap my loop to optimize speed.
The solution involving a macro is perfect in that regard.
Thanks,
Doggyfred
Code: Select all
lea doit(pc),a1
moveq #15,d1
copyloop:
lea code,a0
move.w #(skip-code)/2-1,d0
copyloop2:
move.w (a0)+,(a1)+
dbra d0,copyloop2
dbra d1,copyloop
....
doit: ds.b (skip-code)*16
....
code:
CMP.W #0,D1
BNE skip
NOP ; (some useful code here)
skip:

George
is 73 Falcon patched atari games enough ? ^^
-
- Administrator
- Posts: 2310
- Joined: Tue May 21, 2002 12:44 pm
- Location: Grenoble (38) - France
Yep mister George, it much easier to use your code that mine !ggn wrote: You could use a code generator too:
And this ensures that your routine between 'code' and 'skip' will be copied 16 times. A bit more messy that macros, but Turbo Assembler doesn't contain any macrosCode: Select all
lea doit(pc),a1 moveq #15,d1 copyloop: lea code,a0 move.w #(skip-code)/2-1,d0 copyloop2: move.w (a0)+,(a1)+ dbra d0,copyloop2 dbra d1,copyloop .... doit: ds.b (skip-code)*16 .... code: CMP.W #0,D1 BNE skip NOP ; (some useful code here) skip:
George
-
- Hardware Guru
- Posts: 4704
- Joined: Sat May 29, 2004 7:52 pm
-
- Atari God
- Posts: 1317
- Joined: Sat Dec 28, 2002 4:49 pm
ijor,
Just a few points I can think of now are:
- Uses custom display routines ==> much faster than GEM
- Assembling each line when you press ENTER + syntax checking (much faster assembly times)
- "Foldable" parts (like GFA BASIC - define multiple blocks which you can hide and unhide, so they won't get in your way)
- Jump to label
- Symbol find/replace (much better than doing text find/replace)
- Badass debugger (Bugaboo)
Just for the debugger I could write a small novel! Needles to say that it's reset proof, doesn't use GEM at all, has its own custom mouse driver, it has a hybrid cli/hotkey enviroment, inline assembly etc, etc, etc
Of course, if you want macros, 'INCLUDE's, 030 compatiblilty (although tSCc have done that), and some other stuff, then yeah, go for Devpac. Just don't expect me to do that.
George
Just a few points I can think of now are:
- Uses custom display routines ==> much faster than GEM
- Assembling each line when you press ENTER + syntax checking (much faster assembly times)
- "Foldable" parts (like GFA BASIC - define multiple blocks which you can hide and unhide, so they won't get in your way)
- Jump to label
- Symbol find/replace (much better than doing text find/replace)
- Badass debugger (Bugaboo)
Just for the debugger I could write a small novel! Needles to say that it's reset proof, doesn't use GEM at all, has its own custom mouse driver, it has a hybrid cli/hotkey enviroment, inline assembly etc, etc, etc

Of course, if you want macros, 'INCLUDE's, 030 compatiblilty (although tSCc have done that), and some other stuff, then yeah, go for Devpac. Just don't expect me to do that.
George
is 73 Falcon patched atari games enough ? ^^
-
- Forum Administrator
- Posts: 5836
- Joined: Wed Oct 23, 2002 4:36 pm
- Location: Friedrichshafen, Germany
I actually only miss the INCLUDEs in Turbo Assembler.
One cool feature: TA can directly assemble your code to a GFA inline without the unneeded header. Very handy!
One cool feature: TA can directly assemble your code to a GFA inline without the unneeded header. Very handy!
Simon Sunnyboy/Paradize - http://paradize.atari.org/
Stay cool, stay Atari!
1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
Stay cool, stay Atari!
1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
-
- Hardware Guru
- Posts: 4704
- Joined: Sat May 29, 2004 7:52 pm
Interesting. But you don't mention any actual assembler feature. They are all Editor features, plus the debugger. But the assembler is one thing and the editor is other (There are very good assembler without editor). I normally use Devpac assembler, but I rarely use Devpac editor. Actually, nowadays, I assemble/compiler under Steem and use my favorite Windows editor.ggn wrote:Just a few points I can think of now are:
The debugger looks interesting. Can you (or somebody else) make a quick comparison with Monst?
Of course not. I should have added a smiley on my previous post. We are just chatting. After all, personal preferences matter a lot in these issues.then yeah, go for Devpac. Just don't expect me to do that.
Personally, I would consider lack of Include and Macro support, as very severe limitations for large projects. Strange that a package with such a powerful debugger and editor has a non-macro assembler.
-
- Atari God
- Posts: 1317
- Joined: Sat Dec 28, 2002 4:49 pm
Well, the editor pays a major role for me, and even more in the past, where I only had a STE with a floppy. I wanted an intergrated package where I could code, assemble, run, debug and do it all over again in no time. Loading up program after program to do that tires me a lot. That's why I emphasize on the Editor part.ijor wrote:Interesting. But you don't mention any actual assembler feature. They are all Editor features, plus the debugger. But the assembler is one thing and the editor is other (There are very good assembler without editor). I normally use Devpac assembler, but I rarely use Devpac editor. Actually, nowadays, I assemble/compiler under Steem and use my favorite Windows editor.ggn wrote:Just a few points I can think of now are:
The assembler assembles pretty much everything you throw at it, except that it needs a ';' or a '*' for comments (so pressing one tab and writing comments after the code - as SO many people who use devpac do - will yield an error) and it has a small incombatibility with conditional assembly (no ELSE handling). And of course, no macros

Well, I don't dare compare it with plain monst. It's just unfair.The debugger looks interesting. Can you (or somebody else) make a quick comparison with Monst?






Of course not. I should have added a smiley on my previous post. We are just chatting. After all, personal preferences matter a lot in these issues.then yeah, go for Devpac. Just don't expect me to do that.
[/quote]
I should have added a smiley too. Also just chatting. I sorry if I sounded too hostile.
There is a simple explanation for this. Macros and just-in-time assembly don't mix too wellPersonally, I would consider lack of Include and Macro support, as very severe limitations for large projects. Strange that a package with such a powerful debugger and editor has a non-macro assembler.

Regards, George
is 73 Falcon patched atari games enough ? ^^
-
- Atari God
- Posts: 1459
- Joined: Sat Jan 24, 2004 10:06 am
- Location: Lyon, France
-
- Captain Atari
- Posts: 345
- Joined: Thu May 29, 2003 10:19 am
- Location: Rennes