== apollo_asm ==

this program gets two argument from CLI.
A number (arg1), and a string (arg2).
it will repeat a number of times (arg1) the string (arg2).
if arg2 is missing default message is used instead.

* get arguments, print on console
* credits pisklak for the code

	include exec/types.i
	include exec/libraries.i
	include	exec/exec_lib.i
	include	dos/dos_lib.i


	move.l	a0,string
	move.l	d0,size


openlibs
	move.l  $4,_ExecBase
	lea	DosName,A1
	move.l	#0,d0
	CALLEXEC OpenLibrary
	move.l	d0,_DOSBase
	
	CALLDOS	Output
	move.l	d0,_stdout
	
convertstr
	move.l	string,d1
	move.l	#str_conv,d2
	CALLDOS StrToLong
	cmp.l	#-1,d0
	beq	prt_error
	move.l	str_conv,d0
	cmp.l	#1,d0
	blo	prt_error
	cmp.l	#20,d0
	bhi	prt_error
	move.l	#1,d3
loop	
	cmp.l	str_conv,d3
	bhi	closelibs
	move.l	d3,powt
	move.l	#text,d1
	move.l	#str_conv,d2
	CALLDOS VPrintf
	add.l	#1,d3
	bra	loop	
closelibs
	move.l	_DOSBase,A1
	CALLEXEC CloseLibrary	
	
endprg	clr.l	d0
	RTS
prt_error
	move.l	#mess_error,d1
	move.l	#0,d2
	CALLDOS	VPrintf
	bra	closelibs

size		dc.l	0
string		dc.l	0
str_conv	dc.l	5432
powt		dc.l	0
dlugosc		dc.l    0
text		dc.b    "You give as argument number %lu. Repeat no %lu",10,0
mess_error	dc.b	"You do not give number or your number is not in range 1-20 !",10,0
_ExecBase 	dc.l	0	
_DOSBase		dc.l	0
DosName	dc.b	"dos.library",0
_stdout		dc.l	0
_stdinput	dc.l	0
  • get_argument_then_print_on_console.txt
  • Last modified: 2016/08/31 11:50
  • (external edit)