LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
 
Thread Tools
Old 11-06-2009, 11:40 PM   #1
rardin
LQ Newbie
 
Registered: Nov 2009
Posts: 4
Thanked: 0
hii


[Log in to get rid of this advertisement]
sbdsa

Last edited by rardin; 11-07-2009 at 06:29 PM..
windows_vista rardin is offline     Reply With Quote
Old 11-06-2009, 11:41 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,243
Thanked: 60
with no libraries:
DOS = difficult.
LINUX = impossable.
windows_vista smeezekitty is offline     Reply With Quote
Old 11-07-2009, 01:33 AM   #3
anishakaul
Member
 
Registered: Dec 2008
Location: Gurgaon (India)
Distribution: Suse 10.3 Ubuntu 9.04
Posts: 58
Thanked: 0
I tried the following code as it is on suse 10.3 with the default gcc compilor! While compilation it gave a warning but still compiled without errors and gave the expected output !

int main ()
{
printf ("\nThank God !\n");
return 0;
}


Is this what u wanted ?
linux anishakaul is online now     Reply With Quote
Old 11-07-2009, 01:40 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 1,814
Blog Entries: 5
Thanked: 115
Quote:
Originally Posted by smeezekitty View Post
with no libraries:
LINUX = impossable.
bull. Its possible. And, its spelt "impossible".
linuxfedora ghostdog74 is offline     Reply With Quote
Old 11-07-2009, 03:39 AM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,243
Thanked: 60
Quote:
Originally Posted by ghostdog74 View Post
bull. Its possible. And, its spelt "impossible".
then show.
windows_vista smeezekitty is offline     Reply With Quote
Old 11-07-2009, 03:59 AM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 1,814
Blog Entries: 5
Thanked: 115
Quote:
Originally Posted by smeezekitty View Post
then show.
ever heard of assembly?
linuxfedora ghostdog74 is offline     Reply With Quote
Old 11-07-2009, 04:39 AM   #7
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,497
Thanked: 44
This story comes close...
linuxubuntu Hko is offline     Reply With Quote
Old 11-07-2009, 04:48 AM   #8
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 6,740
Blog Entries: 2
Thanked: 216
You can probably write it using assembly. But, what a stupid interview question. When would you ever need to do this ? Goodness, how much dumber can they get.

All of a sudden the servers all crash, but one is left in a state of limbo, nothing works except gcc and nasm, but the standard libraries have been disabled/deleted. Your only hope is to use gcc or nasm to write a small program to say "hello world", thus telling everyone that everything is ok and not to panic.
linuxslackware H_TeXMeX_H is offline     Reply With Quote
Old 11-07-2009, 05:08 AM   #9
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 1,814
Blog Entries: 5
Thanked: 115
Quote:
Originally Posted by H_TeXMeX_H View Post
You can probably write it using assembly. But, what a stupid interview question.
the point i am making is just to refute what smeezekitty said. In Linux, it is not impossible.
linuxfedora ghostdog74 is offline     Reply With Quote
Old 11-07-2009, 08:20 AM   #10
pcunix
Member
 
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 127
Thanked: 12
Quote:
Originally Posted by H_TeXMeX_H View Post
You can probably write it using assembly. But, what a stupid interview question. When would you ever need to do this ? Goodness, how much dumber can they get.
I suspect that the point of the question is to probe creativity and general knowledge. When I was interviewing, I'd ask questions like this. The point wasn't to write such a program - what I wanted to hear was HOW you'd write it. Do you know the difference between a system call and a library call? Do you know what /dev/tty is?

And no, "That's dumb" wouldn't have been a good answer :-)
macos pcunix is offline     Reply With Quote
Old 11-07-2009, 09:31 AM   #11
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 6,740
Blog Entries: 2
Thanked: 216
Quote:
Originally Posted by pcunix View Post
I suspect that the point of the question is to probe creativity and general knowledge. When I was interviewing, I'd ask questions like this. The point wasn't to write such a program - what I wanted to hear was HOW you'd write it. Do you know the difference between a system call and a library call? Do you know what /dev/tty is?

And no, "That's dumb" wouldn't have been a good answer :-)
Oh, well, but they didn't ask how. They asked you to do it.

