diff --git a/src/6502/_ch395_read_recv_buf_sn.s b/src/6502/_ch395_read_recv_buf_sn.s index f7f806c..9563712 100644 --- a/src/6502/_ch395_read_recv_buf_sn.s +++ b/src/6502/_ch395_read_recv_buf_sn.s @@ -2,30 +2,26 @@ .include "ch395.inc" .endif -.ifndef FROM_ASSEMBLY - .import popax - .importzp ptr1 -.endif +.import popax +.importzp ptr1, ptr2 .export _ch395_read_recv_buf_sn .export ch395_read_recv_buf_sn .proc _ch395_read_recv_buf_sn - ;;@proto void ch395_read_recv_buf_sn(unsigned char *buffer, unsigned int length,unsigned char ID_SOCKET); + ;;@proto void ch395_read_recv_buf_sn(unsigned char *buffer, unsigned int ptr2,unsigned char ID_SOCKET); ;;@inputPARAM_socketid The socketid - - jsr popax - sta length - stx length+1 + sta ptr2 + stx ptr2+1 .endproc .proc ch395_read_recv_buf_sn ;;@inputA Socket id - sty length - stx length+1 + sty ptr2 + stx ptr2+1 ldy #CH395_READ_RECV_BUF_SN sty CH395_COMMAND_PORT @@ -33,64 +29,52 @@ sta CH395_DATA_PORT - lda length - ldx length+1 - + lda ptr2 + ldx ptr2+1 + sta CH395_DATA_PORT ; set ptr2 + stx CH395_DATA_PORT ; set ptr2 - sta CH395_DATA_PORT ; set length - stx CH395_DATA_PORT ; set length - - -.ifdef FROM_ASSEMBLY -.else - jsr popax - sta ptr1 - stx ptr1+1 -.endif - - - lda length+1 - beq @read_only_length - + lda ptr2+1 + beq @read_only_ptr2 @read_256_bytes: - ldy #$00 + @loop2: - lda CH395_DATA_PORT ; set length + lda CH395_DATA_PORT ; set ptr2 sta (ptr1),y iny bne @loop2 inc ptr1+1 - lda length+1 + lda ptr2+1 cmp #$01 beq @exit - dec length+1 + dec ptr2+1 jmp @read_256_bytes @exit: - lda length + lda ptr2 beq @go_rts - jsr @read_only_length + jsr @read_only_ptr2 @go_rts: rts -@read_only_length: +@read_only_ptr2: ldy #$00 @loop: - lda CH395_DATA_PORT ; set length + lda CH395_DATA_PORT ; set ptr2 sta (ptr1),y iny - cpy length + cpy ptr2 bne @loop rts -length: +ptr2: .res 2 .endproc