more serial woe

From: Christopher Phillips (christopher_at_jaruth.com)
Date: 2004-07-27 20:36:24

Hi all.

The following 5 lines of basic merrily destroys a disk directory as I'd 
expect.

1 OPEN 1,8,15,"I0"
2 OPEN 2,8,2,"#"
3 PRINT#1,"BP:2 0"
4 PRINT#2,"HI THERE"
5 PRINT#1,"U2:2 0 18 1"

The attached asm, I would expect to behave the same way.  Instead, HI 
THERE is printed to the console, and the drive complains of a syntax 
error.  Any ideas?

I've used the command channel from asm before, but never the data 
channel.




#define poke(addr,val)	.(:lda #val:sta addr:.)
#define doke(addr,val)	.(:lda #<val:sta addr:lda #>val:sta addr+1:.)


;KERNAL

setlfs  = $ffba
setnam  = $ffbd
open    = $ffc0
close   = $ffc3
chkin   = $ffc6
chkout  = $ffc9
clrchn  = $ffcc
chrin   = $ffcf
chrout  = $ffd2
chrouts = $e716    ;chrout to screen
clall   = $ffe7
unlsn   = $ffae



	*= $0801-2
	.word *+2	; load address
	.byt $0b,$08,$0a,$00,$9e,$32,$30,$36,$31,0,0,0



main:

	jsr opendisk    ; OPEN 1,8,15,"i0"
	jsr opendata    ; OPEN 2,8,2,"#"
	jsr setbp       ; PRINT#1,"BP:2 0:
	jsr printhi     ; PRINT#2,"HI THERE"
	jsr writeblock  ; PRINT#1,"U2:2 0 18 1"

	rts
	jsr clrchn
	jmp closedisk
	
;-------------------------------------------------;
;  open 1,8,15,"I0"                               ;
;-------------------------------------------------;

opendisk:
	lda #1  ; logical file number
	ldx #8  ; drive
	ldy #15 ; cmd channel
	jsr setlfs
	lda #2 ; strlen  - should be 2 or 0
	ldx #<i0str
	ldy #>i0str
	jsr setnam
	jmp open

i0str:
	.byt "I0"

;-------------------------------------------------;
;  open 2,8,2,"#"                                 ;
;-------------------------------------------------;

opendata:
	lda #1  ; logical file number
	ldx #8  ; drive
	ldy #15 ; cmd channel
	jsr setlfs
	lda #2 ; strlen  - should be 2 or 0
	ldx #<hashstr
	ldy #>hashstr
	jsr setnam
	jmp open

hashstr:
	.byt "#"


;-------------------------------------------------;
; print#1,"bp:2 0:
;-------------------------------------------------;

setbp
	.(
	poke(channel,1)
	lda #<cmds
	ldx #>cmds
	ldy #cmde-cmds
	jsr sendcmd
	rts
cmds
	.byt "BP:2 0",13
cmde
	.)


;-------------------------------------------------;
; print#2,"hi there"
;-------------------------------------------------;

printhi
	.(
	poke(channel,2)
	lda #<cmds
	ldx #>cmds
	ldy #cmde-cmds
	jsr sendcmd
	rts
cmds
	.byt "HI THERE"
cmde
	.)


;-------------------------------------------------;
; print#1,"U2:2 0 18 1"
;-------------------------------------------------;

writeblock
	.(
	poke(channel,1)
	lda #<cmds
	ldx #>cmds
	ldy #cmde-cmds
	jsr sendcmd
	rts
cmds
	.byt "U2:2 0 18 1"
cmde
	.)


channel
	.byt 1
;-------------------------------------------------;
;  send cmd to 'channel'  ,ax  is str, y is len   ;
;-------------------------------------------------;

sendcmd .(
	sta loop+1
	stx loop+2
	sty loop-1

	ldx channel
	jsr chkout

	ldx #0
	ldy #0
loop	lda $ffff,x
	jsr chrout
	inx
	dey
	bne loop
	jmp unlsn
	.)

;-------------------------------------------------;
;  close channels 1 and 2                         ;
;-------------------------------------------------;

closedisk:
	lda #2
	jsr close	
	lda #1
	jmp close	

	


       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.