开发者

difference between "int" [closed]

It's difficult to tell what is being asked here. This q开发者_StackOverflowuestion is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