Question: 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 0x00.), generate a sorted linked-list 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 x8,93
svc 0
here are the existing procedures:
insert:
cbz x1, new_head
ldr x2,[x0]
mov x3, x1
mov x4,0
loop:
ldr x5,[x3]
cmp x2, x5
b.le earlier_val
mov x4, x3
ldr x3,[x3,8]
cbz x3, end
b loop
new_head:
str x1,[x0,8]
mov x7, x0
ret
earlier_val:
str x3,[x0,8]
cbz x4, set_head
str x0,[x4,8]
mov x7, x1
ret
end:
str x0,[x4,8]
str xzr,[x0,8]
mov x7, x1
ret
set_head:
mov x7, x0
retnew:
mov x1, x0
mov x8,0xD6
mov x0,0
svc 0
mov x2, x0
add x0, x2,16
mov x8,0xD6
svc 0
str x1,[x2]
mov x3,0x0
str x3,[x2,8]
mov x7, x2
ret

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!