内容1:编程将内存数据段字节单元INDAT存放的一个数n(假设0≤ n≤9 ),以十进制形式在屏幕上显示出来。

data segment
indat   db 8
data ends
code segment
    assume cs:code,ds:data
start:
    mov ax,data
    mov ds,ax
    mov dl,indat
    add dl,30h  
    mov ah,2   
    int 21h
    mov dl,'D'
    mov ah,2
    int 21h
    mov ah,4ch
    int 21h
code ends
  end start

cmd 下运行:
8D

内容2:编写程序段,求AX中存放的带符号数的绝对值,结果存RES单元。


data segment num dw -8 res dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,num cmp ax,0 jge ispositive neg ax ispositive: mov res,ax mov ah,4ch int 21h code ends end start

debug:

-u
1848:0000 B84718        MOV     AX,1847
1848:0003 8ED8          MOV     DS,AX
1848:0005 A10000        MOV     AX,[0000]
1848:0008 3D0000        CMP     AX,0000
1848:000B 7D02          JGE     000F
1848:000D F7D8          NEG     AX
1848:000F A30200        MOV     [0002],AX
1848:0012 B44C          MOV     AH,4C
1848:0014 CD21          INT     21
1848:0016 0000          ADD     [BX+SI],AL
1848:0018 0000          ADD     [BX+SI],AL
1848:001A 0000          ADD     [BX+SI],AL
1848:001C 0000          ADD     [BX+SI],AL
1848:001E 0000          ADD     [BX+SI],AL
-

然后查看寄存器地址:

-g 0014
AX=4C08  BX=0000  CX=0026  DX=0000  SP=0000  BP=0000  SI=0000  DI=0000
DS=1847  ES=1837  SS=1847  CS=1848  IP=0014   NV UP EI PL NZ AC PO CY
1848:0014 CD21          INT     21

最后查看ret中的内容:

-d 1847:0
1847:0000  F8 FF 08 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1847:0010  B8 47 18 8E D8 A1 00 00-3D 00 00 7D 02 F7 D8 A3   .G......=..}....
1847:0020  02 00 B4 4C CD 21 00 00-00 00 00 00 00 00 00 00   ...L.!..........
1847:0030  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1847:0040  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1847:0050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1847:0060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
1847:0070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
-

在-u命令时可以看出ret地址为1847:0002,在-d 1847:0中可以看到这个单元中储存的内容是:0008H,即十进制数8.
则可以看到ret中是取绝对值后的数字。

0
Posted in 汇编语言

Leave a Comment:

电子邮件地址不会被公开。