flat assembler
Message board for the users of flat assembler.

Index > OS Construction > I Have A Problem With Command Interpreter

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



Joined: 10 Jul 2004
Posts: 7
Location: Romania
Dexter 10 Jul 2004, 12:11
Look at the code
It's explained everything in the file


Description: you will need this file too
Download
Filename: MACROS.INC
Filesize: 1.33 KB
Downloaded: 808 Time(s)

Description: This is the command interpreter can be run from dos/dos-box or it can be booted from a disk, it's a simple .com file
Download
Filename: CI.ASM
Filesize: 1.91 KB
Downloaded: 843 Time(s)

Post 10 Jul 2004, 12:11
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 10 Jul 2004, 13:58
Here's a fixed version (I rewrote the CStr procedure and modified the keyboard procedure as well)

Code:
ORG 100H
USE16

include 'macros.inc'

push cs
pop ax
mov ds,ax
mov es,ax

mov ax,03h
int 10h

callp WriteStr,0,1,0,9,Intro
callp WriteStr,0,2,0,12,Prompt


Main:
     callp WriteKey,5,2,0,10,Command

     push $

     callp CStr,Command,SkipMe
     cmp ax,0
     jz .Skipme

     callp CStr,Command,Ver
     cmp ax,0
     jz .CVer

     callp CStr,Command,Exit
     cmp ax,0
     jz CExit

     pop cx
     callp CLine,5,2,0
     jmp Main

.CVer: call CVer        ; Functions need simple wrappers to work properly
       jmp Main         ; You can't just RET from a jump, so we jump, then call
.Skipme: jmp Main       ; Used to handle an error I haven't traced yet

proc CStr,a,b
        begin
        mov si, [a]
        mov di, [b]
        .a: mov ax, [si]
            cmp ax, [di]
            jnz .e
            cmp ax, 0
            jz .b
            inc si
            inc di
            jmp .a
        .b: xor ax, ax
        .e:
        endp

proc WriteKey,x,y,b,f,buff
     begin
        mov  cx,[x]
        mov  dx,126
        add  dx,cx
        mov  di,[buff]
        .aloop:
              mov  [di],byte 0
              xor  ax,ax
              int  16h
              cmp  al,13
              je   .e
              cmp  cx,dx
              je   .e
              mov  [di],al
              pusha
              callp WriteStr,cx,[y],[b],[f],di
              popa
              inc  cx
              inc  di
              jmp  .aloop
              .e:
     endp

proc Cls,c
     begin
        mov ax,0B800h
        mov es,ax
        xor di,di
        mov ah, byte [c]
        shl ah, 4
        or  ah, al
        mov cx,4000
        rep stosw
     endp

proc CLine,x,y,c
     begin
        mov   ax, [y]
        dec   ax
        mov   cx, 80
        mul   cx
        add   ax, [x]
        shl   ax, 1
        mov   di, ax
        mov ax,0B800h
        mov es,ax
        mov ah, byte [c]
        shl ah, 4
        or  ah, al
        mov   cx, 160
        rep   stosw
     endp

proc WriteStr,x,y,b,f,msg
     begin
        pusha
        mov ax,0B800h
        mov es,ax

        mov   ax, [y]
        dec   ax
        mov   cx, 80
        mul   cx
        add   ax, [x]
        shl   ax, 1
        mov   di, ax

        mov   si, [msg]

        mov   ah, byte [b]
        mov   al, byte [f]
        shl   ah, 4
        or    ah, al

        lodsb
      Continue:
        stosw
        lodsb
        or  al, 0
        jnz Continue
        popa
     endp

CVer:
     callp WriteStr,0,1,0,15,Ver
     ret
CCls:
      callp Cls,'a'
      ret
CExit:
      int 20h



Intro db 'Command interpreter',0
Prompt db 'xcmd>',0
Ver  db 'ver',0
Exit db 'exit',0
RAM  db 'ram',0
SkipMe db 'skipme',0

Command: times 128 db 0   
    
