|
Register or have you forgotten your password?
|
|
|
| Amiga OS -- Development This particular forum deals with issues regarding development for all versions of AmigaOS. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||||||||
|
Kindred of Babble-on
![]()
Join Date: Feb 2002
Posts: 2,786
|
I got tired and started reading an assembler tutorial I found on Aminet here. You know, that's where the fun really begins! :-D I regret not having done that sooner.
I URGE EVERYONE IN HERE TO START PROGRAMMING :-D Anyway, either I'm too dumb, or the tutorial is not that well written cause I'm not understanding the dc pseudo operation. The tutorial is old and assumes that you're using AssemPro. Anyway my doubt is: It's said in there that in most cases an address like $1000 (for example) won't be used cause you use a label that point to a cetain address instead. Something like: move #1,$1000 would, more commonly be written like: ... move #1,marker ... marker:dc.w 1 The last instruction is a pseudo instruction for the assembler and defines the marker label. BUT SHOULDN'T IT BE LIKE: marker:dc.w $1000 !!!!!!!!! Another doubt: after reading the various types of addressing I don't get it what this type could be: #$1234678 (example) it should be direct addressing (cause it uses a #) but why then in the other examples of this type of addressing they don't use an hexadecimal number in none of them(I suppose it doesn't matter then)? Yet another doubt: So maybe this is what my doubts are surrounding, when using labels, the declarations at the end of the program (marker:dc.w 1 ;example) are just values that substitute the correspondent labels in the program? Something the also confused me in relation to this was the undocumented use of for example: move #marker,d1 and : move marker,d1 (examples) What's the difference after all? If I stand correct the first one copies the value of the label marker defined at the end, wich could be 1 for example (marker:dc.w 1), to the data register d1. The second example copies the contents of the address $1 to the data register d1?! But the end defines marker as 1 not $1, so I suppose addresses can be refered to as decimal values too? Resuming either I'm too dumb or this tutorial sucks!! :-x Must admit I haven't learned other language though, but it seem pretty straightforward until this doubts come up. I know there are some hardcore Amigans in here so let's do ourselves what we wan instead of just waiting and doing nothing, and one can help each other. Now help me in this cause I'm starta getting pissed off, andI don't have time to clear these doubts by myself. Cheers |
||||||||
|
|
|
|
|
#2 | ||||||||
|
Resident blue troll
Join Date: Feb 2002
Posts: 3,871
|
68k-asm ? Long long ago .... but I will give it a try.
marker: dc.w 1 Means you got an variable (16bit) with the value "1" stored into it. The Assmembler will replace move #1,marker with move value_1 to address marker You should never (really never) put an fixed number on any address, because that variable will move with every piece of code you put before it. Let the assembler sort out that mess ;-) "#" is NO addressing, you will use that number, and not the memory-cell it would point to if used as an address. move #marker,d1 load the address of you variable into d1 move marker,d1 loads the contents of your variable into d1. /me just hopes he hasn't made a complete fool of himself
__________________
1. Make an announcment. 2. Wait a while. 3. Check if it can actually be done. 4. Wait for someone else to do it. 5. Start working on it while giving out hillarious progress-reports. 6. Deny that you have ever announced it 7. Blame someone else |
||||||||
|
|
|
|
|
#3 | ||||||||
|
Kindred of Babble-on
![]()
Join Date: Feb 2002
Posts: 2,786
|
Thanks. More or less what I though. I guess what I need is to start practicing cause I'm starting to forget the doubts I had themselves!!
One thing I'd really need cleared would be: When there's something for example like value_1: dc.w 1 value_2: dc.w 1 I know the second value would be at an uneven address so an align would be necessary but, how da hell do I know the address of value_1 is even? Does the compiler give me info about that? |
||||||||
|
|
|
|
|
#4 | ||||||||
|
Resident blue troll
Join Date: Feb 2002
Posts: 3,871
|
double_di_hoop
__________________
1. Make an announcment. 2. Wait a while. 3. Check if it can actually be done. 4. Wait for someone else to do it. 5. Start working on it while giving out hillarious progress-reports. 6. Deny that you have ever announced it 7. Blame someone else |
||||||||
|
|
|
|
|
#5 | ||||||||
|
Resident blue troll
Join Date: Feb 2002
Posts: 3,871
|
No it's not on an uneven address, it's just not alligned to 4.
AFAIR that is something a bit different on every assembler, so [size=xx-large]RTFM[/size] ;-)
__________________
1. Make an announcment. 2. Wait a while. 3. Check if it can actually be done. 4. Wait for someone else to do it. 5. Start working on it while giving out hillarious progress-reports. 6. Deny that you have ever announced it 7. Blame someone else |
||||||||
|
|
|
|
|
#6 | ||||||||
|
Kindred of Babble-on
![]()
Join Date: Feb 2002
Posts: 2,786
|
"RTFM"...
Yeah, but it should be easier to understand it if the tutorial taugh me it depended on the assembler. I'm learning it cause from what I've always heard, migrating to ppc assembler is a breeze :-D |
||||||||
|
|
|
|
|
#7 | ||||||||
|
Cult Member
![]()
Join Date: Jun 2002
Location: Bristol, UK
Posts: 710
|
Hardware reference manual:
http://www.amigarealm.com/computing/nkb12.htm [not complete but useful] Programming resources, tutorials etc: http://www.amigarealm.com/resources/coding.htm Skippy
__________________
Squareroot of all fluffiness. |
||||||||
|
|
|
|
|
#8 | ||||||||
|
Cult Member
![]()
Join Date: Nov 2002
Posts: 970
|
In asmone there is a pseudo instruction called "even" or ".even", I can't remember. (And here's nothing to look up or try it out.)
In the assembler you can use pretty much numeric formats, the assembler will take care of the rest. If you want to use hexadecimal numbers, just use the "$" character, if you want you can use decimal numbers too, then no extra character required. As Kronos said "#" has not such function, it just indicates that a direct value follows, instead of an address(ing mode). |
||||||||
|
|
|
|
|
#9 | ||||||||
|
Kindred of Babble-on
![]()
Join Date: Feb 2002
Posts: 2,786
|
I've read parts of Amigarealm various times, specially hardware reference stuff.
Lol. Skippy, you almost got me once, with that blonde girl pic you had before :-o For some moments I though you were her. :-D |
||||||||
|
|
|
|
|
#10 | ||||||||
|
Technoid
![]()
Join Date: May 2002
Posts: 366
|
it has always been my dream to learn assembler and code an intro or demo. But for some reason, i never got around to it. And it find it a real pity. Even now there still is that dream.
But i think it would cost me too much time learning asm on my own and i don't have that time anymore :-x Also, i think there are not a lot of good tutorials. What i was looking for was simple tutorials that i can run on AsmOne on my A1200 and from which i can study the code and mess with it. For example, just a black screen with a scrolltext or just one effect...
__________________
A.miga D.emoscene A.rchive: Relive the dreams... |
||||||||
|
|
|
|
|
#11 | ||||||||
|
Kindred of Babble-on
![]()
|
Kronos explained it all quite well, I just wanted to add the following:
If you want to make sure some data is on an even boundary, (ie address ends in 0, 2, 4, 6 etc.) you can do this: even marker: dc.l*0 And if you want it on a longword boundary (IE ends in 0, 4, 8 or a), you can do this: cnop*0,4 marker: dc.l*0 Also, what I tend to do is pick an address register, and reference all my variable like this: lea   ;my_vars(pc),a4 move.w*#123,my_word(a4) move.l*#123,my_long(a4) rts &n bsp; rsreset my_word & nbsp;rs.w*1 my_long & nbsp;rs.l*1 my_vars_length rs.b*0 my_vars & nbsp;ds.b*my_vars_length A little explanation: "rsreset" resets a pre-processor counter that is supported by PhxAss, AsmOne and AsmPro (I *think* devpac supports it too, but i cant remember). rs.w sets the label to the current counter value, and adds 2 to the counter (.b adds 1, .l adds 4), so, its the same as: my_word = 0 my_long = 2 my_vars_length = 6 (the reason we use the rscounter is that we can insert new variables without changing the offsets for all the ones after it). Finally, we allocate the ram for our variables with the ds.b statement. There are several reasons for doing this: 1) You can write to and read from bytes, words and longwords all referenced via your variable register (= faster. You can't do as many operations relative to PC) 2) Flexibility. You can assign space in your executable for variable RAM, like above, but you could just as easily allocate my_vars bytes with AllocMem (and your code could become re-entrant with no changes), or even just allocated on the stack with LINK (for subroutines with local variables). I hope you understood all that... ddd[/color]
__________________
Playstation Network ID: xeron6 |
||||||||
|
|
|
|
|
#12 | ||||||||
|
Cult Member
![]()
Join Date: Jun 2002
Location: Bristol, UK
Posts: 710
|
@Pete,
You do exactly the same as me. Extracts of my copper: Section Misc,Code_C gfxlib dc.b "graphics.library",0 even Doslib dc.b "dos.library",0 even stsv: ds.l 1 even rsreset sysdma: rs.w 1 sysint: rs.w 1 sysirq: rs.w 1 sysadk: rs.w 1 coppersave1 rs.l 1 coppersave2 rs.l 1 viewsave rs.l 1 gfxbase: rs.l 1 sysautovecs: rs.l 6 sysdata: ds.w __rs COUNTER: dc.B 0 fade one every other frame even -----snipped Section Copper,Data_C ; Long frame copperlist copper1:dc.l $01009200 dc.l $008e2981,$009029c1 dc.l $00920038,$009400d0 dc.l $01080000,$010a0000 spts: dc.l $01200000,$01220000,$01240000,$01260000,$01280000, $012a0000,$012c0000,$012e0000 dc.l $01300000,$01320000,$01340000,$01360000,$01380000, $013a0000,$013c0000,$013e0000 cols: dc.l $01800000,$01820fff,$01840000,$01860000,$01880000, $018a0000,$018c0000,$018e0000 dc.l $01900000,$01920000,$01940000,$01960000,$01980000, $019a0000,$019c0000,$019e0000 bplane4:dc.l $00e00000,$00e20000,$00e40000,$00e60000,$00e80000, $00ea0000,$00ec0000,$00ee0000 dc.l $fe0ffffe,$01820000 Copper2:dc.l $fffffffe,$fffffffe Copper3:dc.w $0100,%1100001000000100 HiRes, Interlace,1 plane addr1: dc.l $00800000,$00820000 dc.l $008e2981,$009029c1 dc.l $0092003c,$009400d4 dc.l $01080050,$010a0050 dc.l $01200000,$01220000,$01240000,$01260000,$01280000, $012a0000,$012c0000,$012e0000 dc.l $01300000,$01320000,$01340000,$01360000,$01380000, $013a0000,$013c0000,$013e0000 colsa: dc.l $01800000,$01820122,$01840767,$0186058b dc.l $0188069c,$018a08be,$018c0d99,$018e0bce dc.l $01900a98,$01920ba9,$01940caa,$01960cbb dc.l $01980dcc,$019a0ecc,$019c0fee,$019e0fff bplanea:dc.l $00e00000,$00e20000,$00e40000,$00e60000 dc.l $00e80000,$00ea0000,$00ec0000,$00ee0000 dc.l $fffffffe,$fffffffe Copper4:dc.w $0100,%1100001000000100 HiRes, Interlace,1 plane addr2: dc.l $00800000,$00820000 dc.l $008e2981,$009029c1 dc.l $0092003c,$009400d4 dc.l $01080050,$010a0050 dc.l $01200000,$01220000,$01240000,$01260000,$01280000, $012a0000,$012c0000,$012e0000 dc.l $01300000,$01320000,$01340000,$01360000,$01380000, $013a0000,$013c0000,$013e0000 colsb: dc.l $01800000,$01820122,$01840767,$0186058b dc.l $0188069c,$018a08be,$018c0d99,$018e0bce dc.l $01900a98,$01920ba9,$01940caa,$01960cbb dc.l $01980dcc,$019a0ecc,$019c0fee,$019e0fff bplaneb:dc.l $00e00000,$00e20000,$00e40000,$00e60000,$00e80000, $00ea0000,$00ec0000,$00ee0000 dc.l $fffffffe,$fffffffe ;000,122,767,58b,69c,8be,d99,bce,a98,ba9,caa,cbb,d cc,fee,fff Section Picture,Data_C Screen1:dcb.b (640*256)/8,$00 even Screen2:incbin dh0:storage/sc/-data-/start2.raw 960*27 even Blank dcb.l 16,0 even font2: incbin dh0:storage/sc/-data-/13*8.raw 960*27 even mt_data:incbin dh0:storage/music/xmas.mod END
__________________
Squareroot of all fluffiness. |
||||||||
|
|
|
|
|
#13 | |||||||||
|
Defender of the Faith
![]()
Join Date: Jun 2002
Posts: 1,380
|
Quote:
I recommend to look at the tutorials by Rombust/Nerve Axis which were in later issues of the "Grapevine" diskmag by LSD. They should be on the Aminet somewhere. They are excellent. And also get some good startup/shutdown code - hardware-banging is great fun but for some reason people tend to not be so happy these days when they quit out of your game/demo and their Workbench screen doesnt come back ![]() Start off with something simple like making some copperbars, then making them move up and down, then displaying a picture, then making a scroller and so on... soon you'll end up with a complete intro that you can release at some party. |
|||||||||
|
|
|
|
|
#14 | ||||||||
|
Cult Member
![]()
Join Date: Jun 2002
Location: Bristol, UK
Posts: 710
|
I've just finished archiving over 125+ floppy disks of mine/friends sourcecode dating back to 1992.
These disks also include tutorial code from big name developers from 1988 =>, ie: bullfrog. Currently all in .lha format on my a1200s' hard-drive. When I've got time I'll upload some disks to my website for you. Skippy
__________________
Squareroot of all fluffiness. |
||||||||
|
|
|
|
|
#15 | |||||||||
|
Technoid
![]()
Join Date: May 2002
Posts: 366
|
Quote:
But as said, it's not easy without the right tutorials. I downloaded some sources from internet but they already give an error on assembling in AsmOne :-( The code from some very basic intro, with a copperbar and a scrolltext, that would be nice to start. But i think i will give up on that dream.
__________________
A.miga D.emoscene A.rchive: Relive the dreams... |
|||||||||
|
|
|
![]() |
| Bookmarks |
| Tags |
| 68k , assembler , pseudo |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Right! I want to learn 68k assembler! | SamOS39 | Amiga Software Issues and Discussion | 16 | 10-04-2008 10:46 PM |
| 68k assembler | StormLord | Amiga Software Issues and Discussion | 7 | 01-21-2008 05:30 PM |
| 68k GNU Assembler under OS4 | AMC258 | Amiga OS -- Development | 1 | 01-07-2008 01:12 AM |
| Amiga Assembler | RobinGodd | New User Introductions | 4 | 02-16-2006 06:19 AM |
| X86 Assembler to PPC Assembler Conversion | asian1 | Linux PPC discussion | 4 | 09-15-2003 08:00 AM |