flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Command-Line Interpreter

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 21 Feb 2010, 21:42
I'd like to announce my idea of a command-line interpreter.
It would be similar to COMMAND.COM, but as a prototype it would have limited functionality.

The basic idea of the program would be, that it would be able to read data from its script (file).
It would read each line and execute the command on that line.

The problem I have with this idea is that, I don't know where, or how to start. I have a limited
knowledge of assembly. But I know enough to start this envision the project, and how I will create it.
I posted this topic to ask if anyone could assist in helping me with the project.


The basic algorithm would be something like:

    Scan File
    loop:
    Get Line
    Increment Stack
    If Line = Any Command then
    execute command
    else
    Highlight error
    jump to: loop


That is how is picture the operation of the interpreter. I'd like to someone to
assist me with the basics of the project.

_________________
meshnix
Post 21 Feb 2010, 21:42
View user's profile Send private message Reply with quote
roboman



Joined: 03 Dec 2006
Posts: 122
Location: USA
roboman 23 Feb 2010, 03:07
OpenDos / DR dos might be a good starting point to look at http://drdosprojects.de/

It's in asm open source and has a good batch processor (nearly the same as ms dos) Batch 'programs' are stored in a *.bat file. They were a left over thing from mainframes, where you would write a little script that would run a batch of programs over night or over the weekend. When desktops came around, IBM / Microsoft included the ability to run batch scripts and even expanded it a little. MS & DR dos will both run a batch file called autoex.bat when they start and a lot of programs for Dos were started with a bat file, to make sure the drivers and other things were setup right
Post 23 Feb 2010, 03:07
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 23 Feb 2010, 03:41
Thanks for the info. Very Happy

I checked out DR DOS and, but it's a bit complicated. I was thinking of designing my interpreter purely from assembly. Do you know any open sources like that where I can study the code.
Post 23 Feb 2010, 03:41
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 18 Mar 2010, 07:18
> OpenDos / DR dos might be a good starting point to look at http://drdosprojects.de/
> It's in asm open source and has a good batch processor (nearly the same as ms dos)

Only the kernel is in (not-F)ASM, command thing is in C Shocked

> I'd like to announce my idea of a command-line interpreter.

DOS or Win32 ???

> Do you know any open sources like that where I can study the code.

NO. All known are in C Sad
Post 18 Mar 2010, 07:18
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 18 Mar 2010, 11:55
Oh OK! Thanks!!
Post 18 Mar 2010, 11:55
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Mar 2010, 15:31
MeshNix,

MS-DOS command.com had strange but useful feature: it closed the batch file after the line was parsed (remembering the offset at which the next line will be, to reopen and read later), so current command can modify .Bat and enjoy the possibility of self-modifying batch. 4DOS shell simulated this behavior and have separate .BTM (Batch-to-memory) files for immutable contract. Wink
Post 18 Mar 2010, 15:31
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 18 Mar 2010, 15:52
That is similar to call, and ret, but instead, it closes and returns to the offset at which it was closed
Post 18 Mar 2010, 15:52
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Mar 2010, 16:56
MeshNix,

Yes, but .Bat file can be changed in transit. Hell to debug, but fun to see one.

Do you have specs for syntax/semantics of your batch lang?
Post 18 Mar 2010, 16:56
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 19 Mar 2010, 00:19
Yes- I've designed some syntax for some instructions!
I not sure what to do after this.
Post 19 Mar 2010, 00:19
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 19 Mar 2010, 04:02
MeshNix,

Now you need (at least) function to read one line from file. Wink

Can you present those design docs? To put it under scrutiny of some constructive critique.
Post 19 Mar 2010, 04:02
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 19 Mar 2010, 04:32
I have a draft document.
Post 19 Mar 2010, 04:32
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 19 Mar 2010, 23:39
Quote:
Now you need (at least) function to read one line from file.

What I was planning to do was to read the entire content of the file and store it into a variable, then parse each line until 0Dh (carriage return) is met, then that signifies the end of that line.
The problem is, what if the file contains more than 256 characters. Then it cannot store into the variable.
Post 19 Mar 2010, 23:39
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 19 Mar 2010, 23:53
And why should that "variable" be limited to 256 bytes? Why not allocate as much as you need and load the entire script?
Post 19 Mar 2010, 23:53
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 20 Mar 2010, 04:21
I don't understand
Post 20 Mar 2010, 04:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 20 Mar 2010, 04:33
Allocate a buffer of whatever size needed to store the entire file. No need to limit things to 256 bytes, is there?
Post 20 Mar 2010, 04:33
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 20 Mar 2010, 05:09
I guess not. Do i use rb instead of db?
Post 20 Mar 2010, 05:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 20 Mar 2010, 05:22
Probably best to allocate it dynamically. At runtime, get the file size first and then allocate the needed amount.
Post 20 Mar 2010, 05:22
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 20 Mar 2010, 09:35
MeshNix wrote:
I guess not. Do i use rb instead of db?


You reasonably won't use db for this buffer or any buffer at all Idea

Set some limit (maybe 4 KiB for the beginning), do GetFileSizeEx, check against your limit, reject if too bloated, if good hog the memory, and start processing, be aware of the CR vs LF vs CRLF mess, also don't forget to check for invlaid characters (ZERO) and handle them in a well defined way Idea
Post 20 Mar 2010, 09:35
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 20 Mar 2010, 15:33
CRLF it will be used for EOL.
In using DOS interrupts not Win32 APIs.
Post 20 Mar 2010, 15:33
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 23 Mar 2010, 20:23
I'm seeking advice for my project (codename: Quantum-lite)

(1) My CLI supports loop statements like FOR loop, and WHILE loop.
These loops are mutli-line loops
example:
Code:
.start
FOR A = 1 TO 5:
 {
   PRINT "Repetition was successive " %A " times"
 }
.ENDFOR
.end
    


PRINT writes text to screen.
%A is a variable in the shell.

In that script, how would the shell do a repeat when it only processes line-by-line.
Please give some advices.

(2) What type of commands would you like into be implemented in my shell?
Please provide:
- Command/Statement name
- Syntax
- Description


Last edited by adroit on 24 Mar 2010, 22:59; edited 3 times in total
Post 23 Mar 2010, 20:23
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.