View Full Version : For my First ASM Prog
bippym
01 February 2006, 18:29
For my first ever asm prog I'm going to attempt to open a screen and have a nice copper on it :)
Can anyone give me some basic advice on starting this? what do I need to consider etc.. should I just poke the regs or do it the system way?
bobbybearing
01 February 2006, 20:09
see commented sources posted by Alpha One on http://www.flashtro.com !
1. copperlist
2. bitplan
3. text
4. copperbar
5. cpu scrolltext
Joe Maroni
01 February 2006, 20:32
maybe this is helpful...
just change the copperlist to your choice...:)
;
; Copper-Demo
;
;
s:
move.w #$4000,$dff09a ;disable Interrupts;
move #$0020,$dff096 ;disable Sprites
move.l #copperl,$dff084 ;activate Copperlist
;
loop: move.l $dff004,d0 ;wait for vertical blank
and.l #$fff00,d0
cmp.l #$00003000,d0
bne.s loop
btst #6,$bfe001 ;mousebutton ?
bne.s loop ;yes ?
;
ende: move #$c000,$dff09a ;enable Interrupts
e: rts ;End
;
copperl: dc.w $008e,$3081 ;DIWSTRT
dc.w $0090,$35c1 ;DIWSTOP
dc.w $0104,$0064 ;BPLCON2
dc.w $0092,$0038 ;DDFSTRT
dc.w $0094,$00d0 ;DDFSTOP
dc.w $0102,$0000 ;BPLCON1
dc.w $0108,$0000 ;BPL1MOD
dc.w $010a,$0000 ;BPL2MOD
dc.w $0100,$1200 ;BPLCON0
dc.w $00e0,$0005 ;BPL1PTH
dc.w $00e2,$0000 ;BPL1PTL
dc.w $0180,$0000 ;COLOR00
dc.w $ffff,$fffe ;Copperlist end
;
Alter
01 February 2006, 21:57
I put a copperlist source for you in the zone. I coded it in Asmone and you need Kickstart 1.3 . Try it !!!
Photon
01 February 2006, 22:25
ENDE DER KOMMUNIKATION (c) Tron :P
...anyways good luck bippym, hope to see something nice from you soon! :)
Galahad/FLT
02 February 2006, 01:03
And on another note, when you assemble that little lot, the copperlist MUST be in chip ram or nothing will be displayed.
Program code, music replayer, music note data can all be run in fast ram, copperlists, pictures and sampledata MUST be in chipram.
polish
02 February 2006, 13:22
Is ASM really hard to learn, i was thinking of trying it myself? I mean all the offsets and stuff look hard to understand but i think ill work it out
Galahad you must be one of the most looked up to people on this forum, i really admire you because of the fact that you were in fairlight (awesome group) and that you can code asm, and track mods if im right
as for bippym good luck on your first prog
bippym
02 February 2006, 16:32
I find it hard just remembering everything.
How to assemble gthe actual program (structure) and what offsets are required. Which registers are to be poked with what info etc..
That is what I find hard.
I can read and follow asm to a certain degree.
Joe Maroni
02 February 2006, 18:06
i think it would be better to start with no visual stuff...
its the hardest thing you can start without any knowledge...
a nice thing i remember was to write the current v-blank position to the backgroundcolor register every cycle...
the result is a screen with more than 32 colors...
iŽll try to find the source of this thing...:D
coze
03 February 2006, 16:59
hello x_to,
I just tried to compile your code above but it says illegal operator for the first move.w command. I'm running asmpro (1.16), under winuae with a1200/ks3.0 configuration. where could be the problem ?
hello, btw, this is my first post here. as you can guess, I'm pretty new to asm.
NOB
03 February 2006, 19:32
s:
move.w #$4000,$dff09a ;disable Interrupts;
move #$0020,$dff096 ;disable Sprites
move.l #copperl,$dff084 ;activate Copperlist
..........
.....
press the TAB key to format the asm-source.;)
Joe Maroni
03 February 2006, 23:24
yes thats the problem of the EAB editor...it delete TABs..:(
otherwise it works fine
Ray Norrish
07 February 2006, 01:03
If you like, I released an intro as a tutorial with extremely heavy comments. Let me know and I will send it to you as I still have it all :)
Galahad/FLT
07 February 2006, 01:14
Ray, I still have your source that correctly shuts down the system that you gave me at the Digital party! I think you used it for Sonic Attack :)
Ray Norrish
07 February 2006, 01:41
You know, that code was probably the only true sysdown() sysup() around at the time that worked on every amiga/kick.
Might be worth posting :)
I hand a good hand with that from Randy/Comax for the a4000 compliance. Yes, it was in SA :)
Alter
07 February 2006, 07:31
Hi there Galahad/ray I would really appreciate it if one of you would post that code. I been looking for a startup code like that.....for some time now... :-)
nemazoty
08 February 2006, 14:34
If you like, I released an intro as a tutorial with extremely heavy comments.
I'm interested in it too! Please UL to the zone if you have useful sources (for educational purposes ;)
NOB
08 February 2006, 18:19
If you like, I released an intro as a tutorial with extremely heavy comments. Let me know and I will send it to you as I still have it all :)
Yes, release that intro it is interesting to read commented sources.But make sure it will run on my A500.:D
Ray Norrish
08 February 2006, 23:05
Hi there Galahad/ray I would really appreciate it if one of you would post that code. I been looking for a startup code like that.....for some time now... :-)
I`ve uploaded the System close / restore code into the zone. This works for all processors.
Ray Norrish
08 February 2006, 23:15
I found the intro source, but not the extra commented version I made for tutorials. I`ll upload the code anyway.
Alter
09 February 2006, 17:38
Thanx alot Ray, I will download it right away :-)
NOB
09 February 2006, 19:07
Thanks Ray, checked it out on an original AMIGA.:)
I`ve uploaded the System close / restore code into the zone. This works for all processors.
Can you upload it again? I missed it. Thanks in advance
Can you upload it again? I missed it. Thanks in advance
http://www.aminet.net/search.php?query=phxass439.lha
/PhxAss/Examples/DemoSupp.asm
Very good example.
Here is altered example to one posted by x_to.
Now it compiles fine under vasm.
;
; Copper-Demo
;
CUSTOM = $dff000
CIAA = $bfe001
COP2LC = $084
DMACON = $096
INTENA = $09a
section "code123",code
lea CUSTOM,a6
move.w #$4000,INTENA(a6) ;disable Interrupts
move.w #$0020,DMACON(a6) ;disable Sprites
move.l #copperl,COP2LC(a6) ;activate Copperlist
loop:
btst #6,CIAA ;loop unil mousebutton
bne.s loop ;is pressed
move.w #$8220,DMACON(a6) ;enable Sprites
move.w #$c000,INTENA(a6) ;enable Interrupts
rts
nop ;ignore me
section "data123",data,chip
copperl:
dc.w $008e,$3081 ;DIWSTRT
dc.w $0090,$35c1 ;DIWSTOP
dc.w $0104,$0064 ;BPLCON2
dc.w $0092,$0038 ;DDFSTRT
dc.w $0094,$00d0 ;DDFSTOP
dc.w $0102,$0000 ;BPLCON1
dc.w $0108,$0000 ;BPL1MOD
dc.w $010a,$0000 ;BPL2MOD
dc.w $0100,$1200 ;BPLCON0
dc.w $00e0,$0005 ;BPL1PTH
dc.w $00e2,$0000 ;BPL1PTL
dc.w $0180,$0000 ;COLOR00
; read this http://eab.abime.net/showthread.php?t=21866
; and have fun
dc.w $a051,$fff0
dc.w $0180,$0090
dc.w $a0b1,$fff0
dc.w $0180,$0000
dc.w $ffff,$fffe ;Copperlist end
jaycee
28 September 2006, 18:10
just to jump in.. i used to HATE reading code where the author had written all the hardware addresses and bitflags by hand! There's just no need for it... it's easy to get the include files and do .include "hardware.i" at the top of your source. Especially if its example code for someone to read.
I never liked not using the relative address mode for writing to hardware regs either, especially the $DFF000 range.
jrom
29 September 2006, 15:01
how right you are... for once i'd like to see some code that actually uses the NDK... they didn't release those for nothing!
cdoty
06 October 2006, 17:17
Is ASM really hard to learn, i was thinking of trying it myself? I mean all the offsets and stuff look hard to understand but i think ill work it out
ASM isn't hard to learn. It just requires a lot of attention to detail and getting used to doing things in small steps.
In C/C++ you can do ptr++, and it will increment depending on the size of the pointer (ie an 'long *' will increment 4 bytes on a 32 bit system). In ASM, you have to increment the pointer by the size of the data, unless you use move.l (a0)+, (a1)+
Also, I wouldn't necessary worry about learning the entire instruction set, learn the load/store (move), branching (bne, jsr, etc) and compare (cmp) instructions (inc/dec are important on other chips). Then, keep an instruction set sheet handy for the test, asl, shr, etc type instructions. After using ASM for awhile, you will get used to these instructions.
Learn to use a debugger. Running code through a debugger can teach you more than reading tutorials or instruction sets. MESS is a nice debugger, but is a pain to use with amiga executables. It's hard to find the address where the executable loaded. But, once found, it usually remains the same (assuming you're loading the executable before workbench starts or automatically on boot).
Is there an easy way to determine where an executable will load to?
jaycee
06 October 2006, 17:34
I had 2 sheets of A4 paper with the 68000 instruction set, condition codes and such on it which I kept to hand. I think I got it from Aminet. Later on I downloaded an AmigaGuide file which had a full run-down of 68000 and some 020 instructions to refer to. I formatted and printed it out into an A4 binder file :)
Debuggers - can't really recommend anything here as I was used to RossiMon, and then MonAm3. Both are rather unfriendly, especially MonAm3 which is totally keyboard shortcut driven. I don't know if it's still maintained but PowerVisor looked good too.
You can't really determine where your executable will be loaded... this is entirely up to AmigaDOS' LoadSeg() function which loads your executable. You can use the SECTION directive of the assembler to guarantee your code/data/whatever will load into a particular type of ram, though.
(wow... I pulled out some memories there.. I haven't written any asm on the amiga in at least 8 years!)
jima
23 February 2007, 19:13
... it's easy to get the include files and do .include "hardware.i" at the top of your source. Especially if its example code for someone to read.Any idea where to get "hardware.i" - I need it for another program. I have NDK's 1.2 and 2.1 and have Googled without joy. It will save me changing a lot of code e.g. Bltapth to bltapt etc.
Jim
bippym
23 February 2007, 20:46
it'll be on the ndk ;)
Joe Maroni
23 February 2007, 21:34
otherwise buy one of the Amiga Developer CDs...;)
still available at http://www.vesalia.de
jima
25 February 2007, 20:38
Quote "I have NDK's 1.2 and 2.1.."
Sorry, of course I meant the Developer CD's (I thought you 'experts' would have known that :rolleyes) which I just bought from Vesalia and 'hardware.i' is NOT on either of them. I'm not out to l33ch copyright stuff, I just want the file! Are you SURE it's on the NDK, bippym, x_to was SURE it was on the Developer CD?
Jim
StingRay
26 February 2007, 01:10
Hey Jim, I guess you needed hardware.i for sp's c2p. :) That problem should now be solved I suppose. :D Check the pouet thread, I answered you there. :)
jima
26 February 2007, 02:58
stingray: Yep, that's what kicked it off. I was using hardware/custom.i but was having to change all the blitter equates so rather than hard code a load of equates or build a custom include file it seemed easier to get hardware.i (and I wanted to check for any 'variations' from the standard as sometimes creep in). It's sorted now thanks to your revised source but I'm still curious about hardware.i - why is it even necessary if all the equates are in the standard hardware/custom.i etc? Is it an assembler-specific issue?
StingRay
26 February 2007, 10:03
Well, to be honest, I never used includes when I needed to access hardware regs, for me it's just way more comfortable to write move.w #(256<<6)|20,$58(a6) if I want to start a blit f.e. :) Bad style? Maybe, but I'm doing it like this since 1990/91 so it won't change anymore. ;) Why there is a hardware.i include now I don't know either, custom.i should have been enough I think. I don't have hardware.i so I don't know how it differs to custom.i, would be interesting to know though. The only differences I could spot so far are the Bltxpth constants which are lowercase in custom.i and don't have the h, e.g. Bltapth is called bltapt in custom.i. I guess all custom offsets start with an uppercase letter in hardware.i but I am not sure. I find it pretty stupid anyway to have 2 different include files for the same thing. ;) Another reason why using good old "bad" style has advantages. :D
jima
26 February 2007, 15:37
Yeah, I guess, I was just looking to save some time (and perhaps trouble) in order to focus on getting a clean compile and thought there might have been some tricks and/or traps in there e.g. Devpac throws a wobbly when you try to 16-bits test an 8-bit location in the WAITBLITTER routine (btst #14, $dff002) but ASM-Pro and ASM-One don't even bat an eyelid - heh - just thought, for all that hardware.i stuff and he doesn't even use 'dmaconr' anyway :)
jima
27 February 2007, 23:45
it'll be on the ndk ;)
Erm, apparently I do have all the NDK's - I just checked my (legal version) Developer CD 2.1 and all the NDK's are there (apparently for historical purposes) BUT no "hardware.i" so I must assume this is either a version specific to a particular assembler or a home grown include file. Thanks to StingRay I'm past it but just to close off this part of the thread (BTW I ought to say sorry for hijacking it:crying).
CoDeMaN
28 February 2007, 11:54
Only place i got Hardware.i was from "The hardware reference manual" that i had to type out myself...
That was 10+ years ago thou so i may be wrong lol
IFW
28 February 2007, 23:44
OS/hw header files all came from C= bundled with development software and hardware.
You could also get them from CATS.
SAS/C and Devpac are just two examples where the original package contains all the necessary header files.
These header files were also available with some book (don't remember which one, probably RKM or HRF) and were part of some PD discs too.
C= was quite happy to distribute them in any way that was possible at the time, so feel free to get them.
kamelito
03 March 2007, 00:28
Hi,
Surely a bit off topic but, as ASMONE and ASMPRO are written in assembly and are not to say the least been updated recently (even if sufficient for today's use). It would IMHO be a good idea to clone it using a text editor and an assembler written in C. Suff like DME + VASM for example. This way it would be possible to assemble 68k, PPC code on modern systems.
Any thoughts?
Kamelito.
CmdrVimes
03 September 2010, 14:08
If you like, I released an intro as a tutorial with extremely heavy comments. Let me know and I will send it to you as I still have it all :)
This may be a very long shot, given the date of your original post, but is there any chance you can make this source available please? I am able to find a lot of source in various places but commented source? That's a different matter.
pmc
03 September 2010, 14:52
It'll need some tidying up (I hadn't yet learned to make my own life easy and use equates and things in the early days :D) but you're more than welcome to have my sinescroller source.
It was the first thing I ever coded in asm so I deliberately commented every line. Dunno if that'll be of use to you...?
CmdrVimes
03 September 2010, 14:59
Dunno if that'll be of use to you...?
Too right it would! Thank you. I am trying to collect as much commented source as I can (as long as its not too complicated) so that I have plenty of reference material when I start coding my own stuff.
I am looking at some source at the moment and I might have to post for help shortly.
pmc
03 September 2010, 15:06
Too right it would! Thank you.
No probs. Like I say, I'll tidy it and then send it to you. :)
I am looking at some source at the moment and I might have to post for help shortly.
If I can help, I will. :)
vBulletin® v3.7.0, Copyright ©2000-2013, Jelsoft Enterprises Ltd.