logo

Crowdly

Browser

Add to Chrome

Kokia reikšmė atsiras išvesties prievade (porte, angl. "output port") mūsų nagri...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Kokia reikšmė atsiras išvesties prievade (porte, angl. "output port") mūsų nagrinėtame Harvardo architektūros procesoriuje įvykdžius žemiau nurodytą programą, jei įvesties prievado reikšmė yra 357? Atsakymą nurodykite kaip skaičių be ženklo dešimtainėje sistemoje.

What value will be output to the output port in the Harvard architecture CPU that was discussed in our course, after executiong the program given below, if the input port has value 357? Provide the answer as an unsigned decimal number.

N:      DS  1                   ; The current processed number

CNT:    DS  1                   ; Loop invocation counter

        IN  0                   ; Input from port 0 to A

        ST  N                   ; Store the input value into variable N

        LDC 0

        ST  CNT                 ; Initialise the CNT counter with 0

LOOP:   LD   CNT                ; Increment the counter:

        ADDC 1                  ; counter increment is 1

        ST   CNT                ; CNT := CNT + 1

        LD   N                  ; Check that N ...

        SUBC 1                  ; ... is not 1

        JNZ  CONT               ; When N != 1, perform the loop body

        JMP  OUTPUT             ; When N == 1, finish and output the CNT counter

CONT:   LD   N                  ; Check if N is even or odd

        REMC 2

        JNZ  ODD

EVEN:   LD   N                  ; If N is even, divide it by 2:

        DIVC 2

        ST   N

        JMP  LOOP

ODD:    LD   N                  ; If N is odd, multiply it by 3 ...

        MULC 3

        ADDC 1                  ; ... and add 1

        ST   N

        JMP  LOOP

OUTPUT: LD  CNT                 ; Output the accumulated counter ...

        OUT 0                   ; ... to port 0 (the only port so far ;)

        HALT

More questions like this

Want instant access to all verified answers on emokymai.vu.lt?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome