I need to print only 5 elements of an array in marie
i tried to but it just looped
ORG 100
Main, Load X // Load the address of the array
Store Addr
Load 5 // Set up a counter for 5 elements
Store Count
Loop, Load Addr // Load the address of the array
Add Count // Add the current value of the counter to the address
Subt 1 // Move to the next element (assuming each element is 1 word)
Store Addr
Load Addr // Load the address of the current element
// Print the element
Subt 1 // Decrement the counter
Store Count
Skipcond 000 // If Count <= 0, exit the loop
Jump Loop
Halt
Addr, DEC 0
Count, DEC 0
X, DEC 0
Array, DEC 10 // Example array with 10 elements
DEC 20
DEC 30
DEC 40
DEC 50
DEC 60
DEC 70
DEC 80
DEC 90
DEC 100
Buddhinatha Kodituwakku is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.