I'm sure they could have come up with not only something better, but something meaningful.
linuxslackware H_TeXMeX_H is offline     Reply With Quote
Old 11-07-2009, 12:05 PM   #12
pcunix
Member
 
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 127
Thanked: 12
Quote:
Originally Posted by H_TeXMeX_H View Post
Oh, well, but they didn't ask how. They asked you to do it.

I'm sure they could have come up with not only something better, but something meaningful.
Not to be pedantic, but seeing a written program also answers "how" :-)

Interviewing is tough. A lot of people who really aren't worth hiring can answer the easy stuff. Stepping outside of comfort zones, even if unrealistic, can tell you a lot about a persons true abilities.

It's especially the case when you aren't necessarily looking for specific skills so much as general problem solver.

BTW, Google is famous for asking tough interview questions - sometimes very specific, but sometimes real flights of fancy.
macos pcunix is offline     Reply With Quote
Old 11-07-2009, 01:40 PM   #13
rob.rice
Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 457
Thanked: 4
format ELF executable 3
entry start

segment readable executable

start:

mov eax,4
mov ebx,1
mov ecx,msg
mov edx,msg_size
int 0x80

mov eax,1
xor ebx,ebx
int 0x80

segment readable writeable

msg db 'Hello world!',0xA
msg_size = $-msg

now that I have shown you how it's done
I leave it up to you to find the assembler this syntax works with

Last edited by rob.rice; 11-07-2009 at 01:42 PM..
linux rob.rice is offline     Reply With Quote
Old 11-07-2009, 05:34 PM   #14
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 1,036
Thanked: 52
Quote:
Originally Posted by H_TeXMeX_H View Post
You can probably write it using assembly. But, what a stupid interview question. When would you ever need to do this ? Goodness, how much dumber can they get.

All of a sudden the servers all crash, but one is left in a state of limbo, nothing works except gcc and nasm, but the standard libraries have been disabled/deleted. Your only hope is to use gcc or nasm to write a small program to say "hello world", thus telling everyone that everything is ok and not to panic.
No, the question is not dumb, and there are real needs for things like that.

When I was much younger, I managed to understand how "C" runtime in Borland's Turbo-C was linked to 'main' and how to avoid the linking.

After that I managed to use that Turbo-C to write in "C" for bare metal (with bare minimum inline assembly). That was my job at the time - to write for bare metal. And I was using VGA memory directly for output, so even BIOS was bypassed. And it was actually interesting and useful - I used to "allocate" different screen areas (i.e. various areas in VGA memory) for different diagnostic messages, so I could effectively have a number of checkpoints in my program.

Furthermore, VGA memory was big enough for some small programs/tests - for example, I could test a potentially faulty RAM module - the memory test resided in that VGA memory in the page not currently displayed on screen.

From time to time I (still ?) see job ads with part of job description being programming for bare metal.
linuxsuse Sergei Steshenko is offline     Reply With Quote
Thanked by:
Old 11-07-2009, 05:42 PM   #15
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,243
Thanked: 60
Quote:
Originally Posted by Sergei Steshenko View Post
No, the question is not dumb, and there are real needs for things like that.

When I was much younger, I managed to understand how "C" runtime in Borland's Turbo-C was linked to 'main' and how to avoid the linking.

After that I managed to use that Turbo-C to write in "C" for bare metal (with bare minimum inline assembly). That was my job at the time - to write for bare metal. And I was using VGA memory directly for output, so even BIOS was bypassed. And it was actually interesting and useful - I used to "allocate" different screen areas (i.e. various areas in VGA memory) for different diagnostic messages, so I could effectively have a number of checkpoints in my program.

Furthermore, VGA memory was big enough for some small programs/tests - for example, I could test a potentially faulty RAM module - the memory test resided in that VGA memory in the page not currently displayed on screen.

From time to time I (still ?) see job ads with part of job description being programming for bare metal.
Thats different, linux is a high level protected mode environment that you cannot just call interrupt 0x10 to do the printing.
windows_vista smeezekitty is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
program for scanning libraries nocturna_gr Linux - Software 3 07-31-2009 05:51 PM
how to see which libraries a binary program needs r00tb33r Linux - Software 4 02-23-2008 06:22 AM
C++ hello world program error bahadur Programming 23 07-18-2006 01:04 PM
Linking program with .a libraries rudy2 Programming 2 04-22-2005 06:36 AM
How to check which libraries does a program use? sceadu Programming 7 12-27-2004 08:39 PM


All times are GMT -5. The time now is 05:40 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration