Programming a 64-bit processor, Computer Engineering

You are to write a C program called big_mult.c that multiplies two unsigned 64-bit integers, x and y, read from the command line. The output is a pair of unsigned 64-bit integers representing the most significant and least significant 64 bits of the full 128-bit product x * y. The inputs and outputs are to be given in hexadecimal format. Your C program will take care of reading the inputs and printing the output, but it will call a function mulq.s to do the actual multiplication. Your C program should use only unsigned long long int variables and should not do any arithmetic. To reduce the length of our type declarations, I put the following lines into hw3.h.
typedef unsigned long long int ulli;
typedef long long int lli;

This allows us to abbreviate unsigned long long int with the shorter name ulli and long long int with lli.

The function defined by mulq.s should have the following declaration in C before the function main.
void mulq(ulli x, ulli y, ulli *high, ulli *low);

The least significant 64 bits of the product are to be assigned to low, and the most significant 64 bits of the product are to be assigned to high. Remember to put an appropriate header comment into your assembly file (the ordinary C comment /* ... */ will work for assembly too). You will also need to read carefully the description of the mulq instruction in the Intel 64/IA32 instruction set reference manual, Intel 64/IA32 instruction set reference manual, or equivalent documentation. Learning to read this two-volume 800+ page document is part of your learning experience on this assignment.

One way to approach writing this assembly program is to write a similar program in C, compile it to assembly code using the -S option, and modify the resulting assembly code to do what you need. Your final assembly code should be very short and should contain only one multiplication instruction mulq.
The compile command to test your programs will look like this:
gcc64 -Wall -std=gnu99 -o big_mult big_mult.c mulq.s .

Here are 32- and 64-bit sample outputs to use in testing your programs.
C:>big_mult 2f432f43 629b03cb
2f432f43 x 629b03cb = 12345678 87654321

C:>big_mult 99d0c486a0fad481 76a185cea6f497c7
99d0c486a0fad481 x 76a185cea6f497c7 = 4747474747474747 4747474747474747
.
Remember that arguments are passed differently in the 64-bit architecture than in the 32-bit architecture. The registers used for parameter passing in Windows are different from those described in the textbook for Unix. Windows passes only the first four parameters in registers. The registers used by Unix are %rdi, %rsi, %rdx, %rcx, %r8, %r9 in that order. The registers used by Windows are %rcx, %rdx, %r8, %r9 . See Class10.pdf for details on register usage.

Posted Date: 4/3/2013 2:02:44 AM | Location : United States







Related Discussions:- Programming a 64-bit processor, Assignment Help, Ask Question on Programming a 64-bit processor, Get Answer, Expert's Help, Programming a 64-bit processor Discussions

Write discussion on Programming a 64-bit processor
Your posts are moderated
Related Questions
What is independent process? A process is independent it cannot affect or be affected by the other processes implementing in the system. Any process does not share data with ot

a. Define the Key features of Hop field Neural Networks. b. Compare and contrast among Neural Networks and Expert systems in terms of knowledge representation, acquisition and e

Q: Challenges and Prospects in Changing Information Technology? There is no doubt that information technology has made significant progress during the past two decades. Modern

What is a thread? A thread otherwise called a lightweight process (LWP) is a basic unit of CPU utilization, it comprises of a thread id, a program counter, a register set and a

What is meant by stacked list? A stacked list is nothing but secondary list and is showed on a full-size screen unless you have specified its coordinates using the window comm

Q. Find the Physical address of instruction? Value of Instruction Pointer and holding address of instruction = 1234h Value of code segment register (CS) = 448Ah Physical

Why is Translation Look-aside Buffers (TLBs) important? The implementation of page-table is completed in the following manner: Page table is maintained in main memory.

VBScript is an easy and powerful to learn tool which can be used to add interaction to your Web pages. Web browser receives scripts along with rest of the Web document. Browser par

APIs are proprietary programming interfaces supported by certain platforms. By using an API, you lose all portability. If you know your application will only ever run on single pla

Relocation bits used by relocating loader are specified by? Ans. Relocation bits utilized by relocating loader are identified by Assembler or Translator.