amiga.org
     
iconAll times are GMT -6. The time now is 12:47 PM. | Welcome to Forum, please register to access all of our features.

Amiga.org Operating System Specific Discussions Amiga OS Amiga OS -- Development Assembler (68k) help (about dc pseudo op)

Amiga OS -- Development This particular forum deals with issues regarding development for all versions of AmigaOS.

Reply
 
Thread Tools Display Modes
Old 01-13-2003, 08:09 AM   #1
Jose
Kindred of Babble-on
Points: 23,816, Level: 94 Points: 23,816, Level: 94 Points: 23,816, Level: 94
Activity: 19% Activity: 19% Activity: 19%
 
Join Date: Feb 2002
Posts: 2,807
Default Assembler (68k) help (about dc pseudo op)

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
Jose is offline   Reply With Quote
Old 01-13-2003, 08:20 AM   #2
Kronos
Resident blue troll
Points: 14,420, Level: 77 Points: 14,420, Level: 77 Points: 14,420, Level: 77
Activity: 18% Activity: 18% Activity: 18%
 
Kronos's Avatar
 
Join Date: Feb 2002
Posts: 3,926
Default Re: Assembler (68k) help (about dc pseudo op)

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
Kronos is offline   Reply With Quote
Old 01-13-2003, 08:40 AM   #3
Jose
Kindred of Babble-on
Points: 23,816, Level: 94 Points: 23,816, Level: 94 Points: 23,816, Level: 94
Activity: 19% Activity: 19% Activity: 19%
 
Join Date: Feb 2002
Posts: 2,807
Default Re: Assembler (68k) help (about dc pseudo op)

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?
Jose is offline   Reply With Quote
Old 01-13-2003, 08:42 AM   #4
Kronos
Resident blue troll
Points: 14,420, Level: 77 Points: 14,420, Level: 77 Points: 14,420, Level: 77
Activity: 18% Activity: 18% Activity: 18%
 
Kronos's Avatar
 
Join Date: Feb 2002
Posts: 3,926
Default Re: Assembler (68k) help (about dc pseudo op)

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
Kronos is offline   Reply With Quote
Old 01-13-2003, 08:42 AM   #5
Kronos
Resident blue troll
Points: 14,420, Level: 77 Points: 14,420, Level: 77 Points: 14,420, Level: 77
Activity: 18% Activity: 18% Activity: 18%
 
Kronos's Avatar
 
Join Date: Feb 2002
Posts: 3,926
Default Re: Assembler (68k) help (about dc pseudo op)

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
Kronos is offline   Reply With Quote
Old 01-13-2003, 08:51 AM   #6
Jose
Kindred of Babble-on
Points: 23,816, Level: 94 Points: 23,816, Level: 94 Points: 23,816, Level: 94
Activity: 19% Activity: 19% Activity: 19%
 
Join Date: Feb 2002
Posts: 2,807
Default Re: Assembler (68k) help (about dc pseudo op)

"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
Jose is offline   Reply With Quote
Old 01-13-2003, 09:03 AM   #7
Skippy
Cult Member
Points: 8,511, Level: 62 Points: 8,511, Level: 62 Points: 8,511, Level: 62
Activity: 42% Activity: 42% Activity: 42%
 
Skippy's Avatar
 
Join Date: Jun 2002
Location: Bristol, UK
Posts: 710
Default Re: Assembler (68k) help (about dc pseudo op)

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.
Skippy is offline   Reply With Quote
Old 01-13-2003, 09:04 AM   #8
Warface
Cult Member
Points: 6,312, Level: 51 Points: 6,312, Level: 51 Points: 6,312, Level: 51
Activity: 0% Activity: 0% Activity: 0%
 
Warface's Avatar
 
Join Date: Nov 2002
Posts: 970
Default Re: Assembler (68k) help (about dc pseudo op)

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).
Warface is offline   Reply With Quote
Old 01-13-2003, 09:14 AM   #9
Jose
Kindred of Babble-on
Points: 23,816, Level: 94 Points: 23,816, Level: 94 Points: 23,816, Level: 94
Activity: 19% Activity: 19% Activity: 19%
 
Join Date: Feb 2002
Posts: 2,807
Default Re: Assembler (68k) help (about dc pseudo op)

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
Jose is offline   Reply With Quote
Old 01-13-2003, 09:38 AM   #10
z5
Technoid
Points: 6,462, Level: 52 Points: 6,462, Level: 52 Points: 6,462, Level: 52
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2002
Posts: 366
Default Re: Assembler (68k) help (about dc pseudo op)

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...
z5 is offline   Reply With Quote
Old 01-13-2003, 10:25 AM   #11
xeron
Kindred of Babble-on
Points: 14,959, Level: 79 Points: 14,959, Level: 79 Points: 14,959, Level: 79
Activity: 1% Activity: 1% Activity: 1%
 
xeron's Avatar
 
Join Date: Mar 2002
Posts: 2,533
Blog Entries: 12
Send a message via ICQ to xeron Send a message via MSN to xeron
Default Re: Assembler (68k) help (about dc pseudo op)

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   &nbsp ;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
xeron is offline   Reply With Quote
Old 01-13-2003, 10:55 AM   #12
Skippy
Cult Member
Points: 8,511, Level: 62 Points: 8,511, Level: 62 Points: 8,511, Level: 62
Activity: 42% Activity: 42% Activity: 42%
 
Skippy's Avatar
 
Join Date: Jun 2002
Location: Bristol, UK
Posts: 710
Default Re: Assembler (68k) help (about dc pseudo op)

@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.
Skippy is offline   Reply With Quote
Old 01-13-2003, 11:12 AM   #13
Lando
Defender of the Faith
Points: 11,051, Level: 69 Points: 11,051, Level: 69 Points: 11,051, Level: 69
Activity: 5% Activity: 5% Activity: 5%
 
Join Date: Jun 2002
Posts: 1,384
Default Re: Assembler (68k) help (about dc pseudo op)

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.
Lando is offline   Reply With Quote
Old 01-13-2003, 11:39 AM   #14
Skippy
Cult Member
Points: 8,511, Level: 62 Points: 8,511, Level: 62 Points: 8,511, Level: 62
Activity: 42% Activity: 42% Activity: 42%
 
Skippy's Avatar
 
Join Date: Jun 2002
Location: Bristol, UK
Posts: 710
Default Re: Assembler (68k) help (about dc pseudo op)

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.
Skippy is offline   Reply With Quote
Old 01-13-2003, 03:06 PM   #15
z5
Technoid
Points: 6,462, Level: 52 Points: 6,462, Level: 52 Points: 6,462, Level: 52
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2002
Posts: 366
Default Re: Assembler (68k) help (about dc pseudo op)

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...
z5 is offline   Reply With Quote
Old 01-13-2003, 03:13 PM   #16
Jose
Kindred of Babble-on
Points: 23,816, Level: 94 Points: 23,816, Level: 94 Points: 23,816, Level: 94
Activity: 19% Activity: 19% Activity: 19%
 
Join Date: Feb 2002
Posts: 2,807
Default Re: Assembler (68k) help (about dc pseudo op)

Thanks all for the help. I'll have to look more into it when I have time, but I defenitly will. It's great fun and I now think people that don't learn to programm miss all the fun. Much cooler than playing games!
Jose is offline   Reply With Quote
Old 01-16-2003, 12:28 PM   #17
Cymric
Defender of the Faith
Points: 7,150, Level: 55 Points: 7,150, Level: 55 Points: 7,150, Level: 55
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2002
Posts: 1,031
Default Re: Assembler (68k) help (about dc pseudo op)

Quote:
Jose wrote:
snip... I'm learning it cause from what I've always heard, migrating to ppc assembler is a breeze :-D
The question then of course is 'why would you want to code assembly?' Assembly is tough on a programmer because it has you doing everything yourself. Register allocation, memory management, pointer arithmetic. There are little semantic checks. Debugging can be a nightmare, especially if you're writing a demo. Code can be tough to document, and will span many, many lines. Nowadays, only experts (think Real Programmer Mel here) can produce consistently faster assembly code than that of an optimising compiler, and even then the differences are slim.

Of course, there's noone stopping you from learning assembly: by all means, go right ahead, enjoy! Splurge! Smell the bare metal! Bash that blitter! Coerce that Copper! Pounce at Paula :-)! Nevertheless, if you plan to do program development---and that includes demos---on the A1, my advice would be to forget it has a PPC, and just use C or BASIC or any other high(er) level language.
Cymric is offline   Reply With Quote
Old 01-21-2003, 10:26 AM   #18
Jose
Kindred of Babble-on
Points: 23,816, Level: 94 Points: 23,816, Level: 94 Points: 23,816, Level: 94
Activity: 19% Activity: 19% Activity: 19%
 
Join Date: Feb 2002
Posts: 2,807
Default Re: Assembler (68k) help (about dc pseudo op)

This is much more fun :-D And you learn a lot of stuff, at I do cause my studies are not computer related.
Later I'll learn C. I allways do the opposite normal people do :-D
Jose is offline   Reply With Quote
Old 01-21-2003, 12:03 PM   #19
Cymric
Defender of the Faith
Points: 7,150, Level: 55 Points: 7,150, Level: 55 Points: 7,150, Level: 55
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2002
Posts: 1,031
Default Re: Assembler (68k) help (about dc pseudo op)

Well, okay then. But make sure you do all the nasty stuff only assembly allows you do to. Like writing self-modifying code, or creating code that hooks into the illegal PC-exception vector to have 680x0-code execute at odd addresses. Or one of the many other particularly dirty things :-P.
Cymric is offline   Reply With Quote
Reply

Bookmarks

Tags
68k , assembler , pseudo

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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