Question

In: Computer Science

*Microprocessors* Write a program sequence that will test the byte STATUS and branch to ROOTINE_1 if...

*Microprocessors*

Write a program sequence that will test the byte STATUS and branch to ROOTINE_1 if bit 1, 2, or 4 is 1. Otherwise, it is a branch to ROUTINE_2 if both bits 1 and 3 are 1 and to ROUTINE_3 if both bits 1 and 3 are 0. In all other cases, it is to execute ROUTINE_4. Assume that the routines are more than 128 bytes long. Also, give a flowchart of the sequence.

In ASSEMBLY PROGRAM

Solutions

Expert Solution

Greetings!!

Code with comments:

ORG 100h

.DATA

NUM DB ?

PROMPT DB 10,13,"PLEASE ENTER ANY NUMBER BETWEEN 00-99:$"

M1 DB 10,13,"BITS 1,4 OR 2 ARE 1 & IN ROUTINE 1$"
M2 DB 10,13,"BITS 1 AND 3 ARE 1 & IN ROUTINE 2 $"
M3 DB 10,13,"BITS 1 AND 3 ARE 0 & IN ROUTINE 3$"
M4 DB 10,13,"IN ROUTINE 4$"

.CODE
MOV AX,@DATA
MOV DS,AX
  
MOV DX,OFFSET PROMPT
MOV AH,9
INT 21H

MOV AH,1 ;READ 1ST DIGIT
INT 21H
  
SUB AL,30H
MOV BL,AL
  
SHL BL,4 ;SHIFT THE 1ST DIGIT TO LEFT TO MAKE INDIVIDUAL 2 DIGITS INTO SINGLE 2 DIGIT NUMBER
  
MOV AH,1 ;READ THE SECOND DIGIT
INT 21H
  
SUB AL,30H
ADD AL,BL ;ADD 2 DIGITS TOGETHER TO MAKE ONE 2 DIGIT NUMBER. ie 1 AND 2 COMBINED TO MAKE 12
  
MOV NUM,AL

AND AL,09H ;CHECK WHETHER THE BIT 4 AND BIT 1 IS 1?
CMP AL,09H
JNE L121 ;IF NOT GOTO CHECK BIT 2 AND BIT 1 IS 1?
CALL ROUTINE_1 ;CALL ROUTINE 1 IF 4 AND 1 ARE 1
JMP END
L121:   
MOV AL,NUM
AND AL,03H
CMP AL,03H ;CHECKING 1 AND 2 ARE 1?
JNE L131 ;IF NOT CHECKING I AND 3 ARE 1?
CALL ROUTINE_1 ;IF 1 AND 2 ARE 1,CALL ROUTINE 1
JMP END
L131:   
MOV AL,NUM
AND AL,05H
CMP AL,05H ;CHECK WHETHER 1 AND 3 ARE 1?
JNE L130
CALL ROUTINE_2 ;IF 1 AND 3 ARE 1,THEN CALL ROUTINE 2
JMP END
L130:   
MOV AL,NUM
AND AL,05H
CMP AL,0
JNE ALLOTHER
CALL ROUTINE_3 ;IF 1 AND 3 ARE 0, CALL ROUTINE 3
JMP END
ALLOTHER:
CALL ROUTINE_4 ;ELSE CALL ROUTINE 4
  

END:
HLT
  
PROC ROUTINE_1 NEAR
PUSH AX
MOV DX,OFFSET M1
MOV AH,9
INT 21H
POP AX
RET
  
PROC ROUTINE_2 NEAR
PUSH AX
MOV DX,OFFSET M2
MOV AH,9
INT 21H
POP AX
RET
  
PROC ROUTINE_3 NEAR
PUSH AX
MOV DX,OFFSET M3
MOV AH,9
INT 21H
POP AX
RET
  
PROC ROUTINE_4 NEAR
PUSH AX
MOV DX,OFFSET M4
MOV AH,9
INT 21H
POP AX
RET
  

RET

Output Screenshot:

Hope this helps


Related Solutions

Write a program sequence that will test the byte STATUS and branch to ROOTINE_1 if bit...
Write a program sequence that will test the byte STATUS and branch to ROOTINE_1 if bit 1, 2 or 4 is 1. Otherwise, it is branch to ROUTINE_2 if both bits 1 and 3 are 1 and to ROUTINE_3 if both bits 1 and 3 are 0. In all other cases it is to exeute ROUTINE_4. Assume that the routines are more than 128 bytes long. Also give a flowchart of the sequence.
Write a test program that prompts the user to enter a sequence of numbers ending with...
Write a test program that prompts the user to enter a sequence of numbers ending with 0, and invokes this method to return the largest number in the input. Use inheritance and polymorphism approach. in java please
Write the main.c program for a PSoC project that takes an input byte and converts it...
Write the main.c program for a PSoC project that takes an input byte and converts it to an integer value in base 10 for subsequent processing within the program as an integer. (Example, 0x5A = 9010).
Write a program to detect the deadlock occurrence and write the sequence if there is a...
Write a program to detect the deadlock occurrence and write the sequence if there is a safe state. Noted: C or C++
Write the Bit configuration of PSW( The Program Status Word ).
Write the Bit configuration of PSW( The Program Status Word ).  
Write an inline assembly program that initializes a 100 byte area of memory to 0xFF using...
Write an inline assembly program that initializes a 100 byte area of memory to 0xFF using the STOS instruction with REP using DWORD transfers.
Write an inline assembly program that initialized a 100 byte area of memory using the STOS...
Write an inline assembly program that initialized a 100 byte area of memory using the STOS instruction.
c++ Write a program that displays the status of an order. a) Program uses 2 functions...
c++ Write a program that displays the status of an order. a) Program uses 2 functions (in addition to main ()). b) The first function asks the user for the data below and stores the input values in reference parameters. c) Input data from user: # of spools ordered, # of spools in stock, any special shipping & handling charges over and above the $10 rate. d) The second function receives as arguments any values needed to compute and display...
Write a program that asks the user for their filing status (single or married) and their...
Write a program that asks the user for their filing status (single or married) and their taxable income. Then, using the below table, compute the tax owed and display the filing status, taxable income, and tax owed. If the filing status is single and the taxable income is overbut not over   the tax is of the amount over$0$9,52510%0$9,526$38,700$952.50 + 12%$9,525$38,701$82,500$4,453.50 +22% $38,700 $82,501unlimited$14,089.50 +24% $82,500 If the filing status is married filing jointly and the taxable income is overbut not overthe...
c program Write a program that asks the user to enter a sequence of 15 integers,...
c program Write a program that asks the user to enter a sequence of 15 integers, each either being 0, 1, or 2, and then prints the number of times the user has entered a "2" immediately following a "1". Arrays are not allowed to appear in your code. Include ONLY THE SCREENSHOT OF YOUR CODE in an image file and submit the file.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT