簡體   English   中英

你能在Arduino(C / C ++)中創建128位無符號整數嗎?

[英]Can you make 128 bit unsigned ints in Arduino (C/C++)?

我正在使用uints來存儲位序列,並希望存儲128位序列。我計划使用循環位旋轉來循環它們。 有一個很好的方法來制作一個128位整數? 如果沒有,那么下一個最容易被“循環移位”的東西是什么?

我需要它快速運行,因為它將在中斷中發生。 大概每250微秒。

使用char[16]數組,並在匯編中而不是C中編寫關鍵的移位代碼,因為C沒有一種好的方法可以讓您從移位中訪問進位。

你應該能夠做類似的事情

ldi r29, hi8(array) ; Load Y register
ldi r28, lo8(array) ; (16 bits)
ldi r22, 16         ; Loop counter
ldd r23, Y+15       ; Get the last byte
lsl r23             ; And put the last bit into the carry flag
loop:               ;   so it will be shifted into the first bit
ld r23, Y           ; Load from array into r23
rol                 ; Rotate left through carry
st Y+, r23          ; Store it back and increment Y
dec r22             ; Decrement loop counter
brne loop           ; Loop if not done

做旋轉,但這是未經測試的,我不是AVR組裝專家。 dec是特殊的,不會干擾進位標志,所以它通過循環安全地保存。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM