Page 1 of 1

SET n,r - Newbie question

Posted: Fri Mar 04, 2022 5:30 pm
by aevin
Hello everyone! Nice to be here :)

Im struggling to decipher a small assembly code that creates some graphics on the Amstrad, for a few days now. My knowledge of assembly is pretty limited still but im getting the hang of it. The code that i can't really understand is:

SET 6, H
SET 7, H

I've read the definition of SET, and how this is setting the # bit on a register H, etc - but i don't fully understand how (and why) setting those bits triggers the display to output pixels on the screen - Is it maybe an alternative way to point to the Video ram? I've seen tens of examples but none used this couple of commands.
Any dummuy-proof :ugeek: explanation of the following code will be very appreciated

Thank you!

Here's the whole thing:

Code: Select all

Org &4000
.loop
Set 6, h
Set 7, h
Ld (hl), e
Adc hl, de
Inc de
jr loop
PS. the screenshot is a result of a bit more complex version, using a XOR but still pretty similar.

Re: SET n,r - Newbie question

Posted: Sat Mar 05, 2022 10:55 pm
by akuyou
The set commands here do not affect the contents of the VRAM directly, only the contents of the register, it's the 'Ld (hl), e' command which is altering VRAM.

HL is the pointer to the VRAM address, made up of the H L pair - The set command (along with the ADC) is being used to alter the VRAM destination

With Z80 Any time you see a value in brackets it's an address, so (HL) is using the address in HL as a source or destination, (&1000) is using the address &1000 etc. 'SET 7,(HL)' would directly set a bit of VRAM, but 'SET 7,H' only affects the register H

Re: SET n,r - Newbie question

Posted: Sun Mar 06, 2022 4:51 pm
by aevin
Thanks for the reply! Makes perfect sense :geek: