Question

Convert the following C program to inline assembly int main(){ int i; printf("Hex Dec Oct Ch\n");...

Convert the following C program to inline assembly

int main(){
int i;

printf("Hex Dec Oct Ch\n");

for (i = 32; i < 256; i++){
printf("%2x %3d %3o %c\n",i,i,i,i);
}

return 0;
}

the code below shows where to do the assembly at:

int main(){
int i = 0;
char *hdr = "Hex Dec Oct Ch\n";
char *msg = " %2x %3d %3o %c\n";

printf("%s\n",hdr);

———asm{
// DO ASSEMBLY HERE
}
system("pause");

}

Homework Answers

Answer #1
.LC0:
  .string "Hex Dec Oct Ch"
.LC1:
  .string "%2x %3d %3o %c\n"
main:
  push rbp
  mov rbp, rsp
  sub rsp, 16
  mov edi, OFFSET FLAT:.LC0
  call puts
  mov DWORD PTR [rbp-4], 32
  jmp .L2
.L3:
  mov esi, DWORD PTR [rbp-4]
  mov ecx, DWORD PTR [rbp-4]
  mov edx, DWORD PTR [rbp-4]
  mov eax, DWORD PTR [rbp-4]
  mov r8d, esi
  mov esi, eax
  mov edi, OFFSET FLAT:.LC1
  mov eax, 0
  call printf
  add DWORD PTR [rbp-4], 1
.L2:
  cmp DWORD PTR [rbp-4], 255
  jle .L3
  mov eax, 0
  leave
  ret
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the following code that is contained in the main function of a C program. What...
Consider the following code that is contained in the main function of a C program. What is wrong with the code? unsigned int myUnsignedInt = 100; printf("%c\n", myUnsignedInt);
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
For the following code in C, I want a function that can find "america" from the...
For the following code in C, I want a function that can find "america" from the char array, and print "america is on the list" else "america is not on the list" (Is case sensitive). I also want a function to free the memory at the end of the program. #include <stdio.h> #include <stdlib.h> struct Node { void *data; struct Node *next; }; struct List { struct Node *head; }; static inline void initialize(struct List *list) { list->head = 0;...
I am trying to write a program in C language but keep running into errors. Any...
I am trying to write a program in C language but keep running into errors. Any help would be awesome. here is my code I have so far. #include <stdio.h> #include <conio.h> #include <string.h> int main(){    int lenght, i = 0, state = 0;    char line[100];    printf("enter the string for checking of comment line: \n");    gets(line);    while(i < strline(line)){        switch(state){            case 0: if (line[i] == '/'){               ...
would someone kindly convert the following C code to java? thanks so much # include <stdio.h>...
would someone kindly convert the following C code to java? thanks so much # include <stdio.h> int main(void) { int changeOwed; int check; char invisibleChar; int count = 0; int numQ=0, numD=0, numN=0, numP=0; do{ printf("How much change is owed (in cents)?\n"); check = scanf("%d", &changeOwed); // returns 1 if the input is a number and returns 0 otherwise //Get's rid of any extra invisible characters if the input is a char/String do{ scanf("%c",&invisibleChar); }while(invisibleChar != '\n'); }while(check == 0...
q : explain the code for a beginner in c what each line do Question 2....
q : explain the code for a beginner in c what each line do Question 2. The following code defines an array size that sums elements of the defined array through the loop. Analyze the following code, and demonstrate the type of error if found? What we can do to make this code function correctly ? #include <stdio.h> #define A 10 int main(int argc, char** argv) { int Total = 0; int numbers[A]; for (int i=0; i < A; i++)...
Please provide answer in the format that I provided, thank you Write a program that prompts...
Please provide answer in the format that I provided, thank you Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must...
question : Take the recursive Java program Levenshtein.java and convert it to the equivalent C program....
question : Take the recursive Java program Levenshtein.java and convert it to the equivalent C program. Tip: You have explicit permission to copy/paste the main method for this question, replacing instances of System.out.println with printf, where appropriate. You can get the assert function from assert.h. Try running the Java program on the CS macOS machines. You can compile and run the program following the instructions discussed in class. Assertions are disabled by default. You can enable assertions by running java...
LANGUAGE C The codes below reads another .c or .txt file. Then, it will read the...
LANGUAGE C The codes below reads another .c or .txt file. Then, it will read the contents of every line and store the contents into a string array. Example: .c file that is to be read: #include <stdio.h> int main(){    printf("Hello World");    return ; } _______________(END OF THE FILE)_______________ Therefore, the code will read the contents above and store the contents in every line into an array, such that.... array[0] = "#include <stdio.h>\n" array[1] = "\n" array[2] ="int...
In C language: Partially finished program is given below. The second and third parameters of the...
In C language: Partially finished program is given below. The second and third parameters of the count() function need to be pointer parameters. However, the programmer forgot to write the necessary ampersands and asterisks in the prototype, call, function header, and function code. Add these characters where needed so that changes made to the parameters adults and teens actually change the underlying variables in the main program. #include #define MAX 10 void count( int ages[], int adults, int teens );...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT