IBM-PC汇编语言程序设计答案 - 百度文库 ر

49703100.doc - 20 - ߣUser

AUGW LABEL WORD AUGEND DD 99251 SUM DD ? D_SEG ENDS ϶ݶ ---------------------------------------------------------------- E_SEG SEGMENT ADDW LABEL WORD ADDEND DD -15962 E_SEG ENDS ϶帽Ӷ ---------------------------------------------------------------- C_SEG SEGMENT MAIN PROC FAR

ASSUME CS: C_SEG, DS: D_SEG, ES: E_SEG

START: PUSH DS ÷DOS

SUB AX, AX PUSH AX

MOV AX, D_SEG MOV DS, AX DSֵ MOV AX, E_SEG MOV ES, AX ESֵ

MOV AX, AUGW 6ָмӷ MOV BX, AUGW+2 ADD AX, ES: ADDW ADC BX, ES: ADDW+2 з MOV WORD PTR SUM, AX MOV WORD PTR [SUM+2], BX RET

MAIN ENDP C_SEG ENDS ϶ ----------------------------------------------------------------

END START

4.18 ˵ʾ΢ͽִе֮IJԴӦαʾ

𣺱ʾ΢ָʾMASMı־ԴENDʾ

ִеǽжزϵͳָԴжֱʾINT 20HMOV AX, 4C00H INT 21HԼRETȡ 4.19 ˵ָЩҪPTR

BVAL DB 10H20H WVAL DW 1000H

(1) MOV ALBVAL Ҫ (2) MOV DL[BX] Ҫ (3) SUB [BX]2 ҪSUB BYTE PTR [BX]2 (4) MOV CLWVAL ҪMOV CLBYTE PTR WVAL (5) ADD ALBVAL+1 Ҫ 𣺼ע͡

. ϰ

5.1 ԱдһԳҪԼСдĸôдĸʾ

𣺳£

BEGIN: MOV AH, 1 ӼһַDOS

INT 21H CMP AL, ?a ַ

49703100.doc - 21 - ߣUser

STOP:

CMP JA SUB MOV MOV INT JMP RET

AL, ?z STOP AL, 20H DL, AL AH, 2 21H BEGIN

ַ>?z

תΪдĸAND AL, 1101 1111BҲ

ʾһַDOS

5.2 д򣬴Ӽ̽һСдĸȻҳǰַͺַٰ˳ʾ

ַ

𣺳£

BEGIN: MOV AH, 1 ӼһַDOS

INT 21H CMP AL, ?a ַ?z JA STOP DEC AL õǰַ MOV DL, AL ׼ʾַ MOV CX, 3

DISPLAY: MOV AH, 2 ʾһַDOS

INT 21H INC DL

LOOP DISPLAY

STOP: RET 5.3 AXĴе16λֳ4飬ÿ4λȻֱALBLCLDLС 𣺳£

DSEG SEGMENT STORE DB 4 DUP (?) DSEG ENDS

BEGIN: MOV CL, 4 Ĵ

MOV CH, 4 ѭĴ LEA BX, STORE

A10: MOV DX, AX

AND DX, 0FH ȡAXĵλ MOV [BX], DL λSTORE INC BX SHR AX, CL Ĵ DEC CH JNZ A10 ѭĴ룿

B10: MOV DL, STORE ֱALBLCLDL

MOV CL, STORE+1 MOV BL, STORE+2 MOV AL, STORE+3

STOP: RET 5.4 ԱдһҪȽַSTRING1STRING2ַǷȫͬͬʾ?MATCH ͬʾ?NO MATCH 𣺳£

DSEG SEGMENT

STRING1 DB ?I am a student. STRING2 DB ?I am a student! YES DB ?MATCH, 0DH, 0AH, ?$ NO DB ?NO MATCH, 0DH, 0AH, ?$

49703100.doc - 22 - ߣUser

DSEG ENDS

-------------------------------------------------------------------------- CSEG SEGMENT MAIN PROC FAR

ASSUME CS: CSEG, DS: DSEG, ES: DSEG

START: PUSH DS ÷DOS

SUB AX, AX PUSH AX

MOV AX, DSEG MOV DS, AX DSֵ MOV ES, AX ESֵ

BEGIN: LEA SI, STRING1 ôȽָijֵ

LEA DI, STRING2 CLD

MOV CX, STRING2 - STRING1 REPE CMPSB Ƚ JNE DISPNO LEA DX, YES ʾMATCH JMP DISPLAY

DISPNO: LEA DX, NO ʾNO MATCH DISPLAY: MOV AH, 9 ʾһַDOS

INT 21H RET

MAIN ENDP CSEG ENDS ϶ --------------------------------------------------------------------------

END START

5.5 ԱдһҪܴӼ̽һλNȻN(ASCIIΪ07)

𣺳£

BEGIN: MOV AH, 1 ӼһַDOS

INT 21H SUB AL, ?0 JB STOP ַ?9 JA STOP CBW

MOV CX, AX N JCXZ STOP

BELL: MOV DL, 07H ׼

MOV AH, 2 ʾһַDOSãʵΪ INT 21H

CALL DELAY100ms ʱ100ms LOOP BELL

STOP: RET 5.6 д򣬽һ20ݵMֳ飺P͸Nֱݵĸʾ 𣺳£

DSEG SEGMENT COUNT EQU 20 ARRAY DW 20 DUP (?) COUNT1 DB 0 ĸ ARRAY1 DW 20 DUP (?) COUNT2 DB 0 Ÿĸ ARRAY2 DW 20 DUP (?) Ÿ

49703100.doc - 23 - ߣUser

ZHEN DB 0DH, 0AH, ?The positive number is, ?$ ĸǣ FU DB 0DH, 0AH, ?The negative number is, ?$ ĸǣ CRLF DB 0DH, 0AH, ?$ DSEG ENDS

-------------------------------------------------------------------------- CSEG SEGMENT MAIN PROC FAR

ASSUME CS: CSEG, DS: DSEG

START: PUSH DS ÷DOS

SUB AX, AX PUSH AX

MOV AX, DSEG MOV DS, AX DSֵ

BEGIN: MOV CX, COUNT

LEA BX, ARRAY LEA SI, ARRAY1 LEA DI, ARRAY2

BEGIN1: MOV AX, [BX]

CMP AX, 0 Ǹ룿 JS FUSHU MOV [SI], AX INC COUNT1 +1 ADD SI, 2 JMP SHORT NEXT

FUSHU: MOV [DI], AX Ǹ븺

INC COUNT2 +1 ADD DI, 2

NEXT: ADD BX, 2

LOOP BEGIN1 LEA DX, ZHEN ʾ MOV AL, COUNT1 CALL DISPLAY ʾӳ LEA DX, FU ʾ MOV AL, COUNT2 CALL DISPLAY ʾӳ RET

MAIN ENDP

-------------------------------------------------------------------------- DISPLAY PROC NEAR ʾӳ

MOV AH, 9 ʾһַDOS INT 21H AAM (AL)еĶתΪѹBCD ADD AH, ?0 Ϊ09ASCII MOV DL, AH MOV AH, 2 ʾһַDOS INT 21H

ADD AL, ?0 Ϊ09ASCII MOV DL, AL MOV AH, 2 ʾһַDOS INT 21H LEA DX, CRLF ʾس MOV AH, 9 ʾһַDOS INT 21H RET

DISPLAY ENDP ʾӳ CSEG ENDS ϶