SETAE

Discuss ZX Spectrum Next Games, Tools and more.
Post Reply
User avatar
Maziac
Posts: 60
Joined: Sun Jul 09, 2017 5:56 am

SETAE

Post by Maziac » Thu Sep 13, 2018 4:56 pm

Hello,
the specification is a little vague about this instruction:
will it just set the bit and leave the other bits alone or will it zero out A before setting the bit.

E.g. What is the result of this:
LD A,10000000b
LD E,2
SETAE

Will it be
A=00000100b
or
A=10000100b
?

Alcoholics Anonymous
Posts: 508
Joined: Mon May 29, 2017 7:00 pm

Re: SETAE

Post by Alcoholics Anonymous » Thu Sep 13, 2018 5:06 pm

It zeroes it out, ie it loads one of 1,2,4,8,16,32,64,128 into A.

User avatar
SevenFFF
Posts: 221
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: SETAE

Post by SevenFFF » Thu Sep 13, 2018 5:16 pm

A=00100000b

The primary purpose of SETAE is to make it easy to plot ULA pixels, so the bits are numbered starting from the left.

Jim gives the example:

Code: Select all

ld d, ypos
ld e, xpos
pixelad
setae
or (hl)
ld (hl), a
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

User avatar
Maziac
Posts: 60
Joined: Sun Jul 09, 2017 5:56 am

Re: SETAE

Post by Maziac » Thu Sep 13, 2018 7:53 pm

Thansk for the info, I hadn't expected that.

User avatar
SevenFFF
Posts: 221
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: SETAE

Post by SevenFFF » Thu Sep 13, 2018 9:13 pm

Me neither, I was very surprised! Were you planning to use it for non-pixel purposes, then?
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

User avatar
Maziac
Posts: 60
Joined: Sun Jul 09, 2017 5:56 am

Re: SETAE

Post by Maziac » Fri Sep 14, 2018 10:26 am

Yes, I'm using it in a completely different context.
It is still usable. I just work the other way round now.

Ped7g
Posts: 109
Joined: Mon Jul 16, 2018 7:11 pm

Re: SETAE

Post by Ped7g » Wed Dec 26, 2018 10:21 pm

It's like "RRC 0x80 by E -> A" (E&7 for the identical result with fewer steps) = "rotate 0x80 right E-many-times, store result into A". So it's basically another "barrel" shift instruction, but somewhat different one from the new BSLA/BSRA/..., that it preload constant 0x80 as initial value to be rotated. It feels like it must be usable elsewhere too, although I have no particular idea yet.

Post Reply