Professional Documents
Culture Documents
ITEC1000 Assignment 2
ITEC1000 Assignment 2
Part A:
Part B:
Question 1:
97_GREATER LDA 97
STA RESULT
BRA END
98_EQUAL LDA 98
SUB 99
BRA COMPARE_WITH_99
97 DAT
98 DAT
99 DAT
RESULT DAT
Question 2
LDA 0
STA MAX
Comment:
Load 0 into the accumulator (initialize MAX)
// Store it in MAX memory location
INPUT_LOOP INP
STA VALUE
BRZ END_INPUT
Comment:
Begin the loop to accept input values
// Store the input value in the VALUE memory location
// If the input is 0, go to the end of input
LDA VALUE
SUB MAX
BRZ INPUT_LOOP
Comment:
Load the input value into the accumulator
// Compare with the current MAX value
// If the input value is not greater than MAX, continue the loop
LDA VALUE
STA MAX
BRA INPUT_LOOP
Comment:
Load the input value into the accumulator
// Update MAX if the input value is greater
// Continue looping for further input
Comment:
Load the input value into the accumulator
// Update MAX if the input value is greater
// Continue looping for further input
MAX DAT 0
VALUE DAT
Comment:
Initialize MAX to 0
// Placeholder for input value
Question 3:
LDA 0
//INITIALIZE SUM TO 0
STA SUM
INP
//input the number of values to be added
STA COUNT //store it in count memory location
LOOP BRZ END
//if count is 0, go to the end
INP
ADD SUM
STA SUM
//store the update sum value
SUB ONE
STA COUNT
BRZ END_LOOP
//if count become 0 then go to output
BRA LOOP
// repeat the loop
SUM DAT 0
COUNT DAT
ONE DAT 1
Question 3:
// Data Section
VALUE DAT // Placeholder for the value to be compared
INPUT DAT // Placeholder for the input value