; Simple example
; Writes Hello World to the output

	JMP start
hello: DB "12" ; Variable
       DB 0	; String terminator

start:
        mov a,  hello
  	push a
	call strlength
	pop a
	add a, 0x30
	mov b,1
	call printch
	 
	HLT             ; Stop execution

strlength:     	; +5 ref to string
               	; +4 return address from function
		; +3 A
		; +2 B
	       	; +1 C 
	       	;  +0 <- SP
        PUSH A
	PUSH B
	PUSH C
	MOV B,0 ; intial count
	MOV A, [SP+5]
	MOV C, [A]
 myloop:	CMP C,0
        JZ strexit       
	INC A
	INC B
	MOV C,[A]
        jmp myloop
strexit:
	MOV [SP+5], B
	POP C
	POP B
	POP A
	ret 

printch: ; A char to print
	  ; B adr in display (0..)
	; simple and nasty because vars in regs
	ADD B, 232
	MOV [B], A
        ret
	
