f



CPM3 Time and Date stamping, question

Have just spent the past two days getting a time/day routine to work
with CPM3 and the SD Systems 8IO serial board (with an MM58167 clock
chip).  Nice to have real time stamping on files.  Thanks to the Y2000
patches etc by http://www.gaby.de/edownl.htm and others it=92s really
solid.

But here is my problem.  CPM has a screwball way of storing the date.
It does it as a 16 bit number of a count of the total days since
1/1/1978.  The problem is SD Systems store that 16 bit number in the
RAM of the chip and sets the days/years hardware ports then to count
up from 1. CPM resets the total back to 1 on each update.  This way
with battery backup if the machine is off for days we are all OK on
the next read.
Here is my problem. I like to have the chip give the date with other
systems and on startup in my ROM monitor.  Can figure all of this out
if I could find a way (in Z80 code) to convert that above 16 bit
number into days, months, years.  CPM does it in PL/M which I don=92t
know.
Question:-  Does anybody have  (or seen) Z80 code to convert a 16 bit
number efficiently into days, months, years.   Hope I don=92t have to
reinvent the wheel!

0
monahan (173)
11/15/2009 12:11:24 AM
comp.os.cpm 3422 articles. 0 followers. Post Follow

35 Replies
1864 Views

Similar Articles

[PageSpeed] 36

monahanz <monahan@vitasoft.org> wrote:
: Question:-  Does anybody have  (or seen) Z80 code to convert a 16 bit
: number efficiently into days, months, years.   Hope I don?t have to
: reinvent the wheel!

  c3dmy.z80 (part of ZINC) does this. You'll find it in

<http://www.seasip.demon.co.uk/Cpm/Zinc/c3libsrc.pma>

  It relies on externals (DIVHD and MULHD) for 16-bit multiplication and 
division. They can be found in the SYSLIB library:

<http://www.retroarchive.org/cpm/cdrom/ZSYS/SIMTEL20/SYSLIB/>

  I'm not sure whether it counts as 'efficient' code, either for space or
speed.

-- 
John Elliott

Thinks: This is what a nice clean life leads to. Hmm, why did I ever lead one?
		-- Bluebottle, in the Goon Show
0
John
11/15/2009 1:28:04 AM
On Nov 14, 5:28=A0pm, John Elliott <j...@seasip.demon.co.uk> wrote:
> monahanz <mona...@vitasoft.org> wrote:
>
> : Question:- =A0Does anybody have =A0(or seen) Z80 code to convert a 16 b=
it
> : number efficiently into days, months, years. =A0 Hope I don?t have to
> : reinvent the wheel!
>
> =A0 c3dmy.z80 (part of ZINC) does this. You'll find it in
>
> <http://www.seasip.demon.co.uk/Cpm/Zinc/c3libsrc.pma>
>
> =A0 It relies on externals (DIVHD and MULHD) for 16-bit multiplication an=
d
> division. They can be found in the SYSLIB library:
>
> <http://www.retroarchive.org/cpm/cdrom/ZSYS/SIMTEL20/SYSLIB/>
>
> =A0 I'm not sure whether it counts as 'efficient' code, either for space =
or
> speed.
>
> --
> John Elliott
>
> Thinks: This is what a nice clean life leads to. Hmm, why did I ever lead=
 one?
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- Bluebottle, in the Goon Show

What the hexk is a .pma file?  Checked the web, got something
refferring to "file format used on MSX computers".  Do you have a
sourse for some kind of converter to make it into normal text
0
monahanz
11/15/2009 2:29:16 AM
On Nov 14, 5:28=A0pm, John Elliott <j...@seasip.demon.co.uk> wrote:
> monahanz <mona...@vitasoft.org> wrote:
>
> : Question:- =A0Does anybody have =A0(or seen) Z80 code to convert a 16 b=
it
> : number efficiently into days, months, years. =A0 Hope I don?t have to
> : reinvent the wheel!
>
> =A0 c3dmy.z80 (part of ZINC) does this. You'll find it in
>
> <http://www.seasip.demon.co.uk/Cpm/Zinc/c3libsrc.pma>
>
> =A0 It relies on externals (DIVHD and MULHD) for 16-bit multiplication an=
d
> division. They can be found in the SYSLIB library:
>
> <http://www.retroarchive.org/cpm/cdrom/ZSYS/SIMTEL20/SYSLIB/>
>
> =A0 I'm not sure whether it counts as 'efficient' code, either for space =
or
> speed.
>
> --
> John Elliott
>
> Thinks: This is what a nice clean life leads to. Hmm, why did I ever lead=
 one?
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -- Bluebottle, in the Goon Show

Thanks John. Just discovered your site. What a gem, great work!
What the heck is a .pma file?  Checked the web, got something
referring to "file format used on MSX computers".  Do you have a
source for some kind of converter to make it into normal text?
0
monahanz
11/15/2009 2:44:29 AM
monahanz <monahan@vitasoft.org> wrote:
: What the hexk is a .pma file?  Checked the web, got something
: refferring to "file format used on MSX computers".  Do you have a
: sourse for some kind of converter to make it into normal text

  PMA is an archive format, a variant of LZH. To extract it on a CP/M 
system, use PMEXT, which can be found in the self-extract archive 
<http://ftp.martnet.com/cpm/archivers/pmautoae.com>.

-- 
John Elliott

Thinks: This is what a nice clean life leads to. Hmm, why did I ever lead one?
		-- Bluebottle, in the Goon Show
0
John
11/15/2009 8:18:01 AM
Hi John,

On Sat, 14 Nov 2009 18:44:29 -0800 (PST), monahanz  wrote:

>Thanks John. Just discovered your site. What a gem, great work!
>What the heck is a .pma file?  Checked the web, got something
>referring to "file format used on MSX computers".  Do you have a
>source for some kind of converter to make it into normal text?

http://www.znode51.de/indexe.htm

It helped me in finding the long sought-for LHA-PMA.EXE for
DOS/Windows ! It is a command-line tool, but does a fine job! 

http://www.znode51.de/dostools/lha-pma.exe

Rolf

0
Rolf
11/15/2009 1:03:04 PM
On Nov 15, 5:03=A0am, Rolf Harrmann <rolf-junk-harrm...@t-online.de>
wrote:
> Hi John,
>
> On Sat, 14 Nov 2009 18:44:29 -0800 (PST), monahanz =A0wrote:
> >Thanks John. Just discovered your site. What a gem, great work!
> >What the heck is a .pma file? =A0Checked the web, got something
> >referring to "file format used on MSX computers". =A0Do you have a
> >source for some kind of converter to make it into normal text?
>
> http://www.znode51.de/indexe.htm
>
> It helped me in finding the long sought-for LHA-PMA.EXE for
> DOS/Windows ! It is a command-line tool, but does a fine job!
>
> http://www.znode51.de/dostools/lha-pma.exe
>
> Rolf

Thanks Rolf, that was a great help.  Never ceases to amaze me how much
great stuff is out there.  Will take me some time to digest all this!
0
monahanz
11/15/2009 4:59:37 PM
monahanz wrote:

> (...) CPM has a screwball way of storing the date.

I have never understood why Gary Kildall chose to use this data
structure. There must be a reason.

Interviewer: Do you remember the first program you wrote?

Kildall: Yes. It calculated the number of seconds between any two
times of the day and any two calendar dates. That program is still
around; every time I clean my desk, I find it, like old clothes I find
in my closet.

Interviewer: What about the first professional program you wrote?

Kildall: I wrote it at the navigation school my father owned. We used
to prepare tide tables by hand for one of the local publishing
companies in Seattle. I wrote a FORTRAN program that calculated the
tides. It was the first program I made money on -- $500 or so.

- "Programmers at Work"
   Susan Lammers
   Tempus Books, 1986, p.60

