《《微機(jī)原理及接口技術(shù)》全套PPT電子課件教案作業(yè)分析》由會(huì)員分享,可在線閱讀,更多相關(guān)《《微機(jī)原理及接口技術(shù)》全套PPT電子課件教案作業(yè)分析(31頁珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
1、1. P.528 題3.1A BL 00H 1000H 10H BH 20H 2000H 01H CL 00H CH 10H DL 01H DH 10H AL 10H 注意:十六進(jìn)制數(shù)后綴加Hz1. 已知:DS=2000H,BX=100H,SI=2H, 20100H單元起依次存放數(shù)為2AH,4CH,B7H,65H,試說明下列各條指令執(zhí)行后AX寄存器內(nèi)容。 (1) MOV AX,BX (2) MOV AX,BX (3) MOV AX,BXSI z(2) AX=2AH (3) AX=B7H z注意注意:(1) 十六位數(shù)據(jù)傳送z(3) AX=B765Hz注意注意:低八位在前,高八位在后。100H4C
2、2AH65B7Hz(2) AX=20100H (3) AX=20102Hz注意注意:不是單元地址送AX,是單元內(nèi)容送AX。z2.設(shè)SP=2400H,AX=4000H,BX=3600H, 試問:(1)執(zhí)行PUSH AX 后,SP=? (2)再執(zhí)行PUSH BX及POP AX后, SP=?AX=?BX=?z (1) SP=2398Hz十進(jìn)制與十六進(jìn)制z (2) PUSH或POP執(zhí)行后,SP變化z 3.設(shè)AX=4235H,BX=06FAH,CX=0143H,DX=3105H,CF=1,下列各指令分別執(zhí)行后結(jié)果是什么?CF,ZF,OF是什么值?(1) ADD AL,DH (2) INC BLz (2)
3、 BL=0FAH 增量后BL=0FBH,CF=1,ZF=0,OF=0z 注意:注意:INC指令不影響CF,原CF不變。z 作業(yè):z 有一字符串,每個(gè)元素一個(gè)字節(jié),長(zhǎng)度為10,存放在BUFFER為起始地址的單元內(nèi),檢查該字符串中有無“$“字符,若有則用空格符將其替換,同時(shí)將AL置1,若無將AL置0,試用字符串操作等指令編程完成上述功能。z1. DI為目的字符串指針 z2. AL放關(guān)鍵字z3. 修改DIzREPNE不相等/結(jié)果為非零則重復(fù)z常與SCAS連用,CX放數(shù)據(jù)長(zhǎng)度zSCASB 搜索串指令搜索串指令z1. 指針放SIDILEA DI,BUFFER OFFSET BUFFERAL$DEC DI
4、DIz2. MOV DI,BUFFERz3. 關(guān)鍵字放BL z4. MOV AL,$z6. 空格的ASCII碼是20H,而不是00Hz7. SCASB已修改了DIz8. MOV DI,20HCMP AL,24Hz5. TEST AX,24H LEADI,BUFFER MOV CX,10MOVAL,$ REPNE SCASB JZFOUNDMOVAI,0 JMPDONE FOUND: DECDI MOVDI,20HMOVAL,1 DONE: HLTLEAOFFSETAL$MOV DI,20HSCASB已修改了DI LEADI,BUFFER MOV CX,10MOVAL,$MOVBL,0 AGAI
5、N: SCASB JNZNEXTDECDI MOVDI,20HINCDIMOVBL,1 NEXT:DECCXJNZAGAIN DONE:MOVAL,BLHLTSCASB已修改了DI搜索$初始化不是$結(jié)束控制z1. 有符號(hào)定義語句:z ORG 200Hz ABUF DB 1,2,ABCDz BBUF DW 1030H,0z LEN EQU $ABUFz 求LEN= ,203H單元的內(nèi)容= ,206H單元的內(nèi)容 。 LEN=6,9 ,206H (203H)=BLEN=10(203H)=42H (206H)=30Hz1. 若從0200H單元開始有100個(gè)數(shù),編一個(gè)程序檢查這些數(shù),正數(shù)保持不變,負(fù)數(shù)都
6、取補(bǔ)后送回。z1. data segment mov offset buffer 0200h buffer dw x1,x2,x100 data ends去掉org 0200hz2. 數(shù)據(jù)段: buffer db x1,x2,x100 程序中: mov ax,bxz 數(shù)據(jù)類型(字節(jié)與字)前后要一致。(1)NAME EM NUMBERS BEGIN: COUNT EQU 100 MOV BUFFER,0200H LEA BX,BUFFER AGAIN: MOV AX,BX OR AX,AX JS NEG DEC BX DEC BXDEC CX JMP AGAIN NEG: NOT BX ADD
7、BX,1DEC BXDEC BXDEC CXEND BEGIN用數(shù)據(jù)段定義代碼段不全段寄存器循環(huán)計(jì)數(shù)器初值CX=?INCNEG為指令操作碼,不能用作標(biāo)號(hào)。LOOP AGAINLOOP AGAINJMP DONEDONE:HLT(2) datasegment org0200hdata_firstdb d1,d2,d100 count equ $-data_first data ends stack segment para stack stack db64dup(?)topequ$-stackstackendscode segment assume cs:code,ds:data,ss:stac
8、k start proc farbegin:push dsmov ax,0push axmov ax,datamov ds,axmov ax,stackmov ss,axmov ax,topmov sp,ax定義字節(jié)數(shù)據(jù) mov ax,count lea bx,data_first again:or bx,bx jns next mov ax,bx not axadd ax ,1mov bx,axnext: inc bx loop again retstartendpcode ends end beginCX循環(huán)次數(shù)沒有這指令數(shù)據(jù)定義是字節(jié)數(shù)據(jù),應(yīng)用ALDATASEGMENTORG200H B
9、UFFER DW X1,X2,X100COUNT EQU $-BUFFERDATA ENDSSTACK SEGMENT PARA STACK STACK DB64DUP(?)TOP EQU$-STACKSTACK ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATA,SS:STACKSTART PROCFARBEGIN: PUSH DSMOV AX,0PUSH AXMOV AX,DATAMOV DS,AXMOV AX,STACKMOV SS,AXMOV AX,TOPMOV SP,AXMOV CX,COUNTSHRCX LEA BX,BUFFERAGAIN: TEST
10、BX ,8000H JZ NEXT NEG WORD PTR BXNEXT:INC BX INC BX LOOP AGAIN RETSTART ENDPCODE ENDS END BEGINz2. 若自0500H單元開始有1000個(gè)無符號(hào)數(shù),把它們的最大值找出來,放在2000H單元中。無符號(hào)數(shù)比較,改為JA org 0500horg 2000hz(1) cmp ax,bx jge nextz(2) data segment buffer dw x1,x2,.x100 count equ $-buffer max dw ? data ends(1)STACK SEGMENT STACK DB64
11、DUP(?)STACKENDSCODE SEGMENTASSUME CS:CODE START:MOV BX,0500H MOV CX,3E8H MOV AX,BXINC BXDEC CX AGAIN:CMP AX ,BX JGE NEXT MOV AX,BX NEXT: INC BX LOOP AGAINMOVDI,2000HMOV DI,AXINT 03H CODE ENDS END START沒有數(shù)據(jù)段送AX說明是字?jǐn)?shù)據(jù)無符號(hào)數(shù)比較用JA地址指針只加1說明是字節(jié)數(shù)據(jù)代碼段不全(2) DATASEGMENT BUFFER DW X1,X2,X1000 MAXDW ? DATA ENDS C
12、ODE SEGMENT ASSUME CS:CODE,DS:DATA START PROC FAR BEGIN: MOV CX,1000 LEA BX,BUFFER MOV AX,BX INC BXINC BX SHR CX DEC CX AGAIN: CMP AX ,BX JGE NEXT MOV BX,AX NEXT: INC BX INC BX LOOP AGAINRET CODE ENDS END BEGINORG 500HORG 2000H返回地址處理設(shè)置DS值MOV MAX,AX無符號(hào)數(shù)JAE/JNCNAMESEARCH_MAXDATASEGMENTORG500H BUFFER D
13、W X1,X2,X1000COUNT EQU $-BUFFERORG2000H MAXDW ?DATA ENDSSTACK SEGMENT PARA STACK STACK DB64DUP(?)TOP EQU$-STACKSTACK ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATA,SS:STACKSTART PROCFARBEGIN: PUSH DSMOV AX,0PUSH AXMOV AX,DATAMOV DS,AXMOV AX,STACKMOV SS,AXMOV AX,TOPMOV SP,AXMOV CX,COUNTLEA BX,BUFFERMOV AX ,
14、BXINCBXINCBXSHRCXDECCX AGAIN: CMPAX ,BX JA NEXT MOV AX,BX NEXT:INC BX INC BX LOOP AGAINMOVMAX,AX RET START ENDP CODE ENDS END BEGINz 錯(cuò)誤的指令MOVDL,2000HORBX,BX+1 CMPDI,DI+2MOV2000H,BXLEABL,BUFFERz1. 若自STRING單元開始存放一個(gè)字符串(以字符$結(jié)尾),編一個(gè)程序: (1) 統(tǒng)計(jì)這個(gè)字符串的長(zhǎng)度(不包括$字符); (2) 把字符串的長(zhǎng)度放在STRING單元,把整個(gè)字符串往下移兩個(gè)存儲(chǔ)單元。z(1) 8位
15、與16位 mov cx,dl add di,dlz(2) 沒有的指令 mov di,bx mov di+2,di mov di+1,di-1 lea di,string mov dl,0 mov al ,cragain: scasb je done inc dl jmp againdone: lea bx,ll mov bx,dl mov cx,dla1: dec di mov al,di mov di+2,al loop a1 lea di,string mov di,bxcx:16位,dl:8位沒有這樣的指令LL單元緊跟字符串,下移兩個(gè)單元后,LL單元內(nèi)容已丟失! (1)data segm
16、entstring db abcd,$ll db ?cr equ $data endsdxdw lea di,string mov dl,0 mov al,0dh mov cx,count+10again: scasb je done inc dl dec cx jne againdone: mov di+1,di-1 dec di dec count jnz done mov l1,dl mov di,l1轉(zhuǎn)出錯(cuò)處理沒有這指令不能送l1單元,因此時(shí)l1單元是字符 (2)data segmentstring db abcd,0dhcount equ $-stringl1 db ?data en
17、ds24h24h不能用常量count作計(jì)數(shù)器 data segment string db abcdefghijk,$ db 2dup(?) data ends code segment assume cs:code,ds:data,ss:stack,es:data start proc far begin: push ds mov ax,0 push ax mov ax,data mov ds,ax lea di,string mov dx,0 mov al,$ again: scasb je done inc dx ;長(zhǎng)度+1 jmp again$stringdidi+1di-1 done:mov di,dh ;長(zhǎng)度mov di-1,dlstart endpcode ends end begin mov cx,dxinc cxcxnext: mov al,di-1 ;下移 mov di+1,al loop next