匯編實驗報告_第1頁
匯編實驗報告_第2頁
匯編實驗報告_第3頁
匯編實驗報告_第4頁
匯編實驗報告_第5頁
已閱讀5頁,還剩22頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上合肥工業(yè)大學計算機與信息學院實驗報告課 程:匯編語言程序設計專業(yè)班級:學 號:姓 名:實驗一 Debug程序的使用一. 實驗目的1、熟悉DEBUG程序中的命令,學會在DEBUG下調(diào)試運行匯編語言源程序。2、掌握8086/8088的尋址方式及多字節(jié)數(shù)據(jù)的處理方法。二. 實驗內(nèi)容1、利用DEBUG程序中的“E”命令,將兩個多字節(jié)數(shù)“003F1AE7H”和“006BE5C4H”分別送入起始地址為DS:0200H和DS:0204H兩個單元中。2、分別用直接尋址方式和寄存器間接尋址方式編寫程序段,實現(xiàn)將DS:0200H單元和DS:0204H單元中的數(shù)據(jù)相加,并將運算結(jié)果存放在D

2、S:0208H單元中。要求:本次實驗的內(nèi)容均在DEBUG下完成,實現(xiàn)數(shù)據(jù)的裝入、修改、顯示;匯編語言程序段的編輯、匯編和反匯編;程序的運行和結(jié)果檢查。三. 實驗過程和程序1、啟動DOS操作系統(tǒng)2、運行DEBUG.COM程序(若當前盤為C) C:DEBUG ;(“”為DEBUG提示符,僅當屏幕出現(xiàn)該提示符后,才可輸入DEBUG命令)3、用“A”命令編輯和匯編源程序 A 186E:0100 MOV AX,0200 186E:0103 MOV BX,0202 186E:0107 ADD AX,0204 186E:010B ADC BX,0206 186E:010F MOV 0208,AX 186E:

3、0112 MOV 020A,BX 186E:0116 4、用“U”命令反匯編驗證源程序 U CS:0100 186E:0100 A10002 MOV AX,0200 186E:0103 8B1E0202 MOV BX,0202 186E:0107 ADD AX,0204 186E:010B 131E0602 ADC BX,0206 186E:010F A30802 MOV 0208,AX 186E:0112 891E0A02 MOV 020A,BX 186E:0116 注意:l 檢查源程序是否有錯誤,若有則返回到第3步用“A 地址”命令進行修改,直到程序無錯誤。l DEBUG約定在其命令或源程

4、序中所涉及到的數(shù)據(jù)均被看作十六進制數(shù),其后不用“H”說明。l 在DEBUG下,源程序中不能使用“標號”、“變量”和一些偽指令。l 在DEBUG下,大小寫不敏感。5、程序未執(zhí)行前,用“R”命令觀察,相關寄存器的內(nèi)容。R如:(AX)= 0000H ,(BX)=0000H,(SI)= 0000H , (DI)= 0000H ,(CS)= 0B32H ,(IP)= 0100H 。6、在程序未執(zhí)行前,用“D”命令觀察DS:0200H,DS:0204H、DS:0208H單元的內(nèi)容 D 200 20B 7、用“G”命令運行源程序 G =110 0116 8、再用“D”命令觀察DS:0200HDS:020BH

5、字節(jié)單元中的內(nèi)容 D 200 20B9、用“T”單步操作命令對源程序單步執(zhí)行,觀察AX、BX、CS、IP寄存器內(nèi)容的變化,并與預計的結(jié)果相比較。注意:l D命令顯示內(nèi)存數(shù)據(jù),注意觀察多字節(jié)數(shù)據(jù)在內(nèi)存中的存放方式。l 指令執(zhí)行的時候,IP寄存器隨著變化,注意觀察。1、程序運行結(jié)果:(AX)= 00ABH ,(BX)=00ABH DS:0208H四字節(jié)單元的內(nèi)容: 00AB00ABH 2、試用寄存器間接尋址方式編寫程序段,完成上述程序段的功能。(參考下列程序流程圖)SI200HDI204HBX208HAX SIDXSI+2AXAX+DIDXDX+DI+2 BX(AX)BX+2(DX)開始結(jié)束3、附

6、加題目:1. 從DS:0000H開始的5個16位帶符號數(shù)分別記為x,y,z,v,w,用E命令初始化為:540,1,-1,1080,0, 試求w=(v-(x*y+z-540)/x 2. 完成BX中1的個數(shù)的統(tǒng)計。3. 用串操作指令將DS:0000開始20個字節(jié)初始化為:0CCH。并將這20個字節(jié)的內(nèi)容復制到其后的20個字節(jié)里。cld四. 實驗體會通過這次試驗,對于debug環(huán)境有了一個基本的了解,同時通過對指令的使用而對計算機的數(shù)據(jù)傳送、算術運算、邏輯和移位操作、串操作、控制轉(zhuǎn)移和循環(huán)等指令有了更深的理解。串操作指令是對一個一個字節(jié)進行操作的。實驗二 匯編語言程序設計(順序、循環(huán))一. 實驗目的

7、1、掌握順序和循環(huán)程序結(jié)構(gòu)和設計方法;2、熟悉在PC機上建立、匯編、連接、調(diào)試和運行8086/8088匯編語言程序的過程。二. 實驗內(nèi)容1、X、Y、Z、V均為字變量,在X、Y、Z、V字單元中存放是16位帶符號數(shù)。試編寫匯編語言程序完成以下功能:計算表達式值(V(X*Y+Z-720)/X;將上述表達式運算結(jié)果整數(shù)放在SUM1單元,余數(shù)放在SUM2單元。dseg segmentx dw 2y dw 360z dw 0v dw 5sum1 dw ?sum2 dw ?dseg endscseg segment assume cs:cseg,ds:dsegstart: mov ax,dseg mov d

8、s,ax mov ax,x mov bx,y mul bx mov bx,z add ax,bx sub ax,2d0h mov bx,v sub bx,ax mov ax,bx cbw mov bx,x div bx mov sum1,ax mov sum2,dx mov ah,4ch int 21hcseg ends end start2、求一個班50名學生成績的平均值(附加題:最大值和最小值,并將結(jié)果顯示出來)dseg segmentscore db 10 dup(80,70,60,90,90)avg db ?max db 0dh,0ah,?min db 0dh,0ah,?dseg en

9、dscseg segment assume cs:cseg,ds:dsegstart: mov ax,dseg mov ds,ax mov cx,50 mov ax,0 mov bh,0 mov bl,100 mov si,0l: add al,scoresi adc ah,0 inc si loop l mov dx,si div dl mov avg,al mov cx,50 mov si,0l1: cmp scoresi,bh jbe s1 mov bh,scoresis1: inc si loop l1 mov cx,50 mov si,0l2: cmp scoresi,bl ja s

10、2 mov bl,scoresis2: inc si loop l2 mov al,bl mov ah,0 mov cl,10 div cl cmp al,0 jz gw1 cmp al,10 jz mf1 mov ch,ah add al,30h mov dl,al mov ah,2 int 21h add ch,30h mov dl,ch mov ah,2 int 21h jmp done1gw1: mov dl,ah add dl,30h mov ah,2 int 21h jmp done1mf1: mov dl,31h mov ah,2 int 21h mov dl,30h mov a

11、h,2 int 21h mov dl,30h mov ah,2 int 21hdone1: mov dl,0dh mov ah,2 int 21h mov dl,0ah mov ah,2 int 21h mov al,bh mov ah,0 mov cl,10 div cl cmp al,0 jz gw cmp al,10 jz mf mov ch,ah add al,30h mov dl,al mov ah,2 int 21h add ch,30h mov dl,ch mov ah,2 int 21h jmp donegw: mov dl,ah add dl,30h mov ah,2 int

12、 21h jmp donemf: mov dl,31h mov ah,2 int 21h mov dl,30h mov ah,2 int 21h mov dl,30h mov ah,2 int 21hdone: mov ah,4ch int 21hcseg ends end start 3、從鍵盤讀入一個字符串,以Enter結(jié)束,字符串不超過50個字符,并打印該字符串(附加題:查找中間是否有asm子串。如果有,輸出Yes;否則,輸出No)。data segments1 db 51,?,51 dup($)s3 db 0ah,0dh,Yes$s4 db 0ah,0dh,No$data endsds

13、eg segments2 db asmdseg endscseg segment assume cs:cseg,ds:data,es:dsegstart: mov ax,data mov ds,ax mov ax,dseg mov es,ax lea dx,s1 mov ah,0ah int 21h mov dl,0dh mov ah,2 int 21h mov dl,0ah mov ah,2 int 21h lea dx,s1+2 mov ah,9 int 21h mov cl,s1+1 cmp cl,3 jb notfound lea si,s1 lea di,s2 mov dx,si m

14、ov bx,di mov ah,48 cldagain: mov cx,3 repz cmpsb jz found add dx,1 mov si,dx mov di,bx dec ah jnz again jmp notfound jmp overfound: lea dx,s3 mov ah,9 int 21h jmp overnotfound: lea dx,s4 mov ah,9 int 21hover: mov ah,4ch int 21hcseg ends end start 三. 實驗體會通這次試驗,熟悉了MASM匯編環(huán)境和匯編程序設計的格式,熟悉在PC機上建立、匯編、連接、調(diào)試

15、和運行8086/8088匯編語言程序的過程。同時對順序和循環(huán)程序設計更加熟練,并在編程過程中熟悉了算術運算、位操作和串操作等指令。算術運算中,對于不同類型數(shù)進行運算時,要進行擴展,還有不要忽視進位;對于循環(huán)和控制轉(zhuǎn)移指令,如果有多個循環(huán)或轉(zhuǎn)移指令,則前一個循環(huán)或轉(zhuǎn)移結(jié)束后,一定到無條件轉(zhuǎn)移到結(jié)尾處;串操作指令中,源串和目的串分別定義在DS和ES兩個段中的,不能對ES進行段超越操作等。 實驗三 匯編語言子程序設計(分支、子程序)一. 實驗目的1、掌握分支和子程序結(jié)構(gòu)和設計方法;2、熟悉在PC機上建立、匯編、連接、調(diào)試和運行8086/8088匯編語言程序的過程。3、通過匯編語言了解高級語言的參數(shù)傳

16、遞等知識。二. 實驗內(nèi)容1、1. BL中的只有一位為1。編寫程序測試,并輸出提示信息“The X Bit is 1”,要求:地址表和轉(zhuǎn)移表。dseg segmenta db 2msg0 db 0dh, 0ah,The 0 Bit is 1,$msg1 db 0dh, 0ah,The 1 Bit is 1,$msg2 db 0dh, 0ah,The 2 Bit is 1,$msg3 db 0dh, 0ah,The 3 Bit is 1,$msg4 db 0dh, 0ah,The 4 Bit is 1,$msg5 db 0dh, 0ah,The 5 Bit is 1,$msg6 db 0dh, 0

17、ah,The 6 Bit is 1,$msg7 db 0dh, 0ah,The 7 Bit is 1,$addrtb1 dw func0,func1,func2,func3,func4,func5,func6,func7dseg endscseg segment assume cs:cseg,ds:dsegstart: mov ax,dseg mov ds,ax mov cx,8 mov si,0 mov bl,a cmp bl,0 jz exitl: shr bl,1 jc l1 inc si loop l jmp exit l1: mov ax,si and ax,0fh shl ax,1

18、 mov bx,ax jmp addrtb1bxfunc0:lea dx,msg0 jmp outputfunc1:lea dx,msg1 jmp outputfunc2:lea dx,msg2 jmp outputfunc3:lea dx,msg3 jmp outputfunc4:lea dx,msg4 jmp outputfunc5:lea dx,msg5 jmp outputfunc6:lea dx,msg6 jmp outputfunc7:lea dx,msg7 jmp outputoutput:mov ah,9 int 21hexit: mov ah,4ch int 21hcseg

19、ends end startdseg segmenta db 8msg0 db 0dh, 0ah,The 0 Bit is 1,$msg1 db 0dh, 0ah,The 1 Bit is 1,$msg2 db 0dh, 0ah,The 2 Bit is 1,$msg3 db 0dh, 0ah,The 3 Bit is 1,$msg4 db 0dh, 0ah,The 4 Bit is 1,$msg5 db 0dh, 0ah,The 5 Bit is 1,$msg6 db 0dh, 0ah,The 6 Bit is 1,$msg7 db 0dh, 0ah,The 7 Bit is 1,$dseg

20、 endscseg segment assume cs:cseg,ds:dsegstart: mov ax,dseg mov ds,ax mov cx,8 mov si,0 mov bl,a cmp bl,0 jz exitl: shr bl,1 jc l1 inc si loop l jmp exit l1: mov ax,si and ax,0fh mov bx,ax shl ax,1 add bx,ax add bx,offset jmptb1 jmp bxjmptb1: jmp near ptr func0 jmp near ptr func1 jmp near ptr func2 j

21、mp near ptr func3 jmp near ptr func4 jmp near ptr func5 jmp near ptr func6 jmp near ptr func7func0:lea dx,msg0 jmp outputfunc1:lea dx,msg1 jmp outputfunc2:lea dx,msg2 jmp outputfunc3:lea dx,msg3 jmp outputfunc4:lea dx,msg4 jmp outputfunc5:lea dx,msg5 jmp outputfunc6:lea dx,msg6 jmp outputfunc7:lea d

22、x,msg7 jmp outputoutput:mov ah,9 int 21hexit: mov ah,4ch int 21hcseg ends end start 2. 編寫一個子程序計算z=f(x,y)=x*y+x-y(x,y,z有符號數(shù)內(nèi)存數(shù))。要求通過堆棧(寄存器、內(nèi)存)傳送所有參數(shù)。dseg segmentx db 2y db 4z db ?dseg endscseg segment assume cs:cseg,ds:dsegstart: mov ax,dseg mov ds,ax call result mov ah,4ch int 21hresult proc push ax

23、 push bx mov al,x imul y mov bl,x add al,bl sub al,y mov z,al pop bx pop ax retresult endpcseg ends end start data segment x dw 123 y dw 56 z dw ?data endscode segment assume cs:code,ds:datastart:mov ax,datamov ds,axsub sp,2push xpush ycall cpop zmov ah,4chint 21h c procpush bpmov bp,sppush axpush b

24、xpush dxmov ax,bp+6mov bx,bp+4mul bxmov dx,bp+6sub dx,bxadd ax,dxmov bp+8,ax pop dxpop bxpop axpop bpret 4 mov ah,4chint 21hcode ends end start三. 實驗體會通過本次試驗,進一步熟悉在PC機上建立、匯編、連接、調(diào)試和運行8086/8088匯編語言程序的過程,通過匯編語言了解了高級語言的參數(shù)傳遞等知識,并熟悉了分支程序和子程序的設計方法,對于地址表和轉(zhuǎn)移表的概念、使用及其區(qū)別更加熟悉。實驗四 匯編語言高級編程專題一. 實驗目的1、匯編語言宏程序設計;2、

25、掌握中斷服務子程序的編寫。3、 匯編語言與高級語言的混編。二. 實驗內(nèi)容1、編寫一個宏,求三個數(shù)的最小數(shù),原型為:MIN3 x,y,z,minshift macro x,y,zmov ax,xcmp ax,yjl donemov ax,ydone: cmp ax,zjl exitmov ax,zexit: mov ax,axendmcode segment assume cs:codestart: shift 4,2,3 mov ah, 4ch int 21hcode ends end start2、掛接1CH中斷,正計時60秒后退出。要求屏幕顯示0-59的秒數(shù)。INTNO EQU 1CH U

26、SEINT = 1 DATA SEGMENT OLDISR DW ?,? TIMER DB 100 COUNTER DW 0 ISDONE DB 0 DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV AX,0 MOV ES,AX IF USEINT MOV AL, INTNO MOV AH,35H INT 21H MOV OLDISR0, BX MOV AX,ES MOV OLDISR2, AX ELSE CLI MOV AX, ES:INTNO*4 MOV OLDISR0,AX MOV AX,ES:INTNO*4+2 MOV OLDISR2, AX STI ENDIF IF USEINT PUSH DS MOV AX, SEG ISR MOV D

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論