;; *******************************************************************
|
;; *******************************************************************
|
;; $Id: test.asm,v 1.1 2005-09-07 20:24:30 arniml Exp $
|
;; $Id: test.asm,v 1.1 2005-09-07 20:24:30 arniml Exp $
|
;;
|
;;
|
;; Test interrupt on CALL in Program Memory Bank 1.
|
;; Test interrupt on CALL in Program Memory Bank 1.
|
;; *******************************************************************
|
;; *******************************************************************
|
|
|
INCLUDE "cpu.inc"
|
INCLUDE "cpu.inc"
|
INCLUDE "pass_fail.inc"
|
INCLUDE "pass_fail.inc"
|
|
|
test_byte: equ 020h
|
test_byte: equ 020h
|
|
|
ORG 0
|
ORG 0
|
|
|
;; Start of test
|
;; Start of test
|
jmp start
|
jmp start
|
|
|
ORG 3
|
ORG 3
|
;; check that interrupt hit CALL instruction
|
;; check that interrupt hit CALL instruction
|
;; stack must contain target of CALL instruction at
|
;; stack must contain target of CALL instruction at
|
;; location call_instruction
|
;; location call_instruction
|
mov r0, #00ch
|
mov r0, #00ch
|
mov a, @r0
|
mov a, @r0
|
;; check low byte of program counter on stack
|
;; check low byte of program counter on stack
|
xrl a, #000h
|
xrl a, #000h
|
jnz fail
|
jnz fail
|
inc r0
|
inc r0
|
mov a, @r0
|
mov a, @r0
|
anl a, #00fh
|
anl a, #00fh
|
;; check high byte of program counter on stack
|
;; check high byte of program counter on stack
|
mov r0, a
|
mov r0, a
|
xrl a, #009h ; target of PASS case?
|
xrl a, #009h ; target of PASS case?
|
jz int_goon
|
jz int_goon
|
mov a, r0
|
mov a, r0
|
xrl a, #001h ; target of FAIL case?
|
xrl a, #001h ; target of FAIL case?
|
jnz fail
|
jnz fail
|
|
|
int_goon:
|
int_goon:
|
;; interrupt hit correct instruction
|
;; interrupt hit correct instruction
|
mov r0, #test_byte
|
mov r0, #test_byte
|
mov a, #0ffh
|
mov a, #0ffh
|
mov @r0, a
|
mov @r0, a
|
retr
|
retr
|
|
|
start:
|
start:
|
;; enable interrupt
|
;; enable interrupt
|
en i
|
en i
|
|
|
;; clear test byte
|
;; clear test byte
|
mov r1, #test_byte
|
mov r1, #test_byte
|
clr a
|
clr a
|
mov @r1, a
|
mov @r1, a
|
|
|
call program_memory_bank_1
|
call program_memory_bank_1
|
sel mb0
|
sel mb0
|
|
|
;; check if interrupt was successful
|
;; check if interrupt was successful
|
mov a, @r1
|
mov a, @r1
|
jz fail
|
jz fail
|
|
|
|
|
pass: PASS
|
pass: PASS
|
|
|
fail: FAIL
|
fail: FAIL
|
|
|
|
|
ORG 0100H
|
ORG 0100H
|
;; program flow continues in fail case at address 0100h
|
;; program flow continues in fail case at address 0100h
|
;; after interrupt
|
;; after interrupt
|
;; i.e. bit 11 of address is erroneously cleared.
|
;; i.e. bit 11 of address is erroneously cleared.
|
|
|
;; make sure that jump to fail reaches memory bank 0
|
;; make sure that jump to fail reaches memory bank 0
|
sel mb0
|
sel mb0
|
jmp fail
|
jmp fail
|
|
|
|
|
ORG 0800H
|
ORG 0800H
|
program_memory_bank_1:
|
program_memory_bank_1:
|
;; spend some time and wait for interrupt
|
;; spend some time and wait for interrupt
|
mov r2, #013h
|
mov r2, #013h
|
djnz r2, $
|
djnz r2, $
|
|
|
call_instruction:
|
call_instruction:
|
;; interrupt must hit this CALL (checked by examining stack
|
;; interrupt must hit this CALL (checked by examining stack
|
;; in interrupt handler)
|
;; in interrupt handler)
|
call test_call
|
call test_call
|
ret
|
ret
|
|
|
ORG 0900H
|
ORG 0900H
|
test_call:
|
test_call:
|
;; program flow continues in pass case here after interrupt
|
;; program flow continues in pass case here after interrupt
|
ret
|
ret
|
|
|