当前位置:网站首页>Assembly language learning (7)
Assembly language learning (7)
2022-08-09 14:50:00 【The goal is a tech house】
This part is mainly for the usage examples of some instructions of the flag register in Chapter 11 of Wang Shuang's "Assembly Language".
1.adc carry addition instruction exploration:
Be careful to use statements that do not affect the CF bit
Points to note:
1. Subroutine structure:
Put all the registers to be used on the stack first, and pop them off the stack after the program ends
2. Set the value of CF:
Let sub ax,ax clear the value of CF in advance
Use inc and loop to adjust the offset address instead of add to prevent affecting the value of CF
add128: push axpush cxpush sipush dipush bxsub ax,axmov cx,8s: mov ax,[si]adc ax,[di]mov [bx],axinc diinc diinc siinc siinc bxinc bxloop spop bxpop dipop sipop cxpop axretUse with 2.cmp command
Count the number of bytes with a value of 8 in the data segment.
The idea is to skip the count part if not equal.
mov bx,0mov ax,0mov cx,8s: cmp byte ptr [bx],8jne nextinc axnext: inc bxloop sNumber of bytes whose statistical value is greater than 8: jna next
Number of bytes whose statistical value is less than 8: jnb next
3. Use of string instructions
mov ax,datamov ds,axmov es,axmov di,0mov si,16mov cx,8cldrep movsw4. About popf and pushf
Through these two instructions, you can fetch or modify the value of the flag register
After the following program is executed, what is ax?
mov ax,0push axpopf ;The flag register is 0mov ax,0fff0hadd ax,0010h ;ax = 0 ZF is 0, PF is 1, CF is 1, OF is 0, SF is 0pushfpop ax ;ax is equal to the value of the flags registerand al,11000101Band ah,00001000BGet ax=00000000_01000101ie 0045h
边栏推荐
猜你喜欢
随机推荐
idea安装
汇编语言学习(八)
Mysql seven connection query methods
“未来10年,中国APP不可能回印度了”
*2-4 每日温度 *2-5 接雨水
*1-5 OJ 642 Russian Multiplication
#25-1 OJ 78 Calculate birthday day of the week
Shell course summary
模拟实现strcpy函数的实现(含多次优化思想)
在Word中如何调整编号和文字之间的间距?
汇编语言学习(九)
阿里巴巴开源大规模稀疏模型训练/预测引擎DeepRec
阿里巴巴云原生大数据运维平台 SREWorks 正式开源
除了开心麻花,中国喜剧还有什么?
C语言中的 pow 函数 使用方法及注意事项,和常见报错原因,且分享实战中的使用
*1-2 OJ 190 run-length code
阿里云发布中国云原生数据湖应用洞察白皮书
Kubernetes资源编排系列之三: Kustomize篇
测试研发的人数科学比例
【LeetCode】1413. 逐步求和得到正数的最小值









