A89: Problem With _nostub Mode


[Prev][Next][Index][Thread]

A89: Problem With _nostub Mode



I've been trying to make a program that wll switch kernels.  I have attached the source that I have so far (which is done, and shuld work).  But for some odd reason, when I have a kernel installed (and turn _nostub off), the program gives me random crashes when installing or uninstalling.  But when I have it _nostub on, it just gives me an "Illegal Instruction" error.  Please look the source over and tell me what you think.
 
Juan
;Kernel Selector 1.0
;By Juan Corral
;
;Modify As You See Fit
;Thanks to Gareth, YodaToad, and Dulce97 from #tcpa in EFNet

kb_vars		equ	_ROM_CALL_2A3+$112
K_DIAMOND	equ	$4000

;******************************************** FILE(S) NEEDED TO COMPILE

	include tios.h			; include the TI-OS ROM_CALLs and RAM_CALLs
	include OS.h			; so that the _nostub xdef works

;******************************************** INSTRUCTIONS FOR COMPILER

	xdef _ti89			; compile a TI-89  *.89z file
	xdef _ti92plus			; compile a TI-92+ *.9xz file
	xdef _nostub			; do not include the kernel's stub
	xdef _main			; where the program actually starts
	xdef _exit			; incase of program abortion
	xdef _comment			; comment to show in shells

;******************************************** ACTUAL PROGRAM CODE

_main:					; the actual start of the program
choice:
	jsr tios::ScreenClear		; a TIOS routine to clear the screen
	SetFont #1			; macro to set the font to 1, normal size
	WriteStr #0,#0,#1,msg1		; display "msg1" at (0,0) in color 1 (black)
	WriteStr #0,#16,#1,install	; display "install" at (0,16) in color 1 (black)
	WriteStr #0,#24,#1,uninst	; display "uninst" at (0,24) in color 1 (black)
	bsr idle_loop			; branch to subroutine "idle_loop"
\test_keys				; inner label, makes looping easier
	cmp.w #49,d0			; check to see if 1 was pushed
	beq install_k			; if it was, goto "install_k"
	cmp.w #50,d0			; check to see if 2 was pushed
	beq uninstall_k			; if it was, goto "uninstall_k"
	cmp.w #264,d0			; check to see if ESC was pushed
	beq _exit			; if it was goto "_exit"
	bra \test_keys			; branch to "\test_keys"
	rts				; return from subroutine

install_k:
	jsr tios::ScreenClear		; a TIOS routine to clear the screen
	SetFont #1			; macro to set the font to 1, normal size
	WriteStr #0,#0,#1,msg2		; display "msg2" at (0,0) in color 1 (black)
	WriteStr #0,#16,#1,teos		; display "teos" at (0,16) in color 1 (black)
	WriteStr #0,#24,#1,uos		; display "uos" at (0,24) in color 1 (black)
	WriteStr #0,#32,#1,doorsos	; display "doorsos" at (0,32) in color 1 (black)
	bsr idle_loop			; branch to subroutine "idle_loop"
\test_keys				; inner label, makes looping easier
	cmp.w #49,d0			; check to see if 1 was pushed
	beq teos_selected_i		; if it was, goto "teos_selected_i"
	cmp.w #50,d0			; check to see if 2 was pushed
	beq uos_selected_i		; if it was, goto "uos_selected_i"
	cmp.w #51,d0			; check to see if 3 was pushed
	beq doorsos_selected_i		; if it was, goto "doorsos_selected_i"
	cmp.w #264,d0			; check to see if ESC was pushed
	beq _exit			; if it was goto "_exit"
	bra \test_keys			; branch to "\test_keys"
	rts				; return from subroutine

uninstall_k:
	jsr tios::ScreenClear		; a TIOS routine to clear the screen
	SetFont #1			; macro to set the font to 1, normal size
	WriteStr #0,#0,#1,msg2		; display "msg2" at (0,0) in color 1 (black)
	WriteStr #0,#16,#1,teos		; display "teos" at (0,16) in color 1 (black)
	WriteStr #0,#24,#1,uos		; display "uos" at (0,24) in color 1 (black)
	WriteStr #0,#32,#1,doorsos	; display "doorsos" at (0,32) in color 1 (black)
	bsr idle_loop			; branch to subroutine "idle_loop"
