打印

HotC51共产儿童团入团试题(不晕的提干~~~)

[复制链接]
2154|15
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
HotC51|  楼主 | 2009-3-2 22:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
tc, C51, OTA, TI, ov
/*------------------------------------------------------------
    HotC51汇编数组定义头文件(HotAsm.h V1.05)
最初建立时间: 2009.2.18 
最近修改时间: 2009.3.2    (可以正式 PK MCS51汇编指令集)
增  添原  因: 为全面支持裸奔式实时操作系统HotTask51做准备
              并替代年代久远的HotIns.h/c(不在HotTask51下使用)
应        用: 可以用COM接口技术对HotC51汇编数组进行封装

菜农HotPower@126.com 2008.3.2 于西安大雁塔村农会
---------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------
                HotASM51汇编数组指令集与MCS51汇编指令集对照表
  DB(x)   DB(0~0xff)  //伪指令    asm_DB(250),asm_DB('1'),                  db 250;
  DW(x)   DW(0~0xffff)//伪指令    asm_DW(0x1234),//大端                     dw 0x1234;
  dw(x)   dw(0~0xffff)//伪指令    asm_dw(0x1234),//小端                     dw 0x3412;
  Rn(x)   Rn(0~7)                  asm_MOV_A_R0(), asm_MOV_A_Rn(5),              mov a,r0;mov a,r5;
@ iRn(x)  iRn(0~1)                  asm_MOV_A_iR1(), asm_MOVX_iRn_A(0),         mov a,@r1;movx @r0,a;
! BIT(x)  BIT(0~0x7f, 0x80~0xff)  asm_CLR_BIT(0x30),asm_SETB_P0_0(),          clr 30h;setb p0.0;
& REG(x)  REG(0~0x7f, 0x80~0xff)  asm_MOV_REG_A(HotASM_B),asm_MOV_B_A(),    mov b,a;
# DATA(x) DATA(0~0xff, 0~0xffff)  asm_MOV_A_DATA(250),asm_MOV_A(250)          mov a,#250;
-------------------------------------------------------------------------------------------------*/



#include "hotcom.h"
/*--------------------------------------
    HotTask51汇编数组调用函数库
--------------------------------------*/


/*---------------------------------------------
    HotTask51系统启动函数
    void __HotASM_START__(void)
入口: 无
      Keil DPTR = &__HotASM_START__[0]
           R2D1 = DPTR
出口: 无
结果: 二次RETI后继续执行
特点: 本“函数”可以“动态加载”
-----------------------------------------------*/
HotASM (__HotASM_START__)//(void)
{//DPTR保存的是汇编数组函数的首地址__HotASM_START__
#define lable__HotASM_START__Exit \
(\
    size_CLR_A()\
  + size_MOV_REG_A()\
  + size_JZ()\
  + size_LJMP()\
  + 2 * size_MOV_A_REG()\
  + 2 * size_ADD_A()\
  + 2 * size_PUSH_REG()\
)
    asm_CLR_A(),
    asm_MOV_IE_A(),//关中断
    asm_JZ(size_LJMP() - 1),//NOP()
    asm_LJMP(0x5500),//
    asm_MOV_A_DPL(),
    asm_ADD_A(lable__HotASM_START__Exit),//__HotASM_START__0
    asm_PUSH_ACC(),//压入跳入地址__HotASM_START__0低8位
    asm_MOV_A_DPH(),//
    asm_ADDC_A(0),
    asm_PUSH_ACC(),//压入跳入地址__HotASM_START__0高8位
//lable__HotASM_START__Exit:
    asm_RETI()//(连续调用RETI二次)
};

/*---------------------------------------------
    HotTask51软件复位函数
    void __HotASM_RESET__(void)
入口: 无
      Keil DPTR = &__HotASM_RESET__[0]
           R2D1 = DPTR
出口: 无
结果: 二次RETI后跳入0x0000
特点: 本“函数”可以“动态加载”
-----------------------------------------------*/
HotASM (__HotASM_RESET__)//(void)
{//DPTR保存的是汇编数组函数的首地址__HotASM_RESET__
#define lable__HotASM_RESET__Exit \
(\
    size_CLR_A()\
  + size_MOV_REG_A()\
  + size_JZ()\
  + size_LJMP()\
  + 2 * size_MOV_A_REG()\
  + 2 * size_ADD_A()\
  + 2 * size_PUSH_REG()\
  + size_RETI()\
)
    asm_CLR_A(),
    asm_MOV_IE_A(),//关中断
    asm_JZ(size_LJMP() - 1),//NOP()
    asm_LJMP(0xaa00),//
    asm_MOV_A_DPL(),
    asm_ADD_A(lable__HotASM_RESET__Exit),//lable__HotASM_RESET__0
    asm_PUSH_ACC(),//压入跳入地址lable__HotASM_RESET__0低8位
    asm_MOV_A_DPH(),//
    asm_ADDC_A(0),
    asm_PUSH_ACC(),//压入跳入地址lable__HotASM_RESET__0高8位
    asm_RETI(),//顺序执行下句!!!(调用RETI)
//lable__HotASM_RESET__Exit:
    asm_CLR_A(),
    asm_PUSH_ACC(),//压入复位地址低8位
    asm_PUSH_ACC(),//压入复位地址高8位
    asm_RETI()//跳入复位地址处
};

/*---------------------------------------------
    HotTask51软中断函数
    void __HotASM_ISR__(unsigned char isrNum)
入口: R7   D4D3 中断向量组号  D2D1D0 中断向量号
出口: R7   isrNum
结果: 跳入对应的中断地址 isrNum * 8 + 3
-----------------------------------------------*/
HotASM (__HotASM_ISR__)//(unsigned char isrNum)
{//DPTR保存的是汇编数组函数的首地址__HotASM_ISR__
#define lable__HotASM_ISR__Exit \
(\
  + 3 * size_RL_A()\ 
  + size_ORL_A()\
  + size_CLR_BIT()\
  + 2 *size_PUSH_REG()\
  + size_CLR_A()\
)
    asm_CJNE_R7(0x20, size_SJMP() - 1),//mov a,R7
    asm_MOV_A(0xEF),//mov a,0xef//
    asm_JNC(lable__HotASM_ISR__Exit),//非法软中断号>(0~0x1f)
    asm_RL_A(),
    asm_RL_A(),
    asm_RL_A(),
    asm_ORL_A(0x03),
    asm_CLR_ACC_2(),
    asm_PUSH_ACC(),//压入中断地址低8位
    asm_CLR_A(),
    asm_PUSH_ACC(),//压入中断地址高8位
//lable__HotASM_ISR__Exit:
    asm_RET()//跳入对应的中断地址 isrNum * 8 + 3
};


code const IHotAsmCom_Interface comFunction =//物理分配的COM接口
{
//装配函数 void START(void);
    (pHotAsmFunction)__HotASM_START__,//
//装配函数 void RESET(void);
    (pHotAsmFunction)__HotASM_RESET__,//
//装配函数 void ISR(unsigned char);
    (pHotAsm_uchar_Function)__HotASM_ISR__,//
};


#include "hottask51.h"

