当前位置:网站首页>逻辑运算指令
逻辑运算指令
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
边栏推荐
- 字节跳动多篇论文入选 CVPR 2021,精选干货都在这里了
- ~82 style of table
- Monomer application concept
- Eureka single machine construction
- Detailed explanation of FLV format
- redux使用说明
- 「博士毕业一年,我拿下 ACL Best Paper」
- Spark independent cluster dynamic online and offline worker node
- (multiple methods, need to continue to see) 7-11 go deep into the tiger's Den
- ~69 other ways to use icon fonts
猜你喜欢

Solve the single thread scheduling problem of intel12 generation core CPU (II)

Audio and video development interview questions

Erlang installation

Shell_ 06_ Judgment and circulation

100张图训练1小时,照片风格随意变,文末有Demo试玩|SIGGRAPH 2021

ByteDance technical Interviewer: what kind of candidate do I want to pick most

Full record of ByteDance technology newcomer training: a guide to the new growth of school recruitment

~Introduction to form 80

Ffmpeg command line use

Sublime text code formatting operation
随机推荐
Continue and break jump out of multiple loops
~70 row high
我在字节跳动「修电影」
js垃圾回收机制和内存泄漏
How to generate six digit verification code
I'm "fixing movies" in ByteDance
Gridhome, a static site generator that novices must know
~84 form supplement
字节跳动2022校招研发提前批宣讲会,同学们最关心的10个问题
~83 form introduction
LeetCode 1545. Find the k-th bit in the nth binary string
视频压缩编码和音频压缩编码基本原理
Cartesian tree (modified)
Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]
Educational Codeforces Round 122 (Rated for Div. 2)
LeetCode 1562. Find the latest group of size M
Chapter III principles of MapReduce framework
LeetCode 1636. Sort the array in ascending order by frequency
string. How to choose h and string and CString
~74 JD top navigation bar exercise





