Stories
Slash Boxes
Comments

SoylentNews is people

posted by janrinok on Sunday June 16 2019, @10:40PM   Printer-friendly
from the digital-archeology-now-before-its-too-late dept.

Programmer David Given has done the leg work to contact and ask R. T. Russel about releasing the Z80-based BBC BASIC as Free Software. It is now available under the non-reciprocal zlib license:

As part of the work I've been doing with cpmish I've been trying to track down the copyright holders of some of the more classic pieces of CP/M software and asking them to license it in a way that allows redistribution. One of the people I contacted was R.T. Russell, the author of the classic Z80 BBC BASIC, and he very kindly sent me the source and agreed to allow it to be distributed under the terms of the zlib license. So it's now open source!

[...] So the reason why this is important is that BASIC has, rightly, a reputation for being a pretty terrible language; but BBC BASIC was a dialect specifically commissioned by the BBC in 1981 as an educational aid. As a result, BBC BASIC supports named procedures, local variables, recursion, and other structured programming features. Unlike Microsoft BASIC, you can write proper structured, maintainable programs in BBC BASIC without needing to refer to any line numbers anywhere. And it'll run faster that way: [...]

[...] The original version was written by Sophie Wilson at Acorn in 1981 for their 6502-based range of BBC Micro computers and during the early eighties every school child in the United Kingdom was exposed to it, spawning a whole generation of bedroom programmers.

Earlier on SN:

[Ed's Comment: 170619-0724UTC. Added additional link to the original story]


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by Snotnose on Sunday June 16 2019, @11:01PM (5 children)

    by Snotnose (1623) on Sunday June 16 2019, @11:01PM (#856380)

    Had a TRS-80 bought in '79 or so. Learning assembly, started disassembling the BASIC interpreter. Z-80 assembly had some 3 byte instructions, byte 1 would be jump or jumpSubroutine, the next 2 bytes were the address. In the TRS-80 BASIC it would jump into the middle of that 3 byte instruction. In other words, they crafted it such that an address or offset could also be an op-code for a subroutine.

    Don't know if it was Gates or Allen who did that, but kudos to whomever.

    --
    When the dust settled America realized it was saved by a porn star.
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 0) by Anonymous Coward on Sunday June 16 2019, @11:30PM

    by Anonymous Coward on Sunday June 16 2019, @11:30PM (#856392)

    THINK about the implications of a hack like that.
    You better make damn sure the code doesn't change size so that your magic absolute jump address changes.

  • (Score: 0) by Anonymous Coward on Sunday June 16 2019, @11:42PM

    by Anonymous Coward on Sunday June 16 2019, @11:42PM (#856399)

    The BASIC interpreters of the era stored code in abbreviated form, basically calllng subs in interpreter/mointor. What you are describing is a scenario for compiled c-code doing something super evil and clever.

    Go take your metamucil and be quiet now.

  • (Score: 3, Interesting) by Anonymous Coward on Monday June 17 2019, @12:19AM

    by Anonymous Coward on Monday June 17 2019, @12:19AM (#856411)

    "In other words, they crafted it such that an address or offset could also be an op-code for a subroutine."

    Sounds a bit like http://www.catb.org/jargon/html/story-of-mel.html [catb.org]

  • (Score: 2) by mth on Monday June 17 2019, @12:52PM (1 child)

    by mth (2848) on Monday June 17 2019, @12:52PM (#856604) Homepage

    In general that kind of trick was only used with conditional jumps, where the condition is always false.

    Let's say you want to program the C-like expression "A = Z ? 3 : 4" in Z80 assembly, the obvious version would look like this:

        JR Z,SKIP
        LD A,3
        JR CONTINUE
    SKIP:
        LD A,4
    CONTINUE:
        ; next statement

    This is 8 bytes long (4 instructions that all happen to be 2 bytes each).

    The trick you described would make it look like this:

        JR Z,SKIP
        LD A,3
        JP Z,{truncated}
    SKIP:
        LD A,4
        ; next statement

    Where {truncated} means that the "LD A,4" is actually inside the 2-byte address of the "JP Z". In actual assembly you'd use "DB $CA", a literal containing the opcode for "JP Z,nnnn".

    This sequence is 7 bytes long ("JP Z" is 3 bytes, but effectively 1 because it overlaps the 2-byte LD), so it saves one byte. But when you have to fit your program in for example a 16K ROM, every byte can matter.

    • (Score: 2) by mth on Monday June 17 2019, @12:55PM

      by mth (2848) on Monday June 17 2019, @12:55PM (#856606) Homepage

      Eh, make that "A = Z ? 4 : 3". I broke the example when I tried to make it more clear.