题目
题目

ELEC1601 (ND) ELEC9601 (ND) Essentials Quiz 4 - Requires Respondus LockDown Browser

简答题

Study the following code. It is designed to perform a meaningful function on my_array. If you understand what task it is doing then you will be able to solve this question much quicker. .section .data array_length: .byte 8 my_array: .byte 227, 131, 113, 177, 52, 39, 126, 2 result: .space 1 .section .text .global asm_function asm_function: ldi r26, lo8(my_array) ldi r27, hi8(my_array) lds r20, array_length ldi r16, 10 loop_check: cpi r20, 0 breq after_loop loop: ld r17, X+ dec r20 andi r17, 1 cpi r17, 0 breq loop_check inc r16 jmp loop_check after_loop: sts result, r16 ret .end What is the value stored in result after this code is run?

查看解析

查看解析

标准答案
Please login to view
思路分析
We are given a small AVR-style assembly routine operating on an array of bytes and a single-byte result location. The task is to determine what value gets stored in result after asm_function runs. First, observe the data: the array my_array contains eight bytes: 227, 131, 113, 177, 52, 39, 126, 2. The variable array_length holds the value 8, so the loop is designed to iterate exactly eight times. The register r16 is initialized ......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

Study the following code: .section .data n1: .byte 12 n2: .byte 13 result: .space 1 .section .text .global asm_function asm_function: lds r16, n1 lds r17, n2 loop_check: mov r18, r17 add r18, r16 cpi r18, 50 brsh after_loop cpi r17, 8 brlo after_loop loop: dec r17 add r16, r17 jmp loop_check after_loop: lds r16, n1 sts result, r16 ret  .end What is the value stored in result after this code has finished?

Study the following code. It is designed to perform a meaningful function on my_array. If you understand what task it is doing then you will be able to solve this question much quicker. .section .data array_length: .byte 8 my_array: .byte 101, 197, 17, 180, 16, 127, 113, 146 result: .space 1 .section .text .global asm_function asm_function: ldi r26, lo8(my_array) ldi r27, hi8(my_array) lds r20, array_length ldi r16, 10 loop_check: cpi r20, 0 breq after_loop loop: ld r17, X+ dec r20 andi r17, 1 cpi r17, 0 breq loop_check inc r16 jmp loop_check after_loop: sts result, r16 ret .end What is the value stored in result after this code is run?

Study the following code: .section .data  n: .byte 0 k: .byte 1 result: .space 1 .section .text .global asm_function asm_function: lds r16, n lds r17, k ldi r18, 1 cp r18, r16 brne else ldi r18, 1 cp r17, r18 brne else if: ldi r18, 13 jmp after_if else: ldi r18, 18 after_if: sts result, r18 ret  .end What is the value stored in result after this code is run?

Study the following code: .section .data  n: .byte 14 result: .space 1 .section .text .global asm_function asm_function: lds r16, n mov r17, r16 subi r17, 3 cpi r17, 14 brsh if else: ldi r18, 17 jmp after_if if: ldi r18, 14 after_if: sts result, r18 ret  .end What is the value stored in result after this code is run?

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!