So, the least that can be said is that Gary Kildall knew about
celestial computations. So, it cannot be mere hazard that Gary Kildall
chose the 1st January 1978 for the date of CP/M, especially since we
all know that CP/M was already several years old by then! So, why?

Kildall: (...) as a teacher, I spent a lot of time with students
showing them clean algorithms I had picked up. (Page 63)

Comments welcomed.

> Question:-  Does anybody have  (or seen) Z80 code to convert a 16 bit
> number efficiently into days, months, years.   Hope I don=92t have to
> reinvent the wheel!

Personally, I prefer to reinvent the wheel, to be sure that the
program will really work correctly.

In my experience, I have never seen a calendar program published in a
magazine that was not followed by some corrections. It is amazing how
tricky computing dates can be, without mentioning the fact that dates
have not been constant during history; some countries jumping several
days at a time, and other countries at other times... As soon as you
go back more than a century, you must be really sure of your
algorithm!

It is one of the reasons why I keep old calendars that I find. One
day, when I will finally write my own routine (Old Timers may remember
that SYSVAR displayed the date as an hex integer ("Date: 01DC"), since
I did not know how to translate it), I will use them to check it.

One of the joy of CP/M was its "Software Library". Alas, the one of
the CP/M User Group (UK) is lost, but several Web sites make available
online the Walnut Creek CD-ROM, which contains several US CP/M
libraries.

So, wondering where to find interesting CP/M software, I went to the
Retroarchive Web site, then opened the file containing the names of
all the files:

http://www.retroarchive.org/cpm/cdrom/ALLFILES.TXT

After that (714K later), I just searched the string "date" inside it.
62 times later, I reached the end of the file...

62 programs to chose from! Meanwhile, Windoze users have no such
choice. This must be progress.

Personally, I was very interested by DRI-DATE:

../simtel/sigm/vols100/vol176/dri-date.lbr

but "your mileage may vary".

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/15/2009 9:19:01 PM
monahan@vitasoft.org wrote:
> Question:-  Does anybody have  (or seen) Z80 code to convert a 16 bit
> number efficiently into days, months, years.   Hope I don't have to
> reinvent the wheel!
 
There's BASIC routine PROCDate_ToOrd at http://mdfs.net/blib/Date
that converts a centisecond count to d/m/y. Is that enough to get
you started?
 
DayOfWeek code in Z80 at http://mdfs.net/Info/Comp/Z80/ProgTips
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
BBC BASIC for Windows and Internationalisation
  See http://mdfs.net/Software/BBCBasic/Windows/ProgTips
0
jgh
11/15/2009 11:41:57 PM
Hello, Jonathan!

> There's BASIC routine PROCDate_ToOrd

Since I am a strong believer in using BASIC to debug the logic of some
programming tasks, I was interested.

But I found a problem: the link that you gave, and all the TXT files
that I tried to open on your Web site, contained... binary stuff, not
ASCII!

Could you explain this "eccentricity"?

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/16/2009 9:10:55 AM
Mr. Emmanuel Roche, France wrote:

> So, the least that can be said is that Gary Kildall knew about
> celestial computations. So, it cannot be mere hazard that Gary Kildall
> chose the 1st January 1978 for the date of CP/M, especially since we
> all know that CP/M was already several years old by then! So, why?

I had the idea to make a search on "1 January 1984" and "Celestial".
Imagine my surprise when I found:

"The corrections are based on the THDA temperature at the end of the
exposure (...), and the time (t) expressed as the total number of
elapsed days since 1 January 1978."

http://archive.stsci.edu/iue/manual/iuesips/section6.html

Unfortunately, despite my searchs, impossible to find why this NASA/
ESA "International Ultraviolet Explorer" used this particular date in
its algorithm.

Why the 1st January 1978?

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/16/2009 2:04:46 PM
monahanz schrieb:

> Question:-  Does anybody have  (or seen) Z80 code to convert a 16 bit
> number efficiently into days, months, years.   Hope I don=92t have to
> reinvent the wheel!

I have some fairly efficient (in terms of size and speed) code in my
CPU280 BIOS which I could share.
Take care it is commented in german and translates to BCD day, month and
year (as this is the format which my RTC chip uses).

You can contact me by mail (address is correct).

Tilmann

0
Tilmann
11/16/2009 2:18:20 PM
On Nov 16, 6:18=A0am, Tilmann Reh <usenet2007nos...@autometer.de> wrote:
> monahanz schrieb:
>
> > Question:- =A0Does anybody have =A0(or seen) Z80 code to convert a 16 b=
it
> > number efficiently into days, months, years. =A0 Hope I don=92t have to
> > reinvent the wheel!
>
> I have some fairly efficient (in terms of size and speed) code in my
> CPU280 BIOS which I could share.
> Take care it is commented in german and translates to BCD day, month and
> year (as this is the format which my RTC chip uses).
>
> You can contact me by mail (address is correct).
>
> Tilmann

Thanks everybody John Elliott's routines did the trick. Facinating
reading Emmanuel!
0
monahanz
11/16/2009 2:57:53 PM
On 2009-11-16, Mr Emmanuel Roche, France <roche182@laposte.net> wrote:
> Hello, Jonathan!
>
>> There's BASIC routine PROCDate_ToOrd
>
> Since I am a strong believer in using BASIC to debug the logic of some
> programming tasks, I was interested.
>
> But I found a problem: the link that you gave, and all the TXT files
> that I tried to open on your Web site, contained... binary stuff, not
> ASCII!
>
> Could you explain this "eccentricity"?
>
The file "Date" appears to be a saved Basic program. You can find Date.txt
and other txt files at http://mdfs.net/System/Library/BLib/Docs/
0
Bill
11/16/2009 6:26:44 PM
Hi John,

On Sat, 14 Nov 2009 18:44:29 -0800 (PST), monahanz  wrote:

>Thanks John. Just discovered your site. What a gem, great work!
>What the heck is a .pma file?  Checked the web, got something
>referring to "file format used on MSX computers".  Do you have a
>source for some kind of converter to make it into normal text?

for no long search i have uploaded look the URL.

Elliott_Conn.zip 4,00 KB

Zip-File with Source-Code from

John Elliott's

c3dmy.z80 ca. 4,00 KB

and

Richard Conn's

Externals (DIVHD and MULHD) for 16-bit Multiplication and Division.

SMTH11.Z80 ca. 4,00 KB

SMTH12.Z80 ca. 4,00 KB

http://www.hd64180-z80180.de/assets/download2009/Elliott_Conn.zip

http://www.hd64180-z80180.de/assets/download2009/c3dmy.z80

http://www.hd64180-z80180.de/assets/download2009/SMTH11.Z80

http://www.hd64180-z80180.de/assets/download2009/SMTH12.Z80

Rolf

0
Rolf
11/16/2009 7:08:08 PM
On Nov 16, 11:08=A0am, Rolf Harrmann <rolf-junk-harrm...@t-online.de>
wrote:
> Hi John,
>
> On Sat, 14 Nov 2009 18:44:29 -0800 (PST), monahanz =A0wrote:
> >Thanks John. Just discovered your site. What a gem, great work!
> >What the heck is a .pma file? =A0Checked the web, got something
> >referring to "file format used on MSX computers". =A0Do you have a
> >source for some kind of converter to make it into normal text?
>
> for no long search i have uploaded look the URL.
>
> Elliott_Conn.zip 4,00 KB
>
> Zip-File with Source-Code from
>
> John Elliott's
>
> c3dmy.z80 ca. 4,00 KB
>
> and
>
> Richard Conn's
>
> Externals (DIVHD and MULHD) for 16-bit Multiplication and Division.
>
> SMTH11.Z80 ca. 4,00 KB
>
> SMTH12.Z80 ca. 4,00 KB
>
> http://www.hd64180-z80180.de/assets/download2009/Elliott_Conn.zip
>
> http://www.hd64180-z80180.de/assets/download2009/c3dmy.z80
>
> http://www.hd64180-z80180.de/assets/download2009/SMTH11.Z80
>
> http://www.hd64180-z80180.de/assets/download2009/SMTH12.Z80
>
> Rolf

