Jump to content

Fun With Asm & C


Kamikaze_Badger

Recommended Posts

Please do not take notice to the drunken zombie and crazy badger. Just move along... move along...

 

Back to programming!

608773[/snapback]

 

haha yes, sorry folks. quite a mind warp. probly my fault, so shout at me!

Share this post


Link to post
Share on other sites

How dare they turn a good band like In Flames into that crap.  SIN SIN They will be destroyed.

609021[/snapback]

 

:)

 

;'s go after the brackets and never before a { (can't think of anywhere you'd use one before a { anyway, when declaring a class you need one after the } though)

 

in scanf the %c needed "s around it

 

In the if statements for answer the y and Y needed 's around them to say they're characters, without the 's it was trying to compare against variable y and Y... neither of which exist obviously :P

 

Dont know about the asm stuff.

 

/*Coded while listening to: The Verve Pipe - Bittersweet Symphony*/

#include <stdlib.h>
#include <stdio.h>

char answer;

int main(void) {
/*First, we're going to issue a warning*/
printf("DO NOT RUN THIS PROGRAM! IT WILL MAKE YOU WANT TO DO BAD THINGS\n" \
 	"REALLY! IT WILL! YOU WILL END UP USING LINUX TO RESTORE YOUR STUFF!\n" \
 	"Still wanna do it? Y/N\n>");
        
scanf("%c", &answer);
  
if /*Changing songs: The Ramsus - In The Shadows*/(answer == 'y') {
 printf("Smart choice...\n\n");
 system("pause");
 return 0;
}  else if(answer == 'Y') {
 printf("Smart choice...\n\n");
 system("pause");
 return 0;
}
      
printf("La la laaaaaa...\n\n");

  /*
  asm(
       mov ecx,1
       mov edx,2h
       mov dh,0b /*Not the correct register, but oh well*/
       /*Changing songs: Linkin Park - Papercut*/ /*
       writeDaZeeWohs:
       inc ecx
       int 13h
       int 13h
       int 13h
       int 13h
       int 13h
       int 13h
       int 13h
       int 13h
       loop writeDaZeeWohs
       )
 */
      
/*Changin songs: Groove Coverage - God Is A Girl*/
printf("\n\n\n\nIf you can read this, something didn't work right... DAWM!\n\n");
system("pause");

return 0;

}

 

 

 

Also....!

 

if /*Changing songs: The Ramsus - In The Shadows*/(answer == 'y') {
 printf("Smart choice...\n\n");
 system("pause");
 return 0;
}  else if(answer == 'Y') {
 printf("Smart choice...\n\n");
 system("pause");
 return 0;
}

 

This could be written

 

if /*Changing songs: The Ramsus - In The Shadows*/(answer == 'y' || answer == 'Y') {
 printf("Smart choice...\n\n");
 system("pause");
 return 0;
}

 

Saves a bit of duplicate code there! Could also be done using a switch statement, probably a matter of preference there really though.

 

switch(answer) {
 case 'y':
 case 'Y': {
 	printf("Smart choice...\n\n");
 	system("pause");
 	return 0;

 	break;
 }

 default: {
 	// phft, do nothing!
 }
}

Share this post


Link to post
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...