SET n,r - Newbie question

Post programming questions related to the CPC Here!
Post Reply
aevin
Posts: 2
Joined: Fri Mar 04, 2022 11:04 am

SET n,r - Newbie question

Post by aevin » Fri Mar 04, 2022 5:30 pm

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.
Attachments
FB_IMG_1646381821839.jpg
FB_IMG_1646381821839.jpg (159.85 KiB) Viewed 159 times

User avatar
akuyou
Posts: 511
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: SET n,r - Newbie question

Post by akuyou » Sat Mar 05, 2022 10:55 pm

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
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

aevin
Posts: 2
Joined: Fri Mar 04, 2022 11:04 am

Re: SET n,r - Newbie question

Post by aevin » Sun Mar 06, 2022 4:51 pm

Thanks for the reply! Makes perfect sense :geek:

Post Reply

Return to “Amstrad CPC Assembly Programming”