John/Rolf, I have use the code you mentioned, however for some reason
I don=92t get the correct values returned in [D],[E] & [HL].  The code
is way past me. Hope it=92s OK on the forum to do this, I am including
what I have done below. Does anybody see why I am not getting back the
correct values in D,E and HL.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

;Convert a CP/M 3 day count in HL to D=3Dday E=3Dmonth HL=3Dyear

I come here with the correct CPM3 Days count in [HL] and call C3DMY=85.


C3DMY:push	af
	push	bc
	push	ix

	ld	de,730
	add	hl,de		;HL =3D days since 2 Jan 1976 (so 1 Jan is Day 0)
				;This makes month days come out right at the end
;
; Divide by 1461 to get number of 4-year cycles since 1 Jan 1976
;
	push	hl		;Days since 1/1/1976
	ld	de,1461
	call	DIVHD
	ld	a,l		;A =3D 4-year cycles since 1/1/1976. The CP/M clock
				;   works up to mid-2157 so this is always a byte.
	add	a,a
	add	a,a		;A =3D no. of years since 1/1/1976
	call	MULHD		;HL =3D no. of days in the cycles
	and	a
	pop	de		;DE =3D days since 1/1/1976
	ex	de,hl
	sbc	hl,de		;HL =3D days since start of cycle
;
; If daycount is 59, this is 29 Feb.
;
	ld	c,a		;C =3D years since 1/1/1976
	ld	a,h
	or	a
	jr	nz,notf29
	ld	a,l
	cp	59
	jr	z,f29
	jr	c,ltf29
notf29:	dec	hl		;HL =3D days since start of cycle, taking account
				;    of leap years.
ltf29:	push	hl
	ld	de,365
	call	DIVHD		; L =3D years since start of cycle
	ld	a,l
	add	a,c		; A =3D years since 1/1/1976
	ld	c,a		; C =3D years since 1/1/1976
	call	MULHD		;HL =3D days to start of year
	pop	de
	ex	de,hl
	and	a
	sbc	hl,de		;HL =3D days since start of year
	ld	b,0		; B =3D month
	ld	ix,c3mdys
	ld	(ix+1),28
mclp:	inc	b
	ld	e,(ix+0)
	inc	ix
	ld	d,0		;DE =3D days in this month
	and	a
	sbc	hl,de
	jr	nc,mclp
	add	hl,de		;HL =3D day of month, B =3D month, C =3D years since 1976
	ld	d,l
	inc	d		;Make the days 1-based
	ld	e,b
	jr	fret
;
f29:	ld	de,1D02h	;29 Feb
fret:	ld	b,0		;BC =3D years since 1/1/1976
	ld	hl,1976
	add	hl,bc
	pop	ix
	pop	bc
	pop	af
	ret
;
c3mdys:	db	31,28,31,30,31,30,31,31,30,31,30,31
;
;
;  MULHD -- MULTIPLY HL BY DE, RESULT IN HL
;	CARRY SET MEANS OVERFLOW
;	A IS DESTROYED
;
MULHD:	PUSH	AF
	PUSH	BC		; SAVE REGS
	PUSH	DE
	XOR	A		; SET NO OVFL
	LD	(OVFL),A
	PUSH	HL		; SAVE HL
	LD	HL,0		; ZERO LONG ACC
	LD	(ACC),HL
	POP	HL		; GET HL
	LD	B,16		; 16 LOOPS
MLHD:	CALL	SHFTRHX		; SHIFT RIGHT MULTIPLIER
	JP	NC,MLHD1	; DON'T ADD IN IF LSB IS ZERO
	PUSH	HL		; SAVE VALUE
	LD	HL,(ACC)
	LD	A,L		; ADD IN MULTIPLICAND
	ADD	A,E
	LD	L,A
	LD	A,H
	ADC	A,D
	LD	H,A
	LD	(ACC),HL	; NEW ACCUMULATED VALUE
	JP	NC,MLHD0
	LD	A,0FFH		; SET OVFL FLAG
	LD	(OVFL),A
MLHD0:	POP	HL		; GET VALUE
MLHD1:	EX	DE,HL		; SHIFT LEFT MULTIPLICAND
	CALL	SHFTLHX
	EX	DE,HL
	DEC	B		; COUNT DOWN
	JP	NZ,MLHD
	POP	DE		; RESTORE REGS
	POP	BC
	LD	HL,(ACC)	; GET RESULT
	LD	A,(OVFL)	; OVERFLOW?
	OR	A		; 0=3DNO
	JP	Z,OKRET
OVFLRET:POP	AF		; GET PSW
	SCF			; SET CARRY
	RET
OKRET:	POP	AF
	OR	A	; CLEAR CARRY
	RET
;
;  SHIFT ROUTINES
;
SHFTRHX:		; SHIFT RIGHT
	PUSH	AF
	AND	A	; CLEAR CARRY
	LD	A,H	; SHIFT HIGH
	RRA		; ROTATE 9-BIT ACC RIGHT
	LD	H,A
	LD	A,L	; SHIFT LOW
	RRA
	LD	L,A
	JP	NC,OKRET
	JP	OVFLRET
SHFTLHX:		; SHIFT LEFT
	PUSH	AF
	AND	A	; CLEAR CARRY
	LD	A,L	; SHIFT LOW
	RLA		; ROTATE 9-BIT ACC LEFT
	LD	L,A
	LD	A,H	; SHIFT HIGH
	RLA
	LD	H,A
	JP	NC,OKRET
	JP	OVFLRET
;
;
;  DIVHD -- DIVIDE HL BY DE, RESULT IN HL
;
DIVHD:
	PUSH	AF
	PUSH	BC
	PUSH	HL		; SAVE HL
	LD	HL,0
	LD	(ACC),HL	; ZERO ACCUMULATOR
	POP	HL
;
;  CHECK TO MAKE SURE THAT HL > DE
;
	LD	A,H
	CP	D		; H > D?
	JP	C,DOVFL		; ZERO RESULT IF H < D
	JP	NZ,DNOVFL
	LD	A,L
	CP	E		; L > E?
	JP	C,DOVFL		; ZERO RESULT IF HL < DE
DNOVFL:	LD	B,16		; 16 LOOPS
DVHD:	CALL	SHFTLH		; SHIFT DIVIDEND LEFT
	PUSH	HL		; SAVE DIVIDEND
	LD	HL,(ACC)	; GET ACC
	CALL	SHFLCH		; ROTATE ACC AND MOVE IN CARRY
	LD	(ACC),HL	; NEW ACC
	LD	A,L		; LOW COMPARISON
	SUB	E		; COMPARE AND SUBTRACT
	LD	L,A
	LD	A,H		; HIGH COMPARISON
	SBC	A,D		; COMPARE AND SUBTRACT
	LD	H,A
	JP	C,DVHD0
	LD	(ACC),HL	; SAVE NEW ACC
	POP	HL		; GET DIVIDEND
	LD	A,L		; PLACE IN A 1 TO QUOTIENT
	OR	1
	LD	L,A
	JP	DVHD1
DVHD0:	POP	HL		; GET DIVIDEND AND LEAVE LSB AT ZERO
DVHD1:	DEC	B		; COUNT DOWN
	JP	NZ,DVHD
DVRET:	POP	BC
	POP	AF
	RET
DOVFL:	LD	HL,0		; RESULT IS ZERO
	JP	DVRET

;
;  SHIFT ROUTINES
;
SHFTLH:				; SHIFT HL LEFT
	PUSH	AF
	AND	A		; CLEAR CARRY
