Keil Logo

Memory Type Comparison

When accessing near (bdata, ebdata, idata, and sdata), far, huge, and xhuge variables, the C166 Compiler either generates instructions or calls library routines depending on the device and size of object accessed. Library routines are called when there are no memory type-specific instructions available.

Memory Type 80C166 Access C16x/XC16x Access
near
All Objects
Instructions Instructions
far
All Objects
Instructions Instructions
huge
All Objects
Library Routines Instructions
xhuge
Byte/Word Objects
Library Routines Instructions
xhuge
DWord and Larger Objects
Library Routines Library Routines

The following examples show the code generated for different memory type accesses on the 80C166 and C16x/XC16x devices. The comparisons show the effects of different memory types on 80C166 and C16x/XC16x instructions and help you estimate the size of the code generated.

near Memory Access

unsigned int j;
unsigned int ui;
unsigned int near near_uiarray [10];

i = near_array [j];
80C166 Code C16x/XC16x Code
MOV R4,j
SHL R4,#01H
MOV R4,[R4+#near_uiarray]
MOV ui,R4
MOV R4,j
SHL R4,#01H
MOV R4,[R4+#near_uiarray]
MOV ui,R4

far Memory Access

unsigned int j;
unsigned int ui;
unsigned int far far_uiarray [10];

i = far_array [j];
80C166 Code C16x/XC16x Code
MOV R4,j
SHL R4,#01H
MOV DPP0,#PAG (far_uiarray)
NOP       ; pipeline effect
MOV R4,[R4+#far_uiarray]

MOV ui,R4
MOV  R4,j
SHL  R4,#01H
EXTP #PAG (far_uiarray),#01H


MOV  R4,[R4+#POF(far_uiarray)]
MOV  ui,R4

huge Memory Access

unsigned int j;
unsigned int ui;
unsigned int huge huge_uiarray [10];

i = huge_array [j];
80C166 Code C16x/XC16x Code
MOV   R4,j
SHL   R4,#01H
MOV   R2,#SOF (huge_uiarray)
MOV   R3,#SEG (huge_uiarray)
ADD   R2,R4
CALLA cc_UC,?C_HLOADI


MOV   ui,R4
MOV  R4,j
SHL  R4,#01H




EXTS #SEG (huge_uiarray),#01H
MOV  R4,[R4+#SOF(huge_uiarray)]
MOV  ui,R4

xhuge Memory Access
Byte/Word Objects

unsigned int j;
unsigned int ui;
unsigned int xhuge xhuge_uiarray [10];

i = xhuge_array [j];
80C166 Code C16x/XC16x Code
MOV   R4,j
MOV   R5,#00H
ADD   R4,R4
ADDC  R5,R5
MOV   R2,#SOF (xhuge_uiarray)
MOV   R3,#SEG (xhuge_uiarray)
ADD   R2,R4
ADDC  R3,R5
CALLA cc_UC,?C_HLOADI








MOV   ui,R4
MOV  R4,j
MOV  R5,#00H
ADD  R4,R4
ADDC R5,R5





MOV  R6,R4
MOV  R7,R5
MOV  R4,#SOF (xhuge_uiarray)
MOV  R5,#SEG (xhuge_uiarray)
ADD  R4,R6
ADDC R5,R7
EXTS R5,#01H
MOV  R4,[R4]
MOV  ui,R4

xhuge Memory Access
DWord and Larger Objects

unsigned int j;
unsigned long ul;
unsigned long xhuge xhuge_ularray [10];

i = xhuge_larray [j];
80C166 Code C16x/XC16x Code
MOV   R5,#00H
ADD   R4,R4
ADDC  R5,R5
ADD   R4,R4
ADDC  R5,R5
MOV   R2,#SOF (xhuge_ularray)
MOV   R3,#SEG (xhuge_ularray)
ADD   R2,R4
ADDC  R3,R5
CALLA cc_UC,?C_HLOADL
MOV   ul,R4
MOV   ul+02H,R5
MOV   R5,#00H
ADD   R4,R4
ADDC  R5,R5
ADD   R4,R4
ADDC  R5,R5
MOV   R2,#SOF (xhuge_ularray)
MOV   R3,#SEG (xhuge_ularray)
ADD   R2,R4
ADDC  R3,R5
CALLA cc_UC,?C_HLOADL
MOV   ul,R4
MOV   ul+02H,R5
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.