hw4_D06_sol

hw4_D06_sol - ECE 3803: Microprocessor System Design D Term...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 3803: Microprocessor System Design D Term 2005 Homework 4 -- Solutions 1. In signal processing applications, one often needs to multiple complex quantities. Write a C function to perform multiplication of the form E + jF = (A + jB)(C + jD) where A,B,C and D are 16 bit signed integers and in the result E and F are 32-bit F. ( Hint : There is no need to represent imaginary number, j in your code just calculate E and F). You may ignore overflow. Also write a simple main program that calls your function and displays the results. Use a 16 bit compiler (i.e. MS DOS compatible compiler) such as Turbo C (tcc), Pacific C or even MS Windows Driver Development Kit (CL.EXE and LINK.EXE) to compile and run the program. Show a listing of the assembler code produced for the C function and fully describe how the parameters are passed the function (i.e. in registers and/or on the stack) and how the result is returned . To assemble with tcc use the -S command option. In Pacific C, choose the assemble option from the compile menu [20 pts] Using Turbo C 3.0 ifndef ??version ?debug macro endm $comm macro name,dist,size,count comm dist name:BYTE:count*size endm else $comm macro name,dist,size,count comm dist name[size]:BYTE:count endm endif ?debug S "hw4_tc.c" ?debug C E939689B34086877345F74632E63 _TEXT segment byte public 'CODE' _TEXT ends DGROUP group _DATA,_BSS assume cs:_TEXT,ds:DGROUP _DATA segment word public 'DATA' d@ label byte d@w label word _DATA ends _BSS segment word public 'BSS' b@ label byte b@w label word _BSS ends _TEXT segment byte public 'CODE' ; ; int cplxmul(int re1, int im1, int re2, int im2, long *re, long *im) ; assume cs:_TEXT _cplxmul proc near push bp mov bp,sp
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
push si push di ; arguments passed to cplxmul on stack mov si,word ptr [bp+4] ; a = re1 mov di,word ptr [bp+6] ; b = im1 mov cx,word ptr [bp+8] ; c = re2 ; ; { ; ; (*re) = re1*re2 - im1*im2; // Real part of product ; mov ax,si ; ax = a imul cx ; ax * cx = a*c push ax mov ax,di imul word ptr [bp+10] ; b*d mov dx,ax pop ax sub ax,dx cwd mov bx,word ptr [bp+12] mov word ptr [bx+2],dx ; Push double word e = a*c - b*d mov word ptr [bx],ax ; ; (*im) = re1*im2 + im1*re2; // Imaginary part ; mov ax,si imul word ptr [bp+10] push ax mov ax,di imul cx mov dx,ax pop ax add ax,dx cwd mov bx,word ptr [bp+14] mov word ptr [bx+2],dx ; Push double word f = a*d + b*c mov word ptr [bx],ax
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/29/2009 for the course ECE ECE 3803 taught by Professor Jarvis during the Spring '06 term at WPI.

Page1 / 8

hw4_D06_sol - ECE 3803: Microprocessor System Design D Term...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online