当前位置:网站首页>逻辑运算指令
逻辑运算指令
2022-07-06 09:29:00 【My71】
循环移位
- 移位是针对寄存器中的二进制数进行移位。
- 在 debug 模式中寄存器里的值均已 16 进制显示。
- 当只移一位的时候,可以将数字 1 放到移动指令的源操作数上。若移动位数大于 1,需要将移动的位数存到 cl 寄存器中。
左移 ROL
将权值最高位移动到全职最低位。
例:0110 左移后得到的结果是 1100
代码实现
- 需求:对 12h 进行向左移一位
- 运行结果:24h。
- 原理:12h = 00010010b,向左移位后得 00100100 即 24h
code segment assume cs:code main: mov bx,12h rol bx,1 edit: mov ah,4ch int 21h code ends end main
右移 ROR
- 将权值最低位移动到全职最高位。
- 例:0110 右移后得到的结果是 0011
逻辑运算
知识点
- 同高级语言的逻辑运算,遵循与或原则。
- 与运算:全真为真,一假为假。
- 或运算:一真为真,全假为假。
- 按位运算指的是按二进制位进行运算。
- 在二进制中,1 表示真,0 表示假。
指令
- 按位与运算:AND
- 按位或运算:OR
- 按位非运算:NOT
- 按位异或运算:XOR
例题
计算 24h 和 36h 的与运算
code segment assume cs:code main: mov bx,24h and bx,36h edit: mov ah,4ch int 21h code ends end main
计算 24h 和 36h 的或运算
code segment assume cs:code main: mov bx,24h or bx,36h edit: mov ah,4ch int 21h code ends end main
保留二进制的末尾数,其他高位清零。
code segment assume cs:code main: mov bx,0ffffh and bx,01h edit: mov ah,4ch int 21h code ends end main
综合应用
保留位和 1 做与运算。
清零位和 0 做与运算。
输出二进制
需求:将寄存器中的值以二进制形式输出到终端。
代码
code segment assume cs:code main: mov bl,12h mov cx,8h lopi: rol bl,1 mov dl,bl and dl,01h add dl,30h call d02 loop lopi mov dl,42h call d02 edit: mov ah,4ch int 21h d02 proc near mov ah,02h int 21h ret d02 endp code ends end main
输出十六进制
需求:将寄存器中的值以十六进制形式输出到终端。
代码
code segment assume cs:code main: mov bl,0a2h mov cx,2 lopi: push cx mov cl,4 rol bl,cl pop cx mov dl,bl and dl,0fh cmp dl,09h jg letter jng number letter: add dl,37h call d02 jmp endcmp number: add dl,30h call d02 endcmp: loop lopi mov dl,48h call d02 edit: mov ah,4ch int 21h d02 proc near mov ah,02h int 21h ret d02 endp code ends end main
边栏推荐
- The 116 students spent three days reproducing the ByteDance internal real technology project
- I'm "fixing movies" in ByteDance
- Some instructions on whether to call destructor when QT window closes and application stops
- LeetCode 1557. The minimum number of points that can reach all points
- Submit several problem records of spark application (sparklauncher with cluster deploy mode)
- How to generate six digit verification code
- TypeScript基本操作
- ~78 radial gradient
- The QT program compiled on CentOS lacks a MySQL driven solution
- 7-4 harmonic average
猜你喜欢
原型链继承
One hundred questions of image processing (11-20)
~86m rabbit practice
Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
Shell_ 00_ First meeting shell
The 116 students spent three days reproducing the ByteDance internal real technology project
Error occurred during initialization of VM Could not reserve enough space for object heap
Solve the problem that intel12 generation core CPU single thread only runs on small cores
Shell_ 03_ environment variable
~76 sprite map
随机推荐
Shell_ 07_ Functions and regular expressions
Basic principles of video compression coding and audio compression coding
LeetCode 1984. Minimum difference in student scores
README. txt
~Introduction to form 80
LeetCode 1566. Repeat the pattern with length m at least k times
字节跳动开源GAN模型压缩框架,算力最高节省97.8%丨ICCV 2021
这116名学生,用3天时间复刻了字节跳动内部真实技术项目
Continue and break jump out of multiple loops
Soft music -js find the number of times that character appears in the string - Feng Hao's blog
力扣leetcode第 280 场周赛
Native JS realizes the functions of all selection and inverse selection -- Feng Hao's blog
[graduation project] QT from introduction to practice: realize imitation of QQ communication, which is also the last blog post in school.
谢邀,人在工区,刚交代码,在下字节跳动实习生
字节跳动2022校招研发提前批宣讲会,同学们最关心的10个问题
[unsolved]7-14 calculation diagram
搭建flutter环境入坑集合
Cmake Express
Spark independent cluster dynamic online and offline worker node
我走过最迷的路,是字节跳动程序员的脑回路