Erwthshs:

Gioti Arkoudopoulos gioti1 at yahoo.com
Sun Jan 27 21:03:01 EET 2002


--- Thanos Agathaggelidis <agathaggelidis at hotmail.com>
wrote:

> Exoume to Linux,ta *BSDs, ta Windows, to OS/2, to
> Solarisx86. OLA trexoun se 
> arxitektoniki x86 ok? Otan kanoume compile ena
> programma tote ayto den 
> metatrepetai se assembly (h opoia den eksartatai
> ap'to OS alla apo thn CPU 
> swsta?) kai meta se machine code? Giati tote ena
> programma pou graftike se 
> Win/86 den paizei se Linux/86?

Pos kanoume apo source files ena executable; Otan
ftiaxnoume ena executable ta source files pernoun ta
e3eis stadia: compiling => linking => locating 

   C/C++          C/C++          Assembly
     |              |               |            
  compiler       compiler        assembler
     |              |               |
 object file    object file     object file
     |              |               |
      \___________linker____________/                 

                    |
                relocatable
                    |
                 locator
                    |
                executable 

sto linux to exoume gia compiler C/C++: to gcc
                    gia compiler asm: to as
                    gia linker kai locator: to ld

1)
otan grafeis programmata bazeis kai mesa pragmata san:
 #include <stdio.h>, #include <stdlib.h>, #include
<socket.h>, ktl.
auta ta include files (library routines) einai
diaforetika sto linux kai sto Windoze, kai gia auto
ena programma pou graftike se Win/86 den paizei se
Linux/86. 

2)
ama grapseis ena programma, to ld panta bazei kai ena
kommatakh startup code sto executable sou. To startup
code einai ena kommatakh asm pou profanos kanei to
exeis: 
 - disable all interrupts
 - ...
 - allocate space for and initialize the stack
 - initialize the stack pointer
 - create and initialize the heap
 - execute the constructors and initializers for all  
global variables (C++ only)
 - enable interrupts
 - call main

kai mono meta arxinaiei to diko sou programma. Kai
afto to startup code einai diaforetiko sto Lin/x86 kai
sto Win/x86.

> Epishs
> i)  pia i diafora metaksy machine code kai assembly?

assembly einai p.x.: xor ax, ax 
                     mov ax, [1000]
                     nop
                     ...

ta assembly instructions hparxoun dhladei apo ena
instruction class, p.x. mov, add, sub kai ena h duo
numerands, p.x. ax, 1000, [1000]

ka8e assembly instruction prepei prota nai ginei
translated se machine code protou na mporei na to
katalbei to processor (giath to cpu mono 0 kai 1
katalabenei. den katalabenei assembly :-)
p.x. to assembly instruction: jmp ax se machine code
mporei na einai: 01 000 . Me to 01 gia to jmp kai to
000 gia to ax.

> ii) Giati otan kanoume compile ena programma ayto
> metatrepetai se
>     binary? (ayth kian einai xazh erwthsh, alla DEN
> KSERW :(( )

ama ta katalabes ta apano, 8a to katalbes kai auto :-)


> Any urls?

 - google ?
 - piase kanena kalo biblio apo asm h C/C++
 - ...



=====
Panagiotis Arkoudopoulos

http://users.skynet.be/gioti

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com



More information about the Linux-greek-users mailing list