
	.LIST
	.ASECT
	.=001000
	;-------------------------------------------------------------------------------
START:
	mov #0,r0
	mov #0,r1

	;jmp TstReg	;Register - Value is taken from Registers itself
	;jmp TstRdf	;Register Deferred - Value is taken from address in register
	;jmp TstAIn ;Auto Increment	- Value is taken from address in register.... register increased by bytes read
	;jmp TstAID ;Auto Increment Deferred - Value is taken from address at address in register.... register increased by 2
	;jmp TstAde ;Auto Decrement	- Value is taken from address in register.... register decreased by bytes read
	;jmp TstAdd	;Auto Decrement Deferred - Value is taken from address at address in register.... register decreased by 2
	;jmp TstIdx ;Indexed - Value is taken from address in register + a fixed number
	;jmp TstIdd ;Indexed Deferred - Value is taken from address at address in register + a fixed number
	;jmp TstImm ;Immediate	Fixed numeric value
	;jmp TstAbs	;Absolute	Value from fixed address
	;jmp TstRel	;Relative	Value from relative address
	jmp TstRld	;Relative deferred	Value from address in address
;-------------------------------------------------------------------------------
	;Register 	Value is taken from Registers itself
TstReg:
	mov #177777,r1
	call MonR01
	
	mov r1,r0			;Transfer value from Reg 1 to Reg 0
	
	;mov sp,r1			;R6
	;mov pc,r2			;R7
	
	call MonR01	
	JMP infloop
;-------------------------------------------------------------------------------	
	;Register Deferred 	Value is taken from address in register
TstRdf:	
	call MonR01
	mov #TestData,r1	;Load the address of the test data
	
	mov (r1),r0			;Load R0 from address in R1
	call MonR01	
	mov (r1),r0			;Load R0 from address in R1
	call MonR01	
	
	add #2,r1			;Add 2 to R1
	
	mov (r1),r0			;Load R0 from address in R1
	call MonR01	
	
	inc r1
	mov (r1),r0			;Load from odd boundary... 
	
;Low bytes are stored at even numbered addresses,
;and High bytes are stored at odd addresses
;So we get the same value as last time,even though address is +1
	call MonR01	
	JMP infloop
	
;-------------------------------------------------------------------------------	
	;Auto Increment	- Value is taken from address in register.... register increased by bytes read
TstAIn:	
	mov #TestData,r1	;Load the address of the test data
	call MonR01
	mov (r1)+,r0		;Load R0 from address in R1, add 2 to R1 
	call MonR01	
	mov (r1)+,r0		;Load R0 from address in R1, add 2 to R1 
	call MonR01	
	
	movb (r1)+,r0		;Load R0 from address in R1 (8 bit), add 1 to R1
	call MonR01	
	movb (r1)+,r0		;Load R0 from address in R1 (8 bit), add 1 to R1
	call MonR01	
	JMP infloop
	
;-------------------------------------------------------------------------------		
	;Auto Increment Deferred	Value is taken from address at address in register.... register increased by 2
TstAID:
	mov #TestAddr,r1
	call MonM01
	mov @(r1)+,r0		;Load R0 from address in R1, add 2 to R1 
	call MonM01
	mov @(r1)+,r0		;Load R0 from address in R1, add 2 to R1 
	call MonM01
	
	movb @(r1)+,r0	;Load R0 from address in address in R1 (8 bit), add 2 to R1
	call MonM01
	movb @(r1)+,r0	;Load R0 from address in address in R1 (8 bit), add 2 to R1
	call MonM01
		
	JMP infloop
	
;-------------------------------------------------------------------------------		
	;Auto Decrement	Value is taken from address in register.... register decreased by bytes read
	
TstAde:	
	mov #TestDEnd,r1	;Load the address of the test data
	
	call MonR01
	movb -(r1),r0	;Load R0 from address in R1 (8 bit), subtract 1 from R1
	call MonR01	
	movb -(r1),r0	;Load R0 from address in R1 (8 bit), subtract 1 from R1
	call MonR01	
	
	mov -(r1),r0		;Load R0 from address in R1, subtract 2 from R1
	call MonR01	
	mov -(r1),r0		;Load R0 from address in R1, subtract 2 from R1
	call MonR01	
	
	
	JMP infloop
	
;-------------------------------------------------------------------------------	
	;Auto Decrement Deferred - Value is taken from address at address in register.... register decreased by 2
TstAdd:		
	mov #TestAend,r1
	
	movb @-(r1),r0		;Load R0 from address in address in R1 (8 bit)
	call MonM01
	movb @-(r1),r0		;Load R0 from address in address in R1 (8 bit)
	call MonM01
	
	mov @-(r1),r0		;Load R0 from address in address in R1 
	call MonM01
	mov @-(r1),r0		;Load R0 from address in address in R1 
	call MonM01
	
	JMP infloop
	
;-------------------------------------------------------------------------------	
	;Indexed	Value is taken from address in register + a fixed number
