Page 3 of 4
Re: Funny comments in your OS's Source code?
Posted: Wed Jan 29, 2014 6:31 am
by Bender
Code: Select all
mov ax, 0x7202
push ax
popf
pushf
pop bx
cmp ax, bx
je _386_ok
mov si, _386_NF
invoke NT_PRINTF
int 0x20
; Tell the user to get a life
_386_NF db '386+ Processor Not Found, Are you trolling me or.... Its 2014 man, You better get a life', 13, 10, 0
Re: Funny comments in your OS's Source code?
Posted: Wed Jan 29, 2014 4:44 pm
by Gigasoft
greyOne wrote:Black magic and Witchcraft; they are things you encounter in programming.
Witchcraft indeed, not to mention wrong. The return instruction is missing the high byte of the parameter. For a parameter of 0, just use the 1-byte version instead (0xc3). I also wonder why you are using inline assembly instead of just casting to a function pointer?
Re: Funny comments in your OS's Source code?
Posted: Wed Jan 29, 2014 6:57 pm
by VolTeK
sid123 wrote:_386_NF db '386+ Processor Not Found, Are you trolling me or.... Its 2014 man, You better get a life', 13, 10, 0
That's like saying "get a life" because someone drives an older car.
If they didn't have a life, do you think they would have a vehicle?
His next post shows him being more specific, as i was being overly analytical on his post, as he was on mine in a different thread.
Re: Funny comments in your OS's Source code?
Posted: Thu Jan 30, 2014 1:09 am
by Bender
VolTeK wrote:sid123 wrote:_386_NF db '386+ Processor Not Found, Are you trolling me or.... Its 2014 man, You better get a life', 13, 10, 0
That's like saying "get a life" because someone drives an older car.
If they didn't have a life, do you think they would have a vehicle?
Wikipedia wrote:"Get a life" is an originally American idiom and catch phrase usually intended as a taunt, to indicate that the person being so addressed is devoting an inordinate amount of time to trivial or hopeless matters
Just telling my users not to be obsessed with things like processors who are even
older than 80386.
Re: Funny comments in your OS's Source code?
Posted: Tue Feb 04, 2014 1:15 pm
by greyOne
Gigasoft wrote:Witchcraft indeed, not to mention wrong. The return instruction is missing the high byte of the parameter. For a parameter of 0, just use the 1-byte version instead (0xc3). I also wonder why you are using inline assembly instead of just casting to a function pointer?
Despite this, it works with both MSC and GCC on real hardware and a virtual machine. I actually did try using a function pointer, but that resulted in an invalid op code exception when compiled in MSC, when running on real hardware (the problem I do not remember exactly, but it was immediately notable when looking at the disassembly).
Re: Funny comments in your OS's Source code?
Posted: Sun Mar 23, 2014 1:29 am
by ghost1227
Got some real gems here! I recently launched a site called Inline Comedy to catalog just this type of humor... check it out!
Re: Funny comments in your OS's Source code?
Posted: Tue Apr 22, 2014 1:43 pm
by onlyonemac
It's not really a comment but I once typed this quick note when I thought I had finally deciphered some documentation on my way to the loo:
All ISRs are in the kernel code segment.
All segments (everywhere, not just in the IDT) are done with the lower three bits of 0 and the rest giving the value of
the GDT entry of interest (that's the index of the value, meaning 1 per 8 bytes, so no multiclication is nessecary as
the value is not the byte offset into the GDT but the segment index in the GDT, where a segment is 8 bytes).
That's not even correct!!!
Re: Funny comments in your OS's Source code?
Posted: Thu Apr 24, 2014 1:48 am
by BASICFreak
Funniest thing I have in my OS is the shutdown screen, I did comment out the last part as it required INTs running for timer.
Code: Select all
while(CMD_ACTIVE)
cmd_handler();
movcur(ROWS - 1, COLS - 1);
movcur_disable ++;
setColor (0x0F);
cls();
__asm__ __volatile__ ("cli");
puts("So long, farewell\nAuf Wiedersehen, goodnight\n\n");
puts("I hate to go and leave this pretty sight\n\nSo long, farewell\nAuf Wiedersehen, adieu\n\n");
puts("Adieu, adieu\nTo you and you and you\n\n...\n\n");
puts("The sun has gone\nTo bed and so must I\n\n");
puts("So long, farewell\nAuf Wiedersehen, goodbye\n\n");
puts("Goodbye\nGoodbye\nGoodbye\n\nGoodbye");
setColor (0x0E);
curX = (COLS / 2) - 17;
curY = ((ROWS - 1) / 2) - 1;
puts(" So sad to see you go");
curX = (COLS / 2) - 17;
curY = ((ROWS + 1) / 2) - 1;
puts("It is safe to turn off your computer");
curX = (COLS / 2) - 17;
curY = ROWS - 1;
puts(" GOOD BYE!");
//__asm__ __volatile__ ("sti");
__asm__ __volatile__ ("hlt");
/* sleep(60); //wait 60 seconds and display EASTER EGG
__asm__ __volatile__ ("cli");
setColor (0x1F);
cls();
puts("So long and thanks for all the fish\n\
So sad that it should come to this\nWe tried to warn you all but oh dear?\n\n\
You may not share our intellect\nWhich might explain your disrespect\nFor all the natural wonders that grow around you\n\n\
So long, so long and thanks\nfor all the fish\n\n\
The world's about to be destroyed\nThere's no point getting all annoyed\nLie back and let the planet dissolve\n\n\
Despite those nets of tuna fleets\nWe thought that most of you were sweet\nEspecially tiny tots and your pregnant women\n\n\
So long, so long, so long, so long, so long\nSo long, so long, so long, so long, so long\n\n\
So long, so long and thanks\nfor all the fish\n");
__asm__ __volatile__ ("hlt");*/
Re: Funny comments in your OS's Source code?
Posted: Thu Apr 24, 2014 1:56 am
by max
Haha, I've got one, too. This is my exception handler for everything except divide-by-zero, gpfs or page faults
Code: Select all
// Other exceptions:
// Theres on easy way out
// Theres no shortcut home
// Theres no easy way out
// Giving in cant be wrong
default: {
debug_consoleVideo_out("PANIC - An unhandled error occured.");
debug_consoleVideo_out(" Interrupt number: ");
debug_consoleVideo_outHex(r->intr);
debug_consoleVideo_out(" Exception name: ");
if (r->intr < 32) {
debug_consoleVideo_out(EXCEPTION_NAMES[r->intr]);
} else {
debug_consoleVideo_out("<unknown error>");
}
debug_consoleVideo_out("No detailed information available");
break;
}
Re: Funny comments in your OS's Source code?
Posted: Thu Apr 24, 2014 5:15 am
by onlyonemac
I've got the following block (or a variation of it) at the start of every software interrupt handler:
;Interrupt 0x70 handler (Open file)
.ascii "HANDLERINT112" ;ID string used by the IDT auto-compiler
The "IDT auto-compiler" is the worst C program I have ever written with the sole task of preparing an IDT file for writing to disk (it can't even prepare the IDT itself; it produces an assembler source file full of data macros which then has to be assembled separately).
Re: Funny comments in your OS's Source code?
Posted: Fri Apr 25, 2014 11:40 am
by DavidCooper
This thread would work better if it was called "funny comments you've found in someone else's OS's source code".
Re: Funny comments in your OS's Source code?
Posted: Sat Apr 26, 2014 9:06 am
by onlyonemac
The comments are in our source code, not other people's source code, so no that would not be a good idea.
Are you trolling us because I think we've copied and pasted?
Re: Funny comments in your OS's Source code?
Posted: Sat Apr 26, 2014 9:37 am
by iansjack
I suspect that David means that if we were looking for funny comments in other people's code we might find some that were actually funny. If that's what he meant then I agree with him; it's always more pleasing to read about how funny other people can be than to read about how funny people imagine themselves to be.
Re: Funny comments in your OS's Source code?
Posted: Sat Apr 26, 2014 1:02 pm
by DavidCooper
onlyonemac wrote:
Are you trolling us because I think we've copied and pasted?
Sorry if you thought that, but no: it never crossed my mind that anyone might have pinched them from anywhere else. I just think a relatively short thread with a high rate of funny comments in it would be better than a long thread with a low success rate. I'm not saying this thread's a dud one - I wouldn't keep looking at new posts in it if I thought there was no potential here at all - but it's a lot easier for outsiders to determine what's funny than the person who wrote any particular "funny" comment.
Re: Funny comments in your OS's Source code?
Posted: Mon Apr 28, 2014 2:32 am
by thomasloven
I agree with the above discussion, but thought I should share a bit on an anecdote around a piece of my own code anyway.
At university, we were supposed to include code dumps in reports for a certain course. Obviously, I never expected anyone to actually READ page after page of badly formated MATLAB code from more than 30 students every other week. But then one day it happened.
On the middle of a page, I got a small remark from the TA in red ink, next to the line:
Code: Select all
epsilon = 1e-4; % Note to self: Do Not Ever Name A Variable eps !!! (Debugging time 4.5 hours)
The comment was: "Yeah... been there
"
In MATLAB, eps is the floating point accuracy indicator and is overwritten without warning. Messing with it messes with EVERYTHING.