; mp5.h -- by Douglas W. Jones, Nov. 8, 2014 ; these macros modified from those in sparrowhawk.h, Oct. 30, 2014 revision. ; they replace the ones omitted when the user defines STRICTSPARROW. ; before including this file, ; STRICTSPARROW = 1 ; USE "sparrowhawk.h" ; For the mp4.a one benchmark, ; the original macros in sparrowhawk.h required #171 bytes (371) ; these macros required #133 bytes, a savings of #3E bytes (50 bytes) ; --------------------- ; macros for constant pool needed for relocatable LIL MACRO CONSTPOOL ALIGN 4 qCONSTPOOLq=. ENDMAC ; --------------------- ; support macros that are not to be called except by macros in this file ; load absolute displacement MACRO qABSDSPq =temp,=const IF (const>127)|(const<-128) LIS temp,const >> 8 ORIS temp,const & #FF ELSE LIS temp,const ENDIF ENDMAC ; load PC relative displacement for PC-relative memory reference instrs ; limitations of the SMAL assembler make it difficult to optimize this MACRO qRELCMPq =temp,=const qPCRELq = const-(.+6) LIS temp,qPCRELq >> 8 ORIS temp,qPCRELq & #FF PLUS temp,R0 ENDMAC ; --------------------- ; macros for long Hawk instructions MACRO LEA =dst,=x,=const IF LEN(const)>0 IF dst=x qABSDSPq R1,const PLUS R1,x MOVE dst,R1 ELSE qABSDSPq dst,const PLUS dst,x ENDIF ELSE qRELCMPq dst,x ENDIF ENDMAC MACRO LEACC =dst,=x,=const IF LEN(const)>0 qABSDSPq R1,const ADD dst,R1,x ELSE qRELCMPq dst,x ; cannot use ADD here, does not give access to PC MOVECC dst,dst ENDIF ENDMAC MACRO LOAD =dst,=x,=const IF LEN(const)>0 IF dst=x qABSDSPq R1,const PLUS R1,x LOADS dst,R1 ELSE qABSDSPq dst,const PLUS dst,x LOADS dst,dst ENDIF ELSE qRELCMPq dst,x LOADS dst,dst ENDIF ENDMAC MACRO LOADCC =dst,=x,=const IF LEN(const)>0 IF dst=x qABSDSPq R1,const PLUS R1,x LOADSCC dst,R1 ELSE qABSDSPq dst,const PLUS dst,x LOADSCC dst,dst ENDIF ELSE qRELCMPq dst,x LOADS dst,dst ENDIF ENDMAC MACRO JSR =dst,=x,=const IF LEN(const)>0 IF dst=x qABSDSPq R1,const PLUS R1,x JSRS dst,R1 ELSE qABSDSPq dst,const PLUS dst,x JSRS dst,dst ENDIF ELSE qRELCMPq dst,x JSRS dst,dst ENDIF ENDMAC MACRO STORE =dst,=x,=const IF LEN(const)>0 qABSDSPq R1,const PLUS R1,x STORES dst,R1 ELSE qRELCMPq R1,x STORES dst,R1 ENDIF ENDMAC MACRO LIL =dst,=const IF TYP(const)=0 IF (const > 32767) ! (const < -32768) ! FWD(const) LIS dst, (const >> 16) ORIS dst, (const >> 8) & #FF ORIS dst, (const ) & #FF ELSEIF (const > 127) ! (const < -128) LIS dst, (const > 8) ORIS dst, (const ) & #FF ELSE LIS dst, const ENDIF ELSE LOAD dst,qCONSTPOOLq qLCSAVEq=. .=qCONSTPOOLq W const qCONSTPOOLq=. .=qLCSAVEq ENDIF ENDMAC ; --------------------- ; macros for derived long hawk instructions MACRO TEST =x,=disp LOADCC R0,x,disp ENDMAC MACRO ADDI =dst,=src,=const LEACC dst,src,const ENDMAC MACRO CMPI =x,=disp LEACC R0,x,-disp ENDMAC MACRO JUMP =x,=disp IF LEN(disp)>0 JSR R0,x,disp ELSE JSR R0,x ENDIF ENDMAC MACRO LIW =dst, =const LIL dst, const >> 8 ORIS dst, const & #FF ENDMAC END