;************************************************************************** ; SimpleApp.asm ; ; This is an application which tests our "simple.library" assembly example. ; It opens the simple.library, and calls each of the functions with some ; args. It prints results to the CLI. Then, it close the lib and exits. ; ;Link as follows: ;Blink startup.o simpleapp.o small.lib nodebug to TEST INCLUDE "Simple.i" ;our asm INCLUDE file made by LibTool (-a option) ;from StartUp.o XREF _DOSBase,_SysBase,_stdout ;from amiga.lib or small.lib XREF _LVORawDoFmt,_LVOWrite,_LVOOpenLibrary,_LVOCloseLibrary XDEF _main _main: ;--- Open our simple.library lea SimpleName,a1 moveq #simpleVERSION,d0 ;from the INCLUDE file movea.l _SysBase,a6 jsr _LVOOpenLibrary(a6) lea NoSimple,a0 move.l d0,d7 beq.s printf ;--- Call Add2Numbers and print results moveq #2,d0 moveq #3,d1 movea.l d7,a6 jsr _LVOAdd2Numbers(a6) ;2+3 lea AddAnswer,a0 move.l d0,-(sp) bsr.s printf addq.l #4,sp ;--- Call Sub2Numbers and print results moveq #10,d0 moveq #4,d1 movea.l d7,a6 jsr _LVOSub2Numbers(a6) ;10-4 lea SubAnswer,a0 move.l d0,-(sp) bsr.s printf addq.l #4,sp ;--- Call Mult2Numbers and print results moveq #8,d0 moveq #8,d1 movea.l d7,a6 jsr _LVOMult2Numbers(a6) ;8*8 lea MultAnswer,a0 move.l d0,-(sp) bsr.s printf addq.l #4,sp ;--- Close simple.library and exit movea.l d7,a1 movea.l _SysBase,a6 jmp _LVOCloseLibrary(a6) XDEF printf printf: move.l _stdout,d0 beq.s 3$ lea 4(sp),a1 ;args to format (if any) movem.l d2/d3/a2/a3/a4/a6,-(sp) movea.l d0,a4 moveq #126,d0 suba.l d0,sp ;get a buffer to hold the string lea storeIt,a2 movea.l sp,a3 movea.l _SysBase,a6 jsr _LVORawDoFmt(a6) moveq #-1,d3 1$ move.b (a3)+,d0 Dbeq d3,1$(pc) not.l d3 beq.s 2$ move.l sp,d2 move.l a4,d1 movea.l _DOSBase,a6 jsr _LVOWrite(a6) 2$ moveq #126,d0 adda.l d0,sp movem.l (sp)+,d2/d3/a2/a3/a4/a6 3$ rts storeIt move.b d0,(a3)+ rts SimpleName dc.b 'simple.library',0 NoSimple dc.b 'can',$27,'t get simple.library in LIBS',10,0 AddAnswer dc.b '2 + 3 = %ld',10,0 SubAnswer dc.b '10 - 4 = %ld',10,0 MultAnswer dc.b '8 * 8 = %ld',10,0 END