# HG changeset patch # User aaronwolfe # Date 1267151113 0 # Node ID 8f5daacfb035dc0f85892579b22696727eea8bc2 # Parent d701ee4e07323e2e51d57d5da767e59858b5db8d RFM: oh the humanity diff -r d701ee4e0732 -r 8f5daacfb035 level1/modules/rfm.asm --- a/level1/modules/rfm.asm Thu Feb 25 05:24:23 2010 +0000 +++ b/level1/modules/rfm.asm Fri Feb 26 02:25:13 2010 +0000 @@ -21,10 +21,19 @@ mod eom,RFMName,tylg,atrv,RFMEnt,size -* org V.RFM -pathtmp equ 128 -size equ * - + + rmb $0000 +size equ . + + + org $0000 + +pathlen rmb 1 +pathnum rmb 1 +origu rmb 2 +xfersz rmb 2 +bufptr rmb 2 + RFMName fcs /RFM/ fcb edition @@ -52,29 +61,39 @@ lbra setstt Set Status lbra close Close path -create pshs u - +create stu origu,pc + * put path # on stack lda ,y + sta pathnum,pc pshs a - * put rfm op and DW op on stack + * put rfm op on stack ldb #DW.create bra create1 + -open pshs u - +open stu origu,pc + * put path # on stack lda ,y + sta pathnum,pc pshs a * put rfm op and DW op on stack ldb #DW.open + create1 lda #OP_VFM pshs d + * get system mem + ldd #256 + os9 F$SRqMem ; ask for D bytes (# bytes server said is coming) + stu bufptr,pc ; store pointer to our memory + leax ,s ; point X to stack ldy #3 ; 3 bytes to send + ifgt Level-1 ldu B + leas -1,s ;room for response byte leax ,s ldy #1 jsr 3,u + + * free system mem + ldd #256 + ldu bufptr,pc + os9 F$SRtMem + + * pull server's response into B puls b - cmpb #0 + tstb beq open2 + orcc #1 ;set error -open2 puls u +open2 ldu origu,pc rts makdir lda #DW.makdir @@ -136,23 +166,29 @@ seek lda #DW.seek lbra sendit -read pshs u - +read stu origu,pc + * put path # on stack lda ,y + sta pathnum,pc pshs a - * put rfm op and DW op on stack + * put rfm op on stack ldb #DW.read - bra read1 + bra read1 ; join readln routine + + write lda #DW.write lbra sendit -readln pshs u - + + +readln stu origu,pc ; store pointer to caller's register stack + * put path # on stack lda ,y + sta pathnum,pc ;also store, not really needed (yet?) pshs a * put rfm op and DW op on stack @@ -162,45 +198,57 @@ leax ,s ; point X to stack ldy #3 ; 3 bytes to send + + * set U to dwsub ifgt Level-1 ldu D.DWSubAddr endc + * send dw op, rfm op, path # jsr 6,u leas 3,s ;clean stack - * send max bytes - ldx ,s + * put caller's Y on stack (maximum allowed bytes) + ldx origu,pc ldx R$Y,x pshs x + + * send 2 bytes from stack leax ,s ldy #2 jsr 6,u - leas 1,s + leas 1,s ; leave 1 byte for server response in next section - * read # bytes (0 = eof) + * read # bytes coming (0 = eof) from server leax ,s ldy #1 jsr 3,u - ldb ,s - beq readln1 ; 0 bytes = EOF + * store size + clra + puls b + std xfersz,pc + + * check for 0 + tstb + beq readln1 ; 0 bytes = EOF * read the data from server if > 0 - tfr b,a - comb - incb - leas b,s ; reserve room on stack - pshs a ; save count - leax 1,s - clra - tfr d,y + + * get system mem + pshs u ; save U for later (ptr to dwsub) + os9 F$SRqMem ; ask for D bytes (# bytes server said is coming) + stu bufptr,pc ; store pointer to our memory + puls u ; get dwsub ptr back into U + + * load data from server into mem block + ldx bufptr,pc + ldy xfersz,pc jsr 3,u - * F$Move * a = my task # * b = caller's task # @@ -208,36 +256,40 @@ * Y = byte count * U = dest ptr - puls b - clra - tfr d,y ; y= byte count (was set in dwsub call, not sure if preserved) + * move from our mem to caller - incb - ldx b,s ;pointer to caller's stack is on our stack, behind the data and one byte + ldy xfersz,pc ;Y = byte count (already set?) + + ldx origu,pc ldu R$X,x ; U = caller's X = dest ptr - lda