Add some contents to array a,and you will make the following code displaying a character c in the middle of screen.
The code is :
- Code: Select all
char a[200] = {......};
int main ()
{
((void (far *) ()) (long)a) ();
}
And I add the following hex numbers into array a,and compile the code above ,there is no error.An exe file created.I run the exe file,it displays an character c in the middle of screen.
these hex number is:
- Code: Select all
0xBB,0x00,0xB8,0x8E,0xC3,0xBB,0x90,0x06,0x26,0xC6,0x07,0x63,0xBB,0x00,0xB8,0x8E,0xC3,0xBB,0x91,0x06,0x26,0xC6,0x07,0x02,0xC3
you can think of these hex number as some machine code ,thest machine code is relative to the following code in c:
- Code: Select all
*(char far*) (0xb8000000 + 160 * 10 + 80) = 'c';
*(char far*) (0xb8000000 + 160 * 10 + 81) = 2;
The code above lets computer display a character c in the middle of screen in 8086 PC (I know it is too old).
But today someone told me another method to achieve this:
- Code: Select all
char main[201] = {0xBB,0x00,0xB8,0x8E,0xC3,0xBB,0x90,0x06,0x26,0xC6,0x07,0x63,0xBB,0x00,0xB8,0x8E,0xC3,0xBB,0x91,0x06,0x26,0xC6,0x07,0x02,0xC3};
You can compile it using tcc.exe,and run the created exe files,it can also show a character c in the middle of screen.
But why this can effect??I don`t know clearly.please give me an answer,thank you.
