Hi, can you help with a C programming assignment?
So a small part of the course covers writing/compiling assembler code as well, & I'm having some trouble figuring it out:
Basically it deals with unsigned integer multiplication (specifically in dealing with 32-bit int overflow), using two files: big_mult.c, and mull.s.
So far, I have written the big_mult.c, which contains two methods: int main, & void mull (mull.s).
Code:
#include <stdio.h>
void mull(unsigned int x, unsigned int y, unsigned int* low, unsigned int* high);
int main(char *argv[]) {
unsigned x, y;
unsigned low = high = 0;
sscanf(argv[1],"%x",&x);
sscanf(argv[2],"%x",&y);
mull(x,y,&low,&high);
return 0;
}
Now mull.s function is to be written manually, and will be linked to the final program after compile: $ gcc -Wall -std=c99 -o big_mult.exe big_mult.c mull.s
This is the part I am lost at...
All I really know is that it starts out something like this:
Code:
_mull:
pushl %ebp | save stack pointer
movl %esp, %ebp | new stack pointer
movl 8(%ebp), %eax | get x
movl 12(%ebp), %edx | get y
movl 16(%ebp), (%?) | get *low
movl 20(%ebp), (%?) | get *high
...
...
pop %ebp
ret
Here is the sample output:
Code:
$ ./big_mult 2f432f43 629b03cb
2f432f43 x 629b03cb = 12345678 87654321
* Using Cygwin Bash Shell
Can you please help?
Thank you! Thank you!