table of Contents
Experiment 1 Assembly language programming experiment
1. The purpose of the experiment
2. The instruments used in the experiment
3. Experimental content and basic principles
5. Analysis of experimental results and answering questions (or test environment and test results)
Experiment 2 Digital conversion experiment
1. The purpose of the experiment
2. The instruments used in the experiment
3. Experimental content and basic principles
5. Analysis of experimental results and answering questions
Experiment 3 Basic IO port expansion experiment
1. The purpose of the experiment
2. The instruments used in the experiment
3. Experimental content and basic principles
5. Analysis of experimental results and answering questions
Experiment 4 Programmable parallel interface experiment
1. The purpose of the experiment
2. The instruments used in the experiment
3. Experimental content and basic principles
Fourth, the experimental schematic
5. Analysis of experimental results and answering questions
Experiment 1 Assembly language programming experiment
1. The purpose of the experiment
1. Master the programming method of assembly language
2. Master the usage of DOS function call
3. Master the debugging and running process of assembly language program
2. The instruments used in the experiment
Masm for windows integrated environment
3. Experimental content and basic principles
1. Display the character string data in the specified data area on the screen in the form of ASCII code, and complete the display of necessary prompt information through DOS function call.
2. Display your student ID name information on the screen.
3. Cyclically read characters from the keyboard and display them on the screen, and then display the ASCII codes of the corresponding characters until the end of the input "Q" or "q".
Bytecode to ASCII code flow chart
4. Experimental data record
Student ID name title source code:
Character to ASCII source code:
5. Analysis of experimental results and answering questions (or test environment and test results)
Student ID and name input and output test results:
Character to ASCII test results:
Experiment 2 Digital conversion experiment
1. The purpose of the experiment
1. Master the program design method of conversion between different numbers and codes.
2. Master the programming and debugging methods of arithmetic instructions.
3. Master the design method of the cycle program.
2. The instruments used in the experiment
Masm for windows integrated environment QTHPCI software
3. Experimental content and basic principles
Experimental content:
1. Repeatedly input a decimal number no more than 5 digits from the keyboard, and press the Enter key to end the input;
2. Convert the decimal number to a binary number; the result is displayed on the screen as a binary number;
3. If non-numeric characters are entered, an error message will be reported and re-entered;
4. Until "Q" or "q" is entered, the program operation is completed.
5. Enter a character string on the keyboard and end it with a space. Count the number of numeric characters and display it on the screen
Experimental principle:
4. Experimental data record
|
Decimal (not more than five digits) to binary source code
|
The number of digits in the string
5. Analysis of experimental results and answering questions
Decimal to binary test results:
Test result of the number of digits in the string:
Experiment 3 Basic IO port expansion experiment
1. The purpose of the experiment
1. Understand the method of TTL chip to expand simple I / O port.
2. Grasp the method of data input and output programming.
2. The instruments used in the experiment
QTHPCI software, 74LS244 buffer driver, 74LS273 trigger
3. Experimental content and basic principles
Experimental content:
This experiment requires 74LS244 as the input port, read the switch status, and connect this status to the LED display through 74LS273. The specific experiment content is as follows:
1. When the switch Yi is low, the corresponding LED is on, and when the Yi is high, the corresponding LED is off.
2. When the switch Yi is all high, the LED Qi turns on from left to right.
3. When the switch Yi is all low, the light-emitting diode Qi turns on from right to left.
4. Independently design control and display modes, complete programming and debugging, and demonstrate experimental results.
Experimental principle:
74LS244 is a three-state output 8-bus buffer driver with no latch function. When G is low, the Ai signal is transmitted to Yi. When it is high, Yi is in a high-impedance state;
74LS273 is an 8D flip-flop with clear function, 1D ~ 8D is data input terminal, 1Q ~ 8Q is data output terminal, positive pulse trigger, low level clear, often used as 8-bit address latch.
4. Experimental data record
1. Connect according to the experiment connection diagram:
CS of 244 is connected to 0000H of ISA bus interface module, Y7—Y0——switches K1—K8
CS of 273 is connected to 0020H of ISA bus interface module, Q7-Q0——LEDs L1-L8 The WR and RD of this module are connected to IOWR and IORD of ISA bus interface module respectively. The data of this module (AD0 ~ AD7) is connected to the data of ISA bus interface module (LD0 ~ LD7). 2. Write experiment program, compile link, run program
3. Toggle the switch and observe the change of the LED.
5. Analysis of experimental results and answering questions
1. When the switch Yi is low, the corresponding LED is on, and when the Yi is high, the corresponding LED is off.
2. When the switch Yi is all high, the LED Qi turns on from left to right.
3. When the switch Yi is all low, the light-emitting diode Qi turns on from right to left.
Experiment 4 Programmable parallel interface experiment
1. The purpose of the experiment
1. Understand the internal structure of the programmable parallel interface 8255,
2. Master the working mode, initial programming and application.
2. The instruments used in the experiment
QTHPCI software, 8255 programmable parallel interface circuit
3. Experimental content and basic principles
Experimental content:
1. Water flow lamp experiment: use port A and port 8255 to light up the light-emitting diodes cyclically.
2. Traffic light experiment: Use port A of 8255 to simulate traffic lights.
3. I / O input and output experiment: use 8255 port A to read the switch status, and 8255 port B to send the status to LED display.
4. On the basis of completion (1), increase the circulation direction and circulation mode of the flow lamp controlled by the reading switch.
5. On the basis of completion (2), increase the on and off time of the traffic lights controlled by the reading switch.
Experimental principle:
8255 is a general programmable parallel interface circuit. It has three 8-bit parallel ports A, B and C. Among them, port C can also be used as contact signal and interrupt application signal of ports A and B. Through programming, it can be set to basic input and output, strobe input and output, and bidirectional transmission. For port C, it also has the function of pressing positions 0 and 1.
8255 Control word
D7 |
D6 |
D5 |
D4 |
D3 |
D2 |
D1 |
D0 |
1
(Signature) |
Group A
00 = Mode 0 01 = Mode 1
1X = Method 2 |
A port 0 = output 1 = Enter |
Port C high 4 digits 0 = output 1 = Enter |
Group B mode 0 = mode 0 1 = Method 1 |
Port B 0 = output 1 = Enter |
Lower 4 bits of port C 0 = output 1 = Enter |
|
0
(Signature) |
No need to |
Bit selection
000 = C port 0 bit ... 111 = C port 7 bit |
0 = Reset
1 = set |
Fourth, the experimental schematic
Traffic lights
5. Analysis of experimental results and answering questions
I / O input and output experiment
;交通灯源码
MY_STACK SEGMENT PARA 'STACK'
DB 100 DUP(?)
MY_STACK ENDS
MY_DATA SEGMENT PARA 'DATA'
IO_9054base_address DB 4 DUP(0) ;PCI 卡 9054 芯片 I/O 基地址暂存空间
IO_base_address DB 4 DUP(0) ;PCI 卡 I/O 基地址暂存空间
pcicardnotfind DB 0DH,0AH,'pci card not find or address/interrupt error !!!',0DH,0AH,'$'
GOOD DB 0DH,0AH,'The Program is Executing !',0DH,0AH,'$'
P8255_A DW 0000H
P8255_B DW 0001H
P8255_C DW 0002H
P8255_MODE DW 0003H DELAY_SET EQU 5fffH DELAY_SET1 EQU 18ffH
MES2 DB ' PCI CONFIG READ ERROR! $' MY_DATA ENDs
MY_CODE SEGMENT PARA 'CODE'
MY_PROC PROC FAR
ASSUME CS:MY_CODE, DS:MY_DATA, SS:MY_STACK
START:
.386 ;386 模式编译
MOV AX,MY_DATA
MOV DS,AX
MOV ES,AX
MOV AX,MY_STACK
MOV SS,AX
CALL FINDPCI ;自动查找 PCI 卡资源及 IO 口基址
; MOV
MOV CX,word ptr IO_base_address
CX,0E800H ;直接加入(E800:本机 PCI 卡 IO 口基址)
ADD P8255_A,CX ;PCI 卡 IO 基址+偏移
ADD P8255_B,CX
ADD P8255_C,CX
ADD P8255_MODE,CX
MOV MOV DX,P8255_MODE
AL,80H ;3 个口全部为输出
OUT DX,AL
MOV DX,P8255_A
CALL ST0 ;全为红灯
TRAFFIC1: CALL
CALL ST1
ST5 ;南北为绿灯,东西为红灯
CALL ST2 ;南北红灯闪烁,东西为红灯
CALL ST3
CALL ST6 ;南北为红灯,东西为绿灯
CALL ST4 ;南北为红灯,东西黄灯闪烁
CALL BREAK
JMP TRAFFIC1
MY_PROC ENDp
ST0 PROC NEAR
MOV AL,1BH
OUT DX,AL
CALL DELAY
RET
ST0 ENDp
ST1 PROC NEAR
MOV DX,P8255_A
MOV AL,0EDH
OUT DX,AL
CALL DELAY
CALL DELAY
CALL DELAY
RET
ST1 ENDp
ST5 PROC NEAR
MOV DX,P8255_A
MOV AL,0EBH
OUT DX,AL
CALL DELAY
RET
ST5 ENDp
ST2 PROC NEAR
MOV CX,5H
ST20: MOV AL,0EBH
OUT DX,AL
CALL DELAY1
MOV AL,0EFH
OUT DX,Al
CALL DELAY1
LOOP ST20
RET
ST2 ENDp
ST3 PROC NEAR
MOV AL,0DEH
OUT DX,AL
CALL DELAY
CALL DELAY
CALL DELAY
RET
ST3 ENDp
ST6 PROC NEAR
MOV DX,P8255_A
MOV AL,0BEH
OUT DX,AL
CALL DELAY
RET
ST6 ENDp
ST4 PROC NEAR
MOV CX,5H
ST40: MOV AL,0BEH
OUT DX,AL
CALL DELAY1
MOV AL,0FEH
OUT DX,AL
CALL DELAY1
LOOP ST40
RET
ST4 ENDp
;
;*****************************************************************************
; /* 延时子程序 */
;*****************************************************************************
;
DELAY PROC NEAR ;延时程序
PUSHF PUSH DX
PUSH CX
MOV DX,DELAY_SET
D1: MOV CX,-1
D2: DEC CX
JNZ D2
DEC DX
JNZ D1
POP CX
POP DX POPF
RET
DELAY ENDp
DELAY1 PROC NEAR ;延时程序
PUSHF PUSH DX
PUSH CX
MOV DX,DELAY_SET1
D3: MOV CX,-1
D4: DEC CX
JNZ D4
DEC DX
JNZ D3
POP CX
POP DX POPF
RET
DELAY1 ENDp
;
;*****************************************************************************
; /* 按任意键退出子程序 */
;*****************************************************************************
;
BREAK PROC NEAR ;按任意键退出
PUSHF PUSH AX
PUSH DX
MOV AH,06H
MOV DL,0FFH
INT 21H
JE RETURN
MOV AX,4C00H
INT 21H
RETURN: POP DX
POP AX POPF
RET
BREAK ENDP
;
;*****************************************************************************
; /* 找卡子程序 */
;*****************************************************************************
;
;FUNCTION CODE
IO_port_addre EQU 0CF8H ;32 位配置地址端口
IO_port_data EQU 0CFCH ;32 位配置数据端口
IO_PLX_ID EQU 200810B5H ;PCI 卡设备及厂商 ID
BADR0 = 10H ;基地址寄存器 0
BADR1 = 14H ;基地址寄存器 1
BADR2 = 18H ;基地址寄存器 2
BADR3 = 1CH ;基地址寄存器 3
FINDPCI PROC NEAR ;查找 PCI 卡资源并显示
PUSHAD PUSHFD
MOV EBX,080000000H
FINDPCI_next:
ADD EBX,100H
CMP EBX,081000000H
JNZ findpci_continue
MOV DX,offset pcicardnotfind ;显示未找到 PCI 卡提示信息
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H ;退出
findpci_continue:
MOV
MOV DX,IO_port_addre
EAX,EBX
OUT DX,EAX ;写地址口
MOV DX,IO_port_data
IN EAX,DX ;读数据口
CMP EAX,IO_PLX_ID
JNZ findpci_next ;检查是否发现 PCI 卡
MOV DX,IO_port_addre
MOV EAX,EBX
ADD
OUT EAX,BADR1
DX,EAX ;写地址口
MOV DX,IO_port_data
IN EAX,DX ;读数据口
MOV dword ptr IO_9054base_address,EAX
AND EAX,1
JZ findPCI_next ;检查是否为 i/o 基址信息
MOV EAX,dword ptr IO_9054base_address
AND EAX,0fffffffeh
MOV dword ptr IO_9054base_address,EAX ;去除 i/o 指示位并保存
MOV DX,IO_port_addre
MOV EAX,EBX
ADD EAX,BADR2
OUT DX,EAX ;写地址口
MOV
IN DX,IO_port_data
EAX,DX ;读数据口
MOV dword ptr IO_base_address,EAX
AND
JZ EAX,1
findPCI_next ;检查是否为 i/o 基址信息
MOV EAX,dword ptr IO_base_address
AND
MOV EAX,0fffffffeh
dword ptr IO_base_address,EAX ;去除 i/o 指示位并保存
MOV DX,offset good ;显示开始执行程序信息
MOV AH,09H
INT 21H
POPfd
POPad
RET
findPCI ENDP
MY_CODE ENDS
END START
;I/O 实验源码
DATA SEGMENT DELAY_SET EQU 0FFFH L_TO_R DB ?
R_TO_L DB ?
DATA ENDs
CODE SEGMENT
ASSUME DS : DATA, CS : CODE START:
MOV AX, DATA
MOV DS, AX
MOV L_TO_R, 07FH MOV R_TO_L, 0FEH MOV DX, 0ec03h MOV AL, 89h
OUT DX, AL
X:
MOV DX, 0ec02h IN AL, DX CMP AL, 0h
JE FLOW_1 CMP AL, 00fh JE FLOW_2
MOV DX, 0ec00h OUT DX, AL CALL DELAY JMP START
FLOW_1:
MOV AL, L_TO_R MOV AH, R_TO_L ROR AL, 1
MOV L_TO_R, AL ROL AH, 1
MOV R_TO_L, AH JMP SHOW_1
FLOW_2:
MOV AL, R_TO_L MOV AH, L_TO_R ROR AL, 1
MOV L_TO_R, AL ROL AH, 1
MOV R_TO_L, AH JMP SHOW_2
SHOW_1:
MOV DX, 0ec00h OUT DX, AL MOV AL, AH MOV DX, 0ec01h OUT DX, AL CALL DELAY JMP X
SHOW_2:
MOV DX, 0ec01h OUT DX, AL MOV AL, AH MOV DX, 0ec00h OUT DX, AL CALL DELAY JMP X
DELAY PROC NEAR
PUSHF
PUSH DX
PUSH CX
MOV DX,DELAY_SET
D1: MOV CX,-1
D2: DEC CX
JNZ D2
DEC DX
JNZ D1
POP CX
POP DX
POPF
RET
DELAY ENDp
CODE ENDs END START
;流水灯源码
MY_STACK SEGMENT PARA 'STACK'
DB 100 DUP(?)
MY_STACK ENDS
MY_DATA SEGMENT PARA 'DATA'
IO_9054base_address DB 4 DUP(0) ;PCI 卡 9054 芯片 I/O 基地址暂存空间
IO_base_address DB 4 DUP(0) ;PCI 卡 I/O 基地址暂存空间
pcicardnotfind DB 0DH,0AH,'pci card not find or address/interrupt error !!!',0DH,0AH,'$'
GOOD DB 0DH,0AH,'The Program is Executing !',0DH,0AH,'$'
LA DB ?
LB DB ?
P8255_A DW 0000H
P8255_B DW 0001H
P8255_C DW 0002H
P8255_MODE DW 0003H DELAY_SET EQU 11FFH
MES2 DB ' PCI CONFIG READ ERROR! $' MY_DATA ENDs
MY_CODE SEGMENT PARA 'CODE' MY_PROC PROC FAR
ASSUME CS:MY_CODE, DS:MY_DATA, SS:MY_STACK
START:
.386 ;386 模式编译
MOV AX,MY_DATA
MOV DS,AX
MOV ES,AX
MOV AX,MY_STACK
MOV SS,AX
CALL FINDPCI ;自动查找 PCI 卡资源及 IO 口基址
MOV
ADD CX,word ptr IO_base_address
P8255_A,CX ;PCI 卡 IO 基址+偏移
ADD P8255_B,CX
ADD P8255_C,CX
ADD P8255_MODE,CX
MOV DX,P8255_MODE ;8255 初始化,三个口全为输出
MOV AL,80H
OUT DX,AL
MOV DX,P8255_A ;PA 口赋初值
MOV AL,7FH
OUT DX,AL
MOV LA,AL
MOV DX,P8255_B ;PB 口赋初值
MOV AL,0FEH
OUT DX,AL
MOV LB,AL
CALL DELAY
A1: MOV AL,LA ;PA 口数据右移一位
ROL AL,1
MOV LA,AL
MOV DX,P8255_A
OUT DX,AL
MOV AL,LB
ROR AL,1
MOV LB,AL
MOV DX,P8255_B ;PB 口数据右移一位
OUT DX,AL
CALL DELAY ;延时
CALL BREAK ;按任意键退出
JMP A1
MY_PROC ENDp
DELAY PROC NEAR ;延时程序
PUSHF
PUSH DX
D1: PUSH MOV MOV CX DX,DELAY_SET CX,-1
D2:
DELAY DEC
JNZ DEC JNZ POP POP POPF RET ENDp CX
D2 DX D1 CX DX
BREAK
RETURN: PROC MOV MOV INT JE MOV INT RET NEAR AH,06H DL,0FFH 21H RETURN AX,4C00H 21H
BREAK ENDP
;*****************************************************************************
; /* 找卡子程序 */
;*****************************************************************************
IO_port_addre EQU 0CF8H ;32 位配置地址端口
IO_port_data EQU 0CFCH ;32 位配置数据端口
IO_PLX_ID EQU 200810B5H ;PCI 卡设备及厂商 ID
BADR0 = 10H ;基地址寄存器 0
BADR1 = 14H ;基地址寄存器 1
BADR2 = 18H ;基地址寄存器 2
BADR3 = 1CH ;基地址寄存器 3
FINDPCI PROC NEAR ;查找 PCI 卡资源并显示
PUSHAD PUSHFD
MOV EBX,080000000H
FINDPCI_next:
ADD EBX,100H
CMP EBX,081000000H
JNZ findpci_continue
MOV DX,offset pcicardnotfind ;显示未找到 PCI 卡提示信息
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H ;退出
findpci_continue:
MOV
MOV DX,IO_port_addre
EAX,EBX
OUT DX,EAX ;写地址口
MOV DX,IO_port_data
IN EAX,DX ;读数据口
CMP
JNZ EAX,IO_PLX_ID
findpci_next ;检查是否发现 PCI 卡
MOV DX,IO_port_addre
MOV EAX,EBX
ADD EAX,BADR1
OUT DX,EAX ;写地址口
MOV DX,IO_port_data
IN EAX,DX ;读数据口
MOV dword ptr IO_9054base_address,EAX
AND EAX,1
JZ findPCI_next ;检查是否为 i/o 基址信息
MOV EAX,dword ptr IO_9054base_address
AND EAX,0fffffffeh
MOV dword ptr IO_9054base_address,EAX ;去除 i/o 指示位并保存
MOV DX,IO_port_addre
MOV EAX,EBX
ADD
OUT EAX,BADR2
DX,EAX ;写地址口
MOV DX,IO_port_data
IN EAX,DX ;读数据口
MOV AND dword ptr IO_base_address,EAX EAX,1
JZ findPCI_next ;检查是否为 i/o 基址信息
MOV EAX,dword ptr IO_base_address
AND EAX,0fffffffeh
MOV dword ptr IO_base_address,EAX ;去除 i/o 指示位并保存
MOV DX,offset good ;显示开始执行程序信息
MOV AH,09H
INT 21H
POPfd POPad RET
findPCI ENDP
MY_CODE ENDS END START