Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me solve the error of A label was found which was in no area. The assignment is the picture and the code

Can you help me solve the error of "A label was found which was in no area". The assignment is the picture and the code im using is "AREA .text, CODE, READONLY
EXPORT main
EXPORT euclid
; Function: euclid
; Calculates the greatest common divisor (GCD) of two integers x and y
; Parameters:
; R0= int x
; R1= int y
; R2= int* result
euclid
STMFD SP!,{R4-R6, LR} ; Push registers R4-R6 and LR onto stack for preserving them
MOV R4, R0 ; Move x to R4
MOV R5, R1 ; Move y to R5
; Make x positive
CMP R4, #0
MOVGE R6, R4 ; If x >=0, R6= R4
RSBLT R6, R4, #0 ; If x 0, R6=-R4
; Make y positive
CMP R5, #0
MOVGE R4, R5 ; If y >=0, R4= R5
RSBLT R4, R5, #0 ; If y 0, R4=-R5
MOV R0, R6 ; Move positive x to R0
MOV R1, R4 ; Move positive y to R1
euclid_loop
CMP R0, R1 ; Compare R0 and R1
BEQ euclid_end ; If equal, GCD found
BGT euclid_subtract ; If R0> R1, subtract R1 from R0
SUB R1, R1, R0 ; Else, subtract R0 from R1
B euclid_loop
euclid_subtract
SUB R0, R0, R1
B euclid_loop
euclid_end
STR R0,[R2] ; Store the result at the address in R2
LDMFD SP!,{R4-R6, PC} ; Pop registers R4-R6 and PC (return from function)
; Function: main
; Initialize variables and call euclid function
main
STMFD SP!,{LR} ; Push LR onto stack for preserving it
; Initialize variables (DCD directives will go in the .data area)
LDR R0,=-8 ; Load x0
LDR R1,=9 ; Load y0
LDR R2,=0x20000000 ; Address to store result e0(arbitrary address)
BL euclid ; Call euclid function
; ... Initialize other variables and repeat calls to euclid as necessary ...
LDMFD SP!,{PC} ; Pop PC to return from main
END". Is the code correct and can u fix the error for me
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions