difference between "int" [closed]
how does OS know to differentiate between
int x = 0; //variable
and
int 0x80; //interrupt, call system_call()
By co-incidence, the first 3 letters of 'integer' are the same as the first 3 letters of 'interrupt'. Two different languages have used these 3 letters, and they mean different things.
Similarly, 'chat' is a word in both French and English, but in French it means 'cat' and in English it means 'talk'.
int x = 0;
is C code.
int 0x80;
is assembly code.
Moreover, the OS don't know about that at all, since the compiler / assembler converts it to machine code...
One looks like C the other looks like assembler.
If you generate the assembler for int x = 0; with the -S switch in your compiler you would see how different the code actually is.
Because they are two different programming languages.
The first is a variable declaration and definition in C, the second is the assembly instruction for calling system calls in Linux x86.
They are likely to be interpreted by two different compilers, or if they are in the same file the second instruction is in a block of assembly code, that the compiler knows that must be treated differently.
精彩评论