Zilog Z80380 User Manual

Page 49

Advertising
background image

UM004001-COR1103

2–15

C-Compiler Overview

Incorporating C with assembly

call.ib _imul; (hl)=product

add sp,4; clean the stack

ret; return result in (hl)

Referenced C file.

typedef unsigned long uint32;

typedef unsigned short uint16;

typedef char int8;

uint32

imul(uint16 x, uint16 y)

{

uint32 res;

int8 i;

res = 0;

for (i=0; i < 16; i++)

{

if (y & 1)

{

res += x;

}

x = x << 1;

y = y >> 1;

}

return res;

}

Advertising