\test_keys				; inner label, makes looping easier
	cmp.w #49,d0			; check to see if 1 was pushed
	beq teos_selected_u		; if it was, goto "teos_selected_u"
	cmp.w #50,d0			; check to see if 2 was pushed
	beq uos_selected_i		; if it was, goto "uos_selected_i"
	cmp.w #51,d0			; check to see if 3 was pushed
	beq doorsos_selected_u		; if it was, goto "doorsos_selected_u"
	cmp.w #264,d0			; check to see if ESC was pushed
	beq _exit			; if it was goto "_exit"
	bra \test_keys			; branch to "\test_keys"
	rts				; return from subroutine

teos_selected_i:
	pea teos_i(pc)			; push the Effective Address to the stack
	bsr runprog			; branch to the subroutine "runprog"
	bra _exit			; branch to _exit

teos_selected_u:
	pea teos_u(pc)
	bsr runprog
	bra _exit

uos_selected_i:
	pea uos_i(pc)
	bsr runprog
	bra _exit

doorsos_selected_i:
	pea doors_i(pc)
	bsr runprog
	bra _exit

doorsos_selected_u:
	pea doors_u(pc)
	bsr runprog
	bra _exit

;******************************************** LIBRARY ROUTINES

idle_loop:				; copied from the TEOS version of Userlib :)
					; minor changes for no reason
	movem.l d1-d7/a0-a6,-(a7)
	move.w #2,-(a7)
\idle:
	jsr tios::OSTimerRestart	; empêche Doors de s'éteindre après certains progs
	lea kb_vars+$1C,a6
\wait:
	jsr tios::OSTimerExpired
	tst.w d0
	beq.s \notExpired

\OFF:
	trap #4
	bra.s \idle
\notExpired:
	tst.w (a6)
	beq.s \wait

	clr.w (a6)+
	move.w (a6),d7
	bclr #11,d7

	cmp.w #K_DIAMOND+$10B,d7
	beq.s \OFF

	addq.w #1,(a7)			; pour 3
	jsr tios::ST_busy		; efface le busy
	addq.l #2,a7

	move.w d7,d0
	movem.l (a7)+,d1-d7/a0-a6
	rts

runprog:				; copied from the TEOS version of Userlib
    link.w a6,#-64
    move.l a2,-(sp)
    move.l d3,-(sp)
    move.l    tios::top_estack,a2
    clr.w    -62(a6)
    pea -60(a6)
    jsr    tios::ER_catch
    move.w d0,d3
    addq.l #4,sp
    beq.s .L2
    move.w    d3,-(a7)
    jsr    tios::ERD_dialog
    move.l a2,tios::top_estack
    move.w -62(a6),d0
    beq.s .L3
    move.w -62(a6),-(sp)
    jsr tios::HeapFree
.L3:
    move.w d3,d0
    bra.s .L5
.L2:
    move.w #233,-(sp)
    jsr tios::push_quantum
    move.l 8(a6),-(sp)
    jsr tios::push_parse_text
    addq.l #6,sp
    tst.w d0
    bne.s .L4
    dc.w    $A38E
.L4:
    move.w tios::top_estack+2,d3
    sub.w a2,d3
    addq.w #2,d3
    move.w d3,-(sp)
    clr.w -(sp)
    subq.w #2,d3
    jsr    tios::HeapAllocHigh
    move.w d0,-62(a6)
    move.w -62(a6),-(sp)
    jsr    tios::HLock
    move.w d3,(a0)+
    move.w d3,-(sp)
    clr.w -(sp)
    pea 1(a2)
    move.l a0,-(sp)
    jsr tios::memcpy
    move.w -62(a6),-(sp)
    jsr tios::HeapUnlock
    clr.w -(sp)
    move.w -62(a6),-(sp)
    jsr tios::NG_execute
    move.w -62(a6),-(sp)
    jsr tios::HeapFree
    jsr tios::ER_success
    clr.w d0
.L5:
    move.l -72(a6),d3
    move.l -68(a6),a2
    unlk a6
    rts

;******************************************** PROGRAM ABORTION ROUTINE

_exit:
	rts

;******************************************** MISC. PROGRAM DATA

_comment:	dc.b "Kernel Selector",0

msg1:		dc.b "Please Select Operation",0
msg2:		dc.b "Please Select A Kernel",0

install:	dc.b "1.  Install",0
uninst:		dc.b "2.  Uninstall",0

doorsos:	dc.b "3.  DoorsOS II",0
uos:		dc.b "2.  Universal OS",0
teos:		dc.b "1.  TEOS",0

teos_i:		dc.b "main\iteos()",0
teos_u:		dc.b "main\uteos()",0

uos_i:		dc.b "main\iuos()",0

doors_i:	dc.b "main\idos()",0
doors_u:	dc.b "main\udos()",0

;******************************************** END OF FILE

 end