antoine-source/appleworksgs/Macros/m16.math

1 line
23 KiB
Plaintext
Raw Normal View History

2023-03-04 02:45:20 +00:00
;.............................................................................. ; ; StyleWare Macros` ; ; Macros...: AddWord, AddLong, SubWord, SubLong ; Author...: Mike Hibbetts, (2.0 conversion Scott Lindsey) ; Date.....: June 30, 1987 ... Oct 22,1988 ; Version..: 2.0 ; ; The following is a short description of the available addressing ; modes that may be used with the math macros in m16.math. ; ; Notes: 'a', 'x', and 'y' denote the 65816 registers. ; 's' denotes that an operand is to be either pulled or pushed. ; ; For programmer based optimization, it should be noted that all zero ; page indirect indexing is done out of the 'y' register, and all other ; indexing is done out of the 'x' register. So, for example, ; ; AddLong Addr:#4,[zp]:#4,>Long ; is better coded as ; ldy #4 ; AddLong Addr:y,[zp]:y,>Long, ; (it saves on 1 'ldx') ; and ; ; SubLong Addr1:#offset1,>Long:#offset2,Addr3 ; is better coded as ; ldy #offset2 ; SubLong Addr1:#offset1,>Long:y,Addr3. ; (it saves on 3 'ldx' and costs 1 'ldy') ; ; All other optimizations have been done internally to the macros. ;............................................................................. ; ; Where ; ; P = { Addr, Addr:#offset, Addr:offset, Addr:x, Addr:y, ; [zp], [zp]:#offset, [zp]:offset, [zp]:y, zp:s ; Long, Long:#offset, Long:offset, Long:x, s }, ; ; Q = { a, x, y, #const } + P, ; ; R = { #const } + P, and ; ; T = { a, x, y } + P, ; ; all ; ; AddWord Q,R,T ; AddLong Q,R,P ; SubWord Q,R,T ; SubLong Q,R,P ; ; are allowed. ; ;----------------------------------------------------------------------------- MACRO &lab AddWord &term1,&term2,&dest &lab ; Arith 2,adc,clc,&term1,&term2,&dest MEND MACRO &lab Addw &term1,&term2,&dest &lab AddWord &term1,&term2,&dest MEND ;---------------------------------------------------------------------------- MACRO &lab AddLong &term1,&term2,&dest &lab ; Arith 4,adc,clc,&term1,&term2,&dest MEND MACRO &lab AddL &term1,&term2,&dest &lab AddLong &term1,&term2,&dest MEND ;---------------------------------------------------------------------------- MACRO &lab SubWord &term1,&term2,&dest &lab ; Arith 2,sbc,sec,&term1,&term2,&dest MEND MACRO &lab Subw &term1,&term2,&dest &lab SubWord &term1,&term2,&dest MEND ;---------------------------------------------------------------------------- MACRO &lab SubLong &term1,&term2,&dest &lab ; Arith 4,sbc,sec,&term1,&term2,&dest MEND MACRO &lab Subl &term1,&term2,&dest &lab SubLong &term1,&term2,&dest MEND ;---------------------------------------------------------------------------- MACRO Arith &length,&op1,&op2,&term1,&term2,&dest gbla &same gbla &Yinc gblc &lastX gblc &lastY gbla &OFFinc gblc &pushed &same SETA 0 &OFFinc SETA 0 &Yinc SETA 0 &pushed SETC '' &lastX SETC '' &lastY SETC '' lcla &colon lcla &stack1 lcla &pull1 lcla &pull2 lcla &zp1 lcla &zp2 lcla &zp3 lclc &addr1 lclc &off1 lclc &addr2 lclc &off2 lclc &addr3 lclc &off3 lclc &badreg &badreg SETC 'y' lclc &jump1 lclc &jump2 lclc &jump3 IF &substr(&term1,1,1)<29>'[' GOTO .doterm12 &zp1 seta 1 .doterm12 &colon seta &pos(':',&term1) IF &colon=0 GOTO .no1offset &off1 SETC &substr(