程序汇编实验举例及总结

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

一、实验内容

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

DATAS SEGMENT

STRING DB'HELLO!','$'

ORG100H

DATAS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS

START:

MOV AX,DATAS

MOV DS,AX

LEA DX,STRING

MOV AH,09H

INT 21H

MOV AH,4CH

INT 21H

CODES ENDS

END START

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

DATAS SEGMENT

STRING_A DB'ICH LIEBE DICH','$'

COUNT EQU $-OFFSET STRING_A

DATAS ENDS

STACKS SEGMENT

STRING_B DB COUNT DUP(?)

STACKS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS,SS:STACKS START:

MOV AX,DATAS

MOV DS,AX

MOV AX,STACKS

MOV ES,AX

LEA SI,STRING_A

LEA DI,STRING_B

MOV CX,COUNT

STD

REP MOVSB

LEA DX,STRING_B

MOV AH,9

INT 21H

MOV AH,4CH

INT 21H

MOV AH,4CH

INT 21H

CODES ENDS

END START

3、利用中断调用,在屏幕上显示1—9 之间随机数。中断号86H

DATAS SEGMENT

CLA DB 13,10,'WE ARE GOING TO PRODUCE A NUMBER AT RANDOM:$:' INFON DB 0DH,0AH,'THE PROGRAM RUNS GOOD$'

DATAS ENDS

STACKS SEGMENT STACK

DB 200 DUP(0)

STACKS ENDS

CODES SEGMENT

ASSUME DS:DATAS,SS:STACKS,CS:CODES

START:

MOV AX,DATAS

MOV DS,AX

LEA DX,CLA

MOV AH,9

INT 21H

MOV AX,0

MOV ES,AX;

MOV BX,86H*4

CLI

MOV WORD PTR ES:[BX],OFFSET RAN

MOV WORD PTR ES:[BX+2],SEG RAN

STI

INT 86H

MOV AH,02H

INT 21H

LEA DX,INFON

MOV AH,9

INT 21H

MOV AX,4C00H

INT 21H

RAN PROC

PUSH CX

PUSH DX

MOV AH,0

INT 1AH

MOV AX,DX

XOR DX,DX

MOV BX,10

DIV BX

ADD DL,30H

MOV AH,02H

INT 21H

POP DX

POP CX

IRET

RAN ENDP

CODES ENDS

END START

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

DATAS SEGMENT

STRING_A DB 'still here',13,10,'$'

STRING_L DB '$'

DATAS ENDS

STACKS SEGMENT

STRING_B DB 100 DUP(?)

STACKS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS,SS:STACKS

START:

MOV AX,DATAS

MOV DS,AX

MOV AX,STACKS

MOV SS,AX

LEA SI,STRING_L

MOV AX,SI

LEA SI,STRING_A

LEA DI,STRING_B

SUB AX,SI

SUB AX,3

相关文档
最新文档