Post 10 Jul 2004, 13:58
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 10 Jul 2004, 14:01
Pesonally, I'd recommend scrapping the procedures and using normal routines + macros instead. Procs make the code more confusing than it actually needs to be IMO. Either way, good luck with this Smile
Post 10 Jul 2004, 14:01
View user's profile Send private message Visit poster's website Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 11 Jul 2004, 14:35
Great it's working Smile
We will see the first version very soon Cool
I will wait to see what Dexter says...

Question
Should i create a forum for this OS wannabe ?
( i can make a forum for this but it will not be even 60% up and running because of the internet connection Confused )
Or posting here is fine ?
Post 11 Jul 2004, 14:35
View user's profile Send private message Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 11 Jul 2004, 20:35
Here Is The Very First Working Version... Cool
Made By Dexter And Me Very Happy

crc can u replace the writestr procedure with your writestr macro ?
The macro is much better because we don't need 0 terminated strings
and we can pass the string directly Razz


Description: Here is the main file
Download
Filename: XBIOC.ASM
Filesize: 3.25 KB
Downloaded: 811 Time(s)

Description: Here is the file that you need...
Download
Filename: MACROS.INC
Filesize: 1.26 KB
Downloaded: 812 Time(s)

Post 11 Jul 2004, 20:35
View user's profile Send private message Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 12 Jul 2004, 05:03
This is the 3rd post and still no response....
Oh well here is the second release of XBIOC
There is a new WriteStr procedure wich allows multiple attributes in a string and i added the blink feature too ( just add blink to the foreground color, you can view the full efect with the 'ver' command )
Type 'help' For A List Of Commands...
Have Fun With This... And Tell Me What You Think... Cool

Ahhh....almost forgot, crc can u make a proc that converts a hex/integer value to string ?


Description: Here is the new version
Download
Filename: XBIOC2.ASM
Filesize: 4.72 KB
Downloaded: 808 Time(s)

Description: Here is that boring file macros blah,blah
Download
Filename: MACROS.INC
Filesize: 1.26 KB
Downloaded: 804 Time(s)



Last edited by Gambino on 12 Jul 2004, 05:20; edited 1 time in total
Post 12 Jul 2004, 05:03
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 12 Jul 2004, 05:14
I'm working on both things you asked for, just be patient -- I have a lot to do today Sad
Post 12 Jul 2004, 05:14
View user's profile Send private message Visit poster's website Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 12 Jul 2004, 06:58
OK Very Happy
Did u like the new version Question
Encourage us to work more, tell us nice things about XBIOC Laughing
Waiting for reply..... Cool
Post 12 Jul 2004, 06:58
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 12 Jul 2004, 13:26
This is good stuff !
Write a bootsector as loader for your command-liner and the OS can start kicking Smile

btw. This is going to work with STDIN, STDOUT, STDERR?

btw2. There is a version without szStrings?
Post 12 Jul 2004, 13:26
View user's profile Send private message Yahoo Messenger Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 12 Jul 2004, 16:49
Nice work, have you seen this program?, its called "bootprog" it loads a com or exe from a floppy disk, just put your prog on a floppy and restart your pc and it will boot it. you can not use dos int as there is no dos, but you can use bios int.
I us it for my os testing and its the best prog i,v found.
You can get it from here: http://alexfru.chat.ru/epm.html
Its called "bootprog.zip" , just read the readme file and have fun

ASHLEY4.
Post 12 Jul 2004, 16:49
View user's profile Send private message Reply with quote
Gomer73



Joined: 29 Nov 2003
Posts: 151
Gomer73 12 Jul 2004, 17:11
For printing out hex, you can use my routines in my vesa info prog(cv.asm) found on this forum.

print_dec.end_numb is where everything gets printed(including hex). print_hex prints a word, print_hex_big prints a dword. It prints it without lead zero, so 1 would be printed as 1 and not 00000001.

Thanks to Bogdan for giving the hex convertor without using jmps, I modified it a bit to save an instruction or two.

