MTS-88.C and I/O BOARD -08 has 8 (Eight) 7-segment displays and 20 key-pads on board. The displays are numbered from 7-SEG.1 to 7-SEG.8 and are connected to Port B’s PB7 to PB0 lines respectively. To display a character on a 7-segment display a byte has to be written to port B. The MSB 4 bits are the address of the 7-segment display and LSB 4 bits are the data. So if we write 58 H to port B then the 6th 7-segment display will show data 8.
20 key-pads are numbered from P01 to P20 and are arranged in 5 columns and 4 rows. Rightmost column is connected to PB0 while leftmost column is connected to PB4. Topmost row is connected to PA0 while bottom-most row is connected to PA3. For detecting a key press, first a column must be activated by writing a byte to port B. Next, port A should be read. The valid values are 1, 2, 4 and 8 for row 1, 2, 3 and 4 respectively.
The experiment is to read the keypad and display the pressed key id on the specified 7-segment display. In this experiment, I haven't understood some lines in the assembly code I have shown below. I have made comments beside those lines which I haven't understood.
MEMORY ADDRESS ASSEMBLY CODE
0000:0476 MOV AL,90
0000:0478 OUT 13,AL
0000:047A MOV DL,00
0000:047C MOV CX,0004H //why storing 4 here
0000:047F MOV AL,0F
0000:0481 MOV BL,CL
0000:0483 SHL BL,01 //why left shift for 4 times
0000:0485 SHL BL,01
0000:0487 SHL BL,01
0000:0489 SHL BL,01
0000:048B OR AL,BL //why doing OR operation here
0000:048D OUT 11,AL
0000:048F IN AL,10
0000:0491 MOV BL,01
0000:0493 TEST AL,BL //what is testing here
0000:0495 JE O4A7 //when we are jumping(what is the condition)
0000:0497 INC DL // what are we storing in DL
0000:0499 CMP DL,09
0000:049C JG 047A //why are we comparing DL with 9
0000:049E SHL BL,01
0000:04A0 TEST BL,10 //what is being tested here
0000:04A3 JE 0493
0000:04A5 LOOP O47F
0000:04A7 MOV AL,DL
0000:04A9 OUT 11,AL
0000:04AB PUSH CX
0000:04AC MOV CX,500
0000:04AF NOP //why is this operation needed
0000:04B0 LOOP 04AF
0000:04B2 POP CX
0000:04B3 JMP 047A
What is actually being done with those lines I have marked above?