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
);
for (i=32; i<256; i++) {
printf( %2x %3d %3o %c
, 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 wont show up.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
char *hdr = Hex Dec Oct Ch
;
char *msg = %3x %3d %3o %c
;
__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?

![[Solved] CS 3844-Homework #2](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] CS 3844 Computer Organization Lab #07](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.