Here is the code though:


print_dec_nc:
push word 0
mov cx,1000
jmp print_dec.loop
print_dec:
push word 0
.zero_loop:
mov cx,3
.loop:
xor dx,dx
mov bx,10
div bx
or dl,30h
push dx
or ax,ax
jz .end_numb
loop .loop
push word ','
jmp .zero_loop
.end_numb:
pop dx
or dx,dx
jz .end
mov ah,2
int 21h
jmp .end_numb
.end:
ret

print_hex:
push ax
xor eax,eax
pop ax
print_hex_big:
push word 0
.loop:
push eax
and al,0fh
cmp al,10
cmc
adc al,30h
daa
mov bl,al
pop eax
push bx
shr eax,4
or eax,eax
jz print_dec.end_numb
jmp .loop
Post 12 Jul 2004, 17:11
View user's profile Send private message Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 13 Jul 2004, 14:18
Now me and Dexter we are working on a 'dir' command Very Happy
So posting will delay a bit until we finish that...
Also making the os wannabe to boot from floppy Cool

Gomer73 , i can't use that ! this is an os wannabe Smile , we don't have int 21h (int 21h works only in DOS), i will modify how the routine prints.

Quote:
btw. This is going to work with STDIN, STDOUT, STDERR?

btw2. There is a version without szStrings?


