Stars:
push ebp ; save the base pointer
mov ebp, esp ; set the base pointer to the current stack pointer
mov eax, [ebp+8] ; load the parameter into eax
print_loop:
cmp eax, 0 ; compare the value of the parameter with zero
jle end_print_loop ; jump out of the loop if the value is less than or equal to zero
push eax ; save the value of eax on the stack
mov eax, '*' ; set eax to the character code for the asterisk
push eax ; save the value of eax on the stack
call putchar ; call the putchar function to print the asterisk
add esp, 8 ; clean up the stack by adding 8 bytes
sub eax, 1 ; decrement the value of eax
jmp print_loop ; jump back to the beginning of the loop
end_print_loop:
pop ebp ; restore the base pointer
ret ; return control to the caller
To call this function from the main program and print 12 asterisks, you can use the following code:
mov ecx, 12 ; load the parameter (12) into ecx
call Stars ; call the Stars function
This will print out 12 asterisks (************) to the console.