汇编语言实验-地址表和移位 以及关于db伪指令的一些内容

题目如下:BL中的只有一位为0,编写程序测试0所在的位数,并输出提示信息“The X Bit is 0”,要求使用地址表方法实现。
网上很容易找到答案,但是用了很多跳转指令,太繁琐,嫌弃!
直接上代码

data segment
str1 db 'the 1 bit is 0$',0ah,0dh
str2 db 'the 2 bit is 0$',0ah,0dh
str3 db 'the 3 bit is 0$',0ah,0dh
str4 db 'the 4 bit is 0$',0ah,0dh
str5 db 'the 5 bit is 0$',0ah,0dh
str6 db 'the 6 bit is 0$',0ah,0dh
st7r db 'the 7 bit is 0$',0ah,0dh
str8 db 'the 8 bit is 0$',0ah,0dh
data ends
code segment
assume cs:code,ds:data
start:
mov ax, data
mov ds, ax
mov bl, 11101111b
mov cx,8
mov dx,0
again:
shl bl,1
jnc next	;找0用jnc,找1用jc
add dx,16	;dx+字符串长度,我这里数据段定义的都是长16
loop again
next:
add dx,1	;到下一个字符串的开头位置
mov ah,9	;字符串输出
int 21h	;中断调用
mov ah, 4ch
int 21h
code ends
end start

结果如下图:
在这里插入图片描述

小结

  • db伪指令定义的字符串在数据段中所占长度为n*byte,n为字符串长度(含空格,不含’$’)
  • 使用ds:dx方式访问字符串时(如中断09h),系统会从数据段第dx位开始往后读到第一个’$’
  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值