说明
按照要求,需要根据开关确定写入 SRAM
的方式。00
为规则字、01
为非规则字、10
为字节,11
为退出。
SRAM
空间从 8000:0000H
开始,通过 D8000:0000
查看内存空间。
分析
通过 8255
连接开关,并从 K1K0
读入数据到寄存器。
代码
;; INPUT RULE ;; 00 == ORDERED ;; 01 == UNORDERED ;; 10 == BYTE ;; 11 == STOP SSEG SEGMENT STACK DW 32 DUP(?) SSEG ENDS CODE SEGMENT ASSUME CS:CODE START PROC FAR MOV AL, 1001000B ;; INIT 8255 MOV DX, 0614H OUT DX, AL MOV AX, 8000H ;; SET START OFFSET MOV DS, AX BEGIN_MAIN: CALL FAR PTR READ_KEY CMP BX, 11B JE EXIT CALL FAR PTR WRITE_TO NOP ;; BREAK POINT HERE JMP BEGIN_MAIN EXIT: MOV AX, 4C00H INT 21H START ENDP READ_KEY PROC FAR MOV DX, 0640H ;; READ FROM 8255 IN AL, DX MOV BL, AL ;; SET BX MOV BH, 00H RET READ_KEY ENDP ;;; PARAM: BX(MODE) WRITE_TO PROC FAR MOV SI, BX AND SI, 1B ;; SI = BX & 1 (01 -> 1, 00/10 -> 0) MOV AX, 0H MOV CX, 10H LO: CMP BX, 10B JE BM ;; NORMAL MODE MOV [SI], AX JMP POST BM:;; BYTE MODE MOV [SI], AL MOV [SI+1], AH POST: INC AX INC SI INC SI LOOP BM RET WRITE_TO ENDP CODE ENDS END START