How do I write a subroutine that tests if the registers are odd or even and store the result?












-2















We have to write a subroutine testeven that tests if the integer in register r0 is even and if so sets r1 to 1 or to 0 otherwise. Write a second subroutine testdata that uses the start address, given in register r2, of a memory area
at which there is a series of integers. The subroutine assumes that r3 holds the number of integers in the memory area. The subroutine stores in r4 the number of even integers it finds in the memory area. The testdata subroutine must use the testeven subroutine to identify individual even numbers.Write controlling code to copy the address data_to_test to r2 and to determine the number of dataitems to be tested and store this value in r3. The controlling code must use testdata to determine the number of even values in the data area and then to store the number of even numbers that is found in
the memory location data_even_count.



Here is my code so far not got very far though



THUMB
AREA RESET, CODE, READONLY
EXPORT __Vectors
EXPORT Reset_Handler
__Vectors
DCD 0x20001000 ; top of the stack
DCD Reset_Handler ; reset vector - where the program starts
AREA Task3Code, CODE, READONLY
ENTRY
Reset_Handler
num EQU 16
MOV r1,#0 ;loop counter
MOV r2,#0 ;compare store 1
MOV r3,#0 ;compare store 2
MOV r4,#0 ;compare store 3
MOV r5,#0 ;sum of values
MOV r6,#0 ;which was greater in value
LDR r8,=data_values ;the list of values

AREA Task4DataRO, DATA, READONLY ; data that doesn’t need to be changed
data_to_test
DCD 23, 34, 57, 89, 92 ; example values
AREA Task4DataRW, DATA, READWRITE ; result of operation stored here
data_even_count
DCD 0 ; number of even values found
END


Thank you for your time and any help would be much appreciated.










share|improve this question


















  • 2





    You need to at least try to write the functions testeven and testdata in order to get help here.

    – prl
    Jan 18 at 22:34











  • Did you google for integer odd even arm assembly? That should show you how to use AND to check the low bit. Since you need 1 for even, just flip that with xor.

    – Peter Cordes
    Jan 19 at 3:54
















-2















We have to write a subroutine testeven that tests if the integer in register r0 is even and if so sets r1 to 1 or to 0 otherwise. Write a second subroutine testdata that uses the start address, given in register r2, of a memory area
at which there is a series of integers. The subroutine assumes that r3 holds the number of integers in the memory area. The subroutine stores in r4 the number of even integers it finds in the memory area. The testdata subroutine must use the testeven subroutine to identify individual even numbers.Write controlling code to copy the address data_to_test to r2 and to determine the number of dataitems to be tested and store this value in r3. The controlling code must use testdata to determine the number of even values in the data area and then to store the number of even numbers that is found in
the memory location data_even_count.



Here is my code so far not got very far though



THUMB
AREA RESET, CODE, READONLY
EXPORT __Vectors
EXPORT Reset_Handler
__Vectors
DCD 0x20001000 ; top of the stack
DCD Reset_Handler ; reset vector - where the program starts
AREA Task3Code, CODE, READONLY
ENTRY
Reset_Handler
num EQU 16
MOV r1,#0 ;loop counter
MOV r2,#0 ;compare store 1
MOV r3,#0 ;compare store 2
MOV r4,#0 ;compare store 3
MOV r5,#0 ;sum of values
MOV r6,#0 ;which was greater in value
LDR r8,=data_values ;the list of values

AREA Task4DataRO, DATA, READONLY ; data that doesn’t need to be changed
data_to_test
DCD 23, 34, 57, 89, 92 ; example values
AREA Task4DataRW, DATA, READWRITE ; result of operation stored here
data_even_count
DCD 0 ; number of even values found
END


Thank you for your time and any help would be much appreciated.










share|improve this question


















  • 2





    You need to at least try to write the functions testeven and testdata in order to get help here.

    – prl
    Jan 18 at 22:34











  • Did you google for integer odd even arm assembly? That should show you how to use AND to check the low bit. Since you need 1 for even, just flip that with xor.

    – Peter Cordes
    Jan 19 at 3:54














-2












-2








-2








We have to write a subroutine testeven that tests if the integer in register r0 is even and if so sets r1 to 1 or to 0 otherwise. Write a second subroutine testdata that uses the start address, given in register r2, of a memory area
at which there is a series of integers. The subroutine assumes that r3 holds the number of integers in the memory area. The subroutine stores in r4 the number of even integers it finds in the memory area. The testdata subroutine must use the testeven subroutine to identify individual even numbers.Write controlling code to copy the address data_to_test to r2 and to determine the number of dataitems to be tested and store this value in r3. The controlling code must use testdata to determine the number of even values in the data area and then to store the number of even numbers that is found in
the memory location data_even_count.



