Hello, can you help me look at the program? I want to change the 4*4 matrix keyboard to 4*5 for an assembly calculator (up to 3 digits). The original function can be achieved by using p1.0-p1.3 to connect the rows and p1.4-p1.7 to connect the columns. How to change it to use p3.3 to p3.4 to connect the keyboard columns? The following program is all connected to the p1 port, and the proteus simulation can run. ORG 0000H; JMP MAIN; ORG 0003H; JMP INP0; ORG 0030H; /*The numbers entered by the keyboard are stored in 70H-77H in sequence*/ MAIN: MOV R6, #70H; MOV SP, #60H; CLR 80H; CLR 81H; SETB EA; SETB EX0; SETB IT0; DISP1: MOV R0, #70H;//Store numbers from the first address MOV R2, #01H;//Bit select the first bit DISP2: MOV A, @R0; LCALL SEG7; //Jump segment code MOV P0, A; //P0 output font MOV P2, R2; //Bit select output LCALL D1MS; //Jump delay MOV P2, #0; //Bit select is turned off, segment code is not output INC R0; //Select the next bit; MOV A, R2; CLR C; //Carry flag cleared RLC A; //Scan word right shift MOV R2, A; //Save scan word JNC DISP2; //When C=0, the loop is not finished once, jump to DISP2 PASS: LJMP DISP1; D1MS: MOV R7, #50H;//Delay program DMS: DJNZ R7, DMS; RET; SEG7: MOV DPTR, #TABLE;//Table lookup program MOVC A, @A+DPTR; RET; TABLE: DB 0C0H, 0F9H, 0A4H, 0B0H; DB 99H, 92H, 82H, 0F8H; DB 80H, 90H, 88H, 83H; DB 0C6H, 0A1H, 86H, 8EH; /*P1.0-1.3, row line; P1.4-1.7, column line;*/ /*P0, output font; P2, output bit selection*/ INP0: PUSH ACC; PUSH B; PUSH PSW; START: MOV R4, #00H; L1: MOV R3, #0F7H;//Set the initial scan value, 11110111, P3.3=0 MOV R1, #00H; //Code pointer; /*First row scan*/ L2: MOV A, R3; //Start row scan MOV P1, A; //Scan value output to p1 MOV A, P1; //Read the value of P1 MOV R4, A; //The status of P3.4-3.7 in P3 port is transferred to R4 through A SETB C; //Carry flag is set to 1 MOV R5, #04H; // l3: RLC A; //Press the key to shift left, and judge whether there is 0 in this column by whether C is 0; if there is no 0, r1 is accumulated; if there is 0, jump to delay, JNC KEY; //C=0, jump to delay INC R1; DJNZ R5, L3; MOV A, R3; SETB C; RRC A; //Wrap scan MOV R3,A; JC L2; //C=1, jump to L2 KEY: ACALL DELAY; D1: MOV A,P1; XRL A,R4; JNZ D1; MOV A, R6; //Specify the address to be stored MOV R0, A; MOV A, R1; //Store the number MOV @R0, A; /*Judge the operation method*/ MOV A, R1; XRL A, #0AH;//Judge whether it is the addition symbol JZ ADD1; MOV A, R1; XRL A, #0BH;//Judge whether it is the subtraction symbol JZ SUBB1; MOV A, R1; XRL A, #0CH;//Judge whether it is the multiplication symbol JZ MUL1; MOV A,R1; XRL A, #0DH;//Judge whether it is the division symbol JZ DIV1; MOV A, R1; XRL A, #0EH;//Judge whether it is the equal sign JZ EQUAL1; MOV A, R1; XRL A, #0FH;//Judge whether it is the clear key JZ ON1; INC R0; //Select the next address MOV A, R0; //Store the new value in r0 MOV R6, A; POP PSW; POP B; pop ACC; RET; DELAY: MOV R7, #60;//Eliminate jitter delay program DLY1: DJNZ R7, DLY1; RET; ADD1: MOV A, 80H; //Addition program MOV 81H, A; LJMP D1; MOV A, 81H; ADD A, 80H; MOV 80H, A; RET; SUBB1: MOV A, 80H;//Subtraction program MOV 81H, A; LJMP DD1; MOV A, 80H; SUBB A, 81H; MOV 80H, A; RET; MUL1: MOV A, 80H;//Multiplication program MOV 81H, A; LJMP DD1; MOV A, 80H; MUL AB; MOV 80H, A; RET; DIV1: MOV A, 80H;//Division program MOV 81H, A; LJMP DD1; MOV A, 80H; DIV AB; MOV 80H, A; RET; EQUAL1: MOV A, 80H;//Equal program MOV B, #64H;//Calculate the hundreds digit DIV AB; MOV 72H, A; //Divide this number by 100, put the quotient in 72h and the remainder in 71h. MOV 71H, B; MOV A, 71H; MOV B, 0AH; //Calculate the ten-digit number DIV AB; MOV 71H, A; //Divide this number by 10, put the quotient in 71h and the remainder in 70h. MOV 70H, B; RET; ON1: CLR 70H; //Clear program CLR 71H; CLR 72H; CLR 73H; CLR 78H; CLR 79H; CLR 7AH; CLR 80H; CLR 81H; CLR 82H; CLR 88H; CLR 89H; CLR 8AH; MOV R0, 00H; MOV R1, 00H; MOV R2, 00H; MOV R3, 00H; MOV R4, 00H; MOV R5, 00H; MOV R6, 70H; MOV R7, 00H; RET; DD1: MOV B, #0AH; //Convert the two-digit number to decimal and store it in 80h MOV A, 78H; MUL AB; ADD A, 70H; MOV 80H, A; RET; END;R0; //Store new value in r0 MOV R6, A; POP PSW; POP B; pop ACC; RET; DELAY: MOV R7, #60; //Delay program to eliminate jitter DLY1: DJNZ R7, DLY1; RET; ADD1: MOV A, 80H; //Addition program MOV 81H, A; LJMP D1; MOV A, 81H; ADD A, 80H; MOV 80H, A; RET; SUBB1: MOV A, 80H; //Subtraction program MOV 81H, A; LJMP DD1; MOV A, 80H; SUBB A, 81H; MOV 80H, A; RET; MUL1: MOV A, 80H; //Multiplication program MOV 81H, A; LJMP DD1; MOV A, 80H; MUL AB; MOV 80H, A; RET; DIV1: MOV A, 80H; //Division program MOV 81H, A; LJMP DD1; MOV A, 80H; DIV AB; MOV 80H, A; RET; EQUAL1: MOV A, 80H; //Equal program MOV B, #64H; //Calculate the hundreds digit DIV AB; MOV 72H, A; //Divide this number by 100, put the quotient in 72h, and the remainder in 71h. MOV 71H, B; MOV A, 71H; MOV B, 0AH; //Calculate the tens digit DIV AB; MOV 71H, A; //Divide this number by 10, put the quotient in 71h, and the remainder in 70h. MOV 70H, B; RET; ON1: CLR 70H; //Clear program CLR 71H; CLR 72H; CLR 73H; CLR 78H; CLR 79H; CLR 7AH; CLR 80H; CLR 81H; CLR 82H; CLR 88H; CLR 89H; CLR 8AH; MOV R0, 00H; MOV R1, 00H; MOV R2, 00H; MOV R3, 00H; MOV R4, 00H; MOV R5, 00H; MOV R6, 70H; MOV R7, 00H; RET; DD1: MOV B, #0AH; //Convert the two-digit number to decimal and store it in 80h MOV A, 78H; MUL AB; ADD A, 70H; MOV 80H, A; RET; END;R0; //Store new value in r0 MOV R6, A; POP PSW; POP B; pop ACC; RET; DELAY: MOV R7, #60; //Delay program to eliminate jitter DLY1: DJNZ R7, DLY1; RET; ADD1: MOV A, 80H; //Addition program MOV 81H, A; LJMP D1; MOV A, 81H; ADD A, 80H; MOV 80H, A; RET; SUBB1: MOV A, 80H; //Subtraction program MOV 81H, A; LJMP DD1; MOV A, 80H; SUBB A, 81H; MOV 80H, A; RET; MUL1: MOV A, 80H; //Multiplication program MOV 81H, A; LJMP DD1; MOV A, 80H; MUL AB; MOV 80H, A; RET; DIV1: MOV A, 80H; //Division program MOV 81H, A; LJMP DD1; MOV A, 80H; DIV AB; MOV 80H, A; RET; EQUAL1: MOV A, 80H; //Equal program MOV B, #64H; //Calculate the hundreds digit DIV AB; MOV 72H, A; //Divide this number by 100, put the quotient in 72h, and the remainder in 71h. MOV 71H, B; MOV A, 71H; MOV B, 0AH; //Calculate the tens digit DIV AB; MOV 71H, A; //Divide this number by 10, put the quotient in 71h, and the remainder in 70h. MOV 70H, B; RET; ON1: CLR 70H; //Clear program CLR 71H; CLR 72H; CLR 73H; CLR 78H; CLR 79H; CLR 7AH; CLR 80H; CLR 81H; CLR 82H; CLR 88H; CLR 89H; CLR 8AH; MOV R0, 00H; MOV R1, 00H; MOV R2, 00H; MOV R3, 00H; MOV R4, 00H; MOV R5, 00H; MOV R6, 70H; MOV R7, 00H; RET; DD1: MOV B, #0AH; //Convert the two-digit number to decimal and store it in 80h MOV A, 78H; MUL AB; ADD A, 70H; MOV 80H, A; RET; END;80H; MUL AB; MOV 80H, A; RET; DIV1: MOV A, 80H; //Division program MOV 81H, A; LJMP DD1; MOV A, 80H; DIV AB; MOV 80H, A; RET; EQUAL1: MOV A, 80H; //Equal program MOV B, #64H; //Calculate the hundreds digit DIV AB; MOV 72H, A; //Divide this number by 100, put the quotient in 72h, and the remainder in 71h. MOV 71H, B; MOV A, 71H; MOV B, 0AH; //Calculate the tens digit DIV AB; MOV 71H, A; //Divide this number by 10, put the quotient in 71h, and the remainder in 70h. MOV 70H, B; RET; ON1: CLR 70H; //Clear program CLR 71H; CLR 72H; CLR 73H; CLR 78H; CLR 79H; CLR 7AH; CLR 80H; CLR 81H; CLR 82H; CLR 88H; CLR 89H; CLR 8AH; MOV R0, 00H; MOV R1, 00H; MOV R2, 00H; MOV R3, 00H; MOV R4, 00H; MOV R5, 00H; MOV R6, 70H; MOV R7, 00H; RET; DD1: MOV B, #0AH; //Convert the two-digit number to decimal and store it in 80h MOV A, 78H; MUL AB; ADD A, 70H; MOV 80H, A; RET; END;80H; MUL AB; MOV 80H, A; RET; DIV1: MOV A, 80H; //Division program MOV 81H, A; LJMP DD1; MOV A, 80H; DIV AB; MOV 80H, A; RET; EQUAL1: MOV A, 80H; //Equal program MOV B, #64H; //Calculate the hundreds digit DIV AB; MOV 72H, A; //Divide this number by 100, put the quotient in 72h, and the remainder in 71h. MOV 71H, B; MOV A, 71H; MOV B, 0AH; //Calculate the tens digit DIV AB; MOV 71H, A; //Divide this number by 10, put the quotient in 71h, and the remainder in 70h. MOV 70H, B; RET; ON1: CLR 70H; //Clear program CLR 71H; CLR 72H; CLR 73H; CLR 78H; CLR 79H; CLR 7AH; CLR 80H; CLR 81H; CLR 82H; CLR 88H; CLR 89H; CLR 8AH; MOV R0, 00H; MOV R1, 00H; MOV R2, 00H; MOV R3, 00H; MOV R4, 00H; MOV R5, 00H; MOV R6, 70H; MOV R7, 00H; RET; DD1: MOV B, #0AH; //Convert the two-digit number to decimal and store it in 80h MOV A, 78H; MUL AB; ADD A, 70H; MOV 80H, A; RET; END;A; RET; END;A; RET; END;