
;*****************************************************************
;
; Copyright 2002   PIER LUCA MONTESSORO
;
; University of Udine
; ITALY
;
; montessoro@uniud.it
; www.montessoro.it
;
; This file is part of a freeware open source software package.
; It can be freely used (as it is or modified) as long as this
; copyright note is not removed.
;
; SIMCPU: assembly language examples
;
;******************************************************************

STACKADDR: word 0F000           ; beginning of stack area

;****************************************************************************

; LIBRARY FUNCTIONS

#include "readnum.ixx"
#include "writenum.ixx"
#include "puts.ixx"
#include "div.ixx"

;****************************************************************************

; MAIN PROGRAM

NULLSTR:   BYTE 0

START:     LDWA R15 STACKADDR   ; stack initialization
           SPWR R15             ; NOTE: every function receives input
                                ;       values/addresses in R1, R2, ...
                                ;       and provides output in R0
           CALL READNUM
           PUSH R0
           CALL READNUM
           PUSH R0
           POP R2
           POP R1
           CALL DIV            ; R0 <- R1 / R2 and  R15 <- R1 % R2
           PUSH R15
           PUSH R0
           LDWI R1 NULLSTR
           CALL PUTS
           POP R1
           CALL WRITENUM
           LDWI R1 NULLSTR
           CALL PUTS
           POP R1
           CALL WRITENUM
           HLT