SHFL:	LD	A,L		; SHIFT LOW
	RLA			; ROTATE 9-BIT ACC LEFT
	LD	L,A
	LD	A,H		; SHIFT HIGH
	RLA
	LD	H,A
	JP	NC,OKRETX
	POP	AF
	SCF			; SET CARRY FOR OVERFLOW
	RET
OKRETX:	POP	AF
	OR	A		; CLEAR CARRY FOR NO OVERFLOW
	RET
SHFLCH:				; SHIFT HL LEFT, BUT SHIFT IN CARRY FLAG
	PUSH	AF
	JP	SHFL
;
;  BUFFERS
;
ACC:	DS	2	; TEMP ACCUMULATOR
OVFL:	DS	1	; OVERFLOW FLAG


0
monahanz
11/16/2009 7:41:33 PM
Hello, Bill!

> The file "Date" appears to be a saved Basic program. You can find Date.txt
> and other txt files at http://mdfs.net/System/Library/BLib/Docs/

Many thanks for pointing this to me: I was lost on Jonathan's Web
site.

However, curiously, his doc files do not contain the source code of
the subroutines. Maybe he has not heard about "Literate Programming",
invented many years ago by Don Knuth?

So, I searched a little, and found a Web page one level up:

http://mdfs.net/System/Library/BLib/

For example, on the right, you have "Date". When you click on it, you
get the previous binary file.

Under it, you have "Date.bbc". When you try to open it, you have the
same binary stuff as above, but this time in one block (before, it
showed lines).

On the middle, you have "Date.txt". This time, this is the one you
pointed, really in MS-DOS TXT format, only the names of the functions.

After that, you have the names of the functions.

Finally, you have a one-sentence summary.

Once I downloaded "Date.bbc", I downloaded BBCBASIC, then tried to run
it under 22NICE. At the beginning, each time I was typing "DIR", I was
getting the error message: "Bad command". After typing "DIR" more than
20 years, it took me several minutes before understanding that
BBCBASIC needs "*DIR" to run... Silly!

After that, I tried "*LOAD DATE.BBC", but it did not work. I was fed
up, so erased BBCBASIC. It is quite strange how some BASICs can be.
BBCBASIC is really different from MBASIC and Mallard BASIC. As I
already explained, it is clearly based on "Tiny BASIC". Except PROCs
(and maybe the inline Z-80 assembler?), I simply cannot see any
advantage that it could have upon real full size BASICs. (This should
generate some comments from English fans!)

By the way, how do I read the TXT files that are binary?

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/16/2009 10:30:44 PM
monahanz <monahan@vitasoft.org> wrote:
: John/Rolf, I have use the code you mentioned, however for some reason
: I don?t get the correct values returned in [D],[E] & [HL].  The code
: is way past me. Hope it?s OK on the forum to do this, I am including
: what I have done below. Does anybody see why I am not getting back the
: correct values in D,E and HL.

  I'm sure it worked when I wrote it, but I haven't looked at it for years.
You can see the same algorithm written in Mallard BASIC here:
 <http://www.worldofspectrum.org/Plus3CPMManual/basic8.html>

(It's "Example 1: Getting the date from CP/M" - lines 300-460).

-- 
John Elliott

Thinks: This is what a nice clean life leads to. Hmm, why did I ever lead one?
		-- Bluebottle, in the Goon Show
0
John
11/16/2009 10:51:28 PM
monahanz wrote:

> Question:- =A0Does anybody have =A0(or seen) Z80 code to convert a 16 bit
> number efficiently into days, months, years. =A0 Hope I don=92t have to
> reinvent the wheel!

John Elliott wrote:

> I'm sure it worked when I wrote it, but I haven't looked at it for years.
> You can see the same algorithm written in Mallard BASIC here:
> <http://www.worldofspectrum.org/Plus3CPMManual/basic8.html>

Mr. Emmanuel Roche, France, writes:

Hahaha! I was wondering how to write a Mallard BASIC program to
display the CP/M Plus date, and John Elliott simply copied a 1988
program published in the "Spectrum +3 CP/M Plus Manual"!

So, as usual, I am right: you should have access to as much
documentation as possible. Some standard problems have been
investigated many, many times, by many, many different people. I can't
wait to see how the Locomotive Software program will behave.

300 day% =3D day% + 365 + 366 - 1 : weekday% =3D day% MOD 7
310 IF weekday% =3D 0 THEN weekday$ =3D "Thursday"
320 IF weekday% =3D 1 THEN weekday$ =3D "Friday"
330 IF weekday% =3D 2 THEN weekday$ =3D "Saturday"
340 IF weekday% =3D 3 THEN weekday$ =3D "Sunday"
350 IF weekday% =3D 4 THEN weekday$ =3D "Monday"
360 IF weekday% =3D 5 THEN weekday$ =3D "Tuesday"
370 IF weekday% =3D 6 THEN weekday$ =3D "Wednesday"
380 year% =3D 1976 + 4 * (day% \ (365+365+365+366))
390 day% =3D day% MOD (365+365+365+366)
400 IF day% =3D (31+29-1) THEN day% =3D 29 : month$ =3D "FEB" : GOTO 470
410 IF day% > (31+29-1) THEN day% =3D day% - 1
420 year% =3D year% + day% \ 365
430 day% =3D day% MOD 365
440 READ month.days%, month$
460 IF day% >=3D month.days% THEN day% =3D day% - month.dayS% : GOTO 440
470 PRINT USING"& & ##/&/####";"Today is";weekday$,day%,month$,year%
480 END
490 DATA 31, JAN, 28, FEB, 31, MAR, 30, APR, 31, MAY, 30, JUN
500 DATA 31, JUL, 31, AUG, 30, SEP, 31, OCT, 30, NOV, 31, DEC

Meanwhile, if someone is interested in a code subroutine (self-
contained), I was pretty well impressed by:

> ./simtel/sigm/vols100/vol176/dri-date.lbr

but "your mileage may vary".

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/17/2009 8:59:48 AM
monahanz wrote:

> Hope I don=92t have to reinvent the wheel!

and:

> Fascinating reading, Emmanuel!

Yes, indeed, monahanz, your messages are fascinating: I have never
understood why people just wanted a quick fix solution, and did not
care if it was really working, especially if they say they can program
in assembly language.

In answer to Jonathan, I wrote:

> Since I am a strong believer in using BASIC to debug the logic of some
programming tasks, I was interested.

I stand, as usual, by my words.

John Elliott published a link to a 1988 Mallard BASIC program. So, I
played with it, modifying it the absolute minimum. You will find below
what it says:

A>mallard testdate

Mallard-86  BASIC with Jetsam   Version 1.50
(c) Copyright 1984  Locomotive Software Ltd
All rights reserved

62025 free bytes


Test of the DATE program found in:

- "Spectrum +3 CP/M Plus Manual"
   Part II: Mallard BASIC
   Chapter 8: Machine-level Operations

0000H =3D Saturday 30 December 1977
0001H =3D Sunday 0 January 1978

0002H =3D Monday 1 January 1978
0003H =3D Tuesday 2 January 1978
0004H =3D Wednesday 3 January 1978
0005H =3D Thursday 4 January 1978
0006H =3D Friday 5 January 1978
0007H =3D Saturday 6 January 1978
0008H =3D Sunday 7 January 1978

0009H =3D Monday 8 January 1978
000AH =3D Tuesday 9 January 1978
000BH =3D Wednesday 10 January 1978
000CH =3D Thursday 11 January 1978
000DH =3D Friday 12 January 1978
000EH =3D Saturday 13 January 1978
000FH =3D Sunday 14 January 1978

0010H =3D Monday 15 January 1978
0011H =3D Tuesday 16 January 1978
0012H =3D Wednesday 17 January 1978
0013H =3D Thursday 18 January 1978
0014H =3D Friday 19 January 1978
0015H =3D Saturday 20 January 1978
0016H =3D Sunday 21 January 1978

0017H =3D Monday 22 January 1978
0018H =3D Tuesday 23 January 1978
0019H =3D Wednesday 24 January 1978
001AH =3D Thursday 25 January 1978
001BH =3D Friday 26 January 1978
001CH =3D Saturday 27 January 1978
001DH =3D Sunday 28 January 1978

001EH =3D Monday 29 January 1978
001FH =3D Tuesday 30 January 1978
0020H =3D Wednesday 0 February 1978
0021H =3D Thursday 1 February 1978
0022H =3D Friday 2 February 1978
0023H =3D Saturday 3 February 1978
0024H =3D Sunday 4 February 1978

0025H =3D Monday 5 February 1978
0026H =3D Tuesday 6 February 1978
0027H =3D Wednesday 7 February 1978
0028H =3D Thursday 8 February 1978
0029H =3D Friday 9 February 1978
002AH =3D Saturday 10 February 1978
002BH =3D Sunday 11 February 1978

002CH =3D Monday 12 February 1978
002DH =3D Tuesday 13 February 1978
002EH =3D Wednesday 14 February 1978
002FH =3D Thursday 15 February 1978
0030H =3D Friday 16 February 1978
0031H =3D Saturday 17 February 1978
0032H =3D Sunday 18 February 1978

0033H =3D Monday 19 February 1978
0034H =3D Tuesday 20 February 1978
0035H =3D Wednesday 21 February 1978
0036H =3D Thursday 22 February 1978
0037H =3D Friday 23 February 1978
0038H =3D Saturday 24 February 1978
0039H =3D Sunday 25 February 1978

003AH =3D Monday 26 February 1978
003BH =3D Tuesday 27 February 1978
003CH =3D Wednesday 0 March 1978
003DH =3D Thursday 1 March 1978
003EH =3D Friday 2 March 1978
003FH =3D Saturday 3 March 1978
0040H =3D Sunday 4 March 1978

Break in 130
Ok
system

A> That's All, Folks! (Unless you want to see the 65536 values of an
integer.)