pelaillo i will let Dexter answer those two...
( i don't know what STDIN,STDOUT,STDERR stands for... Silly Me Confused )
( szStrings ?!? hmmm... explain better i'm from Romania Razz )
btw Nice screenshot Shocked
Post 13 Jul 2004, 14:18
View user's profile Send private message Reply with quote
Dexter



Joined: 10 Jul 2004
Posts: 7
Location: Romania
Dexter 13 Jul 2004, 19:24
if szStrings means zero terminated string
I ask you, what is the problem why do you whant to change it ?
do you whant to calculate the size your self as for
This is going to work with STDIN, STDOUT, STDERR?
I don't understand explain better
I am glad you liked our "console"
Post 13 Jul 2004, 19:24
View user's profile Send private message Reply with quote
Gomer73



Joined: 29 Nov 2003
Posts: 151
Gomer73 14 Jul 2004, 16:27
STDIN, STDOUT, STDERR stand for standard in, out, and error.
These are basically file handle type things.
stdin usually comes from the keyboard, but you can "pipe" it from another file.
stdout typically goes to the screen, but you can also "pipe" it to a file or the input of another file.
same thing with stderr, handy if you only want the errors going to a log file.

For my program it uses stdout, which is why I used the int 21 rather than the int 10.

Unless you use the dos stuff, this would require significant programming, because you would need to create your own stream architecture.
Post 14 Jul 2004, 16:27
View user's profile Send private message Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 18 Jul 2004, 14:32
Sorry for not posting for so long, but we was bussy with exams...
In a few days we will continue to work on XBIOC...
Btw we did make XBIOC boot from floppy ( That was a piece of cake Razz )

Any idea how to find out how much RAM has a computer ?

( Found some ints but they are old and only report 64MB max so they are no good.... )
Post 18 Jul 2004, 14:32
View user's profile Send private message Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 24 Jul 2004, 20:54
I see that everybody lost interest on this one....
Nobody is posting anymore...
Post 24 Jul 2004, 20:54
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 24 Jul 2004, 22:48
Just because no one is posting doesn't mean there is no interest. For me, I'm pretty busy with work (retail; we're starting to approach the holiday season) and am finishing up RetroForth 7.0; I'll continue to do some hacking on XBIOC in early August Smile
Post 24 Jul 2004, 22:48
View user's profile Send private message Visit poster's website Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 26 Jul 2004, 07:09
OK Very Happy Nice to hear that !!!

Some good news... did that 'how much ram a computer has' thingie Razz

( 2 routines wich do the same thing... u will understand better when i will upload the latest release )

Also added 3 new (crappy, but useful) commands:

Ram - Finally Made This... Displays Total Memory
Reboot - Restarts The Computer (doh!)
Shutdown - Turns Off Computer ( APM Power Off Command )

And 2 routines :

Hex2Str converts hex value in str like : Input
mov eax,1234FACEh (can be a var)
Hex2Str,eax,string
Output
string db '1234FACEh',0
Dec2Str converts decimal value in str : idem

Stay tuned for the new release....
Coming Soon Cool
Post 26 Jul 2004, 07:09
View user's profile Send private message Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 26 Jul 2004, 14:33
This is code for v2os command.com for pmode, int 20h is the int's for v2os like dos's int 21h.
Code:
[BITS 32]               ;Set code generation to 32 bit mode[ORG 0x0100]            ;Set code start address to 0100h[SEGMENT .text]         ;Main code segmentmain:mov ah, 46call clear_screencall welcome_msgjmp disp_promptwelcome_msg:mov al, 4mov edi, welcome_strint 0x20retdisp_prompt:mov al, 4mov edi, prompt_strint 0x20user_input:mov al, 40mov edi, input_strint 0x20call upper_casetest_input:;Begin test for directory commandmov esi, dir_test_strmov edi, input_strmov al, 30int 0x20test al, aljz dir_command;Begin test for reboot commandmov esi, reboot_strmov edi, input_strmov al, 30int 0x20test al, aljz reboot_command;Begin test for exit commandmov esi, exit_strmov edi, input_strmov al, 30int 0x20test al, aljz exit;Begin test for cls commandmov esi, cls_strmov edi, input_strmov al, 30int 0x20test al, aljz cls_command;Begin test for help commandmov esi, help_strmov edi, input_strmov al, 30int 0x20test al, aljz help_commandexecute_input:mov al, 4mov edi, temp_msgint 0x20jmp disp_promptreboot_command:mov al, 13int 0x20help_command:mov al, 4mov edi, help_msgint 0x20jmp disp_promptcls_command:mov ah, 46call clear_screenjmp disp_promptdir_command:mov al, 25mov edi, dirint 0x20jmp disp_promptupper_case:mov esi, input_strmov al, 31int 0x20retclear_screen:mov al, 4mov edi, blankint 0x20dec ahjnz clear_screenretexit:retf[SEGMENT .data]         ;Initialised data segmentprompt_str:   db 'A:\>',0temp_msg:     db 'Bad command or file name',13,10,0dir:          db 'files',0dir_test_str: db 'DIR',0exit_str:     db 'EXIT',0reboot_str:   db 'REBOOT',0cls_str:      db 'CLS',0help_str:     db 'HELP',0input_str:    times 256 db 0blank:        db ' ',13,10,0;temp_buff:    times 255 db 0welcome_str:  db 13,10,'ÛßßßßßßßßßßßßßßßßßßßßÛ',13,10              db 'Û Welcome to V2-DOS. Û',13,10              db 'Û                    Û',13,10              db 'Û        by:         Û',13,10              db 'Û      Stalin        Û',13,10              db 'ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ',13,10,13,10,0help_msg:     db 13,10,'ÛßßßßßßßßßßßßßßßßßßßßßßÛ',13,10              db 'Û dir: list files      Û',13,10              db 'Û cls: clear screen    Û',13,10              db 'Û exit: exit shell     Û',13,10              db 'Û reboot: quick reboot Û',13,10              db 'ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ',13,10,13,10,0    


ASHLEY4.
Post 26 Jul 2004, 14:33
View user's profile Send private message Reply with quote
Gambino



Joined: 20 Jul 2003
Posts: 44
Location: Romania
Gambino 26 Jul 2004, 18:16
ASHLEY4

You posted on the wrong topic or i don't get it... Very Happy
What is this that code for Question Exclamation Question ...
It's a command interpreter like ours, but why did u post that code ?
I don't see nothing helpful in that code and all those commands except 'dir' where already implemented in the version that will be released in a few days...

P.S. Where is the source of the int20 ?
Post 26 Jul 2004, 18:16
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.