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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
11-06-2009, 10:40 PM
|
#1
|
LQ Newbie
Registered: Nov 2009
Posts: 4
Rep:
|
hii
sbdsa
Last edited by rardin; 11-07-2009 at 05:29 PM.
|
|
|
11-06-2009, 10:41 PM
|
#2
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
|
with no libraries:
DOS = difficult.
LINUX = impossable.
|
|
|
11-07-2009, 12:33 AM
|
#3
|
Senior Member
Registered: Dec 2008
Posts: 4,732
|
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 ?
|
|
|
11-07-2009, 12:40 AM
|
#4
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by smeezekitty
with no libraries:
LINUX = impossable.
|
bull. Its possible. And, its spelt "impossible".
|
|
|
11-07-2009, 02:39 AM
|
#5
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
|
Quote:
Originally Posted by ghostdog74
bull. Its possible. And, its spelt "impossible".
|
then show.
|
|
|
11-07-2009, 02:59 AM
|
#6
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by smeezekitty
then show.
|
ever heard of assembly?
|
|
|
11-07-2009, 03:39 AM
|
#7
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
This story comes close...
|
|
|
11-07-2009, 03:48 AM
|
#8
|
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
|
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.
|
|
|
11-07-2009, 04:08 AM
|
#9
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by H_TeXMeX_H
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.
|
|
|
11-07-2009, 07:20 AM
|
#10
|
Member
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149
Rep:
|
Quote:
Originally Posted by H_TeXMeX_H
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 :-)
|
|
|
11-07-2009, 08:31 AM
|
#11
|
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
|
Quote:
Originally Posted by pcunix
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.
|
|
|
11-07-2009, 11:05 AM
|
#12
|
Member
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149
Rep:
|
Quote:
Originally Posted by H_TeXMeX_H
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.
|
|
|
11-07-2009, 12:40 PM
|
#13
|
Senior Member
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,076
|
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 12:42 PM.
|
|
|
11-07-2009, 04:34 PM
|
#14
|
Senior Member
Registered: May 2005
Posts: 4,481
|
Quote:
Originally Posted by H_TeXMeX_H
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.
|
|
|
11-07-2009, 04:42 PM
|
#15
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
|
Quote:
Originally Posted by Sergei Steshenko
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.
|
|
|
All times are GMT -5. The time now is 06:31 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|