Possible bug in ZX81x2 ROM ?

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
olofsen
Posts: 156
Joined: Wed Jan 08, 2014 12:29 pm

Re: Possible bug in ZX81x2 ROM ?

Post by olofsen » Thu Oct 25, 2018 11:59 pm

Does the attached demo run ok? I changed a few calls to the ROM...

Code: Select all

	defpage 0,16393
	page 0
	incbin HRDEMO30.P

	code !	48f5h
	call	1be9h

	code !	4a40h
	call	nz,1b8dh
	
	code !	4b80h
	call	19fdh
Attachments
p.p
(13.18 KiB) Downloaded 46 times

User avatar
siggi
Posts: 879
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Possible bug in ZX81x2 ROM ?

Post by siggi » Fri Oct 26, 2018 12:23 am

The program does not stop at 1000 (OK!), but some screens are not inverted as expected.
Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
zsolt
Posts: 192
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Possible bug in ZX81x2 ROM ?

Post by zsolt » Fri Oct 26, 2018 10:59 am

Hi,
Have you any contact to authors?
It would be fine to know, what parts of rom are called by this excellent tool.
Thanks,
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]

User avatar
siggi
Posts: 879
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Possible bug in ZX81x2 ROM ?

Post by siggi » Fri Oct 26, 2018 11:05 am

Maybe Greg knows some details?

viewtopic.php?f=5&t=1263#p13470

Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
GCHarder
Posts: 212
Joined: Sat Dec 14, 2013 7:46 pm

Re: Possible bug in ZX81x2 ROM ?

Post by GCHarder » Sat Oct 27, 2018 4:35 am

The "FILL" routine makes a call to n-mod-m (1C37) at 48F5, it's no longer at that location. The program doesn't crash because it hits the RST 08 with error code E6 at 1C49, causing the stack to reset and return to BASIC. That's why nothing is printed.

Regards;

Greg

User avatar
zsolt
Posts: 192
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Possible bug in ZX81x2 ROM ?

Post by zsolt » Mon Oct 29, 2018 4:46 pm

Hi,

The 'MODULUS' subroutine is now in its original location (1C37). :D Thanks Greg!

Regards,
Zsolt

Edit: the TEST_5_SP routine too (see here)
Last edited by zsolt on Tue Oct 30, 2018 10:50 pm, edited 1 time in total.
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]

User avatar
siggi
Posts: 879
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Possible bug in ZX81x2 ROM ?

Post by siggi » Tue Oct 30, 2018 9:38 am

Hi ZSOLT
there is still a problem when running the demo: at the screen, where the current position of the cursor on screen is read back to be used by BASIC, the program stops (or the Zeddy restarts), after I have pressed the key "r" (cursor in the region inside the 2 "circles"):
ZX81m2a.jpg
ZX81m2a-error.jpg
Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
zsolt
Posts: 192
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Possible bug in ZX81x2 ROM ?

Post by zsolt » Tue Oct 30, 2018 2:19 pm

siggi wrote:
Tue Oct 30, 2018 9:38 am
there is still a problem when running the demo...
It is very likely that there are another direct calls to the changed ROM areas... :cry:
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]

User avatar
siggi
Posts: 879
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Possible bug in ZX81x2 ROM ?

Post by siggi » Tue Oct 30, 2018 7:47 pm

Hi ZSOLT
the C compiler z88dk also can use the ZX81 math routines in rom to do floating point calculations (depending on the linked math lib). As I understood the source files, it uses RST $28 to call the rom math routines. Does that still fit to your rom?

Siggi

z88dk file "81fp.def"

Code: Select all

lstoff

; ZX 81 stack calculator functions (ZX81 version of ZXFP)

; $Id: 81fp.def,v 1.7 2015-08-01 09:14:43 stefano Exp $

