flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Thank you,question

Author
Thread Post new topic Reply to topic
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 21 Dec 2008, 05:51
if this is off topic, delete it if you need, but i would like to thank the flat assembler forum for helping me with quickly answering all of my questions, thanks to all of you, im am nearly done with my real mode operating system. now all of the future questions (after done) will have better meaning and worthy for a better non time wasting response (non time wasting for the answerer). corny ok, but i just felt i needed to give you all gratitude you deserved. to tell you the truth, i get better responses here than osdev.

btw, could someone pm me a way of how to get the backspace button to do what i want it to do, i have the if functions just one line and a block for it to go to for ex:

i hit back space it deletes one character could some one give me the code function for it?

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.


Last edited by GhostXoPCorp on 22 Dec 2008, 04:29; edited 1 time in total
Post 21 Dec 2008, 05:51
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 21 Dec 2008, 11:04
Start coding and post your code in case it doesn't work. Such functions are really straightforward. You have to:
1. make sure your buffer contains at least 1 character (and do nothing if it's empty)
2. decrease that buffer's character counter
3. remove the current character from that buffer
4. move your VGA cursor (hint: int 0x10, fct 2) 1 character to the left (or 1 line up if the cursor is already at column 0)
5. remove the current character from display by writing a space (hint: int 0x10, fct 9)
Post 21 Dec 2008, 11:04
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 21 Dec 2008, 19:17
Here it is



org 100h
use16
jmp krnlstrt

;;;;;;;;;;;;;;;;;;;
;;Kernel Strings ;;
;;VolTroX OS 1.1 ;;
;;;;;;;;;;;;;;;;;;;
prmptcmd db 'CONSOLE:|',0

ver: db 'Version 1.01 VolTroX Kernel' ,0
db 'GhostXoP Corperation 2008 2009',0
help: db 'help shows help' ,0
db 'ver shows version' ,0
unknowncmd db 'Unknown Command',0


;;;Non Printable Strings;;;;
vercmd db "ver"
helpcmd db "help"
vx db 1
nline db 10,13,0




buffer:
times 128 db 0


;;End Defined Strings;;
;;;;;;;;;;;;;;;;;;;
;;KernelFunctions;;
;;VolTroX OS 1.1 ;;
;;;;;;;;;;;;;;;;;;;
nextline:
mov si, nline
call print
ret

cursmgr:
call readycursor
mov ah, 02h
mov dl, 1 ;Left Or Right
mov dh, bh ;Going Up Or Down
int 10h
call add1x
ret


add1x:
add bh,1
ret

print:

push ax
mov ah, 0x0E

@@:
lodsb
cmp al, 0x00
je @f
int 0x10
jmp @r

@@:
pop ax
ret
;si = word to print
readycursor:
mov ah, 02h
mov dl, 1 ;Left Or Right
mov dh, bh ;Going Up Or Down
int 10h
ret

halt:
cli
hlt
ret
;;prompt;;
readyprmpt:

mov bx, buffer
cliprmpt:
call nextline
mov ah,ah
mov si, prmptcmd
call print

getcmd:



mov ah, 0x00
int 0x16 ; Interrupt 0x16, AH = 0x00 -> GET KEYSTROKE

mov ah, 0x0E ;
int 0x10 ; Interrupt 0x10, AH = 0x0E -> Teletype output
cmp al, 8
je bspace

cmp al, 0x0D ; Did the user press enter?
je en ; Then check the string

mov [bx], al ; Save it into the buffer
inc bx ; Make bx point to the next byte in the buffer
jmp getcmd ; Loop it over again
en:
;if help

mov cx, 4 ; Move 5 into cx, because there is 5 letters in "hello"
mov si, buffer ; We will check the buffer against "hello"
mov di, helpcmd ; ^
repe cmpsb ; cmpsb will compare the byte at es:di from the byte at ds:si. repe will do this cx times and increase

di and si each time
call nextline
je printhelp ; If it is equal then jump ahead and do something if it is hello
jmp chkbuf4ver ; And if it is not, then do so
chkbuf4ver:
mov cx, 3
mov si, buffer
mov di, vercmd
repe cmpsb
call nextline
je printver
call nextline
mov si,unknowncmd
call print
jmp cliprmpt

;included from Minidos Created By Dex And used for educational
;purposes

bspace:
cmp di,buffer ; Compear pointer to start of buffer
jbe getcmd ; Jump bellow or = to label getkey
dec di ; Go back in buffer
mov al,8 ; Move cursor back
mov ah,0Eh ; Request display
mov bx,0x0001
int 10h ; Call interrupt service
mov al,32 ; Print a space
mov ah,0Eh ; Request display
mov bx,0x0001
int 10h ; Call interrupt service
mov al,8 ; Move cursor back again
mov ah,0Eh ; Request display
mov bx,0x0001
int 10h ; Call interrupt service
jmp getcmd ; Get another key


printhelp:
mov si, help
call print
jmp cliprmpt


printver:
mov si,ver
call print
jmp cliprmpt


;;End Defined Functions;;

krnlstrt:
call readyprmpt
call halt


;another problem is the user can only do one command and then the system stops responding
;even if the system jumps back to the top

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 21 Dec 2008, 19:17
View user's profile Send private message Reply with quote
Scorpio



Joined: 11 Jan 2006
Posts: 5
Scorpio 21 Dec 2008, 20:01
Hi,

I agree with ManOfSteel, you should start coding yourself. From what I see your code is mainly a copy-paste of other peoples code. Do you really understand what all the code does?

GhostXoPCorp wrote:
to tell you the truth, i get better responses here than osdev.

Well people are generally busy with their own hobby operating systems, but they still manage to point you to links with a lot of helpful resources. It just seems like you want to have everything served to you instead of reading and trying on your own.
Also, I guess my response was good enough for you, because I see you are still using my code(yeah my name is Blue there):
http://forum.osdev.org/viewtopic.php?f=1&t=18396

I suggest you to sit down, rewrite your code, and make sure you understand everything you do(dont just copy paste). Of course I could be wrong and you understand all the code, but why do you ask for code for such a simple task? The five points ManOfSteel wrote should be enough to point you in the correct direction.

By the way, if any moderators feel that this is harsh or anything like that, then feel free to delete this post. I just wanted to point out that he should start coding himself, instead of making a Frankenstein out of other peoples code.

Blue/Scorpio
Post 21 Dec 2008, 20:01
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 21 Dec 2008, 20:25
i asked for an answer not a comment on why i should or shouldnt. the backspace code, i understand it, but dex deserves he credit. now, answer the question, i did take the time, i read examples and interpreted into my code, do you think this is the real os i want to build? this is just to educate my self on how it works, i can not learn anything if i learn backspace the wrong way, dont worry this is just a beta, thats why you see things in there that are not needed, just tests to help better understand. but please answer my question, i do not think you post is harsh, you just trying to point something out. i justforgot to tell you that this is to just better prepare my self for the one im wanting to make
Post 21 Dec 2008, 20:25
View user's profile Send private message Reply with quote
Scorpio



Joined: 11 Jan 2006
Posts: 5
Scorpio 21 Dec 2008, 20:50
Hi,

At the moment, I do not see the problem with your code. The code you have from Dex is well commented and explains perfectly what needs to be done in order to delete a character from both the screen and the buffer. The only thing you need to be aware of is that he uses DI for pointing to the buffer, where you use BX. You could fix this with:

Code:
bspace:
mov di, bx ; ---Move the bx-pointer to di---
cmp di,buffer ; Compear pointer to start of buffer

...

int 10h ; Call interrupt service
mov bx, di ; --- Move the new di pointer to bx ---
jmp getcmd ; Get another key 
    


It is a kinda hackish way of fixing it, but that was also why i suggested you to rewrite your code, because you could easily come up with a smarter solution.

Blue/Scorpio
Post 21 Dec 2008, 20:50
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 21 Dec 2008, 21:10
Quote:

;another problem is the user can only do one command and then the system stops responding
;even if the system jumps back to the top

You're not resetting to the shell's defaults after each command, so bx points to the wrong place and your buffer still contains the last command. See "endprmpt", below.


Code:
call halt
    

What's this for?


Code:
readyprmpt: 

mov bx, buffer 
cliprmpt: 
call nextline
    

Why waste a line when nothing has been done yet? Remove that "call nextline" and replace all your "jmp cliprmpt" with a "jmp endprmpt" or something,
Code:
endprmpt:
call nextline

mov di,buffer
cld
mov cx,128
mov al,0
rep stosb

jmp readyprmpt
    



Code:
mov ah, 0x00 
int 0x16 ; Interrupt 0x16, AH = 0x00 -> GET KEYSTROKE 

mov ah, 0x0E ; 
int 0x10 ; Interrupt 0x10, AH = 0x0E -> Teletype output 
cmp al, 8 
je bspace 

cmp al, 0x0D ; Did the user press enter? 
je en ; Then check the string
    

Move all compares right after you get the input and display the input last.


Code:
mov [bx], al ; Save it into the buffer 
inc bx ; Make bx point to the next byte in the buffer 
jmp getcmd ; Loop it over again
    

And when bx gets past 128, you get a buffer overflow.
Code:
mov ah,0
int 0x16

cmp al,8
je bspace

cmp al,0xd
je en

cmp bx,buffer + 128
je getcmd

mov [bx],al
inc bx

mov ah,0xe
int 0x10

jmp getcmd
    



Code:
repe cmpsb
call nextline
je ***
    

"nextline" calls "print", which uses "cmp", which modifies flags. So, remove this "call nextline".


Code:
;included from Minidos Created By Dex And used for educational 
;purposes 

bspace: 
cmp di,buffer ; Compear pointer to start of buffer 
jbe getcmd ; Jump bellow or = to label getkey 
dec di ; Go back in buffer 
mov al,8 ; Move cursor back 
mov ah,0Eh ; Request display 
mov bx,0x0001 
int 10h ; Call interrupt service 
mov al,32 ; Print a space 
mov ah,0Eh ; Request display 
mov bx,0x0001 
int 10h ; Call interrupt service 
mov al,8 ; Move cursor back again 
mov ah,0Eh ; Request display 
mov bx,0x0001 
int 10h ; Call interrupt service 
jmp getcmd ; Get another key
    

When you use someone else's code, at least make sure it'll work properly for you. Your code uses bx as a counter not di!
Also, "push bx" after "dec bx", and "pop bx" before "jmp getcmd".
Post 21 Dec 2008, 21:10
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 22 Dec 2008, 04:21
the probem i have is one

whn the user hits enter it acts like the user typed help ad after that i stops checking the buffer for cammands, wit enter notworking anymore and back space function stops, when the back space does work well for example

COMMAND:|hello_
backspace

COMMAND:|hel_o
it goes back two letters well i will double check the upper corrections.

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 22 Dec 2008, 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: 20337
Location: In your JS exploiting you and your system
revolution 22 Dec 2008, 04:25
GhostXoPCorp: Can you please change the title of this thread to something more appropriate? I would do it myself but I am not a mod.
Post 22 Dec 2008, 04:25
View user's profile Send private message Visit poster's website Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 22 Dec 2008, 04:28
well originally thats why i said "pm" me on an answer. but alright, just a simple task
Post 22 Dec 2008, 04:28
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 22 Dec 2008, 05:45
Quote:

whn the user hits enter it acts like the user typed help ad after that i stops checking the buffer for cammands, wit enter notworking anymore and back space function stops, when the back space does work well for example


Code:
help
hello
    


Its in the process of the command - how it cmp if a valid command...

When it cmps the command- it reads hel from help and hel from hello and it is saying we have a match jmp to the command for help...

if you want to test - type : hel
at the command line - you should get the help function

it prob does a simular with timer and time ect...

you need to rewrite this portion 1st then try the back space! Wink
Code:
mov cx, 4 ; Move 5 into cx, because there is 5 letters in "hello" 
mov si, buffer ; We will check the buffer against "hello" 
mov di, helpcmd ; ^ 
repe cmpsb 
    



after it does the command your buffer pointer is wrong - so its crashing
Thats why it stops working
Post 22 Dec 2008, 05:45
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 22 Dec 2008, 09:43

GhostXoPCorp,
My corrections and suggestions solve your problems. So please, could you at least follow them and try to modify your code, so I don't feel like I wasted all my time for nothing.
Post 22 Dec 2008, 09:43
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 23 Dec 2008, 16:29
i forgot to tell you, the all work, one you tld me to take out ad that ade it all crash, but i put it back in and everything works now, how do you feel now?

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 23 Dec 2008, 16:29
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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.