flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Command-Line Interpreter

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 26 Mar 2010, 22:26
why FOR i = 1 TO 5
you have to process too many variables.
What do you think about the following notation?

REP 6 {
... <commands>
}

repeat 6 times commands in { } brackets.

i use the same REP N CMD command, but it works as single-line prefix for me (just don't need to repeat block of commands).
Post 26 Mar 2010, 22:26
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 27 Mar 2010, 05:17
I used this because, the variable %i would have the steps successive in the structure. So if the it has completed from 1 TO 4, then %i would have the integer value 4.

Quote:
you have to process too many variables.
What do you think about the following notation?

REP 6 {
... <commands>
}

repeat 6 times commands in { } brackets

It could work. I think it's a good idea. I'm just seeking some advice, so you can throw out as much "notations" as you can, whether good or bad, or unsightly.
Post 27 Mar 2010, 05:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 27 Mar 2010, 05:28
MeshNix: It is all about personal taste. If you want to do something then go ahead and do it. But if you keep asking others what they like, then you won't get anywhere. I suspect you are trying to go too deep all at once. Do you have the base done yet? Get the basics running first. Set up a framework to expand into as the project progresses. Start slowly and build it up, fixing bugs along the way.

Are you writing this as a personal challenge, or do you have an actual need? The existing command shells in Windows and *nix are already quite comprehensive. Perhaps they already do what you need? Or maybe you just need to write a small utility proggy to add a function or two that might be missing?
Post 27 Mar 2010, 05:28
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 27 Mar 2010, 05:36
I used this because, the variable %i would have the steps successive in the structure. So if the it has completed from 1 TO 4, then %i would have the integer value 4.

Quote:
you have to process too many variables.
What do you think about the following notation?

REP 6 {
... <commands>
}

repeat 6 times commands in { } brackets

It could work. I think it's a good idea. I'm just seeking some advice, so you can throw out as much "notations" as you can, whether good or bad, or unsightly.
Post 27 Mar 2010, 05:36
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 27 Mar 2010, 06:05
Yea revolution, you got it right. It's a challenge for myself.
I have an (incomplete) technical document prepared with the basics, such as commands, datatypes used, syntax, functions, symbols, etc.
I have just finish writing the one. It just supports basic I/O and coloured text. It was kinda of difficult, even though I copied it from a reference source code. i did this to understand each command and what they do. So know i have the full grip of writing it completely by myself without any help (I think:)).
Post 27 Mar 2010, 06:05
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 27 Mar 2010, 23:05
I've fixed a few bugs as well!
Post 27 Mar 2010, 23:05
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 28 Mar 2010, 18:11
Here is the frame of the shell.
There are few annoying bugs still in the code.

Please feel free to criticize, comment, etc ...


Description: Shell supporting stdin & stdout
Download
Filename: Shell.zip
Filesize: 7.11 KB
Downloaded: 857 Time(s)

Post 28 Mar 2010, 18:11
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 28 Mar 2010, 20:53
Took a quick look at your shell...
Why do you use 15 SetTextColor routines instead of passing text color in AL to a single one? Smile
Code:
mov al, COLORTEXT_BRIGHT_YELLOW
call SetTextColor
...
SetTextColor:
   mov byte[color], al
   ret
    

... and why using call to write single byte of memory? Just write that byte and that's it! No need in creating a procedure, i think

one more thing is that since you decided to use INT 10h to advance cursor position, then i think there's no need to GetCursorPos/SetCursorPos every time. You can get cursor position once. Later, when you need to move cursor, you change only values of cursor_row and cursor_col variables, and issue SetCursorPosition command. No need to call GetCursorPosition every time.

by the way, that Esc, which clears command line is nice. I'll add a shortcut to clear command line in my code, too Smile

ah, and you should definitely process Arrow keys Wink
Post 28 Mar 2010, 20:53
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 29 Mar 2010, 04:41
zhak wrote:

Why do you use 15 SetTextColor routines instead of passing text color in AL to a single one? Smile
Code:
mov al, COLORTEXT_BRIGHT_YELLOW
call SetTextColor
...
SetTextColor:
   mov byte[color], al
   ret
    

... and why using call to write single byte of memory? Just write that byte and that's it! No need in creating a procedure, i think
I was just trying to set the routines. I have enhanced the code to reduce the use of so many routines.

zhak wrote:

by the way, that Esc, which clears command line is nice. I'll add a shortcut to clear command line in my code, too Smile

ah, and you should definitely process Arrow keys Wink

Using arrow keys are kind of difficult.

_________________
meshnix
Post 29 Mar 2010, 04:41
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 29 Mar 2010, 13:24
to fix bugs with Enter key press (incorrect positioning of new line) you can do the following:
1. if current cursor position is unknown, then get current cursor position (cursor_row, cursor_col variables).
2. if cursor_row < 24 then cursor_row := cursor_row + 1 else scroll screen up
3. cursor_col := 0
4. set current cursor position
5. display prompt ($)
Post 29 Mar 2010, 13:24
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 31 Mar 2010, 14:47
Implementing the algorithm was unsuccessful. Remember I have a horizontal bar at row 24. The algorithm doesn't consider it, but I've figured a way how to.
Post 31 Mar 2010, 14:47
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 31 Mar 2010, 17:21
command line interpret is not a command line editor.

but it needs effectivelly a way to edt the command

good that you try to code by yourself Smile, but if you use less BIOS ints, you will have a better code, because:
1/ BIOS ints are very limited
2/ BIOS ints are not PM compatible.

then, i propose to you just a little set of includes to interpret commands.

enjoy, all the syntax of a command line reside in the interpret.

and is like that:

path/path/command param,param,param,param

to create commands, you should edit:

'comnames.inc'
contain the names of available commands

'comfunc.inc'
contain the functions of available commands

'comtable.inc'
contain references to availables commands functions and names.

and include 'comtable.inc' in you code, that's all.


Description:
Download
Filename: Commands.zip
Filesize: 2.19 KB
Downloaded: 865 Time(s)

Post 31 Mar 2010, 17:21
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 02 Apr 2010, 02:05
Thanks for the helpful advice, and the attachment.

I didn't fully code it by myself. I used the framework of bitshifter. To me it was very substantial.

Edit:
Post 02 Apr 2010, 02:05
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.