Menu ▾ ▴

Anyone wanting to play with 8051 compilation by GCBASIC?

Anobium
2026-10-18
2026-10-19
  • Anobium

    Anobium - 2026-10-18

    It has been talked about. I am now planning it.

    I want to start simply, prove the basics work in this context:

    • By using SDCC (sdas8051+sdld) against real AT89S51 hardware with hand-written assembly — independent proof the toolchain and hardware/flashing process work at all.
    • GCBASIC's existing #ASMRAW + ExtAssembler dispatch proven to reach SDCC and reproduce that exact same working .hex, using a new minimal chipdata\AT89S51.dat, the mandatory chipdata\core300.dat, and a new use.ini tool stanza — zero changes to gcbasic.bas for this step.
    • Real GCBASIC-authored 8051 support for:
    • Program structure — #chip AT89S51 compiles to a correct reset vector + Do:Loop, Goto (to a label or into another Sub), Exit Sub, and program-end, via a new ModeI8051 function and ~9 codegen branches mirroring the dormant (never-shipped) Z8 scaffolding.
    • Basic GPIO — Set PinX On/Off compiles to native setb/clr (no Dir needed — classic 8051 has no direction register).
    • Timing — Wait <n> <unit> compiles to a calibrated djnz-based delay loop.</unit></n>
    • Pulses — PulseOut works for free, since it's just a macro over Set + Wait.

    So a real .gcb program like a servo-trigger pulse, an LED blink, or a timed on/off sequence will compile end-to-end through GCBASIC, assemble/link via SDCC, and run on real AT89S51 silicon (if hardware is sourced by then) — that's the concrete "it works" milestone this work can deliver.

    Deliberately NOT included (by design, not oversight):

    • If/While/Until or any comparison — CompileConditions needs a structural label+branch redesign (PIC/AVR's "skip the next instruction" trick doesn't work on 8051's variable-length instructions), explicitly deferred to a future milestone.
    • General variables beyond named pin/SFR bits — CompileVarSet (the big generic assignment function) is untouched.
    • Any peripheral library (I2C, SPI, GLCD, ADC, etc.), interrupts, or multiple chip variants — this is a minimal, experimental single-chip slice, not a shipped target.

    So: a real, narrow, but genuinely working third architecture in GCBASIC — enough to prove the whole approach end-to-end on real hardware, intentionally stopping just before the one piece (If) that needs real design work rather than mechanical translation.

    Anyone want to come and help?

     
  • HackInBlack

    HackInBlack - 2026-10-19

    i can, maybe, help i have an old MikroElektronica Easy AVR board (which only runs on 32-bit windoze) and a tube of AT 89S52 chips.
    If i dig around on one of my older PC's i can find the original demo files...

     
    • Anobium

      Anobium - 2026-10-19

      We need a few more to make this worthwhile.

      The process I have described is same process I used for AVR-DX and PIC-AS. Essentially, ear the elephant piece by piece. :-)

      I will dig out my 8051 kit this week. Report back with what you have.

       
  • HackInBlack

    HackInBlack - 2026-10-19

    I've found the demo's; they are for 8515
    AVR assembly (AVRstudio4)
    BASCOM (Basic)
    ICC (C)
    the disk includes all the software required;but the schematic is not the correct one!
    the demo's start at blinky LED's and go through button sense, UART, DS18S20 temperature sensor,and interrupts.

    this is a very good resource for the 8051 family; though very old.
    https://www.mikroe.com/ebooks/architecture-and-programming-of-8051-mcus

     
  • Anobium

    Anobium - 2026-10-19

    I have ordered new chips. But, I have download and build a simple ASM to HEX. This is all done outside of GCBASIC but I want to know I can assemble ASM and program a chip ( cannot do the last part as my chip here... it is a 32 bit!).

    Now waiting for delivery.

     

Log in to post a comment.