int help
int help
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?
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?
Re: int help
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).
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
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: Select all
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"
Blue
Re: int help
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
Re: int help
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
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
Re: int help
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?
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: int help
That code will only work in real-mode, as it uses BIOS interrupts.
Re: int help
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
Re: int help
You make what
Re: int help
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.
-
- Member
- Posts: 155
- Joined: Fri Oct 27, 2006 5:11 am
- Location: Oberbayern
- Contact:
Re: int help
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
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
http://mikeos.sourceforge.net
Re: int help
thank ya, thats all i needed to know.