bai tap 1
BAi 1 Thiet ke card giao dien 8255 su dung dia chi 3CFh.
Viet chuong trinh xu li du lieu nhap vao tu PA,PB
D(PA) = 2D(PB) thi tong hai du lieu chuyen ra PC
D(PA) > 2D(PB) ------------------------------ PB
D(PA) < 2D(PB) ------------------------------ PA
- Xac dinh dia chi: 3CFh= 0011 1100 1111
ta co A1A0 = 11 suy ra 3CFh la dia chi cua CWR
3CEh -------------- PC
3CDh -------------- PB
3CCh -------------- PA
- Xac dinh tu dieu khien: 1 0 0 A CA 0 B CB
* PA=PB=I,Pc=O ta co 1 0 0 1 0 0 1 0 --> CW1 = 92h
* PB=PC=I,PA=O ta co 1 0 0 0 1 0 1 1 --> CW2 = 8Bh
* PA=PC=I,PB=O ta co 1 0 0 1 1 0 0 1 --> CW3 = 99h
-Chuong trinh:
* Model Small
* Stack 100
* Data
PA EQU 3CCh
PB EQU 3CDh
PC EQU 3CEh
CWR EQU 3CFh
CW1 EQU 92h
CW2 EQU 8Bh
CW3 EQU 99h
*Code
Main proc
MOV AX,@Data
MOV DS,AX
MOV AL,CW1; truong hop PA=PB=I, PC=O
OUT CWR,AL
IN AX,PB; dua D(PB) vao BX
MOV BX,AX
IN AX,PA; dua D(PA) vao AX
MOV DX,BX ; dua D(PB) vao DX de xu li tiep, giu lai BX
SHL DX,1; nhan doi D(PB) luu vao DX
MOV CX,AX; dua D(PA) vao CX de xu li tiep
CMP CX,DX; so sanh D(PA) voi 2D(PB)
JE bang; D(PA)=2D(PB)
JG lon; D(PA)>2D(PB)
JL nho; D(PA)<2D(PB)
bang: ADD CX,BX; tong luu vao CX
MOV AX,CX
OUT PC,AX
JMP Exit
lon: MOV AL,CW3; PB=O
OUT CWR,AL
ADD CX,BX; tong luu vao CX
MOV AX,CX
OUT PB,AX
JMP Exit
nho: MOV AL,CW2; PC=O
OUT CWR,AL
ADD CX,BX; tong luu vao CX
MOV AX,CX
OUT PA,AX
Exit: MOV AH,4Ch
INT 21h
MAIN Endp
END MAIN
Bạn đang đọc truyện trên: AzTruyen.Top