LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-13-2009, 08:01 PM   #1
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Cannot create "LS" command in C for my OS


here is my code:
Code:
/*all i get is random ascii chars*/
#define MK_FP( seg,ofs )( (void _seg * )( seg ) +( void near * )( ofs ))
#define FP_SEG( fp )( (unsigned )( void _seg * )( void far * )( fp ))
#define FP_OFF( fp )( (unsigned )( fp ))

struct __string { //structure returned by qurey filesystem call
char far str[75];
};
void output(char far *s){
do {
_SI = 1;  //Function 1 (putchar)
_AH = *s; //AH = char
asm {int 0x32}; //My Os interrupt is 32h
} while(*s++);
}
void main(){
__string far *s; //only need a pointer
_SI = 16;        //function 16 (qurey filesystem)
asm {int 0x32};  //Returns: bx = # files es:di = pointer to __string struct full of filenames
int c = _BX;     //Get number of files
s = (__string far *)MK_FP(_ES, _DI); //get filenames
for(int j = 0;j < c && j < 255;j++){
output(s[j].str); //loop through the files displaying them
output("\r\n");
}
}
and dont bother looking at the kernel source in general because this uses
the new interrupt call system that is not yet update online yet
 
Old 11-14-2009, 02:18 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Maybe you should start by creating a simple libc? You'll need some of the same procedures that you need for ls for other things.
Kevin Barry
 
Old 11-14-2009, 06:11 PM   #3
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by ta0kira View Post
Maybe you should start by creating a simple libc?
Oh boy, that sounds fun.
where to start?
 
Old 11-14-2009, 07:39 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Assuming you'll eventually need to write one, you'd write out your ls procedure as you would with libc present, then implement the libc calls you used. I'm sure it's a very circular, non-trivial thing to do, though. If you're not in the mood for writing one, maybe you could port busybox or glibc?
Kevin Barry
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] create a "bookmark" for navigating filesystem from the linux command line jlillywh Linux - Newbie 9 09-18-2009 06:05 AM
ns:"error when calling class OldSim"&tclsh:"invalid command+child process exits abn." shojaru Linux - Newbie 0 03-05-2009 04:23 AM
Command "mail" returns "panic: temporary file seek" kenneho Linux - Software 5 12-23-2008 03:27 AM
How do you create shortcuts to "folders" and "binaries" in GNOME? ebenh Linux - Desktop 5 01-21-2008 05:28 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration