| `char' | `c' |
| `unsigned char' | `C' |
| `short' | `s' |
| `unsigned short' | `S' |
| `int' | `i' |
| `unsigned int' | `I' |
| `long' | `l' |
| `unsigned long' | `L' |
| `long long' | `q' |
| `unsigned long' | `Q' |
| `float' | `f' |
| `double' | `d' |
| `void' | `v' |
| `id' | `@' |
| `Class' | `#' |
| `SEL' | `:' |
| `char*' | `*' |
| unknown type | `?' |
| bit-fields | `b' followed by the starting position of the bit-field, the type of the bit-field and the size of the bit-field (the bit-fields encoding was changed from the NeXT's compiler encoding) |
| int myvar=0; | //global variable |
| int main(){ | |
| ... | |
| int x=0; | //lokal variable of main. There is no access to ! |
| return 0; | |
| } |
| test.cpp : | -compil it with: g++ -c test.cpp -o test_cpp.o |
| int myvar=2; | //global variable, however it isn't set to 2 in my test program. |
| char myextravar; | //global variable |
| int sqr(){ | //global function - sqr(void) -> _Z3sqrv |
| myvar = myvar*myvar; | //myvarª |
| return myvar; | //If you have such a line eax holds the value. |
| } | |
| void normal(){ | //-> _Z6normalv |
| myvar = myvar+3; | //Here myvar is hanged at the global position |
| } |
| test.nasm : | -compil it with: nasm -f elf test.nasm |
| EXTERN myvar | ;this makes myvar from the c++ programm useable for you |
| EXTERN _Z3sqrv | ;this makes the function int sqr(void) from the c++ programm useable for you |
| EXTERN _Z6normalv | ;this makes the function void normal(void) from the c++ programm useable for you |
| mov | ecx,20 | ||
| a: | |||
| call | _Z3sqrv | ;call the global c++ function sqr() | |
| call | output | ;a standard output procedure (syscall) eax = output | |
| call | _Z6normalv | ;call the global c++ function normal() | |
| mov | eax,[myvar] | ;or you can get the c++ variabel into eax like this too | |
| call | output | ;a standard output procedure (syscall) | |
| loop | a | ;jmp to a if ecx > 0 | |
| ende: | |||
| mov | eax,1 | ;system call number (sys_exit) | |
| int | $80 | ;call kernel (EXIT) |