]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/circularbytebuffer-asm.S
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / circularbytebuffer-asm.S
index bd0d3109f32d2e6c04bc892ad272d25b6687de7f..493b17cde6a71d07aedcf23f306d80f7dbb87f24 100644 (file)
@@ -1,7 +1,7 @@
 /* circularbytebuffer-asm.S */
 /*
     This file is part of the AVR-circularbytebuffer.
-    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+    Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
 */
 /**
  * \file     circularbytebuffer-asm.S
- * \email    daniel.otte@rub.de
+ * \email    bg@nerilex.org
  * \author   Daniel Otte 
  * \date     2009-07-25
  * \license  GPLv3 or later
  typedef struct {
         uint8_t buffer_size;
         uint8_t fillcount;
-        uint8_tbuffer;
-        uint8_thead;
-        uint8_ttail;
-        uint8_ttop;
+        uint8_t *buffer;
+        uint8_t *head;
+        uint8_t *tail;
+        uint8_t *top;
 } circularbytebuffer_t;
 */
 
@@ -57,7 +57,7 @@
 
 /******************************************************************************/
 /*
- *     uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_tcb){
+ *     uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t *cb){
  *             cb->buffer_size = buffersize;
  *             cb->buffer = malloc(buffersize);
  *             cb->head = cb->tail = cb->buffer;
@@ -105,7 +105,7 @@ circularbytebuffer_init:
 
 /******************************************************************************/
 /*
- *     void circularbytebuffer_free(circularbytebuffer_tcb){
+ *     void circularbytebuffer_free(circularbytebuffer_t *cb){
  *             free(cb->buffer);
  *     }
  *
@@ -124,7 +124,7 @@ circularbytebuffer_free:
 
 /******************************************************************************/
 /*
- *     void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer){
+ *     void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t *cb, void *buffer){
  *             cb->buffer_size = buffersize;
  *             cb->buffer = buffer
  *             cb->head = cb->tail = cb->buffer;
@@ -157,7 +157,7 @@ circularbytebuffer_init2:
 
 /******************************************************************************/
 /*
- *     uint8_t circularbytebuffer_cnt(circularbytebuffer_tcb){
+ *     uint8_t circularbytebuffer_cnt(circularbytebuffer_t *cb){
  *             return (cb->fillcount);
  *     }
  *
@@ -172,7 +172,7 @@ circularbytebuffer_cnt:
        
 /******************************************************************************/
 /*
- *     uint16_t circularbytebuffer_get_lifo(circularbytebuffer_tcb){
+ *     uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t *cb){
  *             uint8_t ret;
  *             if(cb->fillcount==0)
  *                     return 0xffff;
@@ -216,7 +216,7 @@ circularbytebuffer_get_lifo:
 
 /******************************************************************************/
 /*
- *     uint16_t circularbytebuffer_get_fifo(circularbytebuffer_tcb){
+ *     uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t *cb){
  *             uint8_t ret;
  *             if(cb->fillcount==0)
  *                     return 0xffff;
@@ -229,6 +229,8 @@ circularbytebuffer_get_lifo:
  *     }
  *
  * param cb:  r24:r25
+ * return:    r24
+ * modifys:   r22-r27,r30,r31
  */
 .global circularbytebuffer_get_fifo
 circularbytebuffer_get_fifo:
@@ -262,7 +264,7 @@ circularbytebuffer_get_fifo:
 
 /******************************************************************************/
 /*
- *     uint8_t circularbytebuffer_append(uint8_t elem, circularbytebuffer_tcb){
+ *     uint8_t circularbytebuffer_append(uint8_t elem, circularbytebuffer_t *cb){
  *             if(cb->fillcount==cb->buffer_size)
  *                     return 1;
  *             cb->fillcount++;        
@@ -285,6 +287,7 @@ circularbytebuffer_append:
        ldd r23, Z+BUFFER_SIZE_OFFSET
        cp r22, r23
        brne 10f
+5:
        ldi r24, 1
        ret
 10:
@@ -319,7 +322,7 @@ circularbytebuffer_append:
 
 /******************************************************************************/
 /*
- *     uint8_t circularbytebuffer_push(uint8_t elem, circularbytebuffer_tcb){
+ *     uint8_t circularbytebuffer_push(uint8_t elem, circularbytebuffer_t *cb){
  *             if(cb->fillcount==cb->buffer_size)
  *                     return 1;
  *             cb->fillcount++;        
@@ -341,14 +344,15 @@ circularbytebuffer_push:
        ldd r22, Z+FILLCOUNT_OFFSET
        ldd r23, Z+BUFFER_SIZE_OFFSET
        cp r22, r23
-       brne 10f
-       ldi r24, 1
-       ret
+       brlo 10f
+       rjmp 5b
+;      ldi r24, 1
+;      ret
 10:
-       clt
-       tst r22
-       brne 11f
-       set
+;      clt
+;      tst r22
+;      brne 11f
+;      set
 11:    
        inc r22
        std Z+FILLCOUNT_OFFSET, r22
@@ -366,7 +370,7 @@ circularbytebuffer_push:
 20:
        std Z+HEAD_OFFSET, r26
        std Z+HEAD_OFFSET+1, r27
-       brtc 30b
-       std Z+TAIL_OFFSET, r26
-       std Z+TAIL_OFFSET+1, r27
+;      brtc 30b
+;      std Z+TAIL_OFFSET, r26
+;      std Z+TAIL_OFFSET+1, r27
        rjmp 30b