Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site decwrl.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!mcnc!decvax!decwrl!dec-rhea!dec-viking!wasser_1 From: wasser_1@viking.DEC (John A. Wasser) Newsgroups: net.puzzle Subject: Z80 Code Puzzle (from Dr. Dobbs Journal) Message-ID: <1059@decwrl.UUCP> Date: Mon, 11-Mar-85 17:34:03 EST Article-I.D.: decwrl.1059 Posted: Mon Mar 11 17:34:03 1985 Date-Received: Fri, 15-Mar-85 02:19:44 EST Sender: daemon@decwrl.UUCP Organization: DEC Engineering Network Lines: 44 In the January 1985 issue of Dr. Dobb's Journal, on page 17 the following article appeared: David S. Tilton sent us [DDJ] the following sequence of Z80 code. It's an absolutely astonishing implementation of... but you can figure it out. Unfortunately, it requires such narrowly defined conditions that it's probably useless, despite being the fastest one of its kind. What does it do, and what are its narrow requirements for utility? [Comments added by me -JW] ------------------------------------------------------------------------- ; A is an 8 bit register ; B is an 8 bit register ; HL is a 16 bit register made up of H (the high byte) and L (the low byte) ; LOOP: CP (HL) ; Compare A to memory at HL RET Z ; Return if equal. RL L ; Rotate carry and L register (bottom 8 bits of ; HL pair) left (Carry goes into LSB of L) DJNZ LOOP ; B--; if (B != 0) GOTO LOOP LD L,0 ; Load L with the value Zero. RET ; Return ------------------------------------------------------------------------- I have yet to hear a reasonable answer. If you get an answer from DDJ, please don't post it for a couple of weeks... that would spoil the fun! -John A. Wasser Work address: ARPAnet: WASSER%VIKING.DEC@decwrl.ARPA Usenet: {allegra,Shasta,decvax}!decwrl!dec-rhea!dec-viking!wasser USPS: Digital Equipment Corp. Mail stop: LJO2/E4 30 Porter Rd Littleton, MA 01460