微机原理-虚拟仿真实验-DAC0832数模电路汇编代码

微机原理-虚拟仿真实验-DAC0832数模电路汇编代码

;--------------------------------------
DATA SEGMENT
     MESS1 DB 'sawtooth    Q -- Next !',0DH,0AH,'$'
     MESS2 DB 'triangle    Q -- Next !',0DH,0AH,'$'
     MESS3 DB 'sine    Q -- End !',0DH,0AH,'$'
     SINBUF DB 128,88,53,24,6,0,6,24,53,88,128,168,203,232
	       DB 250,255,250,232,203,168
     PORT EQU 428H
DATA ENDS
;--------------------------------------
STACK SEGMENT
  STA DB 200 DUP(?)
  TOP EQU LENGTH STA
STACK ENDS
;--------------------------------------
CRLF MACRO
     MOV DL,0DH
	MOV AH,02H
	INT 21H
	MOV DL,0AH
	MOV AH,02H
	INT 21H
	ENDM
;--------------------------------------
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK,ES:DATA
START:	MOV AX,DATA
	MOV DS,AX
 	MOV AX,STACK
 	MOV SS,AX
 	MOV AX,TOP
 	MOV SP,AX
	MOV DX,OFFSET MESS1
 	MOV AH,09H
	INT 21H
  A1:   MOV DX,PORT
	MOV AL,00H
  BBB:	OUT DX,AL
	INC DX
	OUT DX,AL
	DEC DX
	CALL RELAY

 	ADD AL,10H
	CMP AL,00H
	JNZ BBB
        MOV AH,0BH
	INT 21H
	XOR AL,0FFH
	JNZ A1
	MOV AH,01H
	INT 21H
	CMP AL,'Q'
	JZ QQQ
	CMP AL,'q'
	JNZ A1

  QQQ:	CRLF
	MOV DX,OFFSET MESS2
	MOV AH,09H
	INT 21H

  DDD:  MOV DX,PORT
 	MOV AL,00H
  EEE:	OUT DX,AL
	INC DX
	OUT DX,AL
	DEC DX

	CALL RELAY
	ADD AL,10H
	CMP AL,0F0H
	JNZ EEE

  FFF:	OUT DX,AL
	INC DX
	OUT DX,AL
	DEC DX

	CALL RELAY
	SUB AL,10H
	CMP AL,00H
	JNZ FFF

	MOV AH,0BH
	INT 21H
	XOR AL,0FFH
	JNZ DDD
	MOV AH,01H
	INT 21H
	CMP AL,'Q'
	JZ Q2
	CMP AL,'q'
	JNZ DDD

  Q2:   CRLF
	MOV DX,OFFSET MESS3
	MOV AH,09H
	INT 21H
  GGG:  MOV DX,PORT
  HHH:  MOV SI,OFFSET SINBUF
	MOV BL,20
  III:  MOV AL,[SI]
	OUT DX,AL
	INC DX
	OUT DX,AL
	DEC DX
        CALL RELAY
	CALL RELAY
	INC SI
	DEC BL
	JNZ III
	MOV AH,0BH
	INT 21H
	XOR AL,0FFH
	JNZ GGG
	MOV AH,01H
	INT 21H
	CMP AL,'Q'
	JZ Q3
	CMP AL,'q'
	JNZ GGG

  Q3:	MOV AX,4C00H
	INT 21H

RELAY:	PUSH CX
	PUSH BX
        MOV CX,05H
WW1:    MOV BX,0300H
WA1:	DEC BX
	JNZ WA1
	DEC CX
	JNZ WW1
	POP BX
	POP CX
	RET
CODE    ENDS
;--------------------------------------
      END START


你可能感兴趣的:(本科课程资料,笔记)