Welcome, Guest. Please login or register.

Author Topic: Assembler (68k) help (about dc pseudo op)  (Read 11857 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Assembler (68k) help (about dc pseudo op)
« on: January 13, 2003, 03:09:46 PM »
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
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: Assembler (68k) help (about dc pseudo op)
« Reply #1 on: January 13, 2003, 03:20:40 PM »
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
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Re: Assembler (68k) help (about dc pseudo op)
« Reply #2 on: January 13, 2003, 03:40:09 PM »
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?
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: Assembler (68k) help (about dc pseudo op)
« Reply #3 on: January 13, 2003, 03:42:44 PM »
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
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: Assembler (68k) help (about dc pseudo op)
« Reply #4 on: January 13, 2003, 03:42:58 PM »
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

RTFM ;-)
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
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Re: Assembler (68k) help (about dc pseudo op)
« Reply #5 on: January 13, 2003, 03:51:03 PM »
"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
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Skippy

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 710
    • Show only replies by Skippy
Re: Assembler (68k) help (about dc pseudo op)
« Reply #6 on: January 13, 2003, 04:03:39 PM »
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.
 

Offline Warface

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 970
    • Show only replies by Warface
    • http://www.spacehawks.hu
Re: Assembler (68k) help (about dc pseudo op)
« Reply #7 on: January 13, 2003, 04:04:17 PM »
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).
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Re: Assembler (68k) help (about dc pseudo op)
« Reply #8 on: January 13, 2003, 04:14:16 PM »
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
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline z5

  • Sr. Member
  • ****
  • Join Date: May 2002
  • Posts: 366
    • Show only replies by z5
    • http://ada.untergrund.net
Re: Assembler (68k) help (about dc pseudo op)
« Reply #9 on: January 13, 2003, 04:38:23 PM »
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...
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: Assembler (68k) help (about dc pseudo op)
« Reply #10 on: January 13, 2003, 05:25:22 PM »
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:

[color=000099]    even
marker:
    dc.l 0
[/color]

And if you want it on a longword boundary (IE ends in 0, 4, 8 or a), you can do this:

[color=000099]    cnop 0,4
marker:
    dc.l 0
[/color]

Also, what I tend to do is pick an address register, and reference all my variable like this:

[color=000099]    lea    my_vars(pc),a4
    move.w #123,my_word(a4)
    move.l #123,my_long(a4)
    rts

               rsreset
my_word        rs.w 1
my_long        rs.l 1
my_vars_length rs.b 0

my_vars        ds.b my_vars_length
[/color]

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
 

Offline Skippy

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 710
    • Show only replies by Skippy
Re: Assembler (68k) help (about dc pseudo op)
« Reply #11 on: January 13, 2003, 05:55:53 PM »
@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,dcc,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.
 

Offline Lando

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 1390
    • Show only replies by Lando
    • https://bartechtv.com
Re: Assembler (68k) help (about dc pseudo op)
« Reply #12 on: January 13, 2003, 06:12:33 PM »
Quote

z5 wrote:
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...


Don't give up - assembler is hard to learn to start with but once you grasp the basics its a lot of fun.

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.
 

Offline Skippy

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 710
    • Show only replies by Skippy
Re: Assembler (68k) help (about dc pseudo op)
« Reply #13 on: January 13, 2003, 06:39:45 PM »
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.
 

Offline z5

  • Sr. Member
  • ****
  • Join Date: May 2002
  • Posts: 366
    • Show only replies by z5
    • http://ada.untergrund.net
Re: Assembler (68k) help (about dc pseudo op)
« Reply #14 on: January 13, 2003, 10:06:54 PM »
Quote
Don't give up - assembler is hard to learn to start with but once you grasp the basics its a lot of fun.

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.


Lando, maybe you know that i am webmaster of A.D.A. I've been totally crazy about demos since i saw the first cracktros. So you can imagine that this was a big dream for me. Just being able to make a basic scrolltext would have been cool!

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...