Question: LCM Program START INP / / Input the first number STA NUM _ A / / Store first number in address NUM _ A INP

LCM Program
START INP // Input the first number
STA NUM_A // Store first number in address NUM_A
INP // Input the second number
STA NUM_B // Store second number in address NUM_B
CheckFirstNum
LDA NUM_A // Load the first number
BRP SECONDNUM // Branch to SECONDNUM, if first number is positive
LDA NEGATIVEONE // Load -1
OUT // Output -1
BRA CHECK_NEGATIVE // Branch to CHECKNEGATIVE to continue
CheckSecondNum
LDA NUM_B // Load the second number
BRP CHECK_DIVISION // Branch to CHECK_DIVISION, if second num is positive
LDA NEGATIVEONE // Load -1
OUT // Output -1
BRA CHECK_NEGATIVE // Branch to CHECKNEGATIVE to continue
CheckNegative
LDA NUM_A // Load the first number into ACC
BRP CHECKSEC_NEG // Branch to CHECKSEC_NEG, if first num is positive
LDA NUM_A // load the first number again into ACC
STA LOCATION_A // Store it in LOCATION_A
CheckSecondNegative
LDA NUM_B // Load the second number into ACC
BRP CHECK_DIVISION // Branch to CHECK_DIVISION, if sec number is positive
LDA NUM_B // Load the second number again into ACC
STA LOCATION_B // Store it in LOCATION_B
BRA CHECKDIVISION // Branch to CHECKDIVISION
CheckDIvision
LDA NUM_A // Load the first number into ACC
DIV NUM_B // Divide ACC by the second number
STA QUOTIENT // Store the Quotient
LDA QUOTIENT // Load the Quotient
MUL NUM_B // Multiply the quotient by the second number
SUB NUM_A // Subtract the first number
BRZ OUTPUTRESULT // If the result is 0 then branch to OUTPUTRESULT
LDA ZERO // Load 0 in ACC
OUT // Output 0 as result
BRA START // Branch to the start to input new values
Output results
LDA QUOTIENT // Load the quotient
OUT // Output quotient
END HLT // HALT the program
NUM_A DAT // Memory space for the first number
NUM_B DAT // Memory space for the second number
QUOTIENT DAT // Memory space to store quotient
LOCATION_A DAT // Temporary storage for first number
LOCATION_B DAT // Temporary storage for second number
NEGATIVEONE DAT -1// Store -1
ZERO DAT 0// Store 0
please explain all of this to me and create a flow chart

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!