Im wondering is it possible to change c code to assembly code if its not thanks but if it is can some one give me sum pointers

Recommended Answers

All 9 Replies

#include <stdio.h>
#include <time.h>

int deck ();
int final ();
int main (void)

{ 
int card=0; 
int card1=0;
int card2=0;
    int i,ch,ft;
    int userscore=0; 
    int compscore=0; 
    int Ace_Value; 
    int face_card;
    int user_input;
      srand( time(NULL) );
      card =deck();
      card1 =deck();
      card2 =deck();

printf("Welcome to my BlackJack Program\n");
printf("Would you like to play a round?\n");
printf("Enter 1= Yes , 2=No?\n");
scanf("%d", &user_input);

switch (user_input)
{
case 1:
    //Tells the user the current value of their hand ! 
    printf("Your first card is: %d\n", card);
    printf("Your second card is: %d\n", card1);
    userscore = card1 + card;
    //Tests for Ace's value from the deck of cards. 
if (card == 1)
       {
       printf("Would you like your Ace to be 1 or 11?\n");
       scanf("%d",&Ace_Value); 
       userscore = Ace_Value + card1; 
      }
else if  (card == 11)
      {
       printf("Would you like your Ace to be 1 or 11?\n");
       scanf("%d",&Ace_Value); 
       userscore = Ace_Value + card1; 
      }
if (card1 == 1)
       {
       printf("Would you like your Ace to be 1 or 11?\n");
       scanf("%d", &Ace_Value);
       userscore = Ace_Value + card;
       }
else if   (card1 == 11)
      {
      printf("Would you like your Ace to be 1 or 11?\n");
      scanf("%d", &Ace_Value);
      userscore = Ace_Value + card;
      }
//King, Queen, Jack or 10 
else 
//Face Cards

if (card == 10 || card1 == 10)
    {
        //King =0
        //Queen =1
        //Jack =2 
        // 10 =3 

           face_card=rand()%4;
            if (face_card == 0)
            {
                printf("Your card is a King\n");

            }
            else if (face_card == 1)
            {
                printf("Your card is a Queen\n");
            }
            else if (face_card == 2)
            {
                printf("Your card is a Jack\n");
             }
            else 

            {
                    printf("Your card is a 10\n");
             }
    }
beg:
printf( "Your total is: %d\n", userscore);
printf( "Press 1 to hit & 2 to stay\n");
scanf("%d", &ch);
           if (ch == 1 && userscore < 21)
           {
           userscore = userscore + deck();
           printf( "Your total is: %d\n", userscore);
           goto beg;
           }
           if (ch == 1 && userscore > 21)
           {
           printf( "Total exceeded 21! You bust!\n");
           }
            if (ch == 2 && userscore > 21)
           {
           printf( "Total exceeded 21! You bust!\n");
           }
           if (ch == 2)
           {
           ft = userscore;
           printf( "Your total is: %d\n", ft);
           final(ft);
           }
           
break ; 
case 2:
; 
    break;

}

}



int deck ()
{
    int card;
    card =1+rand()%11;
    return (card);
}
int final(ft)
int ft;
{
int card=0; 
int card1=0;
int card2=0;
    int i,ch,ct; 
    int compscore=0; 
      srand( time(NULL) );
      card =deck();
      card1 =deck();
      card2 =deck();
printf("Your computer's first card is: %d\n", card);
printf("Your computer's second card is: %d\n", card1);
compscore = card1 + card;
check:
if (compscore <= 16)
{
compscore = compscore + deck();
printf("new computer card score %d\n", compscore);
goto check;
}
if (compscore >= 22)
{
    printf("Computer has bust\n");
    printf("YOU WIN\n");
    return 0;
    }
if (compscore >= 17 && compscore <=21)
{
    ct = compscore;
}

if (ct > ft && ct <= 21)
{
    printf("Your total is %d\n", ft);
    printf("The computer total is %d\n", ct);
    printf("YOU LOSE\n");
}
    if (ct < ft && ct <= 21)
{
    printf("Your total is %d\n", ft);
    printf("The computer total is %d\n", ct);
    printf("YOU WIN\n");
}
if (ct == ft && ct <= 21)
{
    printf("Your total is %d\n", ft);
    printf("The computer total is %d\n", ct);
    printf("DRAW\n");
}
return 0;
}

Is it possible

Of course it is. You have to write your own lib with functions for in- and output. It just is quite a fuss.

Try to google a bit, because C-Compilers can convert the code to assembly. This actually makes the code unreadable (in my opinion) but saves a lot of time and nerves.

im not thaty good at it

thanks

Hey can someone compile this for me and post the assembly code for me my visual studios keep givin me an error

What makes you think anyone else will be able to compile it, if your compiler won't.
Besides, "an error" is quite the most useless thing you could say. Be specific.

If you tried "-c" above, then sure that will break because visual studio uses a different compiler, so you need to find out how your particular compiler implements "output assembly".

Im sayn some people may kno how to change the output so it will output assembly when i try to open my vs error sceen pops up

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.