drogon wrote:
GARTHWILSON wrote:
drogon wrote:
And if it was all his own work, then why is all we have what is effectively a disassembly. Is there a properly annotated source file anywhere?
It's available at
https://github.com/jefftranter/6502/blo ... source.zip . It is heavily commented.
It is a very well commented disassembly.
I've no doubt that Lee put a lot of work into this, dissembling, commenting and Enhancing, but I'm not convinced it was all his original work.
-Gordon
I've downloaded the first release of the code from Lee's site via the Wayback machine
https://web.archive.org/web/20030118100532/http://members.lycos.co.uk/leeedavison/6502/ehbasic/.. and compared bits of it with the Microsoft Basic source here
https://github.com/brajeshwar/Microsoft-BASIC-for-6502-Original-Source-Code-1978/blob/master/M6502.MAC.txt.. and there are a lot of similarities you wouldn't expect if the code was all Lee's own work.
The order of the tokens for example starts END, FOR, NEXT, DATA in both and the order for the functions starts SGN, INT, ABS, USR in both. This could explained if Lee was trying to have some degree of token code compatibility but his additions break this later in the table.
Some of the code looks very similar too. For example the code for inserting a line into a program looks like this in the Microsoft version:
Code:
BLTU: JSR REASON ;ASCERTAIN THAT STRING SPACE WON'T
;BE OVERRUN.
STWD STREND
BLTUC: SEC ;PREPARE TO SUBTRACT.
LDA HIGHTR
SBC LOWTR ;COMPUTE NUMBER OF THINGS TO MOVE.
STA INDEX ;SAVE FOR LATER.
TAY
LDA HIGHTR+1
SBC LOWTR+1
TAX ;PUT IT IN A COUNTER REGISTER.
INX ;SO THAT COUNTER ALGORITHM WORKS.
TYA ;SEE IF LOW PART OF COUNT IS ZERO.
BEQ DECBLT ;YES, GO START MOVING BLOCKS.
LDA HIGHTR ;NO, MUST MODIFY BASE ADDR.
SEC
SBC INDEX ;BORROW IS OFF SINCE [HIGHTR].GT.[LOWTR].
STA HIGHTR ;SAVE MODIFIED BASE ADDR.
BCS BLT1 ;IF NO BORROW, GO SHOVE IT.
DEC HIGHTR+1 ;BORROW IMPLIES SUB 1 FROM HIGH ORDER.
SEC
BLT1: LDA HIGHDS ;MOD BASE OF DEST ADDR.
SBC INDEX
STA HIGHDS
BCS MOREN1 ;NO BORROW.
DEC HIGHDS+1 ;DECREMENT HIGH ORDER BYTE.
BCC MOREN1 ;ALWAYS SKIP.
BLTLP: LDADY HIGHTR ;FETCH BYTE TO MOVE
STADY HIGHDS ;MOVE IT IN, MOVE IT OUT.
MOREN1: DEY
BNE BLTLP
LDADY HIGHTR ;MOVE LAST OF THE BLOCK.
STADY HIGHDS
DECBLT: DEC HIGHTR+1
DEC HIGHDS+1 ;START ON NEW BLOCKS.
DEX
BNE MOREN1
RTS ;RETURN TO CALLER.
And this is Lee's
Code:
LAB_11CF
JSR LAB_121F ; check available memory, "Out of memory" error if no room
; addr to check is in AY (low/high)
STA Earryl ; save new array mem end low byte
STY Earryh ; save new array mem end high byte
; open up space in memory
; move (Ostrtl)-(Obendl) to new block ending at (Nbendl)
; don't set array end
LAB_11D6
SEC ; set carry for subtract
LDA Obendl ; get block end low byte
SBC Ostrtl ; subtract block start low byte
TAY ; copy MOD(block length/$100) byte to Y
LDA Obendh ; get block end high byte
SBC Ostrth ; subtract block start high byte
TAX ; copy block length high byte to X
INX ; +1 to allow for count=0 exit
TYA ; copy block length low byte to A
BEQ LAB_120A ; branch if length low byte=0
; block is (X-1)*256+Y bytes, do the Y bytes first
SEC ; set carry for add + 1, two's complement
EOR #$FF ; invert low byte for subtract
ADC Obendl ; add block end low byte
STA Obendl ; save corrected old block end low byte
BCS LAB_11F3 ; branch if no underflow
DEC Obendh ; else decrement block end high byte
SEC ; set carry for add + 1, two's complement
LAB_11F3
TYA ; get MOD(block length/$100) byte
EOR #$FF ; invert low byte for subtract
ADC Nbendl ; add destination end low byte
STA Nbendl ; save modified new block end low byte
BCS LAB_1203 ; branch if no underflow
DEC Nbendh ; else decrement block end high byte
BCC LAB_1203 ; branch always
LAB_11FF
LDA (Obendl),Y ; get byte from source
STA (Nbendl),Y ; copy byte to destination
LAB_1203
DEY ; decrement index
BNE LAB_11FF ; loop until Y=0
; now do Y=0 indexed byte
LDA (Obendl),Y ; get byte from source
STA (Nbendl),Y ; save byte to destination
LAB_120A
DEC Obendh ; decrement source pointer high byte
DEC Nbendh ; decrement destination pointer high byte
DEX ; decrement block count
BNE LAB_1203 ; loop until count = $0
RTS ;
Different labels but its basically the same.
It does appear that Lee disassembled Microsoft Basic and reused portions of it to build EhBasic.