Image Map Image Map
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: GW-BASIC released as open source

  1. #1
    Join Date
    Jan 2019
    Location
    New Hampshire
    Posts
    241

    Default GW-BASIC released as open source

    Haven't looked at the source yet, but check this out:

    https://devblogs.microsoft.com/comma...rces-gw-basic/

    Wow!

  2. #2
    Join Date
    Aug 2017
    Location
    New York, Rome, London
    Posts
    131

    Default

    Thanks for the link - this is really cool!

  3. #3
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    34,339
    Blog Entries
    18

    Default

    Don't know what happened to my original comment, but this must be a very early 8086 version of GWBASIC. The code is auto-translated from 8080, with an enormous amount of excess baggage. It looks as if it comes from Intel CONV86 under "strict" mode. As an example, let's take ADVGRP.ASM at around line 360:

    Code:
    	MOV	BX,QUEINP
    	CALL	WRAP		;CHECK FOR WRAP AROUND CASE
    	POP	DX
    	MOV	BYTE PTR [BX],DL
    	LAHF
    	INC	BX
    	SAHF
    	MOV	BYTE PTR [BX],DH
    	LAHF
    	INC	BX
    	SAHF
    	MOV	BYTE PTR [BX],CL
    	LAHF
    	INC	BX
    	SAHF
    	MOV	BYTE PTR [BX],CH
    	LAHF
    	INC	BX
    	SAHF
    	POP	DX
    	MOV	BYTE PTR [BX],DL
    	LAHF
    	INC	BX
    	SAHF
    	MOV	BYTE PTR [BX],DH
    	LAHF
    	INC	BX
    	SAHF
    	MOV	QUEINP,BX
    	RET
    Only an automatic converter would generate code like this. Let's see what human-generated code might look like:

    Code:
            MOV	BX,QUEINP
    	CALL	WRAP		;CHECK FOR WRAP AROUND CASE
    	POP	[BX]
            MOV        [BX+2],CX
            POP        [BX+4]
            ADD        BX,6
            MOV       QUEINP,BX
    The giveaway is the pairs of LAHF/SAHF instructions (not common in 8086 native code) around the INC BX instructions to preserve the flags. In this case, they serve no purpose, as the setting of the flags has no effect on the code.

  4. #4
    Join Date
    Dec 2012
    Location
    Russia, Moscow
    Posts
    130

    Default

    I tried to compile GW-BASIC from sources but failed. It seems to me that part of the code is missing...
    First of all, I converted files from UNIX-like <LF> style to DOS <CR><LF> because some assemblers went crazy. I tried to use: Intel ASM86 ver 3.1 / 3.2, Digital Research CP-M 8086 Assembler ver 1.1, MASM v1.0, MASM v3.0, MASM v4.0, MASM v5.0 and Borland TASM v4.1. It seemed to me the most correct is working with the source code of version 4 of the MASM. Then i created a makefile where i collected all the assembler files. I had to fix it a little bit in the code:
    Code:
    GWEVAL.ASM line 452: MOV	DX,OFFSET 256*100+OPCNT replaced to MOV	DX,25600+ OFFSET OPCNT
    Also i concatinate files MATH1.ASM and MATH2.ASM in new large file named MATH.ASM and make some fixes:
    Code:
    MATH.ASM line 1311: MOVS	?CSLAB,WORD PTR ?CSLAB replaced to MOVSW
    MATH.ASM line 5020: MOVS	?CSLAB,WORD PTR ?CSLAB replaced to MOVSW
    MATH.ASM line 5022: MOVS	?CSLAB,WORD PTR ?CSLAB replaced to MOVSW
    Now compilation passes without errors, but the main file is not collected due to the lack of definitions of some procedures:
    Code:
    Unresolved externals:
    
    
    MAPSUP in file(s): 
     GIOKYB.OBJ(GIOKYB)
    POKFLT in file(s): 
     GWMAIN.OBJ(GWMAIN)
    SCRINP in file(s): 
     SCNDRV.OBJ(SCNDRV) GWSTS.OBJ(GWSTS)
    POLLEV in file(s): 
     GWSTS.OBJ(GWSTS)
    TRMCOM in file(s): 
     GIOCOM.OBJ(GIOCOM)
    SCRATR in file(s): 
     GWSTS.OBJ(GWSTS)
    SETCLR in file(s): 
     GWSTS.OBJ(GWSTS)
    PNTINI in file(s): 
     ADVGRP.OBJ(ADVGRP)
    SCROUT in file(s): 
     SCNDRV.OBJ(SCNDRV) GWSTS.OBJ(GWSTS)
    SETATR in file(s): 
     ADVGRP.OBJ(ADVGRP) GENGRP.OBJ(GENGRP)
    CSRDSP in file(s): 
     GIOKYB.OBJ(GIOKYB) GWSTS.OBJ(GWSTS)
    ...etc...

  5. #5

    Default

    It would be interesting to do a disassembly of the gw-basic that shipped with ms-dos to see if matches.
    I may have to do that....

    joe

  6. #6
    Join Date
    Aug 2017
    Location
    New York, Rome, London
    Posts
    131

    Default

    Someone commented on the page of the announcement with a similar experience:

    Quote Originally Posted by Diomidis Spinellis
    After making a few changes I was able to assemble all files with MASM 5.10A. You can find them, together with a rough Makefile and a linker script, in this repo. Slightly earlier MASM versions might have also worked, but initially I was moving from one MASM version to the next, trying to find one that would assemble all files without an error. In the end, I fixed a few issues by hand. Sadly, many routines are missing from the source code. It seems to me that this source code was coupled with an OEM vendor-specific file that performed low-level stuff, such as clearing the screen.
    I wonder if itís possible to write a few of those low-level routines from scratch (eg clearing the screen does not sound hard) and eliminate others (eg printing?) to get it to produce an executable...

  7. #7
    Join Date
    Aug 2006
    Location
    Chicagoland, Illinois, USA
    Posts
    6,537
    Blog Entries
    1

    Default

    Quote Originally Posted by Chuck(G) View Post
    Only an automatic converter would generate code like this.
    I did notice this, but there are also very human-produced bits of code, like REP MOVSW which no converter would produce. So maybe it was a human-assisted transcode.

    Seeing the very unoptimal stretches of code makes me wonder if gwbasic could be optimized to be significantly faster.
    Offering a bounty for:
    - A working Sanyo MBC-775, Olivetti M24, or Logabax 1600
    - Music Construction Set, IBM Music Feature edition (has red sticker on front stating IBM Music Feature)

  8. #8
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    34,339
    Blog Entries
    18

    Default

    It might be that the whole thing was auto-translated, then hand-tweaked to make it fit in a limited space.

    Just guessing here...

  9. #9

    Default

    Quote Originally Posted by Chuck(G) View Post
    Don't know what happened to my original comment
    There were two threads posted at close to the same time: http://www.vcfed.org/forum/showthrea...-code-released

  10. #10
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    34,339
    Blog Entries
    18

    Default

    Is this the primary one?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •