Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program to read data starting at the label data: ( the end of the data will be indicated by 0 x 0 0
Write a program to read data starting at the label data: the end of the data will be indicated by x generate a sorted linkedlist using the new: and insert: procedures described above, then flatten: the sorted list back into memory starting at the label data:.
You may assume the existence of procedures new:, insert:, and flatten: as described previously. Since you don't know the implementation details of these procedures, you'd better save any register values you care about!
main:
your code goes here
mov x
svc
here are the existing procedures:
insert:
cbz x newhead
ldr xx
mov x x
mov x
loop:
ldr xx
cmp x x
ble earlierval
mov x x
ldr xx
cbz x end
b loop
newhead:
str xx
mov x x
ret
earlierval:
str xx
cbz x sethead
str xx
mov x x
ret
end:
str xx
str xzrx
mov x x
ret
sethead:
mov x x
retnew:
mov x x
mov xxD
mov x
svc
mov x x
add x x
mov xxD
svc
str xx
mov xx
str xx
mov x x
ret
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started