I am shocked and apalled [Z80]

A General Discussion forum for TI calculators

Moderator: MaxCoderz Staff

User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

I am shocked and apalled [Z80]

Post by Dwedit »

I've just observed this ungodly quirk in the wild:
* People actually use the RLC A instruction! (CB 07)

This is unbelievably freaky and shocking.
You know your hexadecimal output routine is broken when it displays the character 'G'.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

Who uses it? Where?!

Maybe they dont care about wasting cycles? :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Where?
Image
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Technically, this was for the Gameboy's GBZ80, not the regular Z80. I ran the Goomba emulator for an hour, playing various GB/GBC games in it. I was logging every instruction the program executed.

The RLC A instruction was executed 137,027 times total. Don't know which game used it. Yes, the GBZ80 does have the RLCA instruction.

For no reason, here are the Top 16 GBZ80 instructions:

Code: Select all

80,972,151	JR NZ,*
65,096,871	LD A,(nnnn)
63,428,950	JR Z,*
44,654,086	LD A,($FF00+nn)
32,027,560	AND A
28,065,301	LDI A,(HL)
27,762,895	LD (nnnn),A
26,706,384	CP #nn
24,199,159	OR A
22,119,619	AND #nn
20,076,686	RET
18,791,319	CALL $nnnn
18,340,846	LD ($FF00+nn),A
16,734,913	LD HL,#nnnn
16,002,933	LDI (HL),A
15,967,845	CP (HL)
You know your hexadecimal output routine is broken when it displays the character 'G'.
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Good to know.
Image
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Post by calc84maniac »

I wonder how many appearances of SCF\CCF there were... :roll:
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

SCF: 381,473
CCF: 328,272
You know your hexadecimal output routine is broken when it displays the character 'G'.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

I assumed that was in reference to there not being a "clear carry flag" instruction and using SCF/CCF.
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Post by calc84maniac »

I meant instead of "or a".
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

OR A and SCF/CCF both do different things (what if you wanted to preserve S, Z and PV flags?)

Same goes for using LD A,0 rather than XOR A.
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

And the same applies to RLCA in the other direction. What if you want the sign or parity of the resulting value while also needing the carry? RLC A is your friend then.
User avatar
anykey
Extreme Poster
Posts: 420
Joined: Mon 31 Jan, 2005 3:36 am
Location: In the matrix
Contact:

Post by anykey »

can somebody explain to me in layman's terms what's so shocking about this?!
I think, therefore iMac
Image
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

anykey wrote:can somebody explain to me in layman's terms what's so shocking about this?!
They used RLC instruction with the register A (two bytes and 8 tstates) when there is an instruction called RLCA which is a 1-byte instruction that does the same thing in 4 tstates.
Image
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Post by calc84maniac »

Aw CoBB, you stole my post!
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)
User avatar
hop
Extreme Poster
Posts: 378
Joined: Sat 09 Dec, 2006 3:42 pm

Post by hop »

Maybe the logger doesn't make a distinction between the two?
Image
Post Reply