vb程序中实现字节移位操作(byte shift operation in vb program)

vb程序中实现字节移位操作(byte shift operation in vb program)

ID:36228290

大小:19.40 KB

页数:8页

时间:2019-05-07

vb程序中实现字节移位操作(byte shift operation in vb program)_第1页
vb程序中实现字节移位操作(byte shift operation in vb program)_第2页
vb程序中实现字节移位操作(byte shift operation in vb program)_第3页
vb程序中实现字节移位操作(byte shift operation in vb program)_第4页
vb程序中实现字节移位操作(byte shift operation in vb program)_第5页
资源描述:

《vb程序中实现字节移位操作(byte shift operation in vb program)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、vb程序中实现字节移位操作(ByteshiftoperationinVBprogram)Author:LonelyNineSwordEmail:mikaiyue@sina.comDate:2001-7-519:37:15ByteshiftoperationinVBprogram(LiXiangjiang,2001,04,29,11:34)IntheuseofVBdataacquisitionsystemdevelopmentorindustrialcontrolsoftware,orlow-leveloperationso

2、nthefile,oftenrequiresabyteshiftoperation,buttheVBsystemdoesnotprovidebyteshiftoperationinstructionsandfunctions,providesonlyAnd(andOr),and(or)Xor(XOR)andEqu(orthesame),Not(non-)andseveralotherlogicoperations.TheauthorusedVBinthedevelopmentofindustrialcontrolsyste

3、msoftwareintheprocess,encounteredthisproblem,sotheuseofVBinthelogicaloperationinstruction,simulationassemblylanguagebyteshiftinstructionprogramsevenbyteshiftfunction:logicshiftleft,right,right,circularlogicarithmeticleftshift,rotateright,carrycycleleftshiftandrota

4、teright.Inassemblerlanguageinstructionfunction,logicshiftleftequivalentby2,logicshiftfunctionisequivalenttoonly2,usingthisfeatureintheVBprogramby2andinadditiontothe2methodstoachievetheleftandright,andthenAnd(andOr)and(or)logicoperations,judgmentifthereisashiftinth

5、eprocessofcarry,theflagisset.ProgramlistCFisacarryflag,whichusesBooleantypelogicalvariables.IfCFisTrue,thereisacarry,andFalsemeansnocarry.PublicCFAsBoolean'carryflag'1.logicmovesleftPublicFunctionSHL(OPRAsByte,nAsInteger)AsByteDimBDAsByteDimIAsIntegerBD=OPRForI=1,

6、To,N-1BD=(BDAnd&H7F)*2'movestheD7bittothelefttopreventbyteoverflowNextICF=BD,And,&H80'determineswhethertheD7bitiscarriedornotSHL=(BD,And,&H7F)*2EndFunction'2.logicalrightshiftPublicFunctionSHR(OPRAsByte,nAsInteger)AsByteDimBDAsByteDimIAsIntegerBD=OPRForI=1,To,N-1B

7、D=BD2'rightshiftNextICF=BD,And1'determineswhethertheD0bitiscarriedSHR=BD2EndFunction'3.arithmeticrightshiftPublicFunctionSAR(OPRAsByte,nAsInteger)AsByteDimBDAsByteDimIAsIntegerDimFg1AsByteBD=OPRFg1=BD,And,&H80ForI=1,To,N-1BD=BD2'rightshiftNextICF=BDAnd1'determi

8、neswhethertheD0bitiscarriedornotBD=BD2'rightshiftSAR=BD,Or,Fg1EndFunction'4.loopleftshiftPublicFunctionROL(OPRAsByte,nAsInteger)AsByteDimBDAsByteDimIAs

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。