


; --------------= DISASSEMBLY SUB =--------------------
; This code disassembles <n> instructions beginning
; at a particular address.
; Note that whereas X is the addr of the op you want
; disassembled, after disasm is called, X 
; points to the next op!
; -----------------------------------------------------
dis_assembly_sub:
	jsr		parse_address		; returns addr in X. see "util.asm"
	cmpb		#$ff			; checks for an error
	beq		das_error		; prints message if there is an error
	jsr		parse_byte		; returns in A. see "util.asm"
	cmpb		#$ff			; checks for an error
	beq		das_error		; prints message if there is an error
das_loop1:
	psha					; saves A, where A is the number of
						; instructions to disassemble
	jsr		disasm			; disassemble it
	cmpb		#$ff			; checks for an error
	beq		das_incomplete		; prints out error message if error
	pula					; restores A as the counter
	deca					; decrements A
	bne 		das_loop1		; if counter not zero, continue disassembly
	bra		das_done		; when it's done, quit the routine

das_incomplete:
	pula					; gets rid of the counter so it can return properly
	ldy		#dis_incom_msg		; loads message to print
	jsr		print_string		; prints message. see "serial.asm"
	bra		das_done		; quits the routine
das_error:
	ldy		#error_msg		; loads address of error message
	jsr		print_string		; prints the message. see "serial.asm"
das_done:
	rts					; returns
