当前位置: 代码迷 >> 汇编语言 >> 如何这个程序会说小弟我的是32位的,在16位下不行?
  详细解决方案

如何这个程序会说小弟我的是32位的,在16位下不行?

热度:7586   发布时间:2013-02-26 00:00:00.0
怎么这个程序会说我的是32位的,在16位下不行??
Assembly code
;Title: Binary notation;---------------------------------------------------------------------------------------------;Description: Anohter implementation of complemental code edition using bit scan reverse method;Author: ;Finish date:2007-11-16;Modify date:;Algorithm:用一个数组保存16个二进制的ASCII码,初值全设为'0'。从前往后扫描,如里为全'0'则可以;          输出再退出程序,若非'0'刚记下[这是一个数字'1'所在的位置,将字符数组相应设为'1',;          同时将扫描的二进制数的相应位设为0,再重新循环扫描。;----------------------------------------------------------------------------------------------.386data1   segment use16            ;Please   input   here   the   code   of   data   segment             val  dw  -28             msg  db  16 dup('0'),13,10,'$ ' data1   ends stack1   segment  use16        ;Please   input   here   the   code   of   data   segment stack1   ends code1   segment   use16        assume   cs:code1,ds:data1,ss:stack1 start:         mov     ax,data1         mov     ds,ax         ;Please   input   here   the   code   of   code   segment         mov     ax,[val]         mov     si,offset msg         add     si,15dscan:                                                 BSR     cx,ax                         ;Scan   the   binary,   get   the   subscript   of   bit   1         je      quit                          ;If   all   bits   are   0,   then   terminate   the   program         BTR     ax,cx                         ;set   the   bit   1   to   zero         sub     si,cx                         ;Get the offset of the digit 1         mov     byte ptr [si],'1'             ;set   '1 '   to   the   string         mov     si,offset msg         add     si,15d                        ;Reset address        jmp     scan quit:         mov     ah,9         mov     dx,offset   msg         int     21h         mov     ah,4ch         int     21h code1   ends         end     start 

上面的代码为什么一定要加上

.386 ;这个倒在 Assembly language for Intel-based computers fourth edition 里面见过,不过我现在才看100多页,所以不太会,学校里只学16位的。
use16

才能运行呢?
本人现在正在学16位的汇编,望指教。
谢谢!!!

------解决方案--------------------------------------------------------
因为你的程序里用了386CPU才有的指令BSR,BTR
如果不加.386,默认的8086指令集里无此指令,对它们就只能按错误处理。

如果你不愿意用.386,则需要修改程序,用8086指令的小程序段来实现这两条指令的操作功能。


------解决方案--------------------------------------------------------
从386开始,CPU字长是32位的了呀,不加的话,默认你写的是32位程序
  相关解决方案