OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:11 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: int help
PostPosted: Sat Nov 15, 2008 5:12 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 15, 2008 2:37 pm
Posts: 815
Location: The Fire Nation
thisis question if fasm, could somebody help me with something like this n my os

its like cin >> X; }
if (X == "hello"); }
cout << "Hello" << endl;


part braketed are what i need help with

input and if in fasm for my os, could you give an example i could use?


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sat Nov 15, 2008 5:44 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 02, 2007 6:34 am
Posts: 31
Location: on the stack
Hi,

You have not really told us a lot of information about any functions in your operating system. It would be interesting to know if you have any input functions, output functions and so on. But judging by your other topic about finding people to join your team, I suspect that you haven't done that much work yet (Feel free to prove me wrong, in that case we can change the code).
I suggest you to read the FASM manual (if you haven't done so already) and I also suggest you to read the Intel manuals (still if you haven't done so already).

Code:
    mov     bx, Buffer      ; Make sure you have DS set to the proper segment

GetInput:                   ; This will loop as long as the user doesn't press enter
    mov     ah, 0x00       
    int     0x16            ; Interrupt 0x16, AH = 0x00 -> GET KEYSTROKE
   
    mov     ah, 0x0E        ;
    int     0x10            ; Interrupt 0x10, AH = 0x0E -> Teletype output
   
    cmp     al, 0x0D        ; Did the user press enter?
    je      CheckString     ; 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     GetInput        ; Loop it over again
   
CheckString:                ; This function will check if the user typed "hello"
    mov     cx, 5           ; Move 5 into cx, because there is 5 letters in "hello"
    mov     si, Buffer      ; We will check the buffer against "hello"
    mov     di, Hello       ; ^
    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
    je      DoSomething     ; If it is equal then jump ahead and do something if it is hello
    jmp     DoSomethingElse ; And if it is not, then do something else
   
Buffer:
times   16  db 0

Hello db "hello"


Please notice that this is only example code, because I dont know anything about your operating systems functions. And also notice that this does not check for buffer overflow, it does not deal with backspaces, it is case sensetive and so on. I left this for you to do, since I do not want to do all your homework (actually I do not really want to do homework at all, but I do this to point you in the right direction).

Blue


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sat Nov 15, 2008 5:51 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 15, 2008 2:37 pm
Posts: 815
Location: The Fire Nation
thank you very much, this is simple, but for assembly i have never known how to do this. now, hw to use (get the operating system to interpret) a n fat file system


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sat Nov 15, 2008 5:58 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 02, 2007 6:34 am
Posts: 31
Location: on the stack
Hi,

That is not as simple a task as the one before. For that I suggest you to read the information on the wiki about FAT. There should be plenty of information there about reading from and writing to a FAT formatted disk.

Blue


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sat Nov 15, 2008 7:17 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 15, 2008 2:37 pm
Posts: 815
Location: The Fire Nation
oh yeah i too a look after i wrote the reply, by the way will the code up there work on real mode operating enviroments?


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sat Nov 15, 2008 7:27 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
That code will only work in real-mode, as it uses BIOS interrupts.

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sat Nov 15, 2008 8:24 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 15, 2008 2:37 pm
Posts: 815
Location: The Fire Nation
yes! thank you, im making a real mode, in protected mode, it wont be like looking at an inturrupt and seeing if it can run a device (it will) butin protectted mode, not only do you have to look it up, you have to make oyur own int (driver) so thank you, il keep it simple, go real


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sun Nov 16, 2008 4:34 am 
Offline
Member
Member

Joined: Tue Aug 21, 2007 1:41 am
Posts: 207
Location: Germany
You make what :?:


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sun Nov 16, 2008 1:36 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 15, 2008 2:37 pm
Posts: 815
Location: The Fire Nation
in real mode you can use int's for getting to devices, in protected mode, you have to make your own driver. i would rather look for how the int works than look for how the driver works then build it my self. im buildng my first operating system and i need help on how to get my os to read a file on the fat table, i would like an example of the table and of to the side, what everything does and how i can get my os to use it.


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sun Nov 16, 2008 2:12 pm 
Offline
Member
Member

Joined: Fri Oct 27, 2006 5:11 am
Posts: 155
Location: Oberbayern
All that the BIOS does is let you access sectors from the drive. It has no concept of a filesystem.

For example, a floppy disk is typically formatted as FAT12 and has three areas: a FAT table area, a root directory area, and a data area. It's called FAT12 because the 512-byte data clusters (aka sectors) on the disk are referenced by 12-bit numbers in the FAT. This makes it quite confusing to work with, as you can't just grab a byte or two and use it to reference a cluster on the FAT. You have to mix nibbles (4-bit values) with bytes to get what you need. Some docs:

http://www.eit.lth.se/fileadmin/eit/cou ... iption.pdf -- An excellent and concise FAT12 description
http://mikeos.berlios.de -- Not as useful as above, but my mini OS project includes a well documented FAT12 implementation in assembly, showing how to read and write files from a floppy drive.

If you want to work with FAT16 or FAT32, you don't need to worry about the 12-bit problems mentioned above, but it still takes a lot of work. I believe that Dex's project has a FAT32 driver, also in assembly (but still useful for showing you how to deal with data in the FAT):

http://www.dex4u.com

And it has already been brought up, but once more: http://wiki.osdev.org/FAT

Read that again and understand the scale of what you're taking on. It's by no means impossible, but it's a lot of work to get right!

M

_________________
MikeOS -- simple, well-documented x86 real-mode OS written in assembly language
http://mikeos.sourceforge.net


Top
 Profile  
 
 Post subject: Re: int help
PostPosted: Sun Nov 16, 2008 4:48 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 15, 2008 2:37 pm
Posts: 815
Location: The Fire Nation
thank ya, thats all i needed to know.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 60 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group