性无码一区二区三区在线观看,少妇被爽到高潮在线观看,午夜精品一区二区三区,无码中文字幕人妻在线一区二区三区,无码精品国产一区二区三区免费

  • 回復(fù)
  • 收藏
  • 點(diǎn)贊
  • 分享
  • 發(fā)新帖

菜農(nóng)首次發(fā)布HotC51匯編數(shù)組定義頭文件(HotAsm.h V1.01)

HotC51 發(fā)表于 2009-2-22 16:48 侃單片機(jī) ←返回版面    

樓主: HotC51代言首次發(fā)布HotC51匯編數(shù)組定義頭文件(HotAsm.h V1.01)

/*------------------------------------------------------------
    HotC51匯編數(shù)組定義頭文件(HotAsm.h V1.01)
最初建立時(shí)間: 2009.2.18
最近修改時(shí)間: 2009.2.22    (正在添加之中,最終將徹底替代嵌入?yún)R編)
增  添原  因: 為全面支持裸奔式實(shí)時(shí)操作系統(tǒng)HotTask51做準(zhǔn)備
              并替代年代久遠(yuǎn)的HotIns.h/c(不在HotTask51下使用)
應(yīng)        用: 可以用COM接口技術(shù)對(duì)HotC51匯編數(shù)組進(jìn)行封裝
              實(shí)現(xiàn)比嵌入?yún)R編更為靈活和更非典之用,“匯編數(shù)組”的
              出現(xiàn),將程序戰(zhàn)場(chǎng)蔓延至整個(gè)代碼和數(shù)據(jù)區(qū)~~~
--------------------------------------------------------------
    HotTask51匯編數(shù)組調(diào)用函數(shù)庫(kù)(正在添加之中,最后形成“水庫(kù)”)
--------------------------------------------------------------
    第一步:編寫匯編數(shù)組的“匯編代碼” 參見(jiàn)HotIns.h/c
--------------------------------------------------------------
HotASM (__reset_comlib__)[] =
{//應(yīng)該在C文件中編寫
    HotASM_PUSH_DPL(),            
    HotASM_PUSH_DPH(),
    HotASM_RETI(),
    HotASM_CLR_A(),
    HotASM_PUSH_ACC(),            
    HotASM_PUSH_ACC(),
    HotASM_RETI(),
};
--------------------------------------------------------------
    第二步:編寫普通C函數(shù),注意它的名字與調(diào)用關(guān)系不大
--------------------------------------------------------------
void Reset()
{//此法只是演示如何替代HotIns.h/c  
    IE=0;
    DPTR = __reset_comlib__ + 5;
    _icall_(__reset_comlib__);
}
void Start()
{//此法只是演示如何替代HotIns.h/c  
    IE=0;
    PSW=0;
    _icall_(__reset_comlib__ + 4);
    _icall_(__reset_comlib__ + 4);
}
---------------------------------------------------
    第三步:編寫COM接口,填入需要的C函數(shù),
注意它的名稱與調(diào)用次序關(guān)系很大,名稱與調(diào)用關(guān)系不大
最后在HotAsm.h的接口里:
interface
{
    void (*HotAsm_Start)(void);
    void (*HotAsm_Reset)(void);
}IHotCom_AsmVtbl_Interface, *pIHotCom_AsmVtbl_Interface;

則在主程序里的函數(shù)名是asmLib.function.HotAsm_Reset();
----------------------------------------------------------------
IHotCom_Asm_Interface asmLib =//真實(shí)的COM接口
{
    (pHotAsmFunction)Start,//
    (pHotAsmFunction)Reset,
};

#include "hottask51.h"
void main()
{
    asmLib.function.HotAsm_Start();//二次RETI(HotC51將做專題)
    asmLib.function.HotAsm_Reset();//軟件復(fù)位
    HotTaskStart();//此時(shí)任務(wù)永遠(yuǎn)不可能啟動(dòng)
}              
菜農(nóng)HotPower@126.com 2008.2.22 于西安大雁塔村農(nóng)會(huì)授權(quán)HotC51發(fā)布
---------------------------------------------------------------*/


#include
#include
#include

#ifndef __HotASM_H__
#define __HotASM_H__

#ifdef __cplusplus
extern "C"
{
#endif

#include "hottask51.h"http://裸奔之OS系統(tǒng)鏈接頭文件

/*--------------------------------------------
    匯編數(shù)組定義
--------------------------------------------*/
#define HotASM_ARRAY   code unsigned char

/*--------------------------------------------
    匯編數(shù)組成員數(shù)據(jù)類型定義
--------------------------------------------*/
#define HotASM_REG            volatile unsigned char
#define HotASM_IREG            volatile unsigned int
#define HotASM_AREG(reg)    (HotASM_REG)reg
#define HOTASM_LAREG(addr)     (HotASM_REG)addr / 256, (HotASM_REG)addr % 256

/*--------------------------------------------
    匯編數(shù)組"函數(shù)"
--------------------------------------------*/
#define HotASM(name) HotASM_ARRAY (name)

/*--------------------------------------------
    匯編數(shù)組51寄存器定義
--------------------------------------------*/
#define HotASM_REG_P0         (HotASM_REG)0x80
/*--------------------------------------------
    匯編數(shù)組P0寄存器位定義
--------------------------------------------*/
  #define HotASM_BIT_P0_0     (HotASM_REG)0x80
  #define HotASM_BIT_P0_1     (HotASM_REG)0x81
  #define HotASM_BIT_P0_2     (HotASM_REG)0x82
  #define HotASM_BIT_P0_3     (HotASM_REG)0x83
  #define HotASM_BIT_P0_4     (HotASM_REG)0x84
  #define HotASM_BIT_P0_5     (HotASM_REG)0x85
  #define HotASM_BIT_P0_6     (HotASM_REG)0x86
  #define HotASM_BIT_P0_7     (HotASM_REG)0x87
    #define HotASM_REG_SP     (HotASM_REG)0x81
    #define HotASM_REG_DPL    (HotASM_REG)0x82
    #define HotASM_REG_DPH    (HotASM_REG)0x83
    #define HotASM_REG_PCON (HotASM_REG)0x87
/*--------------------------------------------
    匯編數(shù)組PCON寄存器位定義(不能位尋址)
--------------------------------------------*/
  #define HotASM_BIT_PCON_IDL     (HotASM_REG)0x01
  #define HotASM_BIT_PCON_STOP    (HotASM_REG)0x02
  #define HotASM_BIT_PCON_PD    (HotASM_REG)0x03    /* Alternate definition */
  #define HotASM_BIT_PCON_GF0   (HotASM_REG)0x08
  #define HotASM_BIT_PCON_GF1   (HotASM_REG)0x04

  #define HotASM_BIT_PCON_SMOD  (HotASM_REG)0x80
#define HotASM_REG_TCON        (HotASM_REG)0x88
  #define HotASM_BIT_TCON_0        (HotASM_REG)0x88
  #define HotASM_BIT_TCON_1        (HotASM_REG)0x89
  #define HotASM_BIT_TCON_2        (HotASM_REG)0x8A
  #define HotASM_BIT_TCON_3        (HotASM_REG)0x8B
  #define HotASM_BIT_TCON_4        (HotASM_REG)0x8C
  #define HotASM_BIT_TCON_5        (HotASM_REG)0x8D
  #define HotASM_BIT_TCON_6        (HotASM_REG)0x8E
  #define HotASM_BIT_TCON_7        (HotASM_REG)0x8F

  #define HotASM_BIT_TCON_IT0    (HotASM_REG)0x88
  #define HotASM_BIT_TCON_IE0    (HotASM_REG)0x89
  #define HotASM_BIT_TCON_IT1    (HotASM_REG)0x8A
  #define HotASM_BIT_TCON_IE1    (HotASM_REG)0x8B
  #define HotASM_BIT_TCON_TR0    (HotASM_REG)0x8C
  #define HotASM_BIT_TCON_TF0    (HotASM_REG)0x8D
  #define HotASM_BIT_TCON_TR1    (HotASM_REG)0x8E
  #define HotASM_BIT_TCON_TF1    (HotASM_REG)0x8F
#define HotASM_REG_TMOD        (HotASM_REG)0x89
/*--------------------------------------------
    匯編數(shù)組TMOD寄存器位定義(不能位尋址)
--------------------------------------------*/
  #define HotASM_BIT_TMOD_0 (HotASM_REG)0x01
  #define HotASM_BIT_TMOD_1 (HotASM_REG)0x02
  #define HotASM_BIT_TMOD_2 (HotASM_REG)0x04
  #define HotASM_BIT_TMOD_3 (HotASM_REG)0x08
  #define HotASM_BIT_TMOD_4 (HotASM_REG)0x10
  #define HotASM_BIT_TMOD_5 (HotASM_REG)0x20
  #define HotASM_BIT_TMOD_6 (HotASM_REG)0x40
  #define HotASM_BIT_TMOD_7 (HotASM_REG)0x80

    #define HotASM_REG_TL0    (HotASM_REG)0x8a
    #define HotASM_REG_TH0    (HotASM_REG)0x8c
    #define HotASM_REG_TL1    (HotASM_REG)0x8b
    #define HotASM_REG_TH1    (HotASM_REG)0x8d
#define HotASM_REG_P1         (HotASM_REG)0x90
/*--------------------------------------------
    匯編數(shù)組P1寄存器位定義
--------------------------------------------*/
  #define HotASM_BIT_P1_0    (HotASM_REG)0x90
  #define HotASM_BIT_P1_1    (HotASM_REG)0x91
  #define HotASM_BIT_P1_2    (HotASM_REG)0x92
  #define HotASM_BIT_P1_3    (HotASM_REG)0x93
  #define HotASM_BIT_P1_4    (HotASM_REG)0x94
  #define HotASM_BIT_P1_5    (HotASM_REG)0x95
  #define HotASM_BIT_P1_6    (HotASM_REG)0x96
  #define HotASM_BIT_P1_7    (HotASM_REG)0x97
#define HotASM_REG_SCON        (HotASM_REG)0x98
  #define HotASM_BIT_SCON_0 (HotASM_REG)0x98
  #define HotASM_BIT_SCON_1 (HotASM_REG)0x99
  #define HotASM_BIT_SCON_2 (HotASM_REG)0x9A
  #define HotASM_BIT_SCON_3 (HotASM_REG)0x9B
  #define HotASM_BIT_SCON_4 (HotASM_REG)0x9C
  #define HotASM_BIT_SCON_5 (HotASM_REG)0x9D
  #define HotASM_BIT_SCON_6 (HotASM_REG)0x9E
  #define HotASM_BIT_SCON_7 (HotASM_REG)0x9F

  #define HotASM_BIT_SCON_RI     (HotASM_REG)0x98
  #define HotASM_BIT_SCON_TI     (HotASM_REG)0x99
  #define HotASM_BIT_SCON_RB8     (HotASM_REG)0x9A
  #define HotASM_BIT_SCON_TB8     (HotASM_REG)0x9B
  #define HotASM_BIT_SCON_REN     (HotASM_REG)0x9C
  #define HotASM_BIT_SCON_SM2     (HotASM_REG)0x9D
  #define HotASM_BIT_SCON_SM1     (HotASM_REG)0x9E
  #define HotASM_BIT_SCON_SM0     (HotASM_REG)0x9F
#define HotASM_REG_SBUF        (HotASM_REG)0x99
#define HotASM_REG_P2         (HotASM_REG)0xa0
/*--------------------------------------------
    匯編數(shù)組P2寄存器位定義
--------------------------------------------*/
  #define HotASM_BIT_P2_0    (HotASM_REG)0xa0
  #define HotASM_BIT_P2_1    (HotASM_REG)0xa1
  #define HotASM_BIT_P2_2    (HotASM_REG)0xa2
  #define HotASM_BIT_P2_3    (HotASM_REG)0xa3
  #define HotASM_BIT_P2_4    (HotASM_REG)0xa4
  #define HotASM_BIT_P2_5    (HotASM_REG)0xa5
  #define HotASM_BIT_P2_6    (HotASM_REG)0xa6
  #define HotASM_BIT_P2_7    (HotASM_REG)0xa7
#define HotASM_REG_IE        (HotASM_REG)0xa8
  #define HotASM_BIT_IE0    (HotASM_REG)0xa8
  #define HotASM_BIT_IE1    (HotASM_REG)0xa9
  #define HotASM_BIT_IE2    (HotASM_REG)0xaa
  #define HotASM_BIT_IE3    (HotASM_REG)0xab
  #define HotASM_BIT_IE4    (HotASM_REG)0xac
  #define HotASM_BIT_IE5    (HotASM_REG)0xad
  #define HotASM_BIT_IE6    (HotASM_REG)0xae
  #define HotASM_BIT_IE7    (HotASM_REG)0xaf

  #define HotASM_BIT_EX0    (HotASM_REG)0xa8
  #define HotASM_BIT_ET0    (HotASM_REG)0xa9
  #define HotASM_BIT_EX1    (HotASM_REG)0xaa
  #define HotASM_BIT_ET1    (HotASM_REG)0xab
  #define HotASM_BIT_ES        (HotASM_REG)0xac
  #define HotASM_BIT_ET2    (HotASM_REG)0xad
//  #define HotASM_BIT_IE6    (HotASM_REG)0xae
  #define HotASM_BIT_EA        (HotASM_REG)0xaf
#define HotASM_REG_P3         (HotASM_REG)0xb0
/*--------------------------------------------
    匯編數(shù)組P3寄存器位定義
--------------------------------------------*/
  #define HotASM_BIT_P3_0    (HotASM_REG)0xb0
  #define HotASM_BIT_P3_1    (HotASM_REG)0xb1
  #define HotASM_BIT_P3_2    (HotASM_REG)0xb2
  #define HotASM_BIT_P3_3    (HotASM_REG)0xb3
  #define HotASM_BIT_P3_4    (HotASM_REG)0xb4
  #define HotASM_BIT_P3_5    (HotASM_REG)0xb5
  #define HotASM_BIT_P3_6    (HotASM_REG)0xb6
  #define HotASM_BIT_P3_7    (HotASM_REG)0xb7
#define HotASM_REG_IP         (HotASM_REG)0xb8
  #define HotASM_BIT_IP_0    (HotASM_REG)0xb8
  #define HotASM_BIT_IP_1    (HotASM_REG)0xb9
  #define HotASM_BIT_IP_2    (HotASM_REG)0xba
  #define HotASM_BIT_IP_3    (HotASM_REG)0xbb
  #define HotASM_BIT_IP_4    (HotASM_REG)0xbc
  #define HotASM_BIT_IP_5    (HotASM_REG)0xbd
  #define HotASM_BIT_IP_6    (HotASM_REG)0xbe
  #define HotASM_BIT_IP_7    (HotASM_REG)0xbf
#define HotASM_REG_PSW        (HotASM_REG)0xd0
  #define HotASM_BIT_PSW_0    (HotASM_REG)0xd0
  #define HotASM_BIT_PSW_1    (HotASM_REG)0xd1
  #define HotASM_BIT_PSW_2    (HotASM_REG)0xd2
  #define HotASM_BIT_PSW_3    (HotASM_REG)0xd3
  #define HotASM_BIT_PSW_4    (HotASM_REG)0xd4
  #define HotASM_BIT_PSW_5    (HotASM_REG)0xd5
  #define HotASM_BIT_PSW_6    (HotASM_REG)0xd6
  #define HotASM_BIT_PSW_7    (HotASM_REG)0xd7

  #define HotASM_BIT_PSW_PX0    (HotASM_REG)0xd0
  #define HotASM_BIT_PSW_PT0    (HotASM_REG)0xd1
  #define HotASM_BIT_PSW_PX1    (HotASM_REG)0xd2
  #define HotASM_BIT_PSW_PT1    (HotASM_REG)0xd3
  #define HotASM_BIT_PSW_PS        (HotASM_REG)0xd4
  #define HotASM_BIT_PSW_PT2    (HotASM_REG)0xd5
//  #define HotASM_BIT_PSW_6        (HotASM_REG)0xd6
//  #define HotASM_BIT_PSW_7        (HotASM_REG)0xd7

  #define HotASM_BIT_PSW_P        (HotASM_REG)0xd0
  #define HotASM_BIT_PSW_F1        (HotASM_REG)0xd1
  #define HotASM_BIT_PSW_OV        (HotASM_REG)0xd2
  #define HotASM_BIT_PSW_RS0    (HotASM_REG)0xd3
  #define HotASM_BIT_PSW_RS1     (HotASM_REG)0xd4
  #define HotASM_BIT_PSW_F0        (HotASM_REG)0xd5
  #define HotASM_BIT_PSW_AC        (HotASM_REG)0xd6
  #define HotASM_BIT_PSW_C        (HotASM_REG)0xd7
#define HotASM_REG_T2CON    (HotASM_REG)0xc8
    #define HotASM_REG_TH2    (HotASM_REG)0xcd
    #define HotASM_REG_TL2    (HotASM_REG)0xcc
    #define HotASM_REG_RCAP2H    (HotASM_REG)0xcb
    #define HotASM_REG_RCAP2L    (HotASM_REG)0xca
#define HotASM_REG_ACC         (HotASM_REG)0xe0
/*--------------------------------------------
    匯編數(shù)組ACC寄存器位定義
--------------------------------------------*/
  #define HotASM_BIT_ACC_0    (HotASM_REG)0xe0
  #define HotASM_BIT_ACC_1    (HotASM_REG)0xe1
  #define HotASM_BIT_ACC_2    (HotASM_REG)0xe2
  #define HotASM_BIT_ACC_3    (HotASM_REG)0xe3
  #define HotASM_BIT_ACC_4    (HotASM_REG)0xe4
  #define HotASM_BIT_ACC_5    (HotASM_REG)0xe5
  #define HotASM_BIT_ACC_6    (HotASM_REG)0xe6
  #define HotASM_BIT_ACC_7    (HotASM_REG)0xe7
#define HotASM_REG_B         (HotASM_REG)0xf0
/*--------------------------------------------
    匯編數(shù)組B寄存器位定義
--------------------------------------------*/
  #define HotASM_BIT_B_0    (HotASM_REG)0xf0
  #define HotASM_BIT_B_1    (HotASM_REG)0xf1
  #define HotASM_BIT_B_2    (HotASM_REG)0xf2
  #define HotASM_BIT_B_3    (HotASM_REG)0xf3
  #define HotASM_BIT_B_4    (HotASM_REG)0xf4
  #define HotASM_BIT_B_5    (HotASM_REG)0xf5
  #define HotASM_BIT_B_6    (HotASM_REG)0xf6
  #define HotASM_BIT_B_7    (HotASM_REG)0xf7
/*--------------------------------------------
    匯編宏指令操作碼定義
--------------------------------------------*/

#define HotASM_Code_LJMP     (HotASM_REG)0x02
#define HotASM_Code_SJMP     (HotASM_REG)0x80

#define HotASM_Code_LCALL     (HotASM_REG)0x12


#define HotASM_Code_PUSH     (HotASM_REG)0xc0
#define HotASM_Code_INC      (HotASM_REG)0x05
#define HotASM_Code_DEC      (HotASM_REG)0x15

#define HotASM_Code_MOV_DPTR     (HotASM_REG)0x90

/*--------------------------------------------
    匯編宏指令
--------------------------------------------*/
#define HotASM_NOP()               (HotASM_REG)0x00
#define HotASM_RR_A()           (HotASM_REG)0x03
#define HotASM_INC_A()           (HotASM_REG)0x04

#define HotASM_CLR_A()           (HotASM_REG)0xe4

#define HotASM_RET()               (HotASM_REG)0x22
#define HotASM_RETI()           (HotASM_REG)0x32

#define HotASM_MOV_DPTR(addr)     HotASM_Code_MOV_DPTR, HOTASM_LAREG(addr)

#define HotASM_LJMP(addr)         HotASM_Code_LJMP, HOTASM_LAREG(addr)

#define HotASM_LCALL(addr)         HotASM_Code_LCALL, HOTASM_LAREG(addr)
                          
#define HotASM_PUSH_(reg)         HotASM_Code_PUSH, HotASM_AREG(reg)

#define HotASM_PUSH_PSW()         HotASM_Code_PUSH, HotASM_REG_PSW
#define HotASM_PUSH_ACC()         HotASM_Code_PUSH, HotASM_REG_ACC
#define HotASM_PUSH_B()         HotASM_Code_PUSH, HotASM_REG_B
#define HotASM_PUSH_DPL()         HotASM_Code_PUSH, HotASM_REG_DPL
#define HotASM_PUSH_DPH()         HotASM_Code_PUSH, HotASM_REG_DPH


#define HotASM_Code_INC_(reg)     HotASM_Code_INC,HotASM_AREG(reg)
    #define HotASM_INC_SP()     HotASM_Code_INC, HotASM_REG_SP
#define HotASM_Code_DEC_(reg)     HotASM_Code_DEC,HotASM_AREG(reg)
    #define HotASM_DEC_SP()     HotASM_Code_DEC, HotASM_REG_SP

/*--------------------------------------
    HotTask51匯編數(shù)組調(diào)用函數(shù)接口定義
--------------------------------------*/
#define interface typedef struct//COM接口定義

typedef void (*pHotAsmFunction)(void);//函數(shù)指針

interface
{
    void (*HotAsm_Start)(void);
    void (*HotAsm_Reset)(void);
}IHotCom_AsmVtbl_Interface, *pIHotCom_AsmVtbl_Interface;

interface
{
    IHotCom_AsmVtbl_Interface function;
}IHotCom_Asm_Interface, *pIHotCom_Asm_Interface;

extern IHotCom_Asm_Interface asmLib;

extern HotASM_ARRAY (__reset_comlib__)[];

/*--------------------------------------
    HotTask51匯編數(shù)組存放任務(wù)表定義
--------------------------------------*/
//extern HotASM_ARRAY HotTaskTable0[];
//extern HotASM_ARRAY HotTaskTable1[];


#ifdef __cplusplus
}
#endif
#endif//__HotASM_H__
全部回復(fù)(0)
正序查看
倒序查看
現(xiàn)在還沒(méi)有回復(fù)呢,說(shuō)說(shuō)你的想法
發(fā)