使用查找表在 8085 微处理器中查找数字平方值的程序
我们编写一个 8085 汇编语言程序,使用查找表在地址字段中显示一个数字及其平方值,以查找一位数字(0 到 9)的平方值。
FILE NAME MYSQR.ASM ORG C100H X: DB 00H, 01H, 04H, 09H, 16H, 25H, 36H, 49H, 64H, 81H ORG C000H CURAD: EQU FFF7H UPDAD: EQU 06BCH IBUFF: EQU FFFFH MVI A, 0EH ; Load A with 0000 1110B SIM ; Unmask RST5.5 i.e. enable keyboard interrupt. ; The next 4 instructions check if a key is pressed. If a key is ; pressed, RST5.5 pin gets activated but does not interrupt the 8085 ; as it is in DI state. But RIM instruction execution reveals that ; RST5.5 is pending. In such a case, the loop is exited. AGAIN: DI RIM ANI 00010000B JZ AGAIN ; Stay in this loop till a key is pressed EI NOP ; RST5.5 interrupts the 8085 now. Only after NOP is ; executed, interrupt system is enabled. ; So control is transferred to RST5.5 ISS. Details of this ISS ; is discussed in a later chapter when Intel 8279 chip is discussed. ; Execution of this ISS results in location IBUFF getting loaded ; with code of key pressed. Then the control is passed on to the ; program segment shown below. LDA IBUFF CPI 0AH JNC AGAIN ; If code is >= 0AH, jump to AGAIN. LXI H, X ; Point HL to the beginning of the look up table. MOV L, A ; Load L from A. Thus, point HL to the location which ; contains the square of the number input by the user. MOV A, M ; Load A with the square of the number. MOV H, L ; Load H with the number whose square is desired. MOV L, A ; Load L with the square of the number. SHLD CURAD CALL UPDAD ; Display the number and its square. JMP AGAIN ; Jump to read the next value from the keyboard.
广告