Ok. Now, let us examine separately a few lines:

Mallard-86  BASIC with Jetsam   Version 1.50

That is to say: this is the 16-bit version of Mallard BASIC. This
algorithm is portable. I just made a FOR-NEXT loop to display some of
the first values of an integer. I had not enough time to run it under
CP/M Plus.

0001H =3D Sunday 0 January 1978
0020H =3D Wednesday 0 February 1978
003CH =3D Wednesday 0 March 1978

I hope that you are beginning to see the problem of this published
algorithm, by a famous software company! It would be interesting if
John Elliott could find how many Sinclair Spectrums were made, running
under CP/M Plus. This way, we would have a gross idea of how many
people used this algorithm and did not care to look if it was
producing some serious results.

170 REM  Day 1 being Jan 1st 1978

I hope that you can see that the own comment, inside this program,
contradict its output. Apparently, the program works, but it outputs
"0" days. I have no idea if I will manage to "massage" this program.

The only think that I am sure is that an interactive high-level
programming language allowed me to test, in a few minutes, the
correctness of this program.

If you prefer to code directly in assembly language, it is your
problem.

As I wrote:

> In my experience, I have never seen a calendar program published
> in a magazine that was not followed by some corrections. It is amazing
> how tricky computing dates can be, without mentioning the fact that
> dates have not been constant during history; some countries jumping
> several days at a time, and other countries at other times... As soon as
> you go back more than a century, you must be really sure of your
> algorithm!

As usual, I stand by my words.

If someone knows more about calendar and date computations than me, he
is welcomed to anwer me.

(Meanwhile, I am searching a source on the Internet to check all the
dates from the 1 January 1978 to 2009, to be sure that my program will
output the right answers.)

(TESTDATE.BAS is available, if you want a buggy program.)

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/17/2009 9:27:06 AM
Mr Emmanuel Roche, France wrote in message
<434b1a44-f9f3-4191-bbe0-81497afa222c@w19g2000yqk.googlegroups.com>...

[about BBCBASIC]

>Once I downloaded "Date.bbc", I downloaded BBCBASIC, then tried to run
>it under 22NICE. At the beginning, each time I was typing "DIR", I was
>getting the error message: "Bad command". After typing "DIR" more than
>20 years, it took me several minutes before understanding that
>BBCBASIC needs "*DIR" to run... Silly!

Normally it is *CAT or *. The *. works though.

>After that, I tried "*LOAD DATE.BBC", but it did not work. I was fed
>up, so erased BBCBASIC. It is quite strange how some BASICs can be.
>BBCBASIC is really different from MBASIC and Mallard BASIC. As I
>already explained, it is clearly based on "Tiny BASIC". Except PROCs
>(and maybe the inline Z-80 assembler?), I simply cannot see any
>advantage that it could have upon real full size BASICs. (This should
>generate some comments from English fans!)

You should know that you have to use uppercases. Then LOAD "DATE.BBC" (LOAD
"DATE" will do too) and LIST gives the program in lines (CTRL N (before the
return) stops the listing, SHIFT goes on. Running it  - type RUN after
loading - gives an error because it is not a whole program, these are only
procedures.

Katzy.


0
Katzy
11/17/2009 5:18:52 PM
Hello, Katzy!

> [about BBCBASIC]

> Normally it is *CAT or *. The *. works though.

Abbreviating commands with a "." was a distinctive features of "Tiny
BASIC"...

> You should know that you have to use uppercases. Then LOAD "DATE.BBC" (LO=
AD
> "DATE" will do too) and LIST gives the program in lines (CTRL N (before t=
he
> return) stops the listing, SHIFT goes on. Running it =A0- type RUN after
> loading - gives an error because it is not a whole program, these are onl=
y
> procedures.

No, I did not know. One more oddity. Ok. Many thanks for your
explanations: next time I will have a problem (for example, reading
some TXT files on Jonathan's Web site), I will ask you privately.

In France, the "BBC" was a total failure. I only met one man who had
bought one and, of course, he told me that he could find nothing for
it in France. For some unknown reason, Amstrad was much more known
that Acorn.

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/17/2009 8:40:17 PM
"Mr Emmanuel Roche, France" wrote:
> But I found a problem: the link that you gave, and all the TXT files
> that I tried to open on your Web site, contained... binary stuff, not
> ASCII!
 
All the files with ".txt" extensions are text files. If they don't
have a ".txt" extension, they are unlikely to be text files.
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
/* Real programmers don't use comments. */
0
jgh
11/17/2009 11:25:14 PM
"Mr Emmanuel Roche, France" wrote:
> However, curiously, his doc files do not contain the source code of
 
Well, of course not. The Basic code **is** the source code. The
documentation is the documentation.
 
> Once I downloaded "Date.bbc", I downloaded BBCBASIC, then tried to run
[...]
> After that, I tried "*LOAD DATE.BBC", but it did not work. I was fed
 
Did you try LOAD "Date.bbc" - ie, load a file into memory as a
Basic program. Not, load an arbitary file to an arbitary area of
memory?
 
> already explained, it is clearly based on "Tiny BASIC". Except PROCs
 
No, it's not. Read Richard Russell's BBC BASIC history at
rtrussell.co.uk.
 
> (and maybe the inline Z-80 assembler?), I simply cannot see any
> advantage that it could have upon real full size BASICs. (This should
 
BBC BASIC **is** a real full-size BASIC, and is a lot more powerful
than most other Basics around.
 
> By the way, how do I read the TXT files that are binary?
 
As I have said before, any files on my site with a ".txt" EXTENSION
are TEXT FILES. If a file does not have a ".txt" EXTENSION, then it
may not be a TEXT file.
 
There's no such thing as a "TXT file". ".TXT" is an EXTENSION.
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
A Review of Sheffield City Council's Members' Allowances Scheme
                                  See http://mdfs.net/payreform
0
jgh
11/17/2009 11:25:14 PM
"Mr Emmanuel Roche, France" wrote:
> 310 IF weekday% = 0 THEN weekday$ = "Thursday"
> 320 IF weekday% = 1 THEN weekday$ = "Friday"
> 330 IF weekday% = 2 THEN weekday$ = "Saturday"
> 340 IF weekday% = 3 THEN weekday$ = "Sunday"
> 350 IF weekday% = 4 THEN weekday$ = "Monday"
> 360 IF weekday% = 5 THEN weekday$ = "Tuesday"
> 370 IF weekday% = 6 THEN weekday$ = "Wednesday"
 
Arghhh!!!!!!!   What on earth is wrong with:
 
  weekday$=dayname$(weekday%) ....?
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
HADFS System Resources - http://mdfs.net/Software/HADFS
0
jgh
11/17/2009 11:25:15 PM
Ho! My...

I am broken. I cut (among other things) the branches of 3 trees, then
their heads (without falling). After that, I digged with an axe,
managing to uproot one tree before the Sun disappeared. Tomorrow, they
say that it will be the beautifullest day of the week, so I will work,
again, all day long in the garden.

Jonathan: Wait tomorrow for a reply.

Ok. I wrote:

> (Meanwhile, I am searching a source on the Internet to check all the
> dates from the 1 January 1978 to 2009, to be sure that my program will
> output the right answers.)

So, I have found several "Perpetual Gregorian Calendars" on the
Internet but, for some unknown reason, they all display their output
as:

CALENDAR> Enter MONth, Year (JANuary,2001): January, 1978

    January 1978

 Su Mo Tu We Th Fr Sa

  1  2  3  4  5  6  7
  8  9 10 11 12 13 14
 15 16 17 18 19 20 21
 22 23 24 25 26 27 28
 29 30 31

Another calendar (Y/N)? n

Ok

(This is also the case of my own CALENDAR.BAS, but I found it in an
American Web site: In France, all my calendars dislay columns of
dayweeks and numbers.)

The problem is that this format is not convenient to check that we are
getting the right date for a particular INTEGER. As I explained to the
Polish Z-80 programmer, if you are lucky enough to have to test only a
byte value, just test all the 256 values, to sleep well. However, an
INTEGER is 65536...

By the way, for what duration is worth the CP/M date? Start = 1st
January 1978. 65536 / 365 = 179 years. So, 1978 + 179 = 2157. Ok. I
should be dead, then.

So, the problem is to display both the INTEGER value and the date. I
wrote another TESTDATE (since the Locomotive Software algorithm is
buggy), and got:

A>mallard testdate

Mallard-86  BASIC with Jetsam   Version 1.50
(c) Copyright 1984  Locomotive Software Ltd
All rights reserved

62025 free bytes


0001H = Sunday 1 January 1978

0002H = Monday 2 January 1978
0003H = Tuesday 3 January 1978
0004H = Wednesday 4 January 1978
0005H = Thursday 5 January 1978
0006H = Friday 6 January 1978
0007H = Saturday 7 January 1978
0008H = Sunday 8 January 1978

0009H = Monday 9 January 1978
000AH = Tuesday 10 January 1978
000BH = Wednesday 11 January 1978
000CH = Thursday 12 January 1978
000DH = Friday 13 January 1978
000EH = Saturday 14 January 1978
000FH = Sunday 15 January 1978

0010H = Monday 16 January 1978
0011H = Tuesday 17 January 1978
0012H = Wednesday 18 January 1978
0013H = Thursday 19 January 1978
0014H = Friday 20 January 1978
0015H = Saturday 21 January 1978
0016H = Sunday 22 January 1978

0017H = Monday 23 January 1978
0018H = Tuesday 24 January 1978
0019H = Wednesday 25 January 1978
001AH = Thursday 26 January 1978
001BH = Friday 27 January 1978
001CH = Saturday 28 January 1978
001DH = Sunday 29 January 1978

001EH = Monday 30 January 1978
001FH = Tuesday 31 January 1978
0020H = Wednesday 1 February 1978
0021H = Thursday 2 February 1978
0022H = Friday 3 February 1978
0023H = Saturday 4 February 1978
0024H = Sunday 5 February 1978

0025H = Monday 6 February 1978
0026H = Tuesday 7 February 1978
0027H = Wednesday 8 February 1978
0028H = Thursday 9 February 1978
0029H = Friday 10 February 1978
002AH = Saturday 11 February 1978
002BH = Sunday 12 February 1978

002CH = Monday 13 February 1978
002DH = Tuesday 14 February 1978
002EH = Wednesday 15 February 1978
002FH = Thursday 16 February 1978
0030H = Friday 17 February 1978
0031H = Saturday 18 February 1978
0032H = Sunday 19 February 1978

0033H = Monday 20 February 1978
0034H = Tuesday 21 February 1978
0035H = Wednesday 22 February 1978
0036H = Thursday 23 February 1978
0037H = Friday 24 February 1978
0038H = Saturday 25 February 1978
0039H = Sunday 26 February 1978

003AH = Monday 27 February 1978
003BH = Tuesday 28 February 1978
003CH = Wednesday 1 March 1978
003DH = Thursday 2 March 1978
003EH = Friday 3 March 1978
003FH = Saturday 4 March 1978
0040H = Sunday 5 March 1978

Break in 130
Ok
system

A>That's All, Folks!

1) Is this correct?

2) How would you do, to check all the 65536 values?

The problem is that I did not find an outside resource. So, to check
an assembly language DATE subroutine, I am obliged to rely on the
correctness of my Mallard BASIC program... (Who wants to check 65536
lines?)

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/18/2009 10:16:28 PM
Hello, Jonathan!

8 hours to fell a tree! My body hurts.

Ok. Since then, you wrote 4 messages. You should "get a life"!

1) "Well, of course not. The Basic code **is** the source code. The
documentation is the documentation."

Well, in 1992, an American named Don Knuth invented something that he
called "WEB". The problem is that, a few years later, something called
"the Web" (short for "World-Wide Web") became so successful that, of
course, all the Newbies are thinking that the only meaning of WEB is
Web.

Explaining why you would want to use WEB, instead of doc separate from
code, could be a little long. I think that I explained it as simple as
possible in the comp.os.cpm Newsgroup. Else, you can read:

http://en.wikipedia.org/wiki/Literate_programming

2) For some unknown reason, I still have problems with BBC BASIC. Some
(small) files from your Web site can be read and displayed, but not
several others. And Windows systematically opens your unamed files as
TXT files.

(I have been thinking: Is BBC BASIC using the same file format for all
its versions? This could explain why I cannot see the contents of some
files, if you used an esoteric version of BBC BASIC.)

3)

> > As I already explained, it is clearly based on "Tiny BASIC".
> No, it's not. Read Richard Russell's BBC BASIC history at
rtrussell.co.uk.

No need to read what someone, especially not the original author,
says. I am a programmer: the code tells me everything that I need to
know. In addition, the first 3K program that I made in 8080 assembler
was "Palo Alto Tiny BASIC Version 3.0"... So, I recognise a Tiny BASIC
when I see one.

(If challenged, I can *PROVE* this by a *DEMONSTRATION* using...
BBCBASIC itself!)

4)

> > If someone has any other idea(s) about the CP/M date INTEGER
> > starting the 1st January 1978, he is welcome to share it.
>
> Any dating system that uses a monotonically incrementing number
needs a zero point. That zero point is more or less arbitary, but
for practicality needs to be before any likely dates the system
using the dating system is going to use.

Hum... Yes, but I am afraid that you did not understand the reason why
0000H is *NOT* used by the CP/M date... I noticed this when trying to
write my TESTDATE: how do you stop a program displaying all the values
of an INTEGER? (My first version was "looping" endlessly.) All I had
to do was to add a line IF date% = 0 THEN END... I think that this is
why the CP/M date is one-based. Anyway, it would be curious to count
as legal the date after FFFF...

5) "A 15-bit integer count of days since 01/01/1978 extends to the
middle of 2067. Why 15-bit? Well, how many programs have fallen over
assuming a 16-bit integer was unsigned?"

What? My poor Jonathan, you are still using, in 2009, a programming
language that has not UNT (Unsigned iNTeger) among its number formats?
But how do you, then, access the top of the TPA, where are located the
BDOS and BIOS? Is BBC BASIC limited to the lower 32K? Mallard BASIC
has both INT and UNT.

6) "As for the original question, Z80 code to convert to and from
ordinal
dates:

DEFPROCDate_FromOrd(mem%,d%,m%,y%,hr%,mn%,sc%,cs%):y%=y%MOD400
d%=y%*365.25+m%*30+d%+VALMID$("120112234455",m%,1)
d%=d%+((y%MOD4)=0)-((y%-1)DIV100)-
(m%>2AND((y%MOD4)=0AND(y%MOD100)<>0ORy%=0))+36493
IFd%>146066:d%=d%-146097
d%=d%*&41EB:mem%!1=d%+d%:d%=((hr%*60+mn%)*60+sc%)*100+cs%
?mem%=d%:mem%!1=mem%!1+d%DIV256:ENDPROC

(I see the "From", but not the "To".)

Aarrgghh!! Totally unreadable. Have you heard about a novelty called
"Structured Programming"? And MBASIC also suffered from the lack of
spaces before keywords: you could not have variable names containing a
keyword. Silly.

7) "(all untested of course)"

Sigh! I hesitate to write "Newbie", but this is, for sure, a non-
professional way of considering programs.

Me, I only publish programs that became "stable". In my experience,
after you write a program, you never find all the bugs. It is when you
come back to it, 6 months later, that they appear. That's why I never
date a program: as long as I use it, it can evolve. Once I publish it,
it becomes "freezed". Maybe I should use "Version" numbers, but it
simply does not come to my mind.

8) "Converting from a day count to ordinal dates is a bit more
complicated - I hate doing divisions in machine code - so is left as
an exercise for the reader."

Until reading you, it was not in my vocabulary. I made a Wikipedia,
and found:

"An ordinal date is a calendar date consisting of a year and a day of
year ranging between 1 and 366 (starting on January 1). The two
numbers can be formatted as YYYY-DDD to comply with the ISO 8601
ordinal date format."

I am afraid that this is a distraction. I prefer to concentrate on the
question: How do you convert the CP/M date in an INTEGER into its date-
in-letters?

My TESTDATE seems promising. It is written in high-level BASIC, with
lots of spaces and indentation, so is readable.

Unfortunately, I did not find an Internet source for a calendar that
could be compared by computer (Computer-Aided Checking). Maybe I could
type a month/year into my CALENDAR.BAS program, while online to an
Internet calendar, but 179 years * 12 months = 2148 calendars to check
manually...

There are 65536 lines to check. The widest line is:

0012H = Wednesday 17 January 1978

(the one containing "Wednesday") I count 33 chars + CR-LF = 35 chars.

65536 lines * 35 chars = 2293760 bytes.

2293760 / 1024 = 2240KB.

Bigger than a 3.5" floppy, but doable in Mallard BASIC.

Of course, if I use "Mo" and "JAN", this will be shorter, hence
faster, but less readable to a human. And it is me, a human, who needs
to be convinced that my program produces 100% exact results, not the
computer.

Ok. Tomorrow, I will be busy. The next day, I will be away all day
long.

So, next Sunday, I will generate this 2MB file.

After that, I will write my routine in assembler, and check its output
versus the reference file.

This is the only way, as far as I can see, to be sure that all 65536
values are correct.

Fortunately, they forecast rain this week-end. I think that computer
programming is wonderful: I never see the time run.

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/19/2009 10:58:09 PM
roche182@laposte.net wrote:
> byte value, just test all the 256 values, to sleep well. However, an
> INTEGER is 65536...
 
No, an unsigned 16-bit integer is 65535. A signed 32-bit integer is
2147483647, an unsigned 8-bit integer is 255, etc.
 
> By the way, for what duration is worth the CP/M date? Start = 1st
> January 1978. 65536 / 365 = 179 years. So, 1978 + 179 = 2157. Ok. I
> should be dead, then.
 
Depends if the manipulation treats it as signed or unsigned. Safer
to treat it as signed, so it extends to 2067.
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
BBC BASIC for 30+ platforms - http://mdfs.net/Software/BBCBasic
0
jgh
11/19/2009 11:38:05 PM
Hello, Jonathan!

Ok. So, there are 2 files that I have been unable to open with BBC
BASIC (Z80), BBC BASIC-86, and the demo Windows version. They are
listed on:

http://mdfs.net/Software/Z80/

Those files are:

1) RAW_Asm  Roland A. Waddiloves' Z80 assembler.

2) MonZ80  Z80 Disassembler written in BBC BASIC.

The first was, originally, written in Mallard BASIC, but I have been
unable, during the last 20 years, to find it (there were several
Amstrad magazines, but I don't have the reference).

The second is one of my programming project that I need to finish. I
want to see how you have done it.

So, I click on "RAW_Asm", and arrive at:

http://mdfs.net/Software/Z80/RAW_Asm/

When I click on "MonZ80", Windows opens a TXT file, but there is
another Web page:

http://mdfs.net/Software/Assembler/DisAssem/

with "MonZ80" and "DisZ80", which seems to be the main routine.

So, I have not been able to see what is inside those 2 files.

(I seem to be able to open smaller BBC files.)

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/20/2009 5:42:11 PM
roche182@laposte.net wrote:
> 5) "A 15-bit integer count of days since 01/01/1978 extends to the
> middle of 2067. Why 15-bit? Well, how many programs have fallen over
> assuming a 16-bit integer was unsigned?"
> 
> What? My poor Jonathan, you are still using, in 2009, a programming
 
How would somebody writing date manipulation code in 1978 be using
a programming language not available until 2009?
 
> language that has not UNT (Unsigned iNTeger) among its number formats?
> But how do you, then, access the top of the TPA, where are located the
 
The top of the TPA at &F800 is well within the range of &80000000
to &7FFFFFFF (or &00000000 to &FFFFFFFF).
 
> DEFPROCDate_FromOrd(mem%,d%,m%,y%,hr%,mn%,sc%,cs%):y%=y%MOD400
>
> Aarrgghh!! Totally unreadable. Have you heard about a novelty called
 
It's ****LIBRARY*** code. It's purpose is not to be read, but to be
used.
 
> Me, I only publish programs that became "stable". In my experience,
 
And I am prepare to publish untested *CODE* *SNIPPITS* where I
believe that they may be useful bouncing-off points for people. I
will not do people's homework.
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
BBC BASIC for Windows and Internationalisation
  See http://mdfs.net/Software/BBCBasic/Windows/ProgTips
0
jgh
11/22/2009 12:01:37 AM
roche182@laposte.net wrote:
> Ok. So, there are 2 files that I have been unable to open with BBC
> BASIC (Z80), BBC BASIC-86, and the demo Windows version. They are
                                     ^^^^^^^^^^^^
 
I don't believe that. Windows BASIC will load Russell, Wilson and
Text format BASIC files.
 
If you are using a version of BBC BASIC that runs on a platform
with an extensioned filing system (eg CPM, DOS, Windows), then the
interpreter uses Russell format files with a ".bbc" extension. If
you are running a version of BBC BASIC that runs on a platform with
a non-extensioned filing system (eg BBC, RISCOS, Pandora), the
interpreter uses Wilson format files with a "" extension. Tools are
available on all platforms that BBC BASIC runs on to convert files
between Wilson, Russell and text format. See http://bb4w.wikispaces.com/Format
 
