The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Sebastien F4GRX <f4grx@f4grx.net>
To: tuhs@tuhs.org
Subject: [TUHS] Re: Software written in B
Date: Thu, 15 Jun 2023 10:00:43 +0200	[thread overview]
Message-ID: <a9ff39c1-5e86-c0a9-2391-802658cf79a0@f4grx.net> (raw)
In-Reply-To: <ZIodB1CeqLW4M8wn@indra.papnet.eu>

Hello,

That is really interesting, thank you for providing that.

I see that su.b contains non-ascii characters ($11,$12,$13,$14) which 
tripped my linux console when I attempted a copy paste, since $13 is 
XOFF :) Is there a way to escape these characters? Or update them, since 
it looks like a password provided on command line.

In its current state my compiler managed to eat all these sources except 
goto which segfaults for a reason I have not determined yet.


May I have your authorization for copying these files into my own b 
compiler repository ( https://git.sr.ht/~f4grx/bpars )? What licence and 
attribution info shall I indicate?

Sebastien


PS: here is the 68hc11 assembly that the current version of my B 
compiler generates for echo.b. Code is still not functional, parameters 
and locals are not allocated, but instructions are consistent.

this mcu is similar to 6502 and other cpus in the motorola 6800 line: 
two 8-bit accumulators A,B combinable into D, and two 16-bit index reg X 
and Y (Y is not used), 16-bit SP.

/*---------------------------------------------------------------------------*/
         .text
         .global main
         .func   main
main:
#function has no args
#local var i size 2 stack offset 0 TODO
#total stack frame size for compound: 2
         LDD     #1
         STD     i        /*Direct assign - local*/
.Lwhile_1:
/*binop, both complex*/
/*generate RHS in D, then move in temp*/
in gen_index: computing base expression (as lvalue)
in gen_index: lvalue=1
         LDX     #argv /*lvalue-extern*/
in gen_index: computing base expression done
         LDD     0,X
         PSHB
         PSHA
/*generate LHS in D*/
         LDX     #i /*lvalue-local*/
         LDD     0,X     /*Get value in X for easy 16-bit op*/
         XGDX    /*Now value is in X and address in D*/
         INX     /*Do the preinc*/
         XGDX    /*Now updated value is in D and address in X*/
         STD     0,X     /*Save the new value, next code can use it*/
/*execute*/
         PULX    /*--- Recall complex B computed before */
         STX     TEMP    /*---put in temp for binop*/
         CPD     TEMP
         BGT     .Lcond2
#start emit arglist for call
         .section .rodata
.strconst_3:
         .asciz "%s "
         .text
         LDD     #.strconst_3
         PSHB    /*argoff=0*/
         PSHA
in gen_index: computing base expression (as lvalue)
in gen_index: lvalue=1
         LDX     #argv /*lvalue-extern*/
in gen_index: computing base expression done
         LDD     i /*local*/
         LSLD
         STX     TEMP
         ADDD    TEMP
         XGDX
         LDD     0,X
         PSHB    /*argoff=2*/
         PSHA
#end emit arglist, size=4
         JSR     printf  /*undef*/
         PULX
         PULX
/*end of loop, eval condition again*/
         BRA     .Lwhile_1
.Lcond_2:
#start emit arglist for call
         LDD     #10
         PSHB    /*argoff=0*/
         PSHA
#end emit arglist, size=2
         JSR     putchar /*undef*/
         PULX
.Lstmtend_0: /*TODO avoid generating this if the statement does not 
contain breaks (no need for recursion)*/
.Lmain__rts: /* TODO avoid this label if statement contains no return */
         RTS
         .endfunc        # main


Le 14/06/2023 à 22:03, Angelo Papenhoff a écrit :
> After writing this mail I actually started reversing the B binaries.
> You can find them here: http://squoze.net/B/programs/
>
> I did find some differences in versions of the B runtime and library.
> Especially interesting was an implementation of the cksto routine
> in su and stty that checks whether an address in an assignment is in a
> reasonable range ("LV out of range" error if not)
>
> What is perhaps interesting historically is that the su binary contains
> a hardcoded password ^Q^R^S^T, which is not printable for a good reason:
> it is given as a command line argument.
>
> I will hopefully continue with this in the next time (if, goto, mail and
> glob are left).
>
> Best,
> aap
>
> On 14/06/23, Angelo Papenhoff wrote:
>> Thank you two for finding this!
>> I did some disassembling yesterday and have uploaded brt1.s and brt2.s
>> to my site now: http://squoze.net/B/brt/ (I haven't actually assembled
>> them yet, there may be mistakes)
>>
>> Some observations:
>>
>> - The 'chain' format is actually a linked list and not a list of
>> addresses. Phil and I both got this wrong.
>>
>> - The "Init" string is an error message if for some reason the B init
>> chain didn't run or main doesn't look like a function
>>
>> - The cmdline arguments overwrite part of the init code. There's about
>> 80 bytes of space for them before it overwrites the code that builds the
>> argv vector
>>
>> - brt2.s is only to mark the beginning of the stack
>>
>>
>> I also saw some differences in the bilib code but haven't really
>> analyzed that part (yet?)
>>
>> Would be really great if we could get all the files disassembled and
>> decompiled and restore the source code for everything :)
>>
>> Best,
>> Angelo

  parent reply	other threads:[~2023-06-15  8:01 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 10:14 [TUHS] " Sebastien F4GRX
2023-06-07 10:38 ` [TUHS] " Lars Brinkhoff
2023-06-07 15:05 ` Angelo Papenhoff
2023-06-07 15:57 ` Clem Cole
2023-06-07 16:21   ` Lars Brinkhoff
2023-06-07 17:26 ` Bakul Shah
2023-06-07 18:16 ` Phil Budne
2023-06-07 23:49 ` Andrew Hume
2023-06-08  2:10   ` segaloco via TUHS
2023-06-08  3:31     ` Phil Budne
2023-06-08 15:05       ` segaloco via TUHS
2023-06-14 11:51         ` Angelo Papenhoff
2023-06-14 20:03           ` Angelo Papenhoff
2023-06-14 21:53             ` segaloco via TUHS
2023-06-14 22:05               ` Angelo Papenhoff
2023-06-15  8:00             ` Sebastien F4GRX [this message]
2023-06-15  8:21               ` Angelo Papenhoff
2023-06-15  8:33                 ` Sebastien F4GRX
2023-06-17  8:19             ` Angelo Papenhoff
2023-06-19  9:52               ` Sebastien F4GRX
2023-06-19 10:18                 ` Sebastien F4GRX
2023-06-19 10:48                   ` Lars Brinkhoff
2023-06-19 10:55                     ` G. Branden Robinson
2023-06-19 11:07                       ` Sebastien F4GRX
2023-06-19 18:44                         ` segaloco via TUHS
2023-06-23 10:59               ` Angelo Papenhoff
2023-06-23 13:32                 ` Sebastien F4GRX
2023-06-23 14:01                   ` Angelo Papenhoff
2023-06-23 14:14                     ` Sebastien F4GRX
2023-06-23 14:39                       ` Angelo Papenhoff
2023-06-23 14:10                 ` Sebastien F4GRX
2023-06-23 14:49                   ` Angelo Papenhoff
2023-06-23 15:31                     ` Sebastien F4GRX
2023-06-23 15:36                       ` Angelo Papenhoff
2023-06-23 15:53                         ` Sebastien F4GRX
2023-06-08 14:41   ` arnold
2023-06-09  8:56 ` Sebastien F4GRX
2023-06-09  9:57   ` Lars Brinkhoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9ff39c1-5e86-c0a9-2391-802658cf79a0@f4grx.net \
    --to=f4grx@f4grx.net \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).