Re: Math accelerator in native library
Thomas Chenot <tom.chenot-6tN4nzCoH/[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
Walter Fetter Lages wrote: > Hello! > > Has anybody used the math accelarator (32/16 bit mult and div) in > a native method? > > Can it be used in native methods? Yes. > > > If so, math accelerator SFRs (MA, MB, MC) needs to be preserved > across native method invocation? The registers do not have to be preserved BUT you do have to enclose your entire accelerator access code block in a critical section. This will prevent your code from scrogging operations being performed in another process. Example: TINIOS_ENTER_CRITICAL_SECTION mov MCNT1, #10h ; reset coprocessor mov Ma, R0 ; load operand A mov Ma, R1 ; mov Ma, R2 ; mov Ma, R3 ; mov Mb, R0_B1 ; load operand B mov Mb, R1_B1 ; db 0,0,0,0,0,0,0,0,0 ; inject NOPs to wait for result mov R3, Ma ; unload results mov R2, Ma ; mov R1, Ma ; mov R0, Ma ; mov R1_B1, Mb ; mov R0_B1, Mb ; TINIOS_EXIT_CRITICAL_SECTION -- Thomas Chenot _______________________________________________ TINI mailing list TINI-6tN4nzCoH/[email protected] To UNSUBSCRIBE, edit your profile, or see list archives: http://lists.dalsemi.com/mailman/listinfo/tini