Here is my code so far not got very far though



THUMB
AREA RESET, CODE, READONLY
EXPORT __Vectors
EXPORT Reset_Handler
__Vectors
DCD 0x20001000 ; top of the stack
DCD Reset_Handler ; reset vector - where the program starts
AREA Task3Code, CODE, READONLY
ENTRY
Reset_Handler
num EQU 16
MOV r1,#0 ;loop counter
MOV r2,#0 ;compare store 1
MOV r3,#0 ;compare store 2
MOV r4,#0 ;compare store 3
MOV r5,#0 ;sum of values
MOV r6,#0 ;which was greater in value
LDR r8,=data_values ;the list of values

AREA Task4DataRO, DATA, READONLY ; data that doesn’t need to be changed
data_to_test
DCD 23, 34, 57, 89, 92 ; example values
AREA Task4DataRW, DATA, READWRITE ; result of operation stored here
data_even_count
DCD 0 ; number of even values found
END


Thank you for your time and any help would be much appreciated.










share|improve this question














We have to write a subroutine testeven that tests if the integer in register r0 is even and if so sets r1 to 1 or to 0 otherwise. Write a second subroutine testdata that uses the start address, given in register r2, of a memory area
at which there is a series of integers. The subroutine assumes that r3 holds the number of integers in the memory area. The subroutine stores in r4 the number of even integers it finds in the memory area. The testdata subroutine must use the testeven subroutine to identify individual even numbers.Write controlling code to copy the address data_to_test to r2 and to determine the number of dataitems to be tested and store this value in r3. The controlling code must use testdata to determine the number of even values in the data area and then to store the number of even numbers that is found in
the memory location data_even_count.



Here is my code so far not got very far though



THUMB
AREA RESET, CODE, READONLY
EXPORT __Vectors
EXPORT Reset_Handler
__Vectors
DCD 0x20001000 ; top of the stack
DCD Reset_Handler ; reset vector - where the program starts
AREA Task3Code, CODE, READONLY
ENTRY
Reset_Handler
num EQU 16
MOV r1,#0 ;loop counter
MOV r2,#0 ;compare store 1
MOV r3,#0 ;compare store 2
MOV r4,#0 ;compare store 3
MOV r5,#0 ;sum of values
MOV r6,#0 ;which was greater in value
LDR r8,=data_values ;the list of values

AREA Task4DataRO, DATA, READONLY ; data that doesn’t need to be changed
data_to_test
DCD 23, 34, 57, 89, 92 ; example values
AREA Task4DataRW, DATA, READWRITE ; result of operation stored here
data_even_count
DCD 0 ; number of even values found
END


Thank you for your time and any help would be much appreciated.







assembly arm thumb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 18 at 16:22









Hysteria103Hysteria103

62




62








  • 2





    You need to at least try to write the functions testeven and testdata in order to get help here.

    – prl
    Jan 18 at 22:34











  • Did you google for integer odd even arm assembly? That should show you how to use AND to check the low bit. Since you need 1 for even, just flip that with xor.

    – Peter Cordes
    Jan 19 at 3:54














  • 2





    You need to at least try to write the functions testeven and testdata in order to get help here.

    – prl
    Jan 18 at 22:34











  • Did you google for integer odd even arm assembly? That should show you how to use AND to check the low bit. Since you need 1 for even, just flip that with xor.

    – Peter Cordes
    Jan 19 at 3:54








2




2





You need to at least try to write the functions testeven and testdata in order to get help here.

– prl
Jan 18 at 22:34





You need to at least try to write the functions testeven and testdata in order to get help here.

– prl
Jan 18 at 22:34













Did you google for integer odd even arm assembly? That should show you how to use AND to check the low bit. Since you need 1 for even, just flip that with xor.

– Peter Cordes
Jan 19 at 3:54





Did you google for integer odd even arm assembly? That should show you how to use AND to check the low bit. Since you need 1 for even, just flip that with xor.

– Peter Cordes
Jan 19 at 3:54












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257834%2fhow-do-i-write-a-subroutine-that-tests-if-the-registers-are-odd-or-even-and-stor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257834%2fhow-do-i-write-a-subroutine-that-tests-if-the-registers-are-odd-or-even-and-stor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Homophylophilia

Updating UILabel text programmatically using a function

Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage