Program termination: Difference between revisions

m
(Added solution for Action!)
Line 1,702:
 
=={{header|Z80 Assembly}}==
===Zilog Z80===
This mostly depends on the hardware, but typically home computers would boot in BASIC and <code>CALL</code> the starting address on the disk. This means that the return address for BASIC is on top of the stack, and an <code>RET</code> will exit the program and return to BASIC, provided that execution is not inside one of the disk's subroutines. The example below is typical of a home computer such as the Amstrad CPC:
 
Line 1,711 ⟶ 1,712:
ret z ;return to BASIC if equal
jp main ;loop back to main</lang>
 
===Game Boy===
The Game Boy doesn't have BASIC to return to, and the <code>HALT</code> and <code>STOP</code> commands are a bit buggy. The easiest way to programmatically terminate the program is to trap the program counter, although it should be warned that doing so will drain the batteries more quickly than you may like.
 
<lang z80>forever:
jr forever</lang>
 
=={{header|zkl}}==
1,489

edits