📄 c96macro.inc
字号:
;;;
;;; VERSION CONTROL: @(#)c96macro.inc 1.3 97/02/25
;;;
;;; AUTHOR: Kees de Bruin (bruin)
;;;
;;; COPYRIGHT: Copyright (c) 1995 Tasking Software B.V.
;;;
$NOLIST
;;;
;;; Define some EQU's for handling various sizes of operand that are available
;;; on the stack.
;;;
IF _24_BITS_
;;
;; Determine the size of pointers to code addresses
;;
IF _FAR_CODE_
Ret_Addr_Size EQU 4
Code_Addr_Size EQU 4
ELSE
Ret_Addr_Size EQU 2
Code_Addr_Size EQU 2
ENDIF
;;
;; Determine the size of pointers to data addresses
;;
IF (_FAR_DATA_ OR _FAR_CONST_)
Data_Addr_Size EQU 4
ELSE
Data_Addr_Size EQU 2
ENDIF
ELSE
;;
;; All pointers to code/data are 2 bytes
;;
Ret_Addr_Size EQU 2
Code_Addr_Size EQU 2
Data_Addr_Size EQU 2
ENDIF
;;;
;;; Define the temporary registers as externals
;;;
RSEG
EXTRN TMPREG0
IF _24_BITS_ AND (_FAR_DATA_ OR _FAR_CONST_ OR _FAR_CODE_)
EXTRN TMPREG8
ENDIF
R0 EQU 0H
SP EQU 18H
;;;
;;; Useful macros for various accesses to memory
;;;
CSEG
LoadB MACRO Reg, Src
;;
;; This macro will load a BYTE from the data/const segment into the
;; given register.
;;
IF _24_BITS_ AND (_FAR_DATA_ OR _FAR_CONST_)
ELDB Reg, Src
ELSE
LDB Reg, Src
ENDIF
ENDM
LoadW MACRO Reg, Src
;;
;; This macro will load a WORD from the data/const segment into the
;; given register.
;;
IF _24_BITS_ AND (_FAR_DATA_ OR _FAR_CONST_)
ELD Reg, Src
ELSE
LD Reg, Src
ENDIF
ENDM
StoreB MACRO Reg, Src
;;
;; This macro will store a BYTE from the given register into the
;; data segment.
;;
IF _24_BITS_ AND _FAR_DATA_
ESTB Reg, Src
ELSE
STB Reg, Src
ENDIF
ENDM
StoreW MACRO Reg, Src
;;
;; This macro will store a WORD from the given register into the
;; data segment.
;;
IF _24_BITS_ AND _FAR_DATA_
EST Reg, Src
ELSE
ST Reg, Src
ENDIF
ENDM
CallSub MACRO Addr
;;
;; This macro will call the subroutine at Addr.
;;
IF _24_BITS_ AND _FAR_CODE_
ECALL Addr
ELSE
CALL Addr
ENDIF
ENDM
BrSub MACRO Addr
;;
;; This macro will branch to subroutine at Addr.
;;
IF _24_BITS_ AND _FAR_CODE_
EBR Addr
ELSE
BR Addr
ENDIF
ENDM
PopAd MACRO Addr
;;
;; This macro will pop Addr from the stack.
;;
IF _24_BITS_ AND _FAR_CODE_
POP Addr
POP Addr + 2
ELSE
POP Addr
ENDIF
ENDM
PushAd MACRO Addr
;;
;; This macro will push Addr on the stack.
;;
IF _24_BITS_ AND _FAR_CODE_
PUSH Addr + 2
PUSH Addr
ELSE
PUSH Addr
ENDIF
ENDM
GetArg MACRO Reg, Offset, Size
;;
;; This macro will load an argument from the stack
;;
IF Size EQ 1
;;
;; Load a BYTE from the stack
;;
LDB Reg, Offset[SP]
ELSE
IF Size EQ 2
;;
;; Load a WORD from the stack
;;
LD Reg, Offset[SP]
ELSE
IF Size EQ 4
;;
;; Load a LONG WORD from the stack
;;
LD Reg, Offset[SP]
LD Reg+2, 2+Offset[SP]
ELSE
$ERROR('Invalid argument size requested')
ENDIF
ENDIF
ENDIF
ENDM
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -