sys7.1-doc-wip/Interfaces/AIncludes/EndianAware.a
2019-07-27 22:37:48 +08:00

65 lines
1.8 KiB
Plaintext

;
; File: EndianAware.a
;
; Contains: macros for 68K clients that are aware of platform endian-ness
;
; Written by: Craig Prouse
;
; Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <1> 11/10/93 fau first checked in
;
;
IF (&TYPE('__INCLUDINGENDIANAWARE__') = 'UNDEFINED') THEN
__INCLUDINGENDIANAWARE__ SET 1
IF &TYPE('littleEndian') = 'UNDEFINED' THEN
littleEndian SET 1
ENDIF
; ……………………………………………………………………………………………………………………………………………………………………………………………………………………
; ENDSW (pseudo-instruction)
;
; Operation: (Size = Byte) None
; (Size = Word) Dn[8:15] <-> Dn[7:0]
; (Size = Long) Dn[31:24] <-> Dn[7:0]; Dn[23:16] <-> Dn[15:8]
;
; Syntax: ENDSW Dn
;
; Attributes: Size = (Byte, Word, Long)
;
; Description: Exchange bytes within a word or longword to convert between
; big-endian and little-endian representations.
;
; CCR: Undefined
; ……………………………………………………………………………………………………………………………………………………………………………………………………………………
MACRO
ENDSW.&size &Dn
IF &UC(&size) = 'L' OR &UC(&size) = 'W' OR &UC(&size) = 'B' OR &size = '' THEN
IF littleEndian THEN
IF &UC(&size) <> 'B' THEN
rol.w #8,&Dn
ENDIF ; Size <> Byte
IF &UC(&size) = 'L' THEN
swap &Dn
rol.w #8,&Dn
ENDIF ; Size = Long
ENDIF ; littleEndian
ELSE
AERROR (&CONCAT('''',&UC(&size),''' is an invalid operand size for ENDSW'))
ENDIF ; Size = B | W | L
ENDM
ENDIF ; __INCLUDINGENDIANAWARE__