Dark Bit Factory & Gravity
PROGRAMMING => Other languages => ASM => Topic started by: Xalthorn on October 15, 2008
-
Hello folks,
Because of this retro challenge, I'm looking through the source of the one I fancy doing and trying to work out what the heck they're doing (only in general terms so that I can replicate/mimic it).
The source looks like a dump from a disassembler and as this is the first time I've seen Amiga asm, there are some things that don't make full sense to me.
For example:
ptScreens ; 10 lines - 11 glenz-vector/lines
dc.l BpVector
dc.l BpVector+44*32*4*1
dc.l BpVector+44*32*4*2
dc.l BpVector+44*32*4*3
dc.l BpVector+44*32*4*4
dc.l BpVector+44*32*4*5
dc.l BpVector+44*32*4*6
dc.l BpVector+44*32*4*7
dc.l BpVector+44*32*4*8
dc.l BpVector+44*32*4*9
The ptScreens reference is used to load an address register as follows (at least I think that's what it's doing)
lea ptScreens(pc),a0
The BpVector reference is only ever used elsewhere to load a data register as follows
move.l #BpVector,d0
So am I safe in assuming that the dc.l mnemonic is reserving a long word of data (32 bits) and calling it BpVector? And that ptScreens is simply a label to mark the start of the data?
Also with data, there is the following:
dc.w $106,$c00,$1fc,0,$10c,$11
dc.w $1907,$fffe
dc.w $108,0,$10a,0
Am I right in thinking that the values are all words (16 bits) and although they are shown as a mix of decimal and hex values, they are just values and could be presented in either form?
-
Hi Xalthorn,
right.... new to 68000 asm... so here we go
LEA means Load Effective Address
lea ptScreens(pc),A0
means: load effective address named "ptScreens" relative to the current program counter (not absolute address in memory) into register A0
basically puts the address of whatever is at address ptScreens into the A0 (address register). In C this would be the same as assigning the address of, for example an array, to a pointer
MOVE.L #BpVector,D0
means: move the numerical value of BpVector into data register D0. BpVector can be an address (label) or a constant, or whatever number that the assembler may find or calculate during the assembly process.
DC.x
means: Declare where the .x can be .b (byte),.w (16bit word) .l (32bit word). This reserves the space and fills it with the data.SO something like:
DC.L BpVector
will declare a 32bit word storage place containing the value BpVector. BpVector can be either a constant or a pointer (defined as a label somewhere)
I hope this helps a bit
-
Thanks, that certainly confirms my understanding of the basics :)
Here's a weird one though, and I'm not sure what it's doing.
lea 4(a0),a0
move.w d0,4(a0)
swap d0
move.w d0,(a0)
swap d0
As your previous lea example showed that ptScreens(pc) was the address relative to the program counter, does the above code snippet do something along the following lines?
Add four to the address held in a0
Put the right hand 16 bits of d0 into the address four bytes on from that pointed at in a0
swap the two 16 bit words of d0
Put the right hand 16 bits of d0 into the address pointed at in a0
swap the two 16 bit words of d0, effectively restoring it
-
Looks like he's got both the x and y coordinates in d0 (16 bits each, x:y) and wants to unpack them into 2 32bit locations at a0 and 4(a0).
Jim
-
oops... a little bit too late :xmas:
lea 4(a0),a0
move.w d0,4(a0)
swap d0
move.w d0,(a0)
swap d0
start of the routine missing :
move.l #BpVector,d0
add.l d7,d0
lea CLvect-2,a0
moveq #0,d4
moveq #7-1,d7 ; 7 lines
now it's more simple to understand what do the prog :
only install Bitplan Vector address (d0) into the Copperlist Bitplan registers pointed in A0 (CLvect=CopperList)
CopperList:
CLvect
dc.w $e0,0,$e2,0 ; bitplan 0
dc.w $e4,0,$e6,0 ; bitplan 1
dc.w $e8,0,$ea,0 ; bitplan 2
dc.w $ec,0,$ee,0
$ex = $dff0ex = bitplans pointers (screen)
bitplan0 : $dff0e0 long word ($e0 and $e2)
d0=address high.w low.w .
example : for BpVector at d0=$51000
move.w d0 = $1000
swap d0
move.w d0 = $0005
$dff0e0 .w = $0005, $dff0e2 .w =$1000 => $dff0e0 .L = $51000