Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

can you tell me how this simple hello world program works on wondows system and linux

Status
Not open for further replies.

sagar474

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
#include<stdio.h>

int main()
{

printf("Hello world");

return 0;
}

is this program is operating system independent?
no only java like programs can run operaing system independent.

but these type of programs dose not call any APIs during execution how they work?

please help to understand.
thank you.
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,148
Reputation
4,302
Reaction score
2,088
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
windows and unix have gcc compiler support , which when installed installs all the standard library functions in its folder... so stdio.h is an library file with standard pre-defined API's...

using this API's the output is printed on the console.........
 

sagar474

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
then what will API will do?
they pass an interrupt ( int 21) to the processor?
and then what then kernel will do?
 

srizbf

Advanced Member level 5
Joined
Apr 3, 2010
Messages
1,995
Helped
417
Reputation
840
Reaction score
328
Trophy points
1,363
Activity points
10,985
int 21 implements the kernel of msdos.
 

sagar474

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
TITLE ch04p8 This is the string
.MODEL small
.data

message db "This is the string",0dh,0ah,'$'

.code
main proc

mov ax,@data
mov ds,ax

mov ah,9
mov dx, offset message
int 21h
mov ax,4C00h
int 21h
main endp

end main


dose this program works in UNIX?

---------- Post added at 19:49 ---------- Previous post was at 19:48 ----------

the program in assembly and C
will works in same way?
 

srizbf

Advanced Member level 5
Joined
Apr 3, 2010
Messages
1,995
Helped
417
Reputation
840
Reaction score
328
Trophy points
1,363
Activity points
10,985
the given program will not work in linux.
it is msdos assembly program .
can be executed under windows only.
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,185
Helped
1,141
Reputation
2,301
Reaction score
1,116
Trophy points
1,403
Location
Brazil
Activity points
53,371
...but these type of programs dose not call any APIs during execution how they work?...
Program codes wrote in C language are aimplicitly core independent.
It´s up to each compiler generate binary file according target microcontroler.
Remember that C language is sintax-standardized.

Thus those C program codes have an inherent property to run in diferents platforms (different uC cores) with few and little adjusts.

+++
 

sagar474

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
ya now I'm gating understand a little about kernels, ISR and OS.
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
#include<stdio.h>
int main()
{
printf("Hello world");
return 0;
}
is this program is operating system independent?
no only java like programs can run operaing system independent.
thank you.
so long as a C/C++ program uses standard APIs (such as your example) the C/C++ source program may be ported to systems with a different architecture or operating system (e.g. Windows to Linux), recompiled and run. Java, however, does not need to be recompiled. Once compiled from a .java source to a .class the .class file may be ported and will run on any system with a JVM (Java Virtual Machine). This is one of the advantages of Java over C++, e.g. one may write a client/server system in Java and port it without problems. That is not the case in C/C++.
 
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top