?? banksm59128.lst
字號(hào):
716 ?BANK?SELECT SEGMENT CODE
717 ?BANK?DATA SEGMENT DATA
---- 718 RSEG ?BANK?DATA
0000 719 ?B_CURRENTBANK: DS 1
720
721 BANK MACRO N
722 PUBLIC ?B_BANK&N
723 ?B_BANK&N:
724 PUSH ?B_CURRENTBANK
725 MOV A,#HIGH ?BANK?SWITCH
726 PUSH ACC
727 PUSH DPL
728 PUSH DPH
729 ENDM
730
731 SWITCH MACRO N
732 PUBLIC ?B_SWITCH&N
733 IF (LONG_MACRO = 1)
734 ?B_SWITCHJ&N:
735 ELSE
736 ?B_SWITCH&N:
737 ENDIF
738 MOV ?B_CURRENTBANK,#LOW ?B_SWITCH&N
739 SWITCH&N
740 RET
741 ENDM
742
ENDIF
749
750 ?BANK?SWITCH SEGMENT CODE PAGE
751
---- 752 RSEG ?BANK?SWITCH
0000 753 B_SWITCH_START EQU $
754
ENDIF
764
765
766 ; Generate ?B_SWITCHn functions
0000 767 CNT SET 0
768
769 REPT ?B_NBANKS
770 BANK %CNT
771 SWITCH %CNT
772 CNT SET CNT+1
773 ENDM
774+1 BANK %CNT
782+1 SWITCH %CNT
794+1 BANK %CNT
802+1 SWITCH %CNT
814
0022 815 B_SWITCH_SIZE EQU $-B_SWITCH_START
816
ENDIF
820
A51 MACRO ASSEMBLER BANKSM59128 12/11/2006 09:13:36 PAGE 5
821 ENDIF ; close block IF ?B_MODE = 4 *******************************************
822
---- 823 RSEG ?BANK?SELECT
824
825 ;************************ SWITCHBANK FUNCTION *******************************
826 ; *
827 ; SWITCHBANK allows use of bank-switching for C programs *
828 ; *
829 ; prototype: extern switchbank (unsigned char bank_number); *
830 ; *
831 ;******************************************************************************
832 PUBLIC _SWITCHBANK, ?B_SWITCHBANK_A
833
0000 EF 834 _SWITCHBANK: MOV A,R7
835
ENDIF ; close block IF ?B_MODE = 0 *******************************************
852
ENDIF ; close block IF ?B_MODE = 1 *******************************************
868
869 IF ?B_MODE = 4 ;**************************************************************
870
871 IF (?B_VAR_BANKING = 1)
0001 8004 872 SJMP ?B_SWITCHBANK_A
0003 873 SELECT_BANK_R3:
0003 EB 874 MOV A,R3
0004 14 875 DEC A
0005 543F 876 ANL A,#3FH
877 ENDIF
878
0007 879 ?B_SWITCHBANK_A:
0007 900000 F 880 MOV DPTR,#switch_tab
000A 93 881 MOVC A,@A+DPTR
000B 882 ?B_RESTORE_BANK: ; entry for RTX-51/XBANKING bank restore
000B 900000 F 883 MOV DPTR,#?BANK?SWITCH
000E 73 884 JMP @A+DPTR
885
886 S_ENTRY MACRO N
887 DB LOW ?B_SWITCH&N
888 ENDM
889
000F 890 switch_tab:
0000 891 CNT SET 0
892
893 REPT ?B_NBANKS
894 S_ENTRY %CNT
895 CNT SET CNT+1
896 ENDM
897+1 S_ENTRY %CNT
900+1 S_ENTRY %CNT
903 ENDIF ; close block IF ?B_MODE = 4 *******************************************
904
905
906 IF ?B_VAR_BANKING ;***********************************************************
907
908 ;******************************************************************************
909 ; *
910 ; THEORY OF OPERATION *
911 ; ------------------- *
912 ; This section describes how the extended LX51 linker/locater manages the *
913 ; extended address spaces that are addressed with the new C51 memory types *
914 ; 'far' and 'far const'. The C51 Compiler uses 3 byte pointer generic *
915 ; pointer to access these memory areas. 'far' variables are placed in the *
916 ; memory class HDATA and 'far const' variables get the memory class 'HCONST'. *
917 ; The LX51 linker/locater allows you to locate these memory classes in the *
918 ; logical 16 MBYTE CODE or 16 MBYTE XDATA spaces. *
919 ; *
A51 MACRO ASSEMBLER BANKSM59128 12/11/2006 09:13:36 PAGE 6
920 ; The memory access itself is performed via eight different subroutines that *
921 ; can be configured in this assembler module. These routines are: *
922 ; ?C?CLDXPTR, ?C?CSTXPTR ; load/store BYTE (char) in extended memory *
923 ; ?C?ILDXPTR, ?C?ISTXPTR ; load/store WORD (int) in extended memory *
924 ; ?C?PLDXPTR, ?C?PSTXPTR ; load/store 3-BYTE PTR in extended memory *
925 ; ?C?LLDXPTR, ?C?LSTXPTR ; load/store DWORD (long) in extended memory *
926 ; *
927 ; Each function gets as a parameter the memory address with 3 BYTE POINTER *
928 ; representation in the CPU registers R1/R2/R3. The register R3 holds the *
929 ; memory type. The C51 compiler uses the following memory types: *
930 ; *
931 ; R3 Value | Memory Type | Memory Class | Address Range *
932 ; -----------------------+--------------+-------------------------- *
933 ; 00 | data/idata | DATA/IDATA | I:0x00 .. I:0xFF *
934 ; 01 | xdata | XDATA | X:0x0000 .. X:0xFFFF *
935 ; 02..7F | far | HDATA | X:0x010000 .. X:0x7E0000 *
936 ; 80..FD | far const | HCONST | C:0x800000 .. C:0xFD0000 (see note) *
937 ; FE | pdata | XDATA | one 256-byte page in XDATA memory *
938 ; FF | code | CODE | C:0x0000 .. C:0xFFFF *
939 ; *
940 ; Note: the far const memory area is mapped into the banked memory areas. *
941 ; *
942 ; The R3 values 00, 01, FE and FF are already handled within the C51 run-time *
943 ; library. Only the values 02..FE are passed to the XPTR access functions *
944 ; described below. The AX51 macro assembler provides the MBYTE operator *
945 ; that calculates the R3 value that needs to be passed to the XPTR access *
946 ; function. AX51 Assembler example for using XPTR access functions: *
947 ; MOV R1,#LOW (variable) ; gives LSB address byte of variable *
948 ; MOV R1,#HIGH (variable) ; gives MSB address byte of variable *
949 ; MOV R1,#MBYTE (variable) ; gives memory type byte of variable *
950 ; CALL ?C?CLDXPTR ; load BYTE variable into A *
951 ;******************************************************************************
952
953 PUBLIC ?C?CLDXPTR, ?C?CSTXPTR, ?C?ILDXPTR, ?C?ISTXPTR
954 PUBLIC ?C?PLDXPTR, ?C?PSTXPTR, ?C?LLDXPTR, ?C?LSTXPTR
955
956 ?C?LIB_CODE SEGMENT CODE
---- 957 RSEG ?C?LIB_CODE
958
959
ENDIF ; close block IF ?B_MODE = 0 OR ?B_MODE = 1 *************************
1027
1028
ENDIF ; close block IF ?B_MODE = 0 *******************************************
1097
ENDIF ; close block IF ?B_MODE = 1 *******************************************
1145
1146 IF ?B_MODE = 4 ;**************************************************************
1147
1148 ; Select Bank depending on value in R3
1149 SEL_BNK MACRO SaveA
1150 LOCAL lab
1151 IF NOT NUL SaveA
1152 PUSH ACC
1153 ENDIF
1154 CALL SELECT_BANK_R3
1155 IF NOT NUL SaveA
1156 POP ACC
1157 ENDIF
1158 MOV DPL,R1
1159 MOV DPH,R2
1160 CJNE R3,#80H,lab
1161 lab:
1162 ENDM
1163
1164 ; Pop previous Bank and select it again
A51 MACRO ASSEMBLER BANKSM59128 12/11/2006 09:13:36 PAGE 7
1165 POP_BNK MACRO SaveA
1166 IF NOT NUL SaveA
1167 POP DPL
1168 XCH A,DPL
1169 PUSH DPL
1170 CALL ?B_RESTORE_BANK
1171 POP ACC
1172 RET
1173 ELSE
1174 POP ACC
1175 MOV DPTR,#?BANK?SWITCH
1176 JMP @A+DPTR
1177 ENDIF
1178 ENDM
1179
1180 ENDIF ; close block IF ?B_MODE = 4 *******************************************
1181
1182
1183
1184 ; CLDXPTR: Load BYTE in A via Address given in R1/R2/R3
0000 C000 F 1185 ?C?CLDXPTR: PUSH ?B_CURRENTBANK
1186 SEL_BNK
000C 5003 1198 JNC CLDCODE
000E E0 1199 MOVX A,@DPTR
000F 8002 1200 SJMP RETURN_A
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -