Microsoft Basic listing from 1978

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: Microsoft Basic listing from 1978

Post by barrym95838 »

So you actually were able to measure the difference ... cool! I have a slightly different use case for my current coding exercise. It's for my new version of MSBASIC's FIN, which I cheekily renamed atof:

Code: Select all

getnxt:
      iny               ; bump the buffer pointer
gettxt:
      lda   (txtptr),y  ; grab a char from text buffer
      cmp   #' '        ;
      beq   getnxt      ; skip over any space char(s)
      eor   #'0'        ;
      cmp   #10         ; ASCII decimal digit?
      bcc   gottxt      ;   yes: CC, convert to binary
      eor   #'0'        ;   no: CS, return orig. ASCII
gottxt:
      rts               ;
Here, I assume that we're still in the land of NMOS, that the current string of interest is smaller than 256 bytes, and that scanned decimal digits will be used as binary immediately.
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
John West
Posts: 383
Joined: 03 Sep 2002

Re: Microsoft Basic listing from 1978

Post by John West »

I've started looking at what changes I can make to the Commodore 64's BASIC to take advantage of the new instructions in my 65020 design (which I'm working on again, slowly).

Profiling a simple test program showed that a huge amount of time is spent in CHRGET / CHRGOT. This routine always struct me as overcomplicated. Surely you don't always need to know if the character you've fetched is a digit - why go through that lengthy test every time, only to ignore the carry flag when you return?

If you have an LDA (zp) instruction without indexing, it's possible to replace many (but not all) calls to CHRGOT with an inlined LDA (TXTPTR). There's no need to test for space and loop, because CHRGOT can never be called on a space.

So I tried that on one instance, and ... well, it does work, and it does make difference. But in the process I've discovered a latent bug. The program would crash with a "NEXT WITHOUT FOR" error, unless I followed the LDA (TXTPTR) with a NOP.

Here's the code responsible:

Code: Select all

DOPRE1	LDA OPTAB+2,Y
	PHA
	LDA OPTAB+1,Y
	PHA
	JSR PUSHF1
	LDA OPMASK
	JMP LPOPER
SNERR5	JMP SNERR
PUSHF1	LDA FACSGN
	LDX OPTAB,Y
PUSHF	TAY
	PLA
	STA INDEX1
	INC INDEX1
	PLA
	STA INDEX1+1
	TYA
	PHA
The JSR PUSHF1 pushes the address of (one byte before) the next instruction. PUSHF then pops this address, increments it, and stores it in INDEX1. Later on there's a JMP (INDEX1). Can you see the problem?

It's only incrementing the low byte of INDEX1. My changes placed the instruction after JSR PUSHF1 at the start of a page, so the address pushed to the stack ended in $ff. Increment just the low byte of that, and JMP (INDEX1) will take you 256 bytes from where you should be.

It's not a problem in the Commodore 64, because that instruction is normally nowhere near the start of a page. I just got very, very unlucky.
TomC
Posts: 22
Joined: 21 Oct 2010
Location: US

Re: Microsoft Basic listing from 1978

Post by TomC »

Quote:
Funny thing..., the only Microsoft software to ever run on Apple computers were MS Basic and MS Office.. Or am I wrong?
They also published Olympic Decathalon for the Apple ][...
Last edited by TomC on Tue Sep 21, 2021 1:38 pm, edited 1 time in total.
Uncle Warthog
Posts: 14
Joined: 24 Oct 2017

Re: Microsoft Basic listing from 1978

Post by Uncle Warthog »

TomC wrote:
Quote:
Funny thing..., the only Microsoft software to ever run on Apple computers were MS Basic and MS Office.. Or am I wrong?
They also published Olympic Decathalon for the Apple ][...
And also Multiplan, a pretty good spreadsheet program.
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: Microsoft Basic listing from 1978

Post by cbmeeks »

Let's not forget their CP/M card for the Apple II. That was a big seller for them for a while.
I'm sure it had custom ROM code at the very least. :-)
Cat; the other white meat.
Post Reply