Sponsored Content
Full Discussion: Thompson MSH(mini-shell)
Top Forums Shell Programming and Scripting Thompson MSH(mini-shell) Post 302952164 by GLbS on Friday 14th of August 2015 10:48:54 AM
Old 08-14-2015
Reference Thompson MSH(mini-shell)

Hi Guys!

Recently, I disassemble the MSH. And reconstructed. I thought maybe somebody wants to see looked like a second shell. In practice, the most ancient shell. It is written in assembler (AT&T). Owner Ken Thompson, Dennis Ritchie.

Code:
	mov	$parbuf,r1
	mov	$parp,r2
	clr	r3
	jsr	pc,blank
	cmp	r0,$'\n  /
	bne	1f
	sys	exit
1:
	mov	r1,(r2)+
2:
	movb	r0,(r1)+
	jsr	pc,getchar
	cmp	r0,$' / space
	beq	3f
	cmp	r0,$'\n  /
	beq	1f
	br	2b
3:
	clrb	(r1)+
	jsr	pc,blank
	cmp	r0,$'\n  /
	beq	1f
	br	1b
1:
	clr	(r2)+
	tst	r3
	bne	1f
	sys	exec; parbuf; parp /
	sys	exec; binpb; parp /
	br	2f
1:
	mov	$glob,parp
	sys	exec; glob; parp /
2:
	mov	$1,r0	
	sys	write; quest; 2. 
	sys	exit
quest:
	<? >
blank:
	jsr	pc,getchar
	cmp	r0,$' / space
	beq	blank
	rts	pc
getchar:
	clr	r0
	sys	read; chr; 1 / read char
	bcs	xit1
	tst	r0
	beq	xit1
	movb	chr,r0
	cmp	r0,$'? /
	beq	1f
	cmp	r0,$'* /
	beq	1f
	cmp	r0,$'[ /
	bne	2f
1:
	inc	r3
2:
	rts	pc
xit1:
	sys	exit

chr:	.=.+1
glob:
	</etc/glob\0> / globbing
binpb:
	</bin/>
parbuf:	.=.+1000.
parp:		.=.+200.     / real size unknown

Full description in Unix Programmer's Manual, First Edition.
Or here(see below): login(7) - Unix First Edition Manual Page

Last edited by GLbS; 08-14-2015 at 01:08 PM..
 

4 More Discussions You Might Find Interesting

1. Programming

Mini Shell in C

Hi Everyone, I am a student learning C and Unix. I want to create a shell in C which accepts command line arguments and executes them. I am not sure how to do this. Any help would be greatly appreciated. Thanks (5 Replies)
Discussion started by: passat
5 Replies

2. UNIX for Dummies Questions & Answers

mini shell programming (help)

Hi All, Well i m a taking an operating system course (newbie to unix) we have studied till now: the fork () execv() the teacher asked us to create a mini shell that execute a user command: cmd1 he said everything in is optional we can use any combination Well dudes , i m really... (2 Replies)
Discussion started by: ELECTRO
2 Replies

3. Shell Programming and Scripting

Need help in a mini project

Hi All, I want to make something like described below - "Double click on an executable file that will check the health status and other things of various linux servers and send an email to a list of people." I can make shell scripts for individual servers but how to make a script that will check... (1 Reply)
Discussion started by: csrohit
1 Replies

4. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies
ZDIFF(1)						      General Commands Manual							  ZDIFF(1)

NAME
zcmp, zdiff - compare compressed files SYNOPSIS
zcmp [ cmp_options ] file1 [ file2 ] zdiff [ diff_options ] file1 [ file2 ] DESCRIPTION
Zcmp and zdiff are used to invoke the cmp or the diff program on files compressed via gzip. All options specified are passed directly to cmp or diff. If only file1 is specified, it is compared to the uncompressed contents of file1.gz. If two files are specified, their con- tents (uncompressed if necessary) are fed to cmp or diff. The input files are not modified. The exit status from cmp or diff is pre- served. SEE ALSO
cmp(1), diff(1), zmore(1), zgrep(1), znew(1), zforce(1), gzip(1), gzexe(1) BUGS
Messages from the cmp or diff programs may refer to file names such as "-" instead of to the file names specified. ZDIFF(1)
All times are GMT -4. The time now is 03:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy