FIZZBUZZ

Discussion about ZX80 / ZX81 Software
User avatar
gus
Posts: 177
Joined: Fri May 16, 2008 10:18 pm
Location: Buenos Aires. Argentina
Contact:

Re: FIZZBUZZ

Post by gus »

Hi guys !

I take the comment of Rich and made the decision to fix my version in order to meets the rules, I think that the program is correct now but I a new problem arise. Now I can't find the secret image of the ULA can you see something ?


Gus

Image

Attachments
fizzbuzz-4.rar
FizzBuzz by Guzz, bugzz free version :)
(326 Bytes) Downloaded 232 times
RWAP
Posts: 1348
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: FIZZBUZZ

Post by RWAP »

No image of the ULA - but I see an army marching past the screen....
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: FIZZBUZZ

Post by Paul »

The links to the PROGs are broken,
could anybody repost them here?
Thanks Paul
In theory, there is no difference between theory and practice. But, in practice, there is.
User avatar
gus
Posts: 177
Joined: Fri May 16, 2008 10:18 pm
Location: Buenos Aires. Argentina
Contact:

Re: FIZZBUZZ

Post by gus »

Hi paul,

My version is attached.

Be well,
Gus
Attachments
fizzbuzz-4.rar
FizzBuzz by Guzz, bugzz free version :)
(326 Bytes) Downloaded 183 times
Last edited by gus on Tue Jun 21, 2011 3:16 pm, edited 1 time in total.
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: FIZZBUZZ

Post by Paul »

Thanks GUS!
Any chance for the source?
In theory, there is no difference between theory and practice. But, in practice, there is.
User avatar
gus
Posts: 177
Joined: Fri May 16, 2008 10:18 pm
Location: Buenos Aires. Argentina
Contact:

Re: FIZZBUZZ

Post by gus »

Paul,

Here is the source code, maybe a dirty source, because I write it on a record time :)
I normally use PASMO for all my cross assembler works.

Gus

Code: Select all


;-------------------------------------------------
;
;		FIZZBUZZ
;
;		By Gus  gdeldago@gmail.com
;
;-------------------------------------------------
FIZZBUZZ:	
	
	LD 		B, $64
	LD		A, 0

	LD		(FIZZ), A
	LD		(BUZZ), A

LOOP		
	INC		A
	
	PUSH	       AF
	PUSH	       BC
		
	CALL	       PRINT_A_DEC
	
	LD		A, 0
	RST		$10
	
	LD		A, (FIZZ)
	INC		A
	LD		(FIZZ), A
	
	CP		3
	JP		NZ, NO_3
	LD		A, 0
	LD		(FIZZ), A
	
	CALL	PRINT_FIZZ

NO_3:

	LD		A, (BUZZ)
	INC		A
	LD		(BUZZ), A
	
	CP		5
	JP		NZ, NO_5
	LD		A, 0
	LD		(BUZZ), A
	
	CALL	        PRINT_BUZZ

NO_5:
	LD		A, (FIZZ)
	CP		0
	JP		NZ, SIGUE
	RST		$10
SIGUE:	

	POP		BC
	POP		AF
		
	DJNZ 	        LOOP
	
	RET
	
	
PRINT_FIZZ:
	LD		A, _F
	RST		$10
	LD		A, _I
	RST		$10
	LD		A, _Z
	RST		$10
	LD		A, _Z
	RST		$10
	RET

PRINT_BUZZ:
	LD		A, _B
	RST		$10
	LD		A, _U
	RST		$10
	LD		A, _Z
	RST		$10
	LD		A, _Z
	RST		$10
	LD		A, __
	RST		$10

	RET
	
;-------------------------------------------------
;
; 	PRINT REGISTER A IN DECIMAL
;	
; Si quiero suprimir los ceros a la izquierda
; descomento las lineas comentadas. 
;-------------------------------------------------

PRINT_A_DEC:
	
	LD		E, 0
	LD		D, $64 		; 100
DEC81		LD C, $1B 	        ;  "0" - 1
DEC82:		INC	C
	SUB		D
	JP		NC, DEC82
	ADD		A, D
	LD		B, A
	LD  	        A, C
	CP		$1D	                ;  "1"
	JP		NC, DEC84
	LD		A, E
	OR		A
	LD		A, C
	JP		Z, DEC85
DEC84:			
	PUSH	AF
	RST		$10
	POP		AF
	LD		E, $FF		; SET 0 FLAG
DEC85:		LD	A, D
	SUB		$5A			; 90
	LD		D, A
	LD		A, B
	JP		NC, DEC81	        ; AGAIN
	ADD		A, $1C		; "0"

	PUSH	AF
	RST		$10
	POP		AF
	RET

FIZZ	DB	0
BUZZ	DB	0

	DB 		$76             ;N/L
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: FIZZBUZZ

Post by Paul »

I made a small version in Basic without IF and without FOR
It has to be started by goto 10, as the Variables are predefined
It looks a bit funny, but does something similar.
Its still 307 Bytes and I wonder how I could save some more bytes...
any suggestions?
Attachments
Programm.jpg
Programm.jpg (6.88 KiB) Viewed 5922 times
fizz1k.P
FIZZBUZZ_FUNNY_1K
(307 Bytes) Downloaded 186 times
In theory, there is no difference between theory and practice. But, in practice, there is.
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: FIZZBUZZ

Post by Paul »

OK stupid me,
eliminate the numbers!!!
Its down to 292 Bytes
Attachments
fizz1k_1.P
(292 Bytes) Downloaded 188 times
Programm.jpg
Programm.jpg (6.79 KiB) Viewed 5917 times
In theory, there is no difference between theory and practice. But, in practice, there is.
User avatar
gus
Posts: 177
Joined: Fri May 16, 2008 10:18 pm
Location: Buenos Aires. Argentina
Contact:

Re: FIZZBUZZ

Post by gus »

It's a nice version :)
How are you checking the used memory ?
Gus
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: FIZZBUZZ

Post by Paul »

I take the size of the .P file ;)
In theory, there is no difference between theory and practice. But, in practice, there is.
Post Reply