8085 微处理器中模拟扔骰子的程序


编写一个 8085 汇编语言程序,以使用中断模拟掷骰子。

此程序有一个计数器,该计数器对 1 到 6 的范围进行计数,然后以在无限循环中无休止的方式重复计数顺序。通过按键盘上的“Vect Intr”键模拟骰子的投掷得到正面和反面的概率。8085 分支转到 RST7.5 ISS。在此处,显示计数器的当前值数据字段中,该字段控制计数器操作的延续并返回主程序。因此,我们在 1 到 6 之间的随机值按“Vect Intr”键,该值显示在数据字段中,用于模拟掷骰子。

; FILE NAME DIETHROW.ASM

; Main program to reset RST7.5 Flip-Flop, unmask RST7.5, enable interrupts,

; and count from 1 to 6 endlessly in an infinite loop

ORG C000H

CURDT: EQU FFF9H

UPDDT: EQU 06D3H

DELAY: EQU 04BEH

MVI A, 00011011B

SIM ; Reset RST7.5 Flip-Flop, Unmask RST7.5

EI ; Enable interrupt system

; Program segment for an endless counter (1 to 6) loop.

; The 2 NOP instructions are needed because interrupt request

; lines are sensed by 8085 subsequent to JMP BEGIN instruction

; after a short time-interval of about 15 clocks. It may be

; better to have few NOP instructions to provide margin of safety.

BEGIN: MVI A, 01H

LOOP: NOP

NOP

INR A

CPI 06H

JNZ LOOP

JMP BEGIN

; RST7.5 ISS to display the counter value

RST75: STA CURDT

CALL UPDDT ; Display count value in data field

LXI D, FFFFH

CALL DELAY ; Generate a delay of 0.5 second

LDA CURDT

EI

RET

; When VECT INTR key is pressed, RST7.5 line is activated. So

; control is shifted to location 7.5 * 8 = 60 = 003CH. This location

; has JMP FFB1H instruction. (For ESA kit there is JMP 8FBFH). Hence

; it is necessary to write JMP RST75 instruction at location FFB1H.

; This is done by the following 2 instructions.

ORG FFB1H ; For ESA Kit it should be ‘ORG 8FBFH’

JMP RST75

更新于: 30-Jul-2019

447 次浏览

开启你的职业生涯

完成课程获得认证

开始使用
广告