#ifndef __HOTCOM_H__
#define __HOTCOM_H__
#ifdef __cplusplus
extern "C"
{
#endif
//-------- <<< Use Configuration Wizard in Context Menu >>> -----------------


/*--------------------------------------
    HotTask51汇编数组调用函数接口定义
--------------------------------------*/
#define interface typedef struct//COM接口定义


typedef void (*pHotAsmFunction)(void);//函数指针
typedef void (*pHotAsm_uchar_Function)(unsigned char);//函数指针

/*--------------------------------------------
         声明外部“汇编数组函数”
--------------------------------------------*/
extern_HotASM(__HotASM_START__);
extern_HotASM(__HotASM_RESET__);
extern_HotASM(__HotASM_ISR__);

/*--------------------------------------------
         定义COM接口
--------------------------------------------*/
//com函数指针表
interface
{
//声明函数 void START(void);
    const void (*START)(void);
//声明函数 void RESET(void);
    const void (*RESET)(void);
//声明函数 void ISR(unsigned char);
    const void (*ISR)(unsigned char);
}IHotAsmCom_Vtbl_Interface, *pIHotAsmCom_Vtbl_Interface;

//com函数调用的com接口
interface
{
    const IHotAsmCom_Vtbl_Interface Vtbl;//com函数指针表
}IHotAsmCom_Interface, *pIHotAsmCom_Interface;


/*--------------------------------------------
         声明COM接口
--------------------------------------------*/
//最好在最后声明
extern code const IHotAsmCom_Interface comFunction;

//------------- <<< end of configuration section >>> -----------------------
#ifdef __cplusplus
}
#endif
#endif//__HOTCOM_H__


//main.c
#include "hottask51.h"
#include "hotasm.h"
 
void main()
{
    comFunction.Vtbl.START();
    comFunction.Vtbl.ISR(HOTISR_TF2_VECTOR);//软中断到Timer2Isr()
    comFunction.Vtbl.ISR(0x20);//非法软中断
    comFunction.Vtbl.RESET();
    while(1);
}

相关帖子

沙发
HotC51|  楼主 | 2009-3-2 22:26 | 只看该作者

很黄很暴力的HotAsm.h正在完善(约4000行)

/*--------------------------------------------------------------------------------------------
CLR bit
指令名称:直接寻址位清0指令
指令功能:直接寻址位清0
操作内容:bit←0
字 节 数:2
机器周期:1
--------------------------------------------------------------------------------------------*/
#define size_CLR_BIT()                            2//字 节 数
#define HotASM_Code_CLR_BIT                        (HotASM_REG)0xc2//操作码
#define asm_CLR_BIT(bit)                            HotASM_Code_CLR_BIT, HotASM_BIT(bit)
        #define asm_CLR_REG_X(direct, bit)         HotASM_Code_CLR_BIT, HotASM_REG_X(direct, bit)
        #define asm_CLR_SREG_X(direct, bit)     HotASM_Code_CLR_BIT, HotASM_SREG_X(direct, bit)
            #define asm_CLR_ACC_X(bit)            asm_CLR_SREG_X(HotASM_ACC, bit)
                #define asm_CLR_ACC_0()           asm_CLR_ACC_X(HotASM_Bit0)
                #define asm_CLR_ACC_1()           asm_CLR_ACC_X(HotASM_Bit1)
                #define asm_CLR_ACC_2()           asm_CLR_ACC_X(HotASM_Bit2)
                #define asm_CLR_ACC_3()           asm_CLR_ACC_X(HotASM_Bit3)
                #define asm_CLR_ACC_4()           asm_CLR_ACC_X(HotASM_Bit4)
                #define asm_CLR_ACC_5()           asm_CLR_ACC_X(HotASM_Bit5)
                #define asm_CLR_ACC_6()           asm_CLR_ACC_X(HotASM_Bit6)
                #define asm_CLR_ACC_7()           asm_CLR_ACC_X(HotASM_Bit7)
            #define asm_CLR_B_X(bit)            asm_CLR_SREG_X(HotASM_B, bit)
                #define asm_CLR_B_0()           asm_CLR_B_X(HotASM_Bit0)
                #define asm_CLR_B_1()           asm_CLR_B_X(HotASM_Bit1)
                #define asm_CLR_B_2()           asm_CLR_B_X(HotASM_Bit2)
                #define asm_CLR_B_3()           asm_CLR_B_X(HotASM_Bit3)
                #define asm_CLR_B_4()           asm_CLR_B_X(HotASM_Bit4)
                #define asm_CLR_B_5()           asm_CLR_B_X(HotASM_Bit5)
                #define asm_CLR_B_6()           asm_CLR_B_X(HotASM_Bit6)
                #define asm_CLR_B_7()           asm_CLR_B_X(HotASM_Bit7)
            #define asm_CLR_PSW_X(bit)            asm_CLR_SREG_X(HotASM_PSW, bit)
                #define asm_CLR_PSW_0()           asm_CLR_PSW_X(HotASM_Bit0)
                #define asm_CLR_PSW_1()           asm_CLR_PSW_X(HotASM_Bit1)
                #define asm_CLR_PSW_2()           asm_CLR_PSW_X(HotASM_Bit2)
                #define asm_CLR_PSW_3()           asm_CLR_PSW_X(HotASM_Bit3)
                #define asm_CLR_PSW_4()           asm_CLR_PSW_X(HotASM_Bit4)
                #define asm_CLR_PSW_5()           asm_CLR_PSW_X(HotASM_Bit5)
                #define asm_CLR_PSW_6()           asm_CLR_PSW_X(HotASM_Bit6)
                #define asm_CLR_PSW_7()           asm_CLR_PSW_X(HotASM_Bit7)
                    #define asm_CLR_PSW_P()       asm_CLR_PSW_0()
                    #define asm_CLR_PSW_F1()      asm_CLR_PSW_1()
                    #define asm_CLR_PSW_OV()      asm_CLR_PSW_2()
                    #define asm_CLR_PSW_RS0()      asm_CLR_PSW_3()
                    #define asm_CLR_PSW_RS1()      asm_CLR_PSW_4()
                    #define asm_CLR_PSW_F0()       asm_CLR_PSW_5()
                    #define asm_CLR_PSW_AC()       asm_CLR_PSW_6()
                    #define asm_CLR_PSW_CY()       asm_CLR_PSW_7()
                    #define asm_CLR_PSW_C()       asm_CLR_PSW_CY()
                        #define asm_CLR_P()       asm_CLR_PSW_P()
                        #define asm_CLR_F1()      asm_CLR_PSW_F1()
                        #define asm_CLR_OV()      asm_CLR_PSW_OV()
                        #define asm_CLR_RS0()      asm_CLR_PSW_RS0()
                        #define asm_CLR_RS1()      asm_CLR_PSW_RS1()
                        #define asm_CLR_F0()       asm_CLR_PSW_F0()
                        #define asm_CLR_AC()       asm_CLR_PSW_AC()
                        #define asm_CLR_CY()       asm_CLR_PSW_CY()
            #define asm_CLR_IP_X(bit)            asm_CLR_SREG_X(HotASM_IP, bit)
                #define asm_CLR_IP_0()           asm_CLR_IP_X(HotASM_Bit0)
                #define asm_CLR_IP_1()           asm_CLR_IP_X(HotASM_Bit1)
                #define asm_CLR_IP_2()           asm_CLR_IP_X(HotASM_Bit2)
                #define asm_CLR_IP_3()           asm_CLR_IP_X(HotASM_Bit3)
                #define asm_CLR_IP_4()           asm_CLR_IP_X(HotASM_Bit4)
                #define asm_CLR_IP_5()           asm_CLR_IP_X(HotASM_Bit5)
                #define asm_CLR_IP_6()           asm_CLR_IP_X(HotASM_Bit6)
                #define asm_CLR_IP_7()           asm_CLR_IP_X(HotASM_Bit7)
                    #define asm_CLR_IP_PX0()       asm_CLR_IP_0()
                    #define asm_CLR_IP_PT0()       asm_CLR_IP_1()
                    #define asm_CLR_IP_PX1()       asm_CLR_IP_2()
                    #define asm_CLR_IP_PT1()       asm_CLR_IP_3()
                    #define asm_CLR_IP_PS()       asm_CLR_IP_4()
                    #define asm_CLR_IP_PT2()       asm_CLR_IP_5()
                        #define asm_CLR_PX0()   asm_CLR_IP_PX0()
                        #define asm_CLR_PT0()   asm_CLR_IP_PT0()
                        #define asm_CLR_PX1()   asm_CLR_IP_PX1()
                        #define asm_CLR_PT1()   asm_CLR_IP_PT1()
                        #define asm_CLR_PS()       asm_CLR_IP_PS()
                        #define asm_CLR_PT2()   asm_CLR_IP_PT2()
            #define asm_CLR_IE_X(bit)            asm_CLR_SREG_X(HotASM_IE, bit)
                #define asm_CLR_IE_0()           asm_CLR_IE_X(HotASM_Bit0)
                #define asm_CLR_IE_1()           asm_CLR_IE_X(HotASM_Bit1)
                #define asm_CLR_IE_2()           asm_CLR_IE_X(HotASM_Bit2)
                #define asm_CLR_IE_3()           asm_CLR_IE_X(HotASM_Bit3)
                #define asm_CLR_IE_4()           asm_CLR_IE_X(HotASM_Bit4)
                #define asm_CLR_IE_5()           asm_CLR_IE_X(HotASM_Bit5)
                #define asm_CLR_IE_6()           asm_CLR_IE_X(HotASM_Bit6)
                #define asm_CLR_IE_7()           asm_CLR_IE_X(HotASM_Bit7)
                    #define asm_CLR_IE_EX0()       asm_CLR_IE_0()
                    #define asm_CLR_IE_ET0()       asm_CLR_IE_1()
                    #define asm_CLR_IE_EX1()       asm_CLR_IE_2()
                    #define asm_CLR_IE_ET1()       asm_CLR_IE_3()
                    #define asm_CLR_IE_ES()       asm_CLR_IE_4()
                    #define asm_CLR_IE_ET2()       asm_CLR_IE_5()
                    #define asm_CLR_IE_EA()       asm_CLR_IE_7()
                        #define asm_CLR_EX0()   asm_CLR_IE_EX0()
                        #define asm_CLR_ET0()   asm_CLR_IE_ET0()
                        #define asm_CLR_EX1()   asm_CLR_IE_EX1()
                        #define asm_CLR_ET1()   asm_CLR_IE_ET1()
                        #define asm_CLR_ES()       asm_CLR_IE_ES()
                        #define asm_CLR_ET2()   asm_CLR_IE_ET2()
                        #define asm_CLR_EA()       asm_CLR_IE_EA()
            #define asm_CLR_TCON_X(bit)            asm_CLR_SREG_X(HotASM_TCON, bit)
                #define asm_CLR_TCON_0()           asm_CLR_TCON_X(HotASM_Bit0)
                #define asm_CLR_TCON_1()           asm_CLR_TCON_X(HotASM_Bit1)
                #define asm_CLR_TCON_2()           asm_CLR_TCON_X(HotASM_Bit2)
                #define asm_CLR_TCON_3()           asm_CLR_TCON_X(HotASM_Bit3)
                #define asm_CLR_TCON_4()           asm_CLR_TCON_X(HotASM_Bit4)
                #define asm_CLR_TCON_5()           asm_CLR_TCON_X(HotASM_Bit5)
                #define asm_CLR_TCON_6()           asm_CLR_TCON_X(HotASM_Bit6)
                #define asm_CLR_TCON_7()           asm_CLR_TCON_X(HotASM_Bit7)
            #define asm_CLR_T2CON_X(bit)        asm_CLR_SREG_X(HotASM_T2CON, bit)
                #define asm_CLR_T2CON_0()       asm_CLR_T2CON_X(HotASM_Bit0)
                #define asm_CLR_T2CON_1()       asm_CLR_T2CON_X(HotASM_Bit1)
                #define asm_CLR_T2CON_2()       asm_CLR_T2CON_X(HotASM_Bit2)
                #define asm_CLR_T2CON_3()       asm_CLR_T2CON_X(HotASM_Bit3)
                #define asm_CLR_T2CON_4()       asm_CLR_T2CON_X(HotASM_Bit4)
                #define asm_CLR_T2CON_5()       asm_CLR_T2CON_X(HotASM_Bit5)
                #define asm_CLR_T2CON_6()       asm_CLR_T2CON_X(HotASM_Bit6)
                #define asm_CLR_T2CON_7()       asm_CLR_T2CON_X(HotASM_Bit7)
            #define asm_CLR_SCON_X(bit)            asm_CLR_SREG_X(HotASM_SCON, bit)
                #define asm_CLR_SCON_0()           asm_CLR_SCON_X(HotASM_Bit0)
                #define asm_CLR_SCON_1()           asm_CLR_SCON_X(HotASM_Bit1)
                #define asm_CLR_SCON_2()           asm_CLR_SCON_X(HotASM_Bit2)
                #define asm_CLR_SCON_3()           asm_CLR_SCON_X(HotASM_Bit3)
                #define asm_CLR_SCON_4()           asm_CLR_SCON_X(HotASM_Bit4)
                #define asm_CLR_SCON_5()           asm_CLR_SCON_X(HotASM_Bit5)
                #define asm_CLR_SCON_6()           asm_CLR_SCON_X(HotASM_Bit6)
                #define asm_CLR_SCON_7()           asm_CLR_SCON_X(HotASM_Bit7)
        #define asm_CLR_Pn_X(Pn, bit)           HotASM_Code_CLR_BIT, HotASM_Pn_X(Pn, bit)
            #define asm_CLR_P0_X(bit)           asm_CLR_Pn_X(HotASM_Port0, bit)
                #define asm_CLR_P0_0()           asm_CLR_P0_X(HotASM_Bit0)
                #define asm_CLR_P0_1()           asm_CLR_P0_X(HotASM_Bit1)
                #define asm_CLR_P0_2()           asm_CLR_P0_X(HotASM_Bit2)
                #define asm_CLR_P0_3()           asm_CLR_P0_X(HotASM_Bit3)
                #define asm_CLR_P0_4()           asm_CLR_P0_X(HotASM_Bit4)
                #define asm_CLR_P0_5()           asm_CLR_P0_X(HotASM_Bit5)
                #define asm_CLR_P0_6()           asm_CLR_P0_X(HotASM_Bit6)
                #define asm_CLR_P0_7()           asm_CLR_P0_X(HotASM_Bit7)
            #define asm_CLR_P1_X(bit)           asm_CLR_Pn_X(HotASM_Port1, bit)
                #define asm_CLR_P1_0()           asm_CLR_P1_X(HotASM_Bit0)
                #define asm_CLR_P1_1()           asm_CLR_P1_X(HotASM_Bit1)
                #define asm_CLR_P1_2()           asm_CLR_P1_X(HotASM_Bit2)
                #define asm_CLR_P1_3()           asm_CLR_P1_X(HotASM_Bit3)
                #define asm_CLR_P1_4()           asm_CLR_P1_X(HotASM_Bit4)
                #define asm_CLR_P1_5()           asm_CLR_P1_X(HotASM_Bit5)
                #define asm_CLR_P1_6()           asm_CLR_P1_X(HotASM_Bit6)
                #define asm_CLR_P1_7()           asm_CLR_P1_X(HotASM_Bit7)
            #define asm_CLR_P2_X(bit)           asm_CLR_Pn_X(HotASM_Port2, bit)
                #define asm_CLR_P2_0()           asm_CLR_P2_X(HotASM_Bit0)
                #define asm_CLR_P2_1()           asm_CLR_P2_X(HotASM_Bit1)
                #define asm_CLR_P2_2()           asm_CLR_P2_X(HotASM_Bit2)
                #define asm_CLR_P2_3()           asm_CLR_P2_X(HotASM_Bit3)
                #define asm_CLR_P2_4()           asm_CLR_P2_X(HotASM_Bit4)
                #define asm_CLR_P2_5()           asm_CLR_P2_X(HotASM_Bit5)
                #define asm_CLR_P2_6()           asm_CLR_P2_X(HotASM_Bit6)
                #define asm_CLR_P2_7()           asm_CLR_P2_X(HotASM_Bit7)
            #define asm_CLR_P3_X(bit)           asm_CLR_Pn_X(HotASM_Port3, bit)
                #define asm_CLR_P3_0()           asm_CLR_P3_X(HotASM_Bit0)
                #define asm_CLR_P3_1()           asm_CLR_P3_X(HotASM_Bit1)
                #define asm_CLR_P3_2()           asm_CLR_P3_X(HotASM_Bit2)
                #define asm_CLR_P3_3()           asm_CLR_P3_X(HotASM_Bit3)
                #define asm_CLR_P3_4()           asm_CLR_P3_X(HotASM_Bit4)
                #define asm_CLR_P3_5()           asm_CLR_P3_X(HotASM_Bit5)
                #define asm_CLR_P3_6()           asm_CLR_P3_X(HotASM_Bit6)
                #define asm_CLR_P3_7()           asm_CLR_P3_X(HotASM_Bit7)

使用特权

评论回复
板凳
HotC51|  楼主 | 2009-3-2 22:30 | 只看该作者

1.comFunction.Vtbl.START()内藏有多少秘密,暴力在何处???

/*---------------------------------------------
    HotTask51系统启动函数
    void __HotASM_START__(void)
入口: 无
      Keil DPTR = &__HotASM_START__[0]
           R2D1 = DPTR
出口: 无
结果: 二次RETI后继续执行
特点: 本“函数”可以“动态加载”
-----------------------------------------------*/
HotASM (__HotASM_START__)//(void)
{//DPTR保存的是汇编数组函数的首地址__HotASM_START__
#define lable__HotASM_START__Exit \
(\
    size_CLR_A()\
  + size_MOV_REG_A()\
  + size_JZ()\
  + size_LJMP()\
  + 2 * size_MOV_A_REG()\
  + 2 * size_ADD_A()\
  + 2 * size_PUSH_REG()\
)
    asm_CLR_A(),
    asm_MOV_IE_A(),//关中断
    asm_JZ(size_LJMP() - 1),//NOP()
    asm_LJMP(0x5500),//
    asm_MOV_A_DPL(),
    asm_ADD_A(lable__HotASM_START__Exit),//__HotASM_START__0
    asm_PUSH_ACC(),//压入跳入地址__HotASM_START__0低8位
    asm_MOV_A_DPH(),//
    asm_ADDC_A(0),
    asm_PUSH_ACC(),//压入跳入地址__HotASM_START__0高8位
//lable__HotASM_START__Exit:
    asm_RETI()//(连续调用RETI二次)
};

使用特权

评论回复
地板
HotC51|  楼主 | 2009-3-2 22:31 | 只看该作者

2.comFunction.Vtbl.ISR()暗藏什么杀机???

/*---------------------------------------------
    HotTask51软中断函数
    void __HotASM_ISR__(unsigned char isrNum)
入口: R7   D4D3 中断向量组号  D2D1D0 中断向量号
出口: R7   isrNum
结果: 跳入对应的中断地址 isrNum * 8 + 3
-----------------------------------------------*/
HotASM (__HotASM_ISR__)//(unsigned char isrNum)
{//DPTR保存的是汇编数组函数的首地址__HotASM_ISR__
#define lable__HotASM_ISR__Exit \
(\
  + 3 * size_RL_A()\ 
  + size_ORL_A()\
  + size_CLR_BIT()\
  + 2 *size_PUSH_REG()\
  + size_CLR_A()\
)
    asm_CJNE_R7(0x20, size_SJMP() - 1),//mov a,R7
    asm_MOV_A(0xEF),//mov a,0xef//
    asm_JNC(lable__HotASM_ISR__Exit),//非法软中断号>(0~0x1f)
    asm_RL_A(),
    asm_RL_A(),
    asm_RL_A(),
    asm_ORL_A(0x03),
    asm_CLR_ACC_2(),
    asm_PUSH_ACC(),//压入中断地址低8位
    asm_CLR_A(),
    asm_PUSH_ACC(),//压入中断地址高8位
//lable__HotASM_ISR__Exit:
    asm_RET()//跳入对应的中断地址 isrNum * 8 + 3
};

使用特权

评论回复
5
HotC51|  楼主 | 2009-3-3 07:25 | 只看该作者

3.comFunction.Vtbl.RESET()有什么奇怪的???

/*---------------------------------------------
    HotTask51软件复位函数
    void __HotASM_RESET__(void)
入口: 无
      Keil DPTR = &__HotASM_RESET__[0]
           R2D1 = DPTR
出口: 无
结果: 二次RETI后跳入0x0000
特点: 本“函数”可以“动态加载”
-----------------------------------------------*/
HotASM (__HotASM_RESET__)//(void)
{//DPTR保存的是汇编数组函数的首地址__HotASM_RESET__
#define lable__HotASM_RESET__Exit \
(\
    size_CLR_A()\
  + size_MOV_REG_A()\
  + size_JZ()\
  + size_LJMP()\
  + 2 * size_MOV_A_REG()\
  + 2 * size_ADD_A()\
  + 2 * size_PUSH_REG()\
  + size_RETI()\
)
    asm_CLR_A(),
    asm_MOV_IE_A(),//关中断
    asm_JZ(size_LJMP() - 1),//NOP()
    asm_LJMP(0xaa00),//
    asm_MOV_A_DPL(),
    asm_ADD_A(lable__HotASM_RESET__Exit),//lable__HotASM_RESET__0
    asm_PUSH_ACC(),//压入跳入地址lable__HotASM_RESET__0低8位
    asm_MOV_A_DPH(),//
    asm_ADDC_A(0),
    asm_PUSH_ACC(),//压入跳入地址lable__HotASM_RESET__0高8位
    asm_RETI(),//顺序执行下句!!!(调用RETI)
//lable__HotASM_RESET__Exit:
    asm_CLR_A(),
    asm_PUSH_ACC(),//压入复位地址低8位
    asm_PUSH_ACC(),//压入复位地址高8位
    asm_RETI()//跳入复位地址处
};

