CS 3844-Homework #2 Solved

35.00 $

Category:

Description

Rate this product

Homework #2 – Convert C to Assembly

CS 3844 Section 0B1,

Given this C program:

#include <stdio.h>

 

int main(int argc, char *argv[]) {

int i;

printf(“Hex  Dec  Oct   Ch\n”);

for (i=32; i<256; i++) {

printf(” %2x  %3d  %3o   %c\n”, i, i, i, i);

}

}

Output should look like this (from both the C program above and your Assembly version):

Convert it to Assembly (inside C). You must use Visual Studio in the VDI. If you run it on Linux, characters 128 to 255 won’t show up.

#include <stdio.h>

#include <stdlib.h>

 

int main(int argc, char *argv[]) {

char *hdr = “Hex  Dec  Oct   Ch\n”;

char *msg = “%3x  %3d  %3o   %c\n”;

 

__asm {

TBD

}

system(“pause”);

}

Replace the TBD with two parts: a loop on EAX from 32 to 255, and a function. You must do a CALL to your function and RET to return. And you must pass in the loop variable to the function using the EAX register.

Hint: Use the command “call printf” to do the two prints. It expects all the parameters on the Stack. What order do the parameters need to be to printf?

  • hw2-wqwuse.zip