The Register Home Page

back to article Microsoft developer ported vector database coded in SAP’s ABAP to the ZX Spectrum

A Microsoft senior software engineer named Alice Vinogradova has ported a database she wrote in SAP’s ABAP language to the venerable Z80 processor that powered the Sinclair ZX Spectrum – and marveled at the results. Vinogradova’s named her database ZVDB-Z80 and describes it as “a Vector Database developed entirely in ABAP, …

  1. steelpillow Silver badge

    One more for luck

    Fond memories.

    This from the RISC OS era:

    Stick to one standard library and one standard set of library calls. Don't have a thousand apps stashing a thousand and ten sometimes-identical libraries under their armpits, to do exactly the same job.

    1. disk iops

      Re: One more for luck

      But then you'd have to smash the fingers of the know it all youts who worship shiny and force them to actually learn the fundamentals, that are hard. Instead of letting them get away with rewriting things in python and thinking that are now programmers.

      1. Jedit Silver badge
        Joke

        "But then you'd have to smash the fingers of the know it all youths"

        That's not the concern of the software engineers, mate, it's a hardware problem.

        1. Anonymous Coward
          Anonymous Coward

          Re: "But then you'd have to smash the fingers of the know it all youths"

          It's management, not engineering.

          1. Snowy Silver badge
            Joke

            Re: "But then you'd have to smash the fingers of the know it all youths"

            Out source it and then it becomes someone else's problem, "Those are nice fingers, it would be a shame if anything happen to them!!"

    2. FIA Silver badge

      Re: One more for luck

      It's probably worth taking some more modern lessons from RISC OS too.

      * Optimise where needed

      Unless you're really trying to wring out the last milisecond then write in a higher level language these days. Once you get above any slight complexity a modern compiler will produce better code than most people can by hand. (On a modern CPU). Also... a modern compiler will be able to optimise for the next CPU you target at, and also not use those depricated instructions. (I was going to end this sentance MOVS PC,14, but then I realised it'd probably crash).

      RISC OS is blazingly fast, but not on modern hardware as it doesn't run anymore, and basically needs re-writing. Had more of it not been in hand optimised ARM then that would be a lot easier.

      1. Peter Gathercole Silver badge

        Re: One more for luck

        You can still run RiscOS on a 32-bit Raspberry Pi (up to Pi 4s). It's had some re-writes to get around the fact that modern ARM 32-bit processors actually can use the whole of the 32 bit words as addresses, rather than just 26 bits of the original ARM2 processors, but I understand that these were not huge, and were mainly around the use of the 6 unused bits for processor status in the 26 bit ARMs, somewhat reducing the need for a processor status register.

        Moving to 64-bit ARM processors requires more of a rewrite IIRC, and this has only recently been considered as a future project.

        I don't know whether it is a pity, or an opportunity that 64-bit ARMs won't run most 32-bit ARM code. I (still) work on IBM Power systems, and their 32/64 bit model, which allows most 32-bit binaries to run with no change seems to be the sensible way to go, although at the expense of some complexity in the processor (32-bit instructions have, since the first generation of PowerPC processors, always been effectively a size-reduced mode of 64-bit instructions, leading to not having to have different 32 and 64 bit execution units in the processor.)

        1. FIA Silver badge

          Re: One more for luck

          IIRC the problem is newer 64bit ARM will only run 32 bit code in user mode, which makes kernel level stuff hard.

          There's also the difference in the ISA too. ARM32 is from the 80s, written by people who cut their teeth on the 6502 and therefore is great for hand optimisation on in order CPU designs, but a bugger once you start to speculate or execute out of order. ARM64 is more geared towards being easily produced by a compiler, and has eschewed some of the more unique features of the 32 bit ISA such as conditional everything.

      2. Stevie Silver badge

        Re: One more for luck

        But the blistering speed (relatively speaking) here was gained by writing in Z80 assembler. On-the-fly compiling and dynamic linking will slow things down to a very manageable speed.

    3. ThomH

      Re: One more for luck

      But Electron apps are still a fantastic idea, right? Sometimes those pretend-native text boxes are almost 70% similar to the real ones!

    4. Bluck Mutter

      I'm old...

      And I "marvel" at the complexity of the build process of modern software.

      It appears to me that dev's today will include some big arsed 3rd party library with 100's of function calls cause they need one of these calls to do something rather than write the bugger themselves.

      In my day, you had whatever libraries came with your Unix OS and compiler and a manual and it was sink or swim. Need a function not available...write it yourself.

      And chances are, if you are organized, as your career advances you repurpose your lean and mean functions iteratively and end up with a library of useful stuff (i.e. the initial effort isn't a one off sunk cost).

      I have reused stuff I wrote 20/30 years ago at times.

      Today... it's all cut and paste from a 3rd party...and/or download and link....programmers my arse.

      News at 11: Old man yells at clouds.

      Bluck

  2. Fruit and Nutcase Silver badge
    Pint

    Wot no CoPilot?

    I expect she'll be sent to re-education camp for not using CoPilot.

    Yes, the old constraints did mean we took much more care over what our code did under the covers. The modern solution is to put more processing power at the problem.

    icon: a beer, or wine, or whatever her chosen poison for her efforts

    1. b0llchit Silver badge
      Meh

      Re: Wot no CoPilot?

      Don't worry, we'll get that smart-ass thinking eliminated soon enough.

      Who do they think they are, those old school coders? They are nothing compared to modern times. They are just relics trying to show off and suppress the progress we've been making at eliminating those thinkers. Don't worry, they'll be dead soon enough and our automated way will be the only way.

      /s

  3. brainwrong Bronze badge

    Z80: One cycle vs four for random access

    That's not true, not for the original 40pin Z80 used in the ZX81 etc. It may be true for the later Z800000000.

    1. Dan 55 Silver badge

      Re: Z80: One cycle vs four for random access

      I think it means "INC HL" is cheaper than "LD HL, n" if you're doing e.g. "LD A, (HL)" afterwards.

      Maybe you could abuse the stack pointer for something cheaper still, depending on the kind of data.

      1. ThomH

        Re: Z80: One cycle vs four for random access

        If your source is appropriately sized and aligned, you might even be able to get away with an INC L and save two cycles!

        1. Dan 55 Silver badge

          Re: Z80: One cycle vs four for random access

          You're right... but I'm surprised by how much I did remember just by reading that bit of code. It's a shame it won't put food on my family.

  4. Dan 55 Silver badge
    Windows

    I spy an optimization

    From this page, the following code:

    next_byte:

    LD A, (DE) ; Vector B

    XOR (HL) ; Vector A

    [...]

    DEC B

    JR NZ, next_byte

    RET

    "DEC B ; JR NZ next_byte" should be "DJNZ next byte". The first method takes 16 (non-zero) or 11 (zero) T-States. DJNZ takes 13 (non-zero) or 8 (zero) or T-States.

    1. Anonymous Coward
      Anonymous Coward

      Re: I spy an optimization

      Good catch! She uses DJNZ in her listing on Medium: https://medium.com/@elfee/i-ported-sap-to-a-1976-cpu-it-wasnt-that-slow-5d0be2d0a51a

    2. Boris the Cockroach Silver badge
      Boffin

      Re: I spy an optimization

      DJNZ is quite slow compared to

      Dec B

      JP NZ <Address>

      As all the NZ path has to do is replace the program counter with the address specified in the instruction.

      Whereas DJNZ has to dec the B register too, then on the NZ path, retrive the current value of the program counter, add the jump value to it, then replace the prgram counter.(always remember the PC points to the instruction AFTER the DJNZ)

      Oh and for real speed in an interrupt routine always use EX AF AF' and EXX as changing the active registers is way faster than storing them on the stack.

      Gawd I'm such a geek

      1. J.G.Harston Silver badge

        Re: I spy an optimization

        But then you smash the foreground program's EXX registers.

        1. David Hicklin Silver badge

          Re: I spy an optimization

          > But then you smash the foreground program's EXX registers.

          As the Z80 only did one thing at a time, the important trick on ending the INT was to switch them back.

          Unless of course the foreground program was a bastard that was already using that trick!

  5. Yorick Hunt Silver badge
    Facepalm

    And yet...

    ... Microsoft struggles to port code from Windows 10 to Windows 11.

    1. b0llchit Silver badge
      Trollface

      Re: And yet...

      Because they are targeting the wrong processor...

      1. Dan 55 Silver badge
        1. Michael Strorm Silver badge

          Re: And yet...

          You are an ex(?)-Slashdotter and I claim my £5.

          1. Dan 55 Silver badge

            Re: And yet...

            Ex, I sometimes go back and have a look from time to time out of morbid curiosity.

  6. Doctor Syntax Silver badge

    Aren't her points 1 & 4 the same?

    1. Anonymous Coward
      Anonymous Coward

      Aren't her points 1 & 4 the same?

      I am guessing one point was for pre computed tables compiled into the executable and the other for tables calculated at run time possibly based on run time parameters; although in the latter case memoization might save both space and time (calculate as needed, cache [memoize] against future need.)

      I would prefer getting the code right before making it fast - not that Microsoft is often guilty of either infraction separately and never jointly.

      "Premature optimisation is the root of all evil." Knuth 1974.

      1. Ken Shabby Silver badge
        Facepalm

        Premature optimisation

        It’s never happened before, I promise.

        1. Anonymous Coward
          Anonymous Coward

          Re: Premature optimisation

          So true for modern software ... just throw MORE CPU/GPU at it and lots & lots of memory.

          :)

      2. Anonymous Coward
        Anonymous Coward

        Re: Aren't her points 1 & 4 the same?

        Loved this because it is so 'Right' to use the CPU to the maximum.

        "Premature optimisation is the root of all evil." Knuth 1974."

        Quoting IT 'Gods' does not make it True in ALL cases.

        For small well known pieces of code where you KNOW exactly the program flow through that code you WILL optimise the code to the maximum you can, IF the optimisations are necessary.

        P.S.

        I am all for writing fast optimised code IF required ... this does not mean it should be undocumented or spagetti-code.

        It is lazy to simply throw MORE CPU/GPU at it and use more & more memory because it is QUICK to do.

        Look at the HUGE size of the software we use now.

        [Hard hat MODE on ... smashing control with LARGE hammer so it cannot be switched off !!!]

        :)

        1. that one in the corner Silver badge

          Re: Aren't her points 1 & 4 the same?

          >> Premature optimisation is the root of all evil." Knuth 1974.

          > Quoting IT 'Gods' does not make it True in ALL cases.

          Yes, yes it does, as you yourself demonstrate in your very next sentence:

          > For small well known pieces of code where you KNOW exactly the program flow through that code you WILL optimise the code to the maximum you can, IF the optimisations are necessary.

          Notice you wrote "IF the optimisations are necessary"? So you also agree that you should not attempt to optimise when it is premature to do so.

          BTW "where you KNOW exactly the program flow through that code" - I take it you rarely, if ever, write library code or work within a team, otherwise you must have the most amazing precognitive abilities to know how all the possible program flows are going to reach your code!

          For that matter, even working alone on a product for any length of time (i.e. on anything other than a throwaway quickie), Use The Profiler, Luke - rather than relying on your own beliefs about the code; it tends to be very enlightening when you run today's real world data through the "really good" code you wrote a few years ago.

          1. Charlie Clark Silver badge

            Re: Aren't her points 1 & 4 the same?

            Optimisations may be necessary if performance for the specified use case isn't sufficient. Then you start profiling and identifying which parts take the most resources (CPU, memory) and work on them following established patterns for moving high-level code to something more low-level, but also perhaps improving the algorithm. I can't find the post anymore, but there was a recent version of Python which contained some signficant improvements in Python's math module that illustrated: some were simple changes from Python to C, but others involved insights based on number and group theory, IIRC.

            And as for running on small hardware: Micropython does an amazing job compiling down to machine code.

          2. Anonymous Coward
            Anonymous Coward

            Re: Aren't her points 1 & 4 the same?

            I will conceed your point as you have understood what I wrote BUT because of the vageries of the English language I MEANT something slightly different.

            "IF the optimisations are necessary" means there are external drivers defining IF the optimisations are to be done, the case I had in mind was performance.

            i.e. the code as written does not perform at an acceptable speed. (Tends to be the usual reason 'optimisations' are sought, in my experience)

            "where you KNOW exactly the program flow through that code" you have ignored the 'small well known' qualifier and also made the assumption that the code I am writting is via some sort of modern compiler.

            I have experience of writing low-level code in assembler where my original comments also apply, particularly when the memory is constrained.

            You try to maximise the code performance and size.

            I know that low-level coding in assembler is looked down on when 'super whizzy' High level languages are available BUT there is still a need and the skills are relevant in certain corners of industry.

            The comment about looking at 'old' code is true but that goes with improving your skills over time and learning new things.

            You are never so good that you cannot learn something new ... being good at something means you KEEP learning !!!

            :)

  7. wolfetone Silver badge

    I do still work like I have 56k dial up at home, and it's sad to see how many people don't think like that and instead think everyone has superfast machines and things like that.

    1. Fruit and Nutcase Silver badge
      Mushroom

      That 56k modem is what they should be targeting certain mobile sites...

      Try looking up National Rail real-time train information on a weak reception area /from a moving train. The bloody thing keeps loading junk that is not vital to the task at hand

      Or car parking apps...

      1. heyrick Silver badge

        Add to that Android, that when it gets a usable signal, will spend time shuffling internal whotsits and completely ignore whatever the user is trying to do in the foreground. I'm glad that 4G is widespread around here these days as when using the shonkier H or H+, I'd find myself twiddling my thumbs when the signal came back after dropping out because the OS decided checking all the stuff it checked just a few minutes ago was the most important task.

        Written by idiots...

        1. Alumoi Silver badge

          The most important task in Android is to tell Google and Facebook every freaking thing you do.

      2. Jamie Jones Silver badge
        Coat

        I can understand the frustration if the National Rail site keeps loading car parking apps...

        [ sorry! ]

        1. that one in the corner Silver badge

          Absolutely.

          The National Rail site should be loading something useful, say - bus time tables,

          1. Fruit and Nutcase Silver badge
            Mushroom

            Bus timetables!!!

            That's another abomination - a bit of a lottery in finding the right service.

            Though to be fair, I've found that with the TFL website, I can get at the information fairly quickly

  8. Anonymous Coward
    Anonymous Coward

    Eeek

    Hmmm so you suggesting that proper skillful intelligent programming can produce very fast processing on very moderate hardware.

    But that would reasult in an awful lot of overpriced shit being completely unnecessary and on having skillful intelligent programmers not just minimum wage slaves producing junk code by the kilo using AI.

    I would suggest that until this article is long forgotten you avoid high buildings and open windows

  9. Anonymous Coward
    Anonymous Coward

    The grand children got an Xbox with 500GB storage the other day. I naively thought 500GB storage would be plenty. Three games later and they've filled it.

    1. Gene Cash Silver badge

      Updates

      It's even more fun when the games insist on 44GB updates before you can play, about every 3rd time. Looking at you, HALO Infinite.

      1. Anonymous Coward
        Anonymous Coward

        Re: Updates

        You spend a couple of hours downloading the apps and then find they're flaky - just kicking you out at random or refusing to allow you to login.

    2. captain veg Silver badge

      Re: Naive

      Since Covid I've been using my own personal laptop for work, mostly because in the office I had a substantially less than portable Xenon workstation under the desk, but also to avoid the pettifogging BOFH regime. Recently they noticed and insisted on issuing a work-standard (and thoroughly locked down) Windows lappie, albeit one judged suitable for developers rather than ordinary office fodder. This means an i7 processor (gosh!), 16GB RAM (wow!) and 500GB SSD (WHOOPEE!!!). They think this is plenty. I beg to differ. It's (ostensibly) replacing a machine with an i9 processor, 48GB RAM and 4TB SSD. And an nVidia graphics adaptor rather than their Intel tat. So I'm stuck with a serious downgrade, but one which is "compliant".

      Is is mere coincidence that "compliant" is an anagram of "complaint"?

      -A.

    3. mirachu

      3x Call of Duty?

      Huge games (and somewhat huge piles of free/small games; looking at you itch.io and charity bundles) are why I have terabytes of HDD in my desktop, with PrimoCache in front.

  10. joeldillon

    While this is awesome, I'm not sure a 7 year gap is 'near contemporary' by the standards of the time. There's only 5 years between the Speccy and the Acorn Archimedes!

    1. oisee

      I ment to say "ZX Spectrum 48k" (1982) and ABAP (1983), but forgot to update this piece.

  11. Mr Dogshit

    I don't know what this has to do with the ZX Rectum.

    There were so many Z80s produced by Zilog and others under licence that even Zilog doesn't know how many there were. They still serve in vending machines and countless other things.

    1. A Non e-mouse Silver badge

      Plus all the unlicensed ones!

    2. Anonymous Coward
      Anonymous Coward

      What it has to do with the ZX Spectrum

      Last para of the article:

      "Her GitHub page of course includes the code discussed here, plus instructions on how to get it running on an actual Sinclair ZX Spectrum, online emulators JSSpeccy or Qaop/JS, or on local emulators Fuse , ZEsarUX, Speccy, or Retro Virtual Machine."

    3. David 132 Silver badge

      I don't know what this has to do with the ZX Rectum.

      I guess we've found the embittered Jupiter Ace buyer.

      1. Blue Pumpkin

        At least it wasn't an ORIC ....

  12. Simon Harris Silver badge
    Unhappy

    Z80 thinking “Still wins in 2025”

    Pity that in 2024, Z80 thinking was "Let's stop making it now"

    Have to do 6502 thinking in 2025 instead - that's still being made (well, the enhanced 65C02 anyway).

    1. Sam Shore

      Re: Z80 thinking “Still wins in 2025”

      I spotted this a couple of months ago. An 8 bit computer (think spectrum era technology) for learning 80s style computing.... but it has dual CPUs. A Z80 and a 6502.

      https://www.thebyteattic.com/p/cerberus-2100.html

      Interesting piece of retro kit.

      1. Simon Harris Silver badge
        Happy

        Re: Z80 thinking “Still wins in 2025”

        I don't think the AVR processor as I/O controller should count as the third head - it needs a 6809 in there as well for true early 1980s-ness.

  13. Stevie Silver badge
    Joke

    Bah!

    Pshaw!

    Call me back when someone has done this on a Science of Cambridge MK14.

    1. oisee
      Happy

      Re: Bah!

      Could you plz recommend decent emulators?

      https://github.com/oisee/zvdb-z80/blob/master/zvdb_cambridge.txt

      plz test on your hardware. feel free to pull request.

  14. BartyFartsLast Silver badge

    48K

    Is enough for anybody.

    It's definitely more than enough if you have to type it all on that dead flesh keyboard

    1. Simon Harris Silver badge

      Re: 48K

      How did developers for the original Spectrum do it?

      Did they write on something else and cross-assemble for the Spectrum, was there an aftermarket proper keyboard to make it useable, or did they suffer the rubber keys?

      I did some Oric-1 programming back in the day, which had a marginally better keyboard, but it would have driven me crazy if I had to do more than one big project on it.

      1. John 110
        Windows

        Re: 48K

        Presumably they did have add-on keyboards. I certainly stuck my speccy circuit board in a "proper" keyboard. A nice clicky one it was too. I think it's still in the loft somewhere...

        Anyway, if you wait a couple of minutes, I'm sure a speccy programmer will pop up and enlighten us.

        1. Andrew Scott Bronze badge

          Re: 48K

          trs 80 had a proper keyboard and a z80, earlier than the spectrum also.

          1. Simon Harris Silver badge

            Re: 48K

            That is true. At their introduction the TRS-80 was about twice the price (without monitor) of the Spectrum though. I'm sure Clive Sinclair could have made a £300 computer with a proper keyboard and a big case if he'd wanted to, but the rubber keyboard meant it could be cheap and colourful and sold in the millions.

      2. BartyFartsLast Silver badge

        Re: 48K

        Yes, cross compilers on dev systems, some of them were even able to be plugged in to the target system to load and debug code "properly" but there were plenty of aftermarket "proper" keyboards for the 8 bitters which suffered with those crappy horror keyboards.

      3. aje21

        Re: 48K

        Of course the Oric Atmos had a proper keyboard :-)

      4. Anonymous Coward
        Anonymous Coward

        Re: 48K

        I recall Matthew Smith of Manic Miner fame saying he used a TSR 80 to develop games. He also used undocumented Z80 instructions to try and fool disassemblers.

        If you want do (or see) some old school assembler programming in your browser, try the 8bit workshop IDE at https://8bitworkshop.com/

  15. Anonymous Coward
    Happy

    Would a clock speed 14X greater have made much difference?

    Has anyone pointed out the speed differences between the ZX Spectrum's 3.5 MHz Z80 and the fastest, last Z80---50 MHz...and how much a difference this might have made to this person's already-very-impressive achievement? (...and, no; being the slack-ass I am, I have not slogged through all previous comments to find out for myself...)

    1. Simon Harris Silver badge

      Re: Would a clock speed 14X greater have made much difference?

      14 times? Interestingly, that's the same speed boost as between many of the Spectrum's 1MHz 6502 contemporaries and the official top speed of the current 65C02.

  16. Anonymous Anti-ANC South African Coward Silver badge
    Holmes

    My observations from watching Usagi Electric's recent Youtube video on minicomputers etc.

    Back in the day when minis ruled, they absolutely have to do everything in hardware, the CPU was optimized to enable multi-user support, and it worked quite well despite the (when compared to today's standards) minuscule amount of RAM and HDD space.

    Today we have bloated Windows (and not-so-bloated Linux) which need to provide support for multiple users in software, and that is a definite bottleneck.

  17. Andrew Scott Bronze badge

    saw a program for the 6502 that pre loaded a table with 1-90 degrees and their sines and used it to determine sines and cosines for the program without computing anything, just a lookup. quite fast and not much memory required.

    1. Simon Harris Silver badge

      I suspect all 8-bit games programmers did that at some point when they needed fast but not incredibly accurate trigonometry.

      1. Will Godfrey Silver badge
        Happy

        raises hand - a bit nervously.

  18. Boris Dyne

    This headline is the reason I always read the weekly summary from The Reg.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like