Delphi循环移位操作

如果在X86计算机上很简单,直接内嵌汇编ror和rol指令就是循环移位.
但是如果在Android的平台上,asm关键字是无效的.
只能自己实现.

function ror(const Value: DWORD; ShiftValue: Byte): DWORD; overload;
begin
Result := (Value shl (8 * SizeOf(Value) – ShiftValue)) or
(Value Shr ShiftValue);
end;

function ror(const Value: WORD; ShiftValue: Byte): DWORD; overload;
begin
Result := (Value shl (8 * SizeOf(Value) – ShiftValue)) or
(Value Shr ShiftValue);
end;

function ror(const Value: Byte; ShiftValue: Byte): DWORD; overload;
begin
Result := (Value shl (8 * SizeOf(Value) – ShiftValue)) or
(Value Shr ShiftValue);
end;

function rol(const Value: DWORD; ShiftValue: Byte): DWORD; overload;
begin
Result := (Value shr (8 * SizeOf(Value) – ShiftValue)) or
(Value Shl ShiftValue);
end;

function rol(const Value: WORD; ShiftValue: Byte): DWORD; overload;
begin
Result := (Value shr (8 * SizeOf(Value) – ShiftValue)) or
(Value Shl ShiftValue);
end;

function rol(const Value: Byte; ShiftValue: Byte): DWORD; overload;
begin
Result := (Value shr (8 * SizeOf(Value) – ShiftValue)) or
(Value Shl ShiftValue);
end;

举例子:
a := ror(DWORD(1), 1);
注意第一个参数因为给的是常量1,如果不指明类型会按最小的来,也就是会被当成Byte的.

如果是C++用模板不必重载写两个函数就够了.而象Delphi/C#/Java的泛型没法做到这个.
因为C++的泛型是编译时替换的,完全没有类型信息.
而后三种语言首先你要把T做移位就会编译不过.

此条目发表在Delphi, 未分类分类目录。将固定链接加入收藏夹。

Delphi循环移位操作》有 123 条评论

  1. 匿名说:

    厉害,学习了

  2. 匿名说:

    大牛好久没发论文了,今天终于等到了,向大牛学习,以后能不能多发一些学习学习,特别是移动开发,谢谢,向大牛致敬!!!!!!

  3. 匿名说:

    能不能联系我?说不定有些项目我们可以合作一下。QQ617245489,谢谢!

  4. Pingback引用通告: 43ytr.icu/j/GPoAr

  5. Pingback引用通告: abisko.ru

  6. Pingback引用通告: glyxar.ru

  7. Pingback引用通告: wwin-tv.com

  8. Pingback引用通告: hs;br

  9. Pingback引用通告: tureckie_serialy_na_russkom_jazyke

  10. Pingback引用通告: tureckie_serialy

  11. Pingback引用通告: 00-tv.com

  12. Pingback引用通告: +1+

  13. Pingback引用通告: æóêè+2+ñåðèÿ

  14. Pingback引用通告: Ñìîòðåòü ñåðèàëû îíëàéí âñå ñåðèè ïîäðÿä

  15. Pingback引用通告: Ñìîòðåòü âñå ñåðèè ïîäðÿä

  16. Pingback引用通告: watch

  17. Pingback引用通告: ++++++

  18. Pingback引用通告: HD-720

  19. Pingback引用通告: guardians+of+the+galaxy+2

  20. Pingback引用通告: strong woman do bong soon

  21. Pingback引用通告: my id is gangnam beauty

  22. Pingback引用通告: 2020

  23. Pingback引用通告: kpop+star+season+6+ep+9

  24. Pingback引用通告: Video

  25. Pingback引用通告: 1 2 3 4 5 6 7 8 9 10

  26. Pingback引用通告: Watch TV Shows

  27. Pingback引用通告: Kinokrad 2019 Kinokrad Hd

  28. Pingback引用通告: Kinokrad

  29. Pingback引用通告: filmy-kinokrad

  30. Pingback引用通告: kinokrad-2019

  31. Pingback引用通告: filmy-2019-kinokrad

  32. Pingback引用通告: serial

  33. Pingback引用通告: cerialest.ru

  34. Pingback引用通告: youtube2019.ru

  35. Pingback引用通告: dorama hdrezka

  36. Pingback引用通告: movies hdrezka

  37. Pingback引用通告: HDrezka

  38. Pingback引用通告: kinosmotretonline

  39. Pingback引用通告: LostFilm HD 720

  40. Pingback引用通告: trustedmdstorefy.com

  41. Pingback引用通告: bofilm ñåðèàë

  42. Pingback引用通告: bofilm

  43. Pingback引用通告: 1 seriya

  44. Pingback引用通告: Êîíñóëüòàöèÿ ïñèõîëîãà

  45. Pingback引用通告: topedstoreusa.com

  46. Pingback引用通告: hqcialismht.com

  47. Pingback引用通告: viagramdtrustser.com

  48. Pingback引用通告: 4serial.com

  49. Pingback引用通告: Evil-Season-1

  50. Pingback引用通告: Evil-Season-2

  51. Pingback引用通告: Evil-Season-3

  52. Pingback引用通告: Evil-Season-4

  53. Pingback引用通告: Dollface-Season-1

  54. Pingback引用通告: Queer-Eye-We-re-in-Japan-Season-1

  55. Pingback引用通告: serial 2020

  56. Pingback引用通告: Dailymotion

  57. Pingback引用通告: Watch+movies+2020

  58. Pingback引用通告: serial-video-film-online

  59. Pingback引用通告: tvrv.ru

  60. Pingback引用通告: 1plus1serial.site

  61. Pingback引用通告: #1plus1

  62. Pingback引用通告: 1plus1

  63. Pingback引用通告: Watch Movies Online

  64. Pingback引用通告: Film

  65. Pingback引用通告: Film 2020

  66. Pingback引用通告: Film 2021

  67. Pingback引用通告: watch online TV LIVE

  68. Pingback引用通告: parazity-oskar-2020

  69. Pingback引用通告: human design

  70. Pingback引用通告: DSmlka

  71. Pingback引用通告: viagra

  72. Pingback引用通告: viagra online

  73. Pingback引用通告: +

  74. Pingback引用通告: ¯jak Son³k

  75. Pingback引用通告: astrolog

  76. Pingback引用通告: film-kalashnikov-watch

  77. Pingback引用通告: generic cialis

  78. Pingback引用通告: cialis 20mg

  79. Pingback引用通告: kinoxaxru.ru

  80. Pingback引用通告: pobachennya u vegas

  81. Pingback引用通告: Proshanie so Stalinym

  82. Pingback引用通告: strelcov 2020

  83. Pingback引用通告: film t-34

  84. Pingback引用通告: online pharmacy

  85. Pingback引用通告: canadian pharmacy

  86. Pingback引用通告: Beograd film 2020

  87. Pingback引用通告: psiholog

  88. Pingback引用通告: pomoshh-psihologa-online

  89. Pingback引用通告: psixolog

  90. Pingback引用通告: coronavirus

  91. Pingback引用通告: PSYCHOSOCIAL

  92. Pingback引用通告: Cherekasi

  93. Pingback引用通告: Film Doktor Liza (2020)

  94. Pingback引用通告: film djoker

  95. Pingback引用通告: t.me/psyhell

  96. Pingback引用通告: Îíëàéí Ïñèõîëîã

  97. Pingback引用通告: viagra coupons

  98. Pingback引用通告: viagra over the counter

  99. Pingback引用通告: buy viagra online

  100. Pingback引用通告: viagra pill

  101. Pingback引用通告: otc viagra

  102. Pingback引用通告: cialis

  103. Pingback引用通告: cialis coupon

  104. Pingback引用通告: canadian pharmacy cialis

  105. Pingback引用通告: cialis 5mg

  106. Pingback引用通告: rlowcostmd.com

  107. Pingback引用通告: bitly.com

  108. Pingback引用通告: bitly

  109. Pingback引用通告: Zemlyane 2005 smotret onlajn

  110. Pingback引用通告: viagra 100mg

  111. Pingback引用通告: smotret onlajn besplatno v kachestve hd 1080

  112. Pingback引用通告: malenkie-zhenshhiny-2020

  113. Pingback引用通告: dom 2

  114. Pingback引用通告: zoom-psykholog

  115. Pingback引用通告: zoom-viber-skype

  116. Pingback引用通告: Vratar Galaktiki Film, 2020

  117. Pingback引用通告: Vratar

  118. Pingback引用通告: Cherkassy

  119. Pingback引用通告: chernobyl-hbo-2020-1-sezon-2-sezon

  120. Pingback引用通告: moskva-psiholog

  121. Pingback引用通告: batmanapollo.ru

  122. Pingback引用通告: dom2-ru

  123. Pingback引用通告: psy psy psy psy

发表评论

电子邮件地址不会被公开。

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

你必须启用JavaScript