收藏 分享(赏)

vb程序中实现字节移位操作(Byte shift operation in VB program).doc

上传人:dreamzhangning 文档编号:2790203 上传时间:2018-09-27 格式:DOC 页数:9 大小:19.40KB
下载 相关 举报
vb程序中实现字节移位操作(Byte shift operation in VB program).doc_第1页
第1页 / 共9页
vb程序中实现字节移位操作(Byte shift operation in VB program).doc_第2页
第2页 / 共9页
vb程序中实现字节移位操作(Byte shift operation in VB program).doc_第3页
第3页 / 共9页
vb程序中实现字节移位操作(Byte shift operation in VB program).doc_第4页
第4页 / 共9页
vb程序中实现字节移位操作(Byte shift operation in VB program).doc_第5页
第5页 / 共9页
点击查看更多>>
资源描述

1、vb程序中实现字节移位操作(Byte shift operation in VB program)Author: Lonely Nine SwordEmail: Date: 2001-7-5 19:37:15Byte shift operation in VB program(Li Xiangjiang, 2001, 04, 29, 11:34)In the use of VB data acquisition system development or industrial control software, or low-level operations on the file, ofte

2、n requires a byte shift operation, but the VB system does not provide byte shift operation instructions and functions, provides only And (and Or), and (or) Xor (XOR) and Equ (or the same), Not (non -) and several other logic operations. The author used VB in the development of industrial control sys

3、tem software in the process, encountered this problem, so the use of VB in the logical operation instruction, simulation assembly language byte shift instruction program seven byte shift function: logic shift left, right, right, circular logic arithmetic left shift, rotate right, carry cycle left sh

4、ift and rotate right.In assembler language instruction function, logic shift left equivalent by 2, logic shift function is equivalent to only 2, using this feature in the VB program by 2 and in addition to the 2 methods to achieve the left and right, and then And (and Or) and (or) logic operations,

5、judgment if there is a shift in the process of carry, the flag is set.Program listCF is a carry flag, which uses Boolean type logical variables. If CF is True, there is a carry, and False means no carry.Public CF As Boolean carry flag1. logic moves leftPublic Function SHL (OPR As Byte, n As Integer)

6、 As ByteDim BD As ByteDim I As IntegerBD = OPRFor I = 1, To, N - 1BD = (BD And &H7F) * 2 moves the D7 bit to the left to prevent byte overflowNext ICF = BD, And, &H80 determines whether the D7 bit is carried or notSHL = (BD, And, &H7F) * 2End Function2. logical right shiftPublic Function SHR (OPR As

7、 Byte, n As Integer) As ByteDim BD As ByteDim I As IntegerBD = OPRFor I = 1, To, N - 1BD = BD 2 right shiftNext ICF = BD, And 1 determines whether the D0 bit is carriedSHR = BD 2End Function3. arithmetic right shiftPublic Function SAR (OPR As Byte, n As Integer) As ByteDim BD As ByteDim I As Integer

8、Dim Fg1 As ByteBD = OPRFg1 = BD, And, &H80For I = 1, To, N - 1BD = BD 2 right shiftNext ICF = BD And 1 determines whether the D0 bit is carried or notBD = BD 2 right shiftSAR = BD, Or, Fg1End Function4. loop left shiftPublic Function ROL (OPR As Byte, n As Integer) As ByteDim BD As ByteDim I As Inte

9、gerDim Fg1 As ByteBD = OPRFor I = 1, To, nFg1 = (BD And &H80) 128 determines whether D7 bit is carried or notBD = (BD And &H7F) * 2) Or Fg1 left with carryNext ICF = Fg1ROL = BDEnd Function5. loop right shiftPublic Function ROR (OPR As Byte, n As Integer) As ByteDim BD As ByteDim I As IntegerDim Fg1

10、 As ByteDim Fg2 As ByteBD = OPRFor I = 1, To, nFg1 = (BD And 1) * 128 determines whether D0 bit is carried or notBD = (BD 2) Or Fg1 move right with carryNext ICF = Fg1ROR = BDEnd Function6. carry loop left shiftPublic Function RCL (OPR As Byte, n As Integer) As ByteDim BD As ByteDim I As IntegerDim

11、Fg1 As ByteDim Fg2 As ByteBD = OPRFg2 = CF And 1For I = 1 To nFg1 = (BD And &H80) 128 determines whether D7 bit is carried or notBD = (BD And &H7F) * 2) Or Fg2 left with carryFg2 = Fg1Next ICF = Fg1RCL = BDEnd Function7. carry loop right shiftPublic Function RCR (OPR As Byte, n As Integer) As ByteDi

12、m BD As ByteDim I As IntegerDim Fg1 As ByteDim Fg2 As ByteBD = OPRFg2 = CF And 128For I = 1, To, nFg1 = (BD And 1) * 128 determines whether D0 bit is carried or notBD = (BD 2) Or Fg2 move right with carryFg2 = Fg1Next ICF = Fg1RCR = BDEnd FunctionConcluding remarksThe function and usage of the above seven byte shift operation function with macro assembler language shift instruction is basically the same, but only for single byte operation, but the program is modified, can be a double byte and four byte Integer type Long type shift operation.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 大学课件

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报