; function codes:

		; RST 28h activates the FP calculator
		DEFC	ZXFP_BEGIN_CALC	= $28

		DEFC	ZXFP_STK_PTR	= $401C

		DEFC	ZXFP_STK_STORE	= $12C3
		DEFC	ZXFP_TEST_5_FP	= $19EB
		DEFC	ZXFP_STK_STR	= $12C3
		DEFC	ZXFP_STK_FETCH	= $13F8
		DEFC	ZXFP_STACK_A	= $151D
		DEFC	ZXFP_STACK_BC	= $1520
		DEFC	ZXFP_FP_TO_BC	= $158A
		DEFC	ZXFP_FP_TO_A	= $15CD
		
		DEFC	ZXFP_INT_TO_FP	= $1548
		DEFC	ZXFP_DEC_TO_FP	= $14D9

		DEFC	ZXFP_JUMP_TRUE	= $00
		DEFC	ZXFP_EXCHANGE	= $01
		DEFC	ZXFP_DELETE	= $02

		DEFC	ZXFP_SUBTRACT	= $03
		DEFC	ZXFP_MULTIPLY	= $04
		DEFC	ZXFP_DIVISION	= $05
		DEFC	ZXFP_TO_POWER	= $06
		DEFC	ZXFP_OR		= $07
		DEFC	ZXFP_NO_AND_NO	= $08
		DEFC	ZXFP_NO_L_EQL	= $09
		DEFC	ZXFP_NO_GR_EQL	= $0A
		DEFC	ZXFP_NOS_NEQL	= $0B
		DEFC	ZXFP_NO_GRTR	= $0C
		DEFC	ZXFP_NO_LESS	= $0D
		DEFC	ZXFP_NOS_EQL	= $0E

		DEFC	ZXFP_ADDITION	= $0F

		DEFC	ZXFP_STR_AND_NO	= $10	; String and Number
		DEFC	ZXFP_STR_L_EQL	= $11	; String <=
		DEFC	ZXFP_STR_GR_EQL	= $12	; String >=
		DEFC	ZXFP_STRS_NEQL	= $13	; String <>
		DEFC	ZXFP_STRS_GRTR	= $14	; String >
		DEFC	ZXFP_STRS_LESS	= $15	; String <
		DEFC	ZXFP_STRS_EQL	= $16	; String =
		DEFC	ZXFP_STRS_ADD	= $17	; String addition
		
		DEFC	ZXFP_NEGATE	= $18

		DEFC	ZXFP_CODE	= $19
		DEFC	ZXFP_VAL	= $1A
		DEFC	ZXFP_LEN	= $1B

		DEFC	ZXFP_SIN	= $1C
		DEFC	ZXFP_COS	= $1D
		DEFC	ZXFP_TAN	= $1E
		DEFC	ZXFP_ASN	= $1F
		DEFC	ZXFP_ACS	= $20
		DEFC	ZXFP_ATN	= $21
		DEFC	ZXFP_LN 	= $22
		DEFC	ZXFP_EXP	= $23
		DEFC	ZXFP_INT	= $24
		DEFC	ZXFP_SQR	= $25
		DEFC	ZXFP_SGN	= $26
		DEFC	ZXFP_ABS	= $27

		DEFC	ZXFP_PEEK	= $28
		DEFC	ZXFP_USR_NO	= $29
		
		DEFC	ZXFP_STRS	= $2A
		DEFC	ZXFP_CHRS	= $2B
		DEFC	ZXFP_NOT	= $2C

		DEFC	ZXFP_DUPLICATE	= $2D
		DEFC	ZXFP_N_MOD_M	= $2E
		
		DEFC	ZXFP_JUMP	= $2F
		DEFC	ZXFP_STK_DATA	= $30		
		DEFC	ZXFP_DEC_JR_NZ	= $31
		
		DEFC	ZXFP_LESS_0	= $32
		DEFC	ZXFP_GREATER_0	= $33
		
		DEFC	ZXFP_END_CALC	= $34	; END

		DEFC	ZXFP_GET_ARGT	= $35
		DEFC	ZXFP_TRUNCATE	= $36
		DEFC	ZXFP_FP_CALC_2	= $37

		DEFC	ZXFP_E_TO_FP	= $38
		
		DEFC	ZXFP_SERIES_00	= $80
		DEFC	ZXFP_SERIES_01	= $81
		DEFC	ZXFP_SERIES_02	= $82
		DEFC	ZXFP_SERIES_03	= $83
		DEFC	ZXFP_SERIES_04	= $84
		DEFC	ZXFP_SERIES_05	= $85
		DEFC	ZXFP_SERIES_06	= $86
		DEFC	ZXFP_SERIES_07	= $87
		DEFC	ZXFP_SERIES_08	= $88
		DEFC	ZXFP_SERIES_09	= $89
		DEFC	ZXFP_SERIES_0A	= $8A
		DEFC	ZXFP_SERIES_0B	= $8B
		DEFC	ZXFP_SERIES_0C	= $8C
		DEFC	ZXFP_SERIES_0D	= $8D
		DEFC	ZXFP_SERIES_0E	= $8E
		DEFC	ZXFP_SERIES_0F	= $8F

		DEFC	ZXFP_STK_ZERO	= $A0
		DEFC	ZXFP_STK_ONE	= $A1
		DEFC	ZXFP_STK_HALF	= $A2
		DEFC	ZXFP_STK_PI_D_2	= $A3
		DEFC	ZXFP_STK_TEN	= $A4
		
		DEFC	ZXFP_ST_MEM_0	= $C0
		DEFC	ZXFP_ST_MEM_1	= $C1
		DEFC	ZXFP_ST_MEM_2	= $C2
		DEFC	ZXFP_ST_MEM_3	= $C3
		DEFC	ZXFP_ST_MEM_4	= $C4
		DEFC	ZXFP_ST_MEM_5	= $C5

		DEFC	ZXFP_GET_MEM_0	= $E0
		DEFC	ZXFP_GET_MEM_1	= $E1
		DEFC	ZXFP_GET_MEM_2	= $E2
		DEFC	ZXFP_GET_MEM_3	= $E3
		DEFC	ZXFP_GET_MEM_4	= $E4
		DEFC	ZXFP_GET_MEM_5	= $E5

		; System variables
		DEFC	ZXFP_CH_ADD	= $4016

lston

z88dk file "atof.asm"

Code: Select all

;
;       ZX Maths Routines
;
;       9/12/02 - Stefano Bodrato
;
;       $Id: atof.asm,v 1.5 2016-06-22 19:59:18 dom Exp $
;


;double atof(char *)     - convert string to number, leave in fa

IF FORts2068
		INCLUDE  "target/ts2068/def/ts2068fp.def"
ENDIF
IF FORzx
		INCLUDE  "target/zx/def/zxfp.def"
ENDIF
IF FORzx81
		INCLUDE  "target/zx81/def/81fp.def"
ENDIF
IF FORlambda
		INCLUDE  "target/lambda/def/lambdafp.def"
ENDIF

                SECTION  code_fp
                PUBLIC    atof

                EXTERN	stkequ

;.casave		defw	0

.atof
		pop	hl
		pop	de	;the string
		push	de
		push	hl

		ld	hl,(ZXFP_CH_ADD)
		push	hl
		
.nobloop	ld	a,(de)			; load the first number digit in A
		cp	' '			; skip spaces
		jr	nz,noblank
		inc	de
		jr	nobloop
.noblank	
		cp	'-'
		push	af
		jr	nz,noneg
		inc	de
		ld	a,(de)
.noneg

IF (FORzx | FORts2068)
ELSE
		ld	hl,txtbuffer
		push	hl
.nloop
		cp	0
		jr	z,converted
		sub	20
		cp	26
		jr	nz,nodot
		ld	a,27
.nodot
		ld	(hl),a
		inc	hl
		inc	de
		ld	a,(de)
		jr	nloop
 
.txtbuffer	defs	15

.converted
		ld	a,$76
		ld	(de),a
		pop	de
		ld	a,(de)
		
ENDIF

		ld	(ZXFP_CH_ADD),de		; Init the BASIC interpreter pointer
		call	ZXFP_DEC_TO_FP		; ask BASIC to load the string into a number
		
		pop	af
		jr	nz,noneg1
		rst	ZXFP_BEGIN_CALC
IF FORlambda
	defb	ZXFP_NEGATE + 128
ELSE
	defb	ZXFP_NEGATE
	defb	ZXFP_END_CALC
ENDIF
.noneg1

		pop	hl
		ld	(ZXFP_CH_ADD),hl		; restore the pointer

		jp      stkequ
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
GCHarder
Posts: 212
Joined: Sat Dec 14, 2013 7:46 pm

Re: Possible bug in ZX81x2 ROM ?

Post by GCHarder » Tue Oct 30, 2018 10:20 pm

I'll check the whole listing tonight to see if there are any another esoteric ROM calls.

Regards;

Greg

Post Reply