From 9f5f3caa74d66d5cc90eebec71a5e743f7c5a970 Mon Sep 17 00:00:00 2001 From: kvigor Date: Tue, 4 Feb 2003 05:52:45 +0000 Subject: [PATCH] Minor ds390 performance enhancement on generic pointer reads git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2214 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/lib/_gptrget.c | 76 +++++++++++++++++++++++++++++++++++++++++++ src/ds390/gen.c | 23 +++++++------ 2 files changed, 89 insertions(+), 10 deletions(-) diff --git a/device/lib/_gptrget.c b/device/lib/_gptrget.c index 7eaca491..ca8bc1bd 100644 --- a/device/lib/_gptrget.c +++ b/device/lib/_gptrget.c @@ -84,3 +84,79 @@ unsigned char _gptrget () _endasm ; } + +#ifdef SDCC_ds390 +unsigned int _gptrgetWord () +{ + _asm + ; + ; depending on the pointer type acc. to SDCCsymt.h + ; + mov a,b + jz 00001$ ; 0 near + dec a + jz 00002$ ; 1 far + dec a + jz 00003$ ; 2 code + dec a + jz 00004$ + dec a ; 4 skip generic pointer + dec a + jz 00001$ ; 5 idata + ; + ; any other value for type + ; return xFF + mov a,#0xff + sjmp 00006$ + ; + ; Pointer to data space + ; + 00001$: + push ar0 + mov r0,dpl ; use only low order address + mov _ap,@r0 + inc r0 + mov a,@r0 + inc dpl + sjmp 00005$ + ; + ; pointer to xternal data + ; + 00002$: + movx a,@dptr + mov _ap,a + inc dptr + movx a,@dptr + sjmp 00006$ +; +; pointer to code area +; + 00003$: + ; clr a is already 0 + movc a,@a+dptr + mov _ap,a + clr a + inc dptr + movc a,@a+dptr + sjmp 00006$ +; +; pointer to xternal stack +; + 00004$: + push ar0 + mov r0,dpl + movx a,@r0 + mov _ap,a + inc r0 + movx a,@r0 + inc dpl +; +; restore and return +; +00005$: + pop ar0 +00006$: + _endasm ; + +} +#endif diff --git a/src/ds390/gen.c b/src/ds390/gen.c index ecf14b94..e87d5855 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -9510,29 +9510,32 @@ genGenPointerGet (operand * left, /* if bit then unpack */ if (IS_BITVAR (retype) || IS_BITVAR (letype)) + { genUnpackBits (result, "dptr", GPOINTER); + } else { - size = AOP_SIZE (result); - offset = 0; + size = AOP_SIZE (result); + offset = 0; - while (size--) + while (size--) { -// Whoops; uncooked experimental code which was accidentally committed. -// Kevin should either finish cooking this or yank it soon. -#if 0 if (size) { - emitcode("push", "b"); + // Get two bytes at a time, results in _AP & A. + // dptr will be incremented ONCE by __gptrgetWord. + // + // Note: any change here must be coordinated + // with the implementation of __gptrgetWord + // in device/lib/_gptrget.c emitcode ("lcall", "__gptrgetWord"); - aopPut (AOP (result), "b", offset++); + aopPut (AOP (result), DP2_RESULT_REG, offset++); aopPut (AOP (result), "a", offset++); - emitcode("pop", "b"); size--; } else -#endif { + // Only one byte to get. emitcode ("lcall", "__gptrget"); aopPut (AOP (result), "a", offset++); } -- 2.47.2