TstIdx:			
	mov #TestData,r1
	call MonR01
	mov (r1),r0			;Load R0 from address in R1
	call MonR01
	
	mov 2(r1),r0		;Load R0 from address in R1+2
	call MonR01
	movb 4(r1),r0		;Load R0 from address in R1+4 (8 bit)
	call MonR01
	movb 5(r1),r0		;Load R0 from address in R1+5 (8 bit)
	call MonR01
	
	JMP infloop

;-------------------------------------------------------------------------------		
	;Indexed Deferred	Value is taken from address at address in register + a fixed number
TstIdd:
	mov #TestAddr,r1
	call MonM01
	mov @(r1),r0		;Load R0 from address in R1, add 2 to R1 
	call MonM01
	mov @2(r1),r0		;Load R0 from address in R1, add 2 to R1 
	call MonM01
	
	movb @4(r1),r0 ;Load R0 from address in address in R1 (8 bit), add 2 to R1
	call MonM01
	movb @6(r1),r0 ;Load R0 from address in address in R1 (8 bit), add 2 to R1
	call MonM01
	
	JMP infloop
	
;-------------------------------------------------------------------------------		
	;Immediate	Fixed numeric value
TstImm:
	mov #1234,r0
	Mov #2345,r1
	call MonR01
	
	JMP infloop
	
;-------------------------------------------------------------------------------		
	;Absolute	Value from fixed address
TstAbs:
	mov @#TestData+2,r0
	mov @#1000,r1
	call MonR01
	
	call NewLine
	
	mov #TestData,r4	;Source address to show
	mov #4.,r3			;Number of words 
	jsr pc,MemDump		;Show memory onscreen

	mov #1000,r4	;Source address to show
	mov #4.,r3			;Number of words 
	jsr pc,MemDump		;Show memory onscreen
	
	JMP infloop	
	
;-------------------------------------------------------------------------------		
	;Relative	Value from relative address
TstRel:
	mov .+^d16,r1 ;pc+16 bytes (4 byte cmd) 
	mov .+^d12,r0 ;pc+12 bytes (4 byte cmd) 
;.=Current address (start of command)
	call MonR01		;(4 byte cmd)
	
	JMP infloop		;(4 byte cmd)
	.word 114422
;-------------------------------------------------------------------------------		
	;Relative deferred	Value from address in address
TstRld:
	mov @.+^d16,r1 ;pc+16 bytes (4 byte cmd) 
	mov @.+^d12,r0 ;pc+12 bytes (4 byte cmd) 
	call MonR01		;(4 byte cmd)
	
	JMP infloop		;(4 byte cmd)
	
	.word TestD2  	;This points to 777
	
infloop:
	JMP infloop

TestData:
	.word 111,222
	.byte 33,44,55,66,77
TestDEnd:
	.even					
TestD2:
	.word 777,666
TestAddr:
	.word TestData,TestD2,TestData,TestD2
TestAend:	

TestRam:
	.byte 0,0,0,0,0,0,0,0	;Define 8 bytes of ram
;	.word 0,0,0,0			;Define 4 words (8 bytes)
	.even				;Word align memory


	
SubT1:	;SubTest1		
		mov #'A,r0
		jsr pc,PrintChar
	RTS PC			;Return From Subroutine, POP PC off stack
	
SubT2:	;SubTest1		
		mov #'B,r0
		Call PrintChar		;Same as JSR PC,
	RETURN 					;
	
	.INCLUDE /Funct.mac/
	.INCLUDE /Monito.mac/
	

SubT3:	;SubTest1		
		mov #'C,r0
		jsr pc,PrintChar
	RTS r4			;Return From Subroutine, POP R4 off stack R4->PC

MonM01:
	mov r2,-(sp)
	mov r1,-(sp)	
		mov r1,-(sp)
			mov #'0,r1
			mov r0,r2
			jsr PC,MONREG		
		mov (sp)+,r1
		mov r1,r2
		mov #'1,r1
		jsr PC,MONREG
		
		
		mov #TestAddr,r4	;Source address to show
		mov #4.,r3			;Number of words 
		jsr pc,MemDump		;Show memory onscreen
		
		call NewLine
	mov (sp)+,r1
	mov (sp)+,r2
	RTS PC
	
MonR01:
	mov r2,-(sp)
	mov r1,-(sp)	
		mov r1,-(sp)
			mov #'0,r1
			mov r0,r2
			jsr PC,MONREG		
		mov (sp)+,r1
		mov r1,r2
		mov #'1,r1
		jsr PC,MONREG
		call NewLine
	mov (sp)+,r1
	mov (sp)+,r2
	RTS PC

MonR0:
	mov r2,-(sp)
	mov r1,-(sp)	
		mov #'0,r1
		mov r0,r2
		jsr PC,MONREG		
	mov (sp)+,r1
	mov (sp)+,r2
	RTS PC

	

	.EVEN			
;Space for Stack - Stack starts at end of program
	.BLKB 128.	

	.END    START
