中级会员
- 积分
- 355
- 威望
- 272
- 贡献
- 73
- 兑换币
- 0
- 注册时间
- 2011-1-11
- 在线时间
- 5 小时
|
#include "hidef.h"
#include "non_bank.sgm"
#include "runtime.sgm"
#ifndef __HCS12X__/
#if defined(HCS12) || defined(_HCS12) || defined(__HCS12__)
#define PPAGE_ADDR (0x30+REGISTER_BASE)
#ifndef __PPAGE__
#define __PPAGE__
#endif
#elif defined DG128
#define PPAGE_ADDR (0xFF+REGISTER_BASE)
#ifndef __PPAGE__
#define __PPAGE__
#endif
#elif defined(HC812A4)
#endif
#if !defined(__EPAGE__) && !defined(__PPAGE__) && !defined(__DPAGE__)
/* as default use all page registers */
#define __DPAGE__
#define __EPAGE__
#define __PPAGE__
#endif
#define EPAGE_LOW_BOUND 0x400u
#define EPAGE_HIGH_BOUND 0x7ffu
#define DPAGE_LOW_BOUND 0x7000u
#define DPAGE_HIGH_BOUND 0x7fffu
#define PPAGE_LOW_BOUND (DPAGE_HIGH_BOUND+1)
#define PPAGE_HIGH_BOUND 0xBFFFu
#define REGISTER_BASE 0x0u
#ifndef DPAGE_ADDR
#define DPAGE_ADDR (0x34u+REGISTER_BASE)
#endif
#ifndef EPAGE_ADDR
#define EPAGE_ADDR (0x36u+REGISTER_BASE)
#endif
#ifndef PPAGE_ADDR
#define PPAGE_ADDR (0x35u+REGISTER_BASE)
#endif
#if EPAGE_LOW_BOUND >= EPAGE_HIGH_BOUND || EPAGE_HIGH_BOUND >= DPAGE_LOW_BOUND || DPAGE_LOW_BOUND >= DPAGE_HIGH_BOUND || DPAGE_HIGH_BOUND >= PPAGE_LOW_BOUND || PPAGE_LOW_BOUND >= PPAGE_HIGH_BOUND
#error
#endif
#if DPAGE_HIGH_BOUND+1 != PPAGE_LOW_BOUND
#error
#endif
--------------------------- _LOAD_FAR_24 ----------------------------------*/
#ifdef __cplusplus
extern "C"
#endif
#pragma NO_ENTRY
#pragma NO_EXIT
#pragma NO_FRAME
void NEAR _LOAD_FAR_24(void) {
#if USE_SEVERAL_PAGES
__asm {
PSHX ;// save X register
__PIC_JSR(_GET_PAGE_REG)
BEQ L_NOPAGE
PSHA ;// save A register
LDAA 0,X ;// save page register
STAB 0,X ;// set page register
LDAB 0,Y ;// actual load, overwrites page of address
LDY 1,Y ;// actual load, overwrites offset of address
STAA 0,X ;// restore page register
PULA ;// restore A register
PULX ;// restore X register
RTS
L_NOPAGE:
LDAB 0,Y ;// actual load, overwrites page of address
LDY 1,Y ;// actual load, overwrites offset of address
PULX ;// restore X register
RTS
}
#else /* USE_SEVERAL_PAGES */
__asm {
PSHA ;// save A register
LDAA PAGE_ADDR ;// save page register
STAB PAGE_ADDR ;// set page register
LDAB 0,Y ;// actual load, overwrites page of address
LDY 1,Y ;// actual load, overwrites offset of address
STAA PAGE_ADDR ;// restore page register
PULA ;// restore A register
RTS
}
#endif /* USE_SEVERAL_PAGES */
}
#ifdef __cplusplus
extern "C"
#endif
#pragma NO_ENTRY
#pragma NO_EXIT
#pragma NO_FRAME
void NEAR _STORE_FAR_24(void) {
#if USE_SEVERAL_PAGES
__asm {
PSHX ;// save X register
__PIC_JSR(_GET_PAGE_REG)
BEQ L_NOPAGE
PSHA
LDAA 0,X ;// save page register
STAB 0,X ;// set page register
MOVW 1,SP, 1,Y ;// store the value passed in X
MOVB 0,SP, 0,Y ;// store the value passed in A
STAA 0,X ;// restore page register
PULA ;// restore A register
PULX ;// restore X register
RTS
L_NOPAGE:
STX 1,Y ;// store the value passed in X
STAA 0,Y ;// store the value passed in X
PULX ;// restore X register
RTS
}
#else /* USE_SEVERAL_PAGES */
__asm {
PSHA ;// save A register
LDAA PAGE_ADDR ;// save page register
STAB PAGE_ADDR ;// set page register
MOVB 0,SP, 0,Y ;// store the value passed in A
STX 1,Y ;// store the value passed in X
STAA PAGE_ADDR ;// restore page register
PULA ;// restore A register
RTS
}
#endif /* USE_SEVERAL_PAGES */
}
#ifdef __cplusplus
extern "C"
#endif
#pragma NO_ENTRY
#pragma NO_EXIT
#pragma NO_FRAME
void NEAR _FAR_COPY_LOGICAL_GLOBAL(void) {
__asm {
STAA __GPAGE_ADR__
PSHX ;// allocate some space where _SET_PAGE_REG_HCS12X can return the page
__PIC_JSR(_SET_PAGE_REG_HCS12X)
Loop: LDAB 1,X+
GSTAB 1,Y+
DECW 4,SP
BNE Loop
PULX
STAA 0,X ;// restore old page content (necessary if it was PPAGE)
LDX 4,SP+ ;// load return address and clean stack
JMP 0,X
}
}
#endif |
|