flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Thank you,question |
Author |
|
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) |
|||
21 Dec 2008, 11:04 |
|
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. |
|||
21 Dec 2008, 19:17 |
|
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 |
|||
21 Dec 2008, 20:01 |
|
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
|
|||
21 Dec 2008, 20:25 |
|
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 |
|||
21 Dec 2008, 20:50 |
|
ManOfSteel 21 Dec 2008, 21:10
Quote:
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". |
|||
21 Dec 2008, 21:10 |
|
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. |
|||
22 Dec 2008, 04:21 |
|
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.
|
|||
22 Dec 2008, 04:25 |
|
GhostXoPCorp 22 Dec 2008, 04:28
well originally thats why i said "pm" me on an answer. but alright, just a simple task
|
|||
22 Dec 2008, 04:28 |
|
dosin 22 Dec 2008, 05:45
Quote:
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! 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 |
|||
22 Dec 2008, 05:45 |
|
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. |
|||
22 Dec 2008, 09:43 |
|
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. |
|||
23 Dec 2008, 16:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.