View Single Post
Old 19 January 2007, 15:42   #17
Steve
I Identify as an Ewok
 
Steve's Avatar
 
Join Date: Jul 2001
Location: North Lincolnshire
Age: 45
Posts: 2,356
A couple of notes...

Some jargon stuff incase anyone is confused:

8 bits = byte
16 bits = word (2 bytes)
32 bits = long word (4 bytes)


Also commands such as move, add, mul and div all have a . extension which indicates how many 'bits' of the particular register are to be copied, added, multiplied etc. I think you can leave out the extension and it defaults to byte size calculations. I think.


move.b (this copies the lower 8 bits of the source to the lower 8 bits of the destination)
move.w (this copies the lower 16 bits of the source to the lower 16 bits of the destination)
move.l (this copies all 32 bits of the source to all 32 bits of the destination)


Also...

rts = return from subroutine
dc = define constant variable (a bit of memory you can name and give a value)
ds = define storage variable (a bit of memory you can name and reserve for future use)


Variables in 68000 can also be declared as byte, word or long word size. If you know a variable will never exceed a specific value then limit the size of your variable. For example don't create a dc.l 32-bit variable when the value it holds will never be larger than 100. It won't cause any problems by setting it as 32-bit but it is wasteful of memory which is quite precious on an Amiga.

Another instruction I think is worth mentioning at this stage is the equate directive: EQU. This is very similar to the define constant instruction which is described above except that the value it holds is set in stone and can never change. These constant values can contain decimal, hexadecimal or even binary values! These constant values are very useful and are used a lot in assembly programming! Note that the equate command does not accept a size extension like the dc and ds instructions.

Here is a quick example taken from the GameBoy Mr Do source code:
Code:
MRDOSPEED	EQU	128+64+32
EATSPEED	EQU	128+32
BALLSPEED	EQU	2
BRDLEN		EQU	9		;SCORE BOARD LENGTH

STACK		EQU	$CFFF
OBJSET		EQU	$8000		;$1000
BGSET		EQU	OBJSET+$1000	;$800
DISPSCREEN	EQU	$9800		;$400
STATSCREEN	EQU	$9C00		;$400
BACKSCREEN	EQU	$C800		;$400
BYTESCREEN	EQU	$CC00		;$100
WORKRAM	EQU	$C000
OAMRAM		EQU	$FE00
INTRAM		EQU	$FF80
BLITS		EQU	INTRAM
OBJDATA		EQU	OAMRAM

Last edited by Steve; 19 January 2007 at 17:01.
Steve is offline  
 
Page generated in 0.16995 seconds with 11 queries