As an example the f/ "__DIV" code has been generated by C compiler
from "c=a/b". So we may that way create any floating point-function
in few seconds. However, it is up to amforth community to agree the
integration standards. When the ___frutine will be hard coded to
certain amforth registers, the Q is what happens when Matthias will
change the regs allocation in future. Therefore I've tried to create
an "interface" with ".def _tempX = Rx". The original ___froutine's
Rx registers will be renamed to _tmpX and renamed by ".def _tmp24 =
R14" as you want. The same as Matthias does with temp0,1,2...

So my point when integrating a ready to use asm code to amforth is
(AN Example):

; ..core\words\f_div.asm
; ( a b --  c ) Function c = a / b
; R( ? -- ? )
VE_FDIV:
.dw $ff02 
.db "f/"
.dw VE_HEAD
.set VE_HEAD = VE_FDIV
XT_FDIV:
.dw PFA_FDIV
PFA_FDIV:
.cseg
; $$$ REGS REDEFINITION $$$$$$$$$$$$$$$$$$$$$
; _tmpX is RX used in the code
.def    _tmp0 = R8
.def    _tmp1 = R9
;       .def    _tmp2 = Rx
.....
;       .def    _tmp15 = Rx
.def    _tmp17 = R13
.def    _tmp18 = R18            ;  used as word
.....
.def    _tmp23 = R23
.def    _tmp24 = R16            ;24 tosl
.def    _tmp25 = R17            ;25 tosh
.def    _tmp26 = R26            ;26 X   word used
.def    _tmp27 = R27            ;27 X   
.def    _tmp28 = R14            ;28 Y   do not use,word used    
.def    _tmp29 = R15            ;29 Y   do not use,
.def    _tmp30 = R30            ;30 Z   Word used
.def    _tmp31 = R31            ;31 Z
;  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; save registers if needed
...........
push R30 
push R31 
;###################################################### 
;main body
; Floating point B = A / B      
; IEEE 754
;     High        Low
; A = R25 R24 R27 R26  IN
; B = R23 R22 R31 R30  IN / OUT

fdiv:
; &&&&&&&& I/O &&&&&&&&&&&&
; fetch B 
mov _tmp22, tosl
mov _tmp23, tosh        
ld _tmp30, Y+
ld _tmp31, Y+
; fetch A       
ld _tmp24, Y+
ld _tmp25, Y+
ld _tmp26, Y+
ld _tmp27, Y+

CALL __DIV

; store B
st -Y , _tmp31
st -Y , _tmp30
mov tosh, _tmp23
mov tosl, _tmp22
jmp end_fdiv

;########## DO NOT TOUCH >>> THE ASM ROUTINE ###############    
__DIVfrank:
PUSH _tmp21
RCALL __UNxxx
CPI  _tmp23, 0x80
BRNE __DIV889
TST  _tmp1
__DIVjoe:
BRPL __DIV324
RJMP __RNM
...............
ROL  _tmp22
DEC  _tmp23
BRVS __DIV2332
__DIVmary:
RCALL __R443
POP  _tmp21
RET
;######################################################         
end_fdiv:
..........
pop R31
pop R30 
jmp_ DO_NEXT   ; this is the end of the word "f_div"

So the framework..P.








------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Amforth-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to