Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #2603
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Benoit0123 <bgilon@free.fr> |
| Newsgroups | comp.sys.apple2.programmer |
| Subject | Re: Unix V6 : Sample C to 65c02 translation from 'sh' |
| Date | Tue, 29 Mar 2016 12:56:56 -0000 (UTC) |
| Organization | Mac GUI |
| Lines | 68 |
| Message-ID | <benoit0123-1459256408@macgui.com> (permalink) |
| References | <b93a0604-1d2d-4b82-8300-45854e06ec9e@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Tue, 29 Mar 2016 12:56:56 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="ac9e0e4d7dd3957fb97803ee6801bab8"; logging-data="28545"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PqUZcMRFfu+ruCaw9SZoi" |
| User-Agent | Mac GUI Usenet |
| In-Reply-To | <b93a0604-1d2d-4b82-8300-45854e06ec9e@googlegroups.com> |
| Cancel-Lock | sha1:Tct8JLCIWCy71ChZEBajVCdHb+k= |
| Xref | csiph.com comp.sys.apple2.programmer:2603 |
Show key headers only | View raw
wssimms wrote: > I've started working on translating the Unix V6 sh to 65c02 assembler. > This shell is called the Thompson shell because it was written by Ken > Thompson. It is less sophisticated than the Bourne Shell that was > included in 7th Edition Unix, but it's actually more complicated than > I thought because the last time I looked at shell source (about 9 months > ago), I was looking at the 1st Edition Unix shell. > > The 6th Edition shell is written in C and includes a recursive descent > parser for the (very simple) command language it accepts. Here is one > of the parse functions. There is an array of pointers to char called > args[] that contains the tokens of the input line. The pointers p1 & p2 > being passed into syn1, are pointers to the first and last+1 elements > of args[] that are to be parsed by this function (i.e, they delimit a > subrange of the tokenized input line) > > The purpose of this function is to find expression delimiters in the > input line and build a list of parse subtrees of the expressions between > the delimiters. The result is a pointer to a tree node consisting of > four words: a type, flags, a pointer to a left subtree, and a pointer to > a right subtree. The chain of right-subtree links represents the list > of delimited expresssions. > > The possible delimiters are ';', which results in sequential execution > of the subexpressions, and '&', which results in background execution > of the preceding subexpression. This should be pretty familiar to most > people. Here's the C code from 6th Edition Unix > (snip) a) Should the code extract below 2: inx inx // advance to next arg bra 9b 1: cmp #'&' beq 2f cmp #';' beq 2f cmp #'\n' bne 2b // if not '&' ';' '\n' advance to next arg 2: lda parcnt // if nesting depth is nonzero bne 2b // advance to next arg read 2: inx inx // advance to next arg bra 9b 1: cmp #'&' beq 1f cmp #';' beq 1f cmp #'\n' bne 2b // if not '&' ';' '\n' advance to next arg 1: lda parcnt // if nesting depth is nonzero bne 2b // advance to next arg instead? otherwise there might be an infinite loop within the current process? b) Your code seems to use self modifying tricks (bytes at addresse 9:+1 and 8:+1), beware if an interrupt occured after those addressed are updated but before they are accessed again within the code. But I might be wrong if your code is considered private and stored into a dedicated (i.e. not shared) segment to the current process. -- Growing old is mandatory.. growing up is optional.. But the other way round is as true.
Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unix V6 : Sample C to 65c02 translation from 'sh' wssimms@gmail.com - 2016-03-28 21:32 -0700
Re: Unix V6 : Sample C to 65c02 translation from 'sh' Benoit0123 <bgilon@free.fr> - 2016-03-29 12:56 +0000
Re: Unix V6 : Sample C to 65c02 translation from 'sh' wssimms@gmail.com - 2016-03-29 06:56 -0700
csiph-web