forked from OldSkoolCoder/OSKMon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibGoCommand.asm
51 lines (47 loc) · 1.63 KB
/
libGoCommand.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;*******************************************************************************
;* Gosub Operation *
;*******************************************************************************
;* Syntax : G (addr)<RETURN>
;*******************************************************************************
COM_GOSUB
jsr INPUT_COMMAND ; get command line character
cmp #CHR_Return ; is it return
beq GO3 ; Yes
jsr ibyte1+3 ; get address word
jsr ibyte2+3
sta ADDVEC + 1 ; Store in Address Vector
stx ADDVEC
jmp GO_STACK_ADDRESS
GO3
ldy #0
lda (ADDVEC),y ; load Address value
cmp #0 ; is it a break BRK instruction
bne GO_STACK_ADDRESS ; No, Continue the command
PREPARE_TO_GO
lda PCHIREG ; Load PC Counter with Address
pha ; Store it on the stack
lda PCLOREG
pha
sei ; Set Interrupts
lda IRQINT
ldx IRQINT + 1
sta CINV ; Reset IRQ back to brk values
stx CINV + 1
lda NMIINT ; Reset NMI back to BRK Values
ldx NMIINT + 1
sta NMINV
stx NMINV + 1
cli ; Clear Interrupts
lda ACCREG ; Load Registers
ldx XREG
ldy YREG
rts ; Return to Stack Address
GO_STACK_ADDRESS
sec
lda ADDVEC ; Load Address
sbc #1 ; Minus 1 as rts is always Address -1
sta PCLOREG ; Store Back
lda ADDVEC + 1
sbc #0
sta PCHIREG
jmp PREPARE_TO_GO