Earlier quoted context omitted.
That's an old-school C function declaration. Note that the function return type are parameter types are implicitly int. nE is then explicitly declared to be a char pointer pointer.
But the char is outside of the declaration and before the opening brace - is this legal? And especially, why isn't it written like main(BX,char nE)? Doesn't save any bytes,it rather adds one semicolon...
An 8086 PC emulator in 4043 bytes
11–20 of 39 posts
Re: An 8086 PC emulator in 4043 bytes
#12Earlier quoted context omitted.
That's an old-school C function declaration. Note that the function return type are parameter types are implicitly int. nE is then explicitly declared to be a char pointer pointer.
But the char is outside of the declaration and before the opening brace - is this legal? And especially, why isn't it written like main(BX,char nE)? Doesn't save any bytes,it rather adds one semicolon...
I think the reason for doing it this way rather than putting the type declaration alongside the parameter is then it would also demand also adding an int declaration for the BX parameter which would then cause the code to be longer. That is to say with:
main(BX,char**nE){
.. it would throw an expected identifier error on the char. So you'd be putting the original: main(BX,nE)n**nE;{
Against this error-free alternative: main(int BX,n**nE){
.. but that's one byte longer.If I got any of this wrong, I hope someone will correct me though :)
Re: An 8086 PC emulator in 4043 bytes
#13Earlier quoted context omitted.
But the char is outside of the declaration and before the opening brace - is this legal? And especially, why isn't it written like main(BX,char nE)? Doesn't save any bytes,it rather adds one semicolon...
Yes, it's very old fashioned (K&R era). I think the reason for doing it this way rather than putting the type declaration alongside the parameter is then it would also demand also adding an int declaration for the BX parameter which would then cause the code to be longer. That is to say with: main(BX,char**nE){ .. it would throw an expected identifier error on the char. So you'd be putting the original: main(BX,nE)n*…
Re: An 8086 PC emulator in 4043 bytes
#14I still haven't puzzled out exactly what all the variables are, but I think that this makes the structure much clearer.
Re: An 8086 PC emulator in 4043 bytes
#15Earlier quoted context omitted.
But the char is outside of the declaration and before the opening brace - is this legal? And especially, why isn't it written like main(BX,char nE)? Doesn't save any bytes,it rather adds one semicolon...
Yes, it's very old fashioned (K&R era). I think the reason for doing it this way rather than putting the type declaration alongside the parameter is then it would also demand also adding an int declaration for the BX parameter which would then cause the code to be longer. That is to say with: main(BX,char**nE){ .. it would throw an expected identifier error on the char. So you'd be putting the original: main(BX,nE)n*…
Re: An 8086 PC emulator in 4043 bytes
#16This is interesting, though it might be a bit of a cheat. He's put some data in the BIOS image to assist in decoding instructions (not to take away from how amazing this is!): "CPU supports the full 8086/186 instruction set. Due to the complexities of the 8086’s arbitrary-length instruction decoding and flags, 8086 instructions are first converted to a simpler intermediate format before being executed. This conversio…
Re: An 8086 PC emulator in 4043 bytes
#17Re: An 8086 PC emulator in 4043 bytes
#18MS Visual C++ 2013 chokes on this with "'KB' undeclared identifier" error.
Re: An 8086 PC emulator in 4043 bytes
#19The source itself: http://ioccc.org/2013/cable3/cable3.c Or after running through preprocessing (not a huge help I found, sadly): https://gist.github.com/peterc/8259713