1

I am a beginner using assembler. I know this isn't the fastest to change the background color (using a function) but why doesn't the 2nd example work?

THIS WORKS :

**** void change_back(int color) *************************************
change_back:
	.set	_ARGS, 4
	
	move.l _ARGS(a7),d0
	move.w d0,0x401ffe
	rts
THIS DOESN'T

**** void change_back(int color) *************************************

change_back:
	.set	_ARGS, 4

	move.w _ARGS(a7),0x401ffe
	rts

Appreciate any help/explanation. Thank you.

2

you are moving a "long" in the first example, and only using the last word of the long, so if your long value is 0x12345678, you are moving 0x5678
in the second example you move the first word of the argument, so you are moving 0x1234
if you want to move 0x5678 you must add 2 to a7 pointer
move.w _ARGS+2(a7),0x401ffe

3

Artemis (./2) :
you are moving a "long" in the first example, and only using the last word of the long, so if your long value is 0x12345678, you are moving 0x5678
in the second example you move the first word of the argument, so you are moving 0x1234
if you want to move 0x5678 you must add 2 to a7 pointer
move.w _ARGS+2(a7),0x401ffe

Excellent. Thank you. I thought it must be something like that but I assumed the lower part of the longword would be stored in memory first.

4

68000 is big endian, so the high part is stored first
most modern computer are low endian, that's why this may be confusing

5

Artemis (./4) :
68000 is big endian, so the high part is stored first
most modern computer are low endian, that's why this may be confusing

Sadly I don't have that excuse. I have only programmed on the PC using BlitzMax (a high level language like BASIC). I have written a few basic things in 68000 assembly over the years but actually never had this problem until now!