BBC BASIC for Windows uses Russell format, but will also load
Wilson format files into the editor. The PDP-11, Spectrum and BBC
Z80 versions load both formats.
 
> When I click on "MonZ80", Windows opens a TXT file, but there is
 
Wossa "TXT file"? There's no such thing as a "TXT file" in the file
settings on my Windows PC. There's "Text file" which is associated
with the ".txt" *extension*.
 
Anyway, I doubt it. What probably actually happens is *INTERNET*
*EXPLORER* tries to save the file as a file with a ".txt"
extension.
 
You can fix this problem by dropping to the command line and
issuing the command:
 
del /r /s /q "C:\Program Files\Internet Explorer"
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
RISC OS Internationalisation - http://mdfs.net/Software/RISCOS
0
jgh
11/22/2009 12:01:37 AM
Hello, Jonathan!

> I don't believe that.

<sigh!> A new Saint-Thomas... Ok.

http://mdfs.net/Software/Z80/

Then, I click on "RAW Asm", which leads me to

http://mdfs.net/Software/Z80/RAW_Asm/

I then click on "AsmZ80_402", and Windows opens a dialogue window with

T=E9l=E9chargement de fichier

(...)

Nom du fichier : AsmZ80_402.txt
Type du fichier : Document texte
De :                  mdfs.net

[Ouvrir] [Enregister] etc.

So, I save it. I then rename it "AsmZ80" (without file type). I then
click on "BBC BASIC for Windows".

"This is the evaluation version of BBC BASIC for Windows. bla-bla-
bla."

"File" -- "Load" -- Only 2 options appear:

1) "BBC BASIC Files (*.BBC, *.BAS)
2) "All files (*.*)"

Since files without a file type are not recognized by BBC BASIC, I
take option 2, and chose, among the files displayed, "AsmZ80".

Result: "Not enough room for file AmsZ80".

Ok. You wrote:

> If you are using a version of BBC BASIC that runs on a platform
> with an extensioned filing system (eg CPM, DOS, Windows), then the
> interpreter uses Russell format files with a ".bbc" extension. If
> you are running a version of BBC BASIC that runs on a platform with
> a non-extensioned filing system (eg BBC, RISCOS, Pandora), the
> interpreter uses Wilson format files with a "" extension. Tools are
> available on all platforms that BBC BASIC runs on to convert files
> between Wilson, Russell and text format.
> See http://bb4w.wikispaces.com/Format

So, I had a look to this Web page, and discovered that "you should
never assume a file's format from its filetype or extension (...) the
format can be easily determined by looking at the final few bytes of
the file".

I then dumped the 2 BBC BASIC files that I have been unable to read
for one week, and found that both are ending with 0D FF, that is to
say: they are 6502 formats...

Both Z-80 programs are saved in 6502 format!

No wonder, then, that all the versions of BBC BASIC that I tried could
not open them!

Do you believe me, now?

Yours Sincerely,
Mr. Emmanuel Roche, France

0
Mr
11/22/2009 10:49:05 AM
Mr Emmanuel Roche, France wrote:

> Hello, Jonathan!
> 
>> I don't believe that.
> 
> <sigh!> A new Saint-Thomas... Ok.
> 
> http://mdfs.net/Software/Z80/
> 
> Then, I click on "RAW Asm", which leads me to
> 
> http://mdfs.net/Software/Z80/RAW_Asm/
> 
> I then click on "AsmZ80_402", and Windows opens a dialogue window with
> 
> Téléchargement de fichier
> 
> (...)
> 
> Nom du fichier : AsmZ80_402.txt
> Type du fichier : Document texte
> De :                  mdfs.net
> 
> [Ouvrir] [Enregister] etc.
> 
> So, I save it. I then rename it "AsmZ80" (without file type). I then
> click on "BBC BASIC for Windows".
> 
> "This is the evaluation version of BBC BASIC for Windows. bla-bla-
> bla."
> 
> "File" -- "Load" -- Only 2 options appear:
> 
> 1) "BBC BASIC Files (*.BBC, *.BAS)
> 2) "All files (*.*)"
> 
> Since files without a file type are not recognized by BBC BASIC, I
> take option 2, and chose, among the files displayed, "AsmZ80".
> 
> Result: "Not enough room for file AmsZ80".
> 
> Ok. You wrote:
> 
>> If you are using a version of BBC BASIC that runs on a platform
>> with an extensioned filing system (eg CPM, DOS, Windows), then the
>> interpreter uses Russell format files with a ".bbc" extension. If
>> you are running a version of BBC BASIC that runs on a platform with
>> a non-extensioned filing system (eg BBC, RISCOS, Pandora), the
>> interpreter uses Wilson format files with a "" extension. Tools are
>> available on all platforms that BBC BASIC runs on to convert files
>> between Wilson, Russell and text format.
>> See http://bb4w.wikispaces.com/Format
> 
> So, I had a look to this Web page, and discovered that "you should
> never assume a file's format from its filetype or extension (...) the
> format can be easily determined by looking at the final few bytes of
> the file".
> 
> I then dumped the 2 BBC BASIC files that I have been unable to read
> for one week, and found that both are ending with 0D FF, that is to
> say: they are 6502 formats...
> 
> Both Z-80 programs are saved in 6502 format!
> 
> No wonder, then, that all the versions of BBC BASIC that I tried could
> not open them!
> 
> Do you believe me, now?
> 
> Yours Sincerely,
> Mr. Emmanuel Roche, France


Roche,

On this page:
http://mdfs.net/Software/BBCBasic/Windows/
it says:
Free demo version restricted to 8K of memory. 

When you download the file:
it is 13 KB long

When you try to load the file, you get:
 "Not enough room for file AmsZ80".

The fact that the file is in Wilson/Acorn format is not your problem.

The program you are trying to load is too big to be used with the free
version.

The free version does support the type of file you are trying to load, just
not the size.


0
joe
11/22/2009 2:46:07 PM
Hello.

Mr Emmanuel Roche, France wrote in message ...
Hello, Jonathan!

> I don't believe that.

I had the same problems...

>I then dumped the 2 BBC BASIC files that I have been unable to read
for one week, and found that both are ending with 0D FF, that is to
say: they are 6502 formats...

>Both Z-80 programs are saved in 6502 format!

Ah, that was the clue. Now I could do more. I transferred the tokenized basic
files to my Acorn BBC Master and back in ASCII to the PC again, while the PC
was in terminal mode. Nice!

Bye, Katzy.


0
Katzy
11/22/2009 11:12:36 PM
katzy@noname.at.all wrote:
> Ah, that was the clue. Now I could do more. I transferred the tokenized
basic
> files to my Acorn BBC Master and back in ASCII to the PC again, while the PC
 
If you're trying to load it on a PC, are you running Windows, in
which case, why not just.... load it directly into BBC BASIC for
Windows?
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
BBC BASIC for Windows and Internationalisation
  See http://mdfs.net/Software/BBCBasic/Windows/ProgTips
0
jgh
11/23/2009 9:44:18 PM
Hello.

Jonathan Graham Harston wrote in message <091123215505@arcade.demon.co.uk>...
>katzy@noname.at.all wrote:
>> Ah, that was the clue. Now I could do more. I transferred the tokenized
>basic
>> files to my Acorn BBC Master and back in ASCII to the PC again, while the
PC
>
>If you're trying to load it on a PC, are you running Windows, in
>which case, why not just.... load it directly into BBC BASIC for
>Windows?

Because I don't owe BBC BASIC for Windows, just an old DOS version (gave a Bad
Program), but I DO owe the real thing on my Acorn BBC Master, BBC and
Electron... ;)

Bye, Katzy.


0
Katzy
11/24/2009 12:28:58 PM
Reply: