Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jedeoric committed Feb 6, 2024
1 parent c04c326 commit 30018dd
Showing 1 changed file with 23 additions and 39 deletions.
62 changes: 23 additions & 39 deletions src/6502/_ch395_read_recv_buf_sn.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,79 @@
.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

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

0 comments on commit 30018dd

Please sign in to comment.