当前位置:网站首页>逻辑运算指令
逻辑运算指令
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
边栏推荐
- How to configure hosts when setting up Eureka
- Sublime text code formatting operation
- 谢邀,人在工区,刚交代码,在下字节跳动实习生
- Shell_ 00_ First meeting shell
- ~69 other ways to use icon fonts
- Solr new core
- LeetCode 1566. Repeat the pattern with length m at least k times
- Solve the problem that intel12 generation core CPU single thread only runs on small cores
- 7-10 punch in strategy
- Jedis
猜你喜欢

One hundred questions of image processing (11-20)

LeetCode 1020. Number of enclaves

Shell_ 04_ Shell script

ffmpeg命令行使用

~81 long table

Simply try the new amp model of deepfacelab (deepfake)

亮相Google I/O,字节跳动是这样应用Flutter的

LeetCode 1584. Minimum cost of connecting all points

Shell_ 06_ Judgment and circulation

The most lost road I have ever walked through is the brain circuit of ByteDance programmers
随机推荐
~68 Icon Font introduction
After the subscript is used to assign a value to the string type, the cout output variable is empty.
7-6 sum of combinatorial numbers
One hundred questions of image processing (1-10)
字节跳动技术面试官现身说法:我最想pick什么样的候选人
JS encapsulates the method of array inversion -- Feng Hao's blog
LeetCode 1557. The minimum number of points that can reach all points
Cartesian tree (modified)
ffmpeg命令行使用
搭建flutter环境入坑集合
Data config problem: the reference to entity 'useunicode' must end with ';' delimiter.
LeetCode 1637. The widest vertical area between two points without any point
Educational Codeforces Round 122 (Rated for Div. 2)
音视频开发面试题
~81 long table
Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
Shell_ 01_ data processing
~71 abbreviation attribute of font
I'm "fixing movies" in ByteDance
Continue and break jump out of multiple loops





