Z80 Assembler

Muppz

Active member
Feedback
6 (100%)
Credits
362CR
Afternoon folks,

I'm having a play with an old msx and some of the assembler source code examples for the video processor have me a bit confused which is not hard to do these days and Z80 was never my strongest language.

the bit that is confusing me is the meaning of the following (its a section from how to program the palettes)

defb 4*0, 4*0, 4*0

defb 4*3, 4*7, 4*3

I may well be being a numpty but I've never come across that notation before.

My best guess is its some sort of array concept...

Can anyone clue me in?

Cheers

Chris
 

Hurray Banana

Moderator
Staff member
vacBacker
Feedback
8 (100%)
Credits
2,714CR
Looks like a assembler specific statement ptobsbly filling 4 bytes with zero then doing the same with another eight. the next statement filling the next 4 bytes with 3 then the next 4 with 7 then the final 4 with 3 again.

Just a guess mind
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,640CR
defb = define bytes

Assuming the assembler you're using treats '*' as multiply then the above would be the same as :-

defb 0,0,0
defb 12,28,12

Seems an odd way of defining bytes to me but it may well have been the norm for the person who originally wrote the examples!
 

Muppz

Active member
Feedback
6 (100%)
Credits
362CR
cheers cmonkey,

I think I eventually figured it out after seeing another example with 4 palette sets and it makes even less sense, the * appears to be being used like a delimiter, the 4 seems to mean the palette number and the bit after the * was the value for the Red, Green, Blue components.

That must have been one crazy assembler the original coder used.
 

Hurray Banana

Moderator
Staff member
vacBacker
Feedback
8 (100%)
Credits
2,714CR
ade you're explanation makes sense, not done assembly for so long fotget conventions i ysed to use. i remember now that I used to define look up tables using similar formatting.
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,640CR
You're right there Muppz, it sure must have been a crazy assembler that the original coder used! I've never seen a Z80 assembler use '*' as a delimiter, and I've certainly used a fair share of Z80 assemblers in my time!
 

Muppz

Active member
Feedback
6 (100%)
Credits
362CR
My thinking it was a delimiter was wrong and you were right about the multiplier.

The 4 palette thing was a co-incidence in that he set each palette so palette 1 was dfb 1*2, 1*3,1*0 palette 2 was 2*0,2*5,2*1 and so on for palettes 3 & 4

I've found it's his coding style to just multiplies values up a lot rather than put in the actual value, so to clear 4 palettes he just loads up a counter like this LD B,64 * 4

I suppose it makes sense but without comments in the source its hard work.

I've spent to much time with high level languages, I need to go back to being 13 again.

Thanks for input chaps.
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,640CR
The instruction LD B,64*4 would probably fail during assembly as it would overflow register B because it's only an 8-bit register (valid values 0-255) and 64*4 = 256. LD BC,64*4 would be OK though.

In contrast to you I spend ALL my time in low level languages and haven't a clue how to program in modern day high-level languages! I need to grow up and move into the modern world!
 

Muppz

Active member
Feedback
6 (100%)
Credits
362CR
you are correct it was a typo, should have been 64 *3

At least with ASM you don't have to worry about tracking down errors due to compiler optimisations and their inherent problems like if you write to a location and read it back form the location and its not what you expected because it tried to be clever and put it into a register and just read it back from there instead of the memory location you wanted to read.
 
Top