Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Handling End Conditions

Name: Cudder !cXCudderUE 2017-01-27 17:54

C:
c = getchar();
if(c == EOF)
...
...
c = getchar();
if(c == EOF)
...
...
c = getchar();
if(c == EOF)
...
...


C++:

int my_get_char() {
int c = getchar();
if(c == EOF)
throw EOF;
return c;
}
...

try {
...
c = my_get_char();
...
c = my_get_char();
...
} catch(int eof) {
...
}


Asm:
my_get_char:
cmp eax, EOF
jz is_eof
ret
is_eof:
pop eax
jmp eof_handler
...
call my_get_char
eof_at_1:
...
call my_get_char
eof_at_2:
...
call my_get_char
eof_at_3:
...
eof_handler:
cmp eax, eof_at_1
jz do_eof_at_1
...


No need to check EOF everywhere. Less bloat than exceptions. Asm is superior.

Name: Anonymous 2017-01-28 4:44

You can do exactly the same thing in C with goto and jmp_buf.

For how long do you plan to keep making these posts about micro-optimizing your assembly code? This is stuff that 14-year-olds find interesting after they've discovered ASM for the first time and subsequently grow out of when they realize it has no bearing on writing real software. You're basically still masturbating with bit-twiddle kiddy shit while the grown-ups have moved on to fucking their ENTERPRISE-grade vaginas.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List