使用特权

评论回复
6
HotC51|  楼主 | 2009-3-3 07:42 | 只看该作者

感谢苍天没收俺走~~~8个小时后俺有回到人间~~~

HotC51 发表于 2009-3-2 22:31 侃单片机 ←返回版面    

4楼: 2.comFunction.Vtbl.ISR()暗藏什么杀机??? 

 
HotC51 发表于 2009-3-3 07:25 侃单片机 ←返回版面    

5楼: 3.comFunction.Vtbl.RESET()有什么奇怪的??? 

 

使用特权

评论回复
7
xwj| | 2009-3-3 07:51 | 只看该作者

这就叫眼睛一闭,再一睁开,一天就过去了

如果眼睛一闭,不睁,那一辈子就过去了

使用特权

评论回复
8
xwj| | 2009-3-3 07:58 | 只看该作者

唉,不看则已,一看...

老hot,.COM技术可不是这么封装的哦

使用特权

评论回复
9
zusen| | 2009-3-3 09:22 | 只看该作者

晕了

不看

使用特权

评论回复
10
huangqi412| | 2009-3-3 09:25 | 只看该作者

老x没晕,,,可以当学生会的了

使用特权

评论回复
11
李冬发| | 2009-3-3 10:39 | 只看该作者

真的是晕了,大量的_asm_...怎么移植?

使用特权

评论回复
12
HotC51|  楼主 | 2009-3-3 10:58 | 只看该作者

俺把COM接口改了,这样更适应与MCU~~~人是活的,规则是死的

使用特权

评论回复
13
HotC51|  楼主 | 2009-3-3 11:11 | 只看该作者

俺看还是等邓苗同志吧~~~他比俺还晕~~~

使用特权

评论回复
14
xsl.| | 2009-3-3 12:47 | 只看该作者

人是活的,规则是死的

半死也算是活的

使用特权

评论回复
15
mohanwei| | 2009-3-3 13:20 | 只看该作者

mohanwei到此一游……

使用特权

评论回复
16
原野之狼| | 2009-3-6 01:00 | 只看该作者

顶一下!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

36

主题

306

帖子

0

粉丝