zoukankan      html  css  js  c++  java
  • C166 8位字节位运算赋值-代码优化

    8位字节位运算赋值优化特记录下:

    unsigned short func1()
    {
    unsigned short a;
    return a;
    }

    unsigned char func2()
    {
    unsigned char a;
    return a;
    }

    unsigned short u_16;
    unsigned char u_8;

    void sub_027F08()
    {
    UINT8 t8u;

    // ERAM_u16_81F48 = ((sub_035EC8() == 0) & 1) <<14 | (ERAM_u16_81F48 & (~(1<<14)));
    // ERAM_u8_81F64 = (FDC_INT8U)(((FDC_INT8U)sub_032AE4() != 0) & 1) << 6 | (FDC_INT8U)(ERAM_u8_81F64 & (~(1<< 6)));
    u_16 = ((func1() == 0) & 1)<<14 | (u_16 & (~(1<<14)));
    // u_8 = ((func1() == 0) & 1)<<14 | (u_8 & (~(1<<14)));

    t8u = (func1() == 0) ? (UINT8)1: (UINT8)0;
    t8u &= 1;
    t8u <<= 6;
    u_8 =(UINT8)t8u | (UINT8)(u_8 & (UINT8)(~(1<<6)));

    return;
    }

    结果如下:

    1264: t8u = (func1() == 0) ? (UINT8)1: (UINT8)0;
    00027F34 DA02087F CALLS func1(0x27F08)
    00027F38 E10A MOVB RL5,#0x00
    00027F3A 4840 CMP R4,#0
    00027F3C 3D01 JMPR CC_NZ,0x027F40
    00027F3E E11A MOVB RL5,#0x01
    1265: t8u &= 1;
    00027F40 69A1 ANDB RL5,#1
    1266: t8u <<= 6;
    00027F42 5C65 SHL R5,#0x06
    1267: u_8 =(UINT8)t8u | (UINT8)(u_8 & (UINT8)(~(1<<6)));
    1268:
    00027F44 F3F8D805 MOVB RL4,DPP0:0x05D8
    00027F48 67F8BF00 ANDB RL4,#0x00BF
    00027F4C 718A ORB RL4,RL5
    00027F4E F7F8D805 MOVB DPP0:0x05D8,RL4
    1269: return;
    00027F52 DB00 RETS

  • 相关阅读:
    20201015-3 每周例行报告
    20201008-1 每周例行报告
    20200924-2 功能测试
    贺敬文2019102936-1总结
    20191114-1 每周例行报告
    20191107-1 每周例行报告
    20191031-1 每周例行报告
    每周例行报告
    20191017-1 每周例行报告
    每周例行报告
  • 原文地址:https://www.cnblogs.com/xihong2014/p/10099470.html
Copyright © 2011-2022 走看看