指令系统与汇编语言程序设计例 通过对部分汇编语言源程序的 阅读,提高读程序的能力
1 指令系统与汇编语言程序设计例 通过对部分汇编语言源程序的 阅读,提高读程序的能力
程序1 DATA SEGMENT NAMES DB TOM。,20 DB CATE, 25 DATA ENDS 该数据区在内存中的存放情况?
2 程序1 DATA SEGMENT NAMES DB ‘TOM..’,20 DB ‘CATE’,25 DATA ENDS 该数据区在内存中的存放情况?
程序2 DATA SEGMENT LP: MOV AH, 2 A DB 123ABC MOV AL,[B为] DATA ENDS XCHG AL, DL CODE SEGMENT INC BX ASSUME CS: CODE, INT 21H DS: DATA LOOP LP START: MOV AX, DATA MOV AH, 4CH MOV DS, AX INT 21H LEA BX, A CODE ENDS MOV CX, 6 END START
3 程序2 DATA SEGMENT A DB ‘123ABC’ DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA START:MOV AX,DATA MOV DS,AX LEA BX,A MOV CX,6 LP:MOV AH,2 MOV AL,[BX] XCHG AL,DL INC BX INT 21H LOOP LP MOV AH,4CH INT 21H CODE ENDS END START
程序3 DATA SEGMENT TABLE DV3400H,5600H,2300H,4500H, 2300H,1200H,2344H,3500H DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOVAX, DATA MOV DS, AX
4 程序3 DATA SEGMENT TABLE DW 3400H,5600H,2300H,4500H, 2300H,1200H, 2344H,3500H DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS;DATA START:MOV AX,DATA MOV DS,AX
程序3(续) MOV BX OFFSET TABLE MOV SI, 06H A: JMP DWORD PTRIBX+SI+2] 程序执行完标号为A的指令后: CS=? IP=?
5 程序3(续) MOV BX,OFFSET TABLE MOV SI,06H A:JMP DWORD PTR[BX+SI+2] …… 程序执行完标号为A的指令后: CS=? IP=?
程序4 DATA SEGMENT STR1 DB HELLO WORLD STR2 DB HELLO WOOLD COUNT DB 12 FLAG DB DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, ES: DATA
6 程序4 DATA SEGMENT STR1 DB ‘HELLO WORLD!’ STR2 DB ‘HELLO WOOLD!’ COUNT DB 12 FLAG DB ? DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA,ES:DATA
程序4(序) START: MOVAX DATA MOV DS, AX MOVES, AX LEA BX FLAG LEA SI, STR1 LEA DI, STR2 MOV CX, COUNT CLD
7 程序4(序) START:MOV AX,DATA MOV DS,AX MOV ES,AX LEA BX,FLAG LEA SI,STR1 LEA DI,STR2 MOV CX,COUNT CLD
程序4(序) REPE CMPSB JZ NEXTI MOV [BX], OOH JMIP STOP NEXT2: MOV [BX], OFFH STOP 执行到SToP时,SI=?DI=?cX=? FLAGE? ZF=?
8 程序4(序) REPE CMPSB JZ NEXT1 MOV [BX],00H JMP STOP NEXT2:MOV [BX],0FFH STOP:…… 执行到STOP时,SI=? DI=? CX=? FLAG=? ZF=?
程序5 DATA SEGMENT SUM DB 8 DUP (O) DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX LEA BX, SUM
9 程序5 DATA SEGMENT SUM DB 8 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START:MOV AX,DATA MOV DS,AX LEA BX,SUM
程序5(序) MOV DX, 280H IN AL, DX MOV Cx, 8 nEXT: ROR AL, 1 JNC NEXT1 MOV Byte PTR[BX], OFFH JMP NEXT2 NEXT1: MOV [BX], 0
10 程序5(序) MOV DX,280H IN AL,DX MOV CX,8 NEXT: ROR AL,1 JNC NEXT1 MOV Byte PTR[BX],0FFH JMP NEXT2 NEXT1:MOV [BX],0