程序汇编实验举例及总结

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

一、实验内容

1•在屏幕上显示一个字符的源程序:

DATASSEGMENT

STRINGS 'HELLO!;'$'

ORG 100H

DATASENDS

C0DES5EGMENT

ASSUMECS:CODES,DS:DATAS

START

MOV AX,DATAS

MOV DS,AX LEADX,STRING

MOV AH,09H

INT 21H

MOV AH,4CH

INT 21H

CODESENDS

ENDSTART

01DATfiS SEGMENT

62STRING DB * HELLO!' /S'

03ORG 1O0H

仙DATAS ENDS

CODES SEGMENT

Q6ASSUME CS:CODES.DS:DATAS

07START:

朋MOU AK.DATAS

09MOU DS,AX

10LEA DX, STR ING

11MOV AH,@9H

12INT 21H

13MOU AH,UCH

1U I NT 21H

15 16CODES ENDS

END STfiUT

H DOSBox 074, Cpu speed:

HELLU!

Pre&s araj Jccy to contilKic

2.编写一个程序,实现字符串的复制功能,并且将复制的字符串显示出来

DATASSEGMENT

STRING_ADB 'ICH LIEBE DIC障

COUNTEQU&OFFSEETRING—A

DATASENDS

STACK S EGMENT

STRING_BDB COUNTDUP(?)

STACKSENDS

CODESSEGMENT

ASSUMECS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS

MOV DS,AX

MOV AX,STACKS

MOV ES,AX

LEASI,STRING_A

LEADI,STRING_B

MOV CX,COUNT

STD

REP MOVSB

LEADX,STRING_B

MOV AH,9

INT 21H

MOV AH,4CH

INT 21H

MOV AH,4CH

INT 21H

CODESENDS

ENDSTART

01 02 03 的 ti5 加 07 08 09 10 DATAS SEGMENT string_a db 1 ICH LIEBE DICH ・*■$ count equ $-offset string_a DATA? ENDS STACKS SEGMENT string b db count dup(?) STfiCKs"EMI>S CODES SEGMENT ASSUME CSzCODESxDSzDnTAS.SSzSTACKS START : 13 MOV AK r DATAS 仙 M(JU 15 MOU AK,STACKS 16

MOU 17 LEA SI ,string_a 18 LEfi Di f stringlb 19 nou CX^count 20 STD 21 FICP MOUSB 12 r Cpu speec 3、利用中断调用,在屏幕上显示 1—9之间随机数。中断号86H DATASSEGMENT CLADB 13,10,'WE ARE GOING TO PRODUCE A NUMBER AT RANDOM:$:' INFONDB 0DH,0AH ;THE PROGRAM RUNS GOOD$' DATASENDS STACK S EGMENTSTACK DB200 DUR0) STACKSENDS CODES5EGMENT ASSUMEDS:DATAS,SS:STACKS,CS:CODES START MOV AX,DATAS MOV DS,AX LEADX,CLA MOV AH,9 INT 21H MOV AX,0 MOV ES,AX MOV BX,86H*4 CLI

MOV WORD PTR ES:[BJX]FFSE _RAN

MOV WORD PTR ES:[BX+S2]E, GRAN

STI

INT 86H

MOV AH,02H

INT 21H

LEADX,INFON

MOV AH,9

INT 21H

MOV AX,4C00H

INT 21H

RAN PROC

PUSHCX

PUSHDX

MOV AH,0

INT 1AH

MOV AX,DX

XORDX,DX

MOV BX,10

DIV BX

ADD DL,30H

MOV AH,02H

INT 21H

POPDX

POPCX

IRET

RAN ENDP

CODESENDS

ENDSTART

NOI T AlTfl

U6IHT

U7MOU

48KOR

49MOV BK.10

se DIV BX

51ADD DL,30H

52HOU AH,02H

53IHT21H

Sh FOP DX

55POP CX

56

I RET

57

I^DOSBox 0+74r Cpu speed:.

58

59

區RRE ^OKHG;TO FROHJCZ R NUrBEH flT Bail DOM 60RAN ENDP IHE FROGHAM BUNS GDDD

61CODES ENDS Press 也瞇I key to c

62

闘END START

4. 复制字符串,并倒序输出

DATASBEGMENT

STRING_QB 'still here',13,10,'$' STRING_DB'$' DATASENDS

STACK S EGMENT

STRING_B)B 100 DUR?)

STACKSNDS

C0DES5EGMENT

ASSUMECS:CODES,DS:DATAS,SS:STACKS START

MOV AX,DATAS

MOV DS,AX

MOV AX,STACKS

MOV SS,AX

LEASI,STRING_L

MOV AX,SI

LEASI,STRING_A

LEADI,STRING_B

SUBAX,SI

SUBAX,3

MOV CX,AX

MOV BX,AX

STD

REP MOVSB LEADX,STRING_B MOV AH,9

INT 21H

相关文档
最新文档