Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Unsigned Multiplication O/F (C Assembly)

LanguidLegendLanguidLegend Member Posts: 4
Hi, can you help with a C programming assignment?
A small part of the course covers writing/compiling assembler code as well, so I have this problem that I can't figure 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
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;
}[/code]
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[/code]
[hr]
Here is the sample output:
[code]$ ./big_mult 2f432f43 629b03cb
2f432f43 x 629b03cb = 12345678 87654321
* Using Cygwin Bash Shell[/code]

Can you please help?
[b]Thank you![/b]
Sign In or Register to comment.