初级汇编语言
<p><span style="font-family: 宋体">汇编调试程序</span>DEBUG<span style="font-family: 宋体">的常用命令和功能,</span>DEBUG<span style="font-family: 宋体">环境下调试程序的方法.</span></p><p> </p>
<ol>
<li>两个无符号数相加,将结果数存入指定地址单元。被加数,加数及和存放地址及数据如下:</li>
</ol>
<p> <span style="font-family: 宋体">地址</span> <span style="font-family: 宋体">数据</span></p>
<p><span style="font-family: 宋体">被加数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0000 9FH</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0001 6BH</span></p>
<p> <span style="font-family: 宋体">加数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0002 5CH</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0003 42H</span></p>
<p> <span style="font-family: 宋体">和</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0004 </span></p>
<p> ~ 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0006</span></p>
<p> </p>
<div class="cnblogs_code">
<p>-e 2000:0000 9f 6b 5c 42<br>-a 1000:0<br> mov ax,<br> mov bx,<br> add ax,bx<br> mov 2000:,ax<br>-r cs<br>1000<br>-r ip<br>0<br>-t-t-t -t</p>
</div>
<p> </p>
<p><img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200522170709021-1317484005.jpg" alt=""></p>
<p> </p>
<p> </p>
<p> 2.两个无符号数相减,将差存入指定地址单元。被减数,减数及差的存放地址及数据如下:</p>
<p> <span style="font-family: 宋体">地址</span> <span style="font-family: 宋体">数据</span></p>
<p><span style="font-family: 宋体">被减数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0100 8C</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0101 42</span></p>
<p> <span style="font-family: 宋体">减数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0102 92</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0103 5A</span></p>
<p> <span style="font-family: 宋体">差</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0104</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0105</span></p>
<p> </p>
<div class="cnblogs_code">
<p>-e 2000:0100 8c 42 92 5a<br>-a 1000:0<br> mov ax,2000:<br> mov bx,2000:<br> sub ax,bx<br> mov 2000:,ax<br>-r cs<br>1000<br>-r ip<br>0<br>-t -t -t -t</p>
</div>
<p> </p>
<p><img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200522170829923-163503163.jpg" alt=""></p>
<p> </p>
<p> 3.两个无符号数相乘,将积存入指定地址单元。被乘数,乘数及积存放的地址及数据如下:</p>
<p> <span style="font-family: 宋体">地址</span> <span style="font-family: 宋体">数据</span></p>
<p><span style="font-family: 宋体">被乘数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">1000 56</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">1001 2C</span></p>
<p> <span style="font-family: 宋体">乘数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">1002 3A</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">1003 1C</span></p>
<p> <span style="font-family: 宋体">积</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">1004</span></p>
<p> ~ 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">1007</span></p>
<p> </p>
<div class="cnblogs_code">
<p>-e 2000:0200 56 2C 3A 1C<br>-a 1000:0000<br> mov ax,2000:<br> mov bx,2000:<br> mul bx<br> mov 2000:,ax<br> mov 20000:,dx<br>-r cs <br>1000<br>-r ip<br>0<br>-t -t -t -t -t</p>
</div>
<p> </p>
<p><img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200522170904113-400315826.jpg" alt=""></p>
<p> </p>
<p> 4.两个无符号数相除,将商及余数存入指定的地址单元。被除数,除数,商及余数存放的地址及数据如下:</p>
<p> <span style="font-family: 宋体">地址</span> <span style="font-family: 宋体">数据</span></p>
<p><span style="font-family: 宋体">被除数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0200 2A</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0201 3B</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0202 4C</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0203 5D</span></p>
<p> <span style="font-family: 宋体">除数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0204 7C</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0205 5D</span></p>
<p> <span style="font-family: 宋体">商</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0206</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0207</span></p>
<p> <span style="font-family: 宋体">余数</span> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0208</span></p>
<p> 2000<span style="font-family: 宋体">:</span><span style="font-family: Calibri">0209</span></p>
<p> </p>
<div class="cnblogs_code">
<p>-e 2000:0200 2a 3b 4c 5d 7c 5d<br>-a 1000:0<br> mov ax,2000:<br> mov bx,2000:<br> div bx<br> mov 2000:,ax<br> mov 2000:,dx<br>-r cs<br>1000<br>-r ip<br>0<br>-t -t -t -t -t</p>
</div>
<p> </p>
<p><img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200522170931671-2120548304.jpg" alt=""></p>
<p> </p>
<p><span style="font-family: 宋体">屏幕显示计算机提问</span>:</p>
<p>Do you like this book ?</p>
<p><span style="font-family: 宋体">若用户回答</span>N, <span style="font-family: 宋体">计算机回答</span><span style="font-family: Calibri">:</span></p>
<p>You may go to the next store.</p>
<p>若用户回答Y, <span style="font-family: 宋体">计算机回答</span><span style="font-family: Calibri">:</span></p>
<p> I think you will buy it.</p>
<p> </p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">DATA SEGMENT
SEN1 DB 0DH,0AH,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Do you like this book </span><span style="color: rgba(128, 0, 0, 1)">"</span>,0x3fh,0DH,0AH,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
SEN2 db 0DH,0AH,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">You may go to the next store.</span><span style="color: rgba(128, 0, 0, 1)">"</span>,0DH,0AH,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
SEN3 DB 0DH,0AH,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">I think you will buy it</span><span style="color: rgba(128, 0, 0, 1)">"</span>,0DH,0AH,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
SEN4 DB 0DH,0AH,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Please input a word(Y or N)</span><span style="color: rgba(128, 0, 0, 1)">"</span>,0DH,0AH,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:MOV AX,DATA
MOV DS,AX
MOV Ah,2h
MOV BH,</span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
MOV DH,</span><span style="color: rgba(128, 0, 128, 1)">5</span><span style="color: rgba(0, 0, 0, 1)">
MOV DL,</span><span style="color: rgba(128, 0, 128, 1)">12</span><span style="color: rgba(0, 0, 0, 1)">
INT 10H
BEAGIN: MOV DX,OFFSET SEN1
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
MOV AH,09H
CMP AL,</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">N</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
JE NOT
CMP AL,</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">Y</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
JE OK
CMP AL,</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">Q</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
JE END
JMP KEY
OK: MOV DX,OFFSET SEN2
INT 21H
JMP BEAGIN
NOT: MOV DX,OFFSET SEN3
INT 21H
JMP BEAGIN
KEY:MOV DX,OFFSET SEN4
INT 21H
JMP BEAGIN
END: NOP
MOV AH,4CH
INT 21H
CODE ENDS
END START</span></pre>
</div>
<p><img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200522171145900-1701489745.jpg" alt="" width="600" height="450"></p>
<p><span style="font-family: 宋体">屏幕显示计算机提问</span>:</p>
<p>Would you like tea or coffee?</p>
<p><span style="font-family: 宋体">用户用键盘输入回答</span>,<span style="font-family: 宋体">并显示出来</span><span style="font-family: Calibri">.</span></p>
<p> </p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">DATA SEGMENT
SEN DB 0dh,0ah,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Would you like tea or coffee</span><span style="color: rgba(128, 0, 0, 1)">"</span>,0x3fh,0dh,0ah,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
SEN2 DB 0dh,0ah,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Your input is:</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
SEN3 DB 0DH,0AH,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
STRING DB </span><span style="color: rgba(128, 0, 128, 1)">20</span>,<span style="color: rgba(128, 0, 128, 1)">0</span>,<span style="color: rgba(128, 0, 128, 1)">20</span> DUP(<span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">)
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:MOV AX,DATA
MOV DS,AX
MOV Ah,2h
MOV BH,</span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
MOV DH,</span><span style="color: rgba(128, 0, 128, 1)">5</span><span style="color: rgba(0, 0, 0, 1)">
MOV DL,</span><span style="color: rgba(128, 0, 128, 1)">12</span><span style="color: rgba(0, 0, 0, 1)">
INT 10H
MOV DX,OFFSET SEN
MOV AH,09H
INT 21H
MOV DX,OFFSET STRING
MOV AH,0AH
INT 21H
MOV CL,STRING</span>+<span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
XOR CH,CH
ADD DX,CX
MOV BX,DX
MOV BYTE PTR,<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
MOV AH,09H
MOV DX,OFFSET SEN3
INT 21H
MOV DX,OFFSET STRING
ADD DX,</span><span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START</span></pre>
</div>
<p> <img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200522193936819-1021180850.png" alt="" width="934" height="450"></p>
<p> </p>
<div> 按宏汇编语言程序的格式,采用INT 21H 0A号功能调用显示一字符串:<br> ‘I hope you work hard</div>
<div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">DATA SEGMENT
SEN DB </span><span style="color: rgba(128, 0, 128, 1)">30</span>,<span style="color: rgba(128, 0, 128, 1)">0</span>,<span style="color: rgba(128, 0, 128, 1)">30</span> DUP(<span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">)
QUE DB </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Please input a string which would be displayed on the screen:</span><span style="color: rgba(128, 0, 0, 1)">"</span>,0dh,0ah,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
QUE1 DB 0dh,0ah,</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Your input sentence is :</span><span style="color: rgba(128, 0, 0, 1)">"</span>,0dh,0ah,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV AH,</span><span style="color: rgba(128, 0, 128, 1)">9</span><span style="color: rgba(0, 0, 0, 1)">
MOV DX,OFFSET QUE
INT 21H
MOV AH,0AH
MOV DX,OFFSET SEN
INT 21H
MOV CL,SEN</span>+<span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
MOV CH,</span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
ADD DX,CX
MOV BX,DX
MOV BYTE PTR,<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">$</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
MOV AH,</span><span style="color: rgba(128, 0, 128, 1)">9</span><span style="color: rgba(0, 0, 0, 1)">
LEA DX,QUE1
INT 21H
LEA DX,SEN
ADD DX,</span><span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START</span></pre>
</div>
<p><img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200523143321779-1981105607.png" alt="" width="934" height="450"></p>
</div>
<p>按宏汇编语言程序程序的格式,采用INT 21H 2号功能调用显示:<br>‘ I like computer very much</p>
<p> </p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">data segment
str db </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">I like computer very much.</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
count EQU $</span>-<span style="color: rgba(0, 0, 0, 1)">str
data ends
code segment
assume ds:data, cs:code
start:mov ax, data
mov ds, ax
MOV AH,</span><span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">
MOV DH,</span><span style="color: rgba(128, 0, 128, 1)">10</span><span style="color: rgba(0, 0, 0, 1)">
MOV DL,</span><span style="color: rgba(128, 0, 128, 1)">20</span><span style="color: rgba(0, 0, 0, 1)">
INT 10H
mov di, offset str
mov cx, count
MOV AH,02H
S:PUSH CX
MOV CX,</span><span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)">
MOV BH,</span><span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
MOV AH,</span><span style="color: rgba(128, 0, 128, 1)">9</span><span style="color: rgba(0, 0, 0, 1)">
MOV BL,10100101B
INT 10H
MOV AH,</span><span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">
mov DL,
</span><span style="color: rgba(0, 0, 255, 1)">int</span><span style="color: rgba(0, 0, 0, 1)"> 21h
INC DI
POP CX
LOOP S
MOV AH,4CH
INT 21H
code ends
end start</span></pre>
</div>
<p><img src="https://img2020.cnblogs.com/blog/1921103/202005/1921103-20200523234653074-249645808.png" alt="" width="934" height="450"></p><br><br>
来源:https://www.cnblogs.com/a-runner/p/12939357.html
頁:
[1]