Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
191 lines (119 sloc)
4.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include(`z88dk.m4') | |
dnl############################################################ | |
dnl## Z80_CRT_0.ASM.M4 - STANDALONE TARGET ## | |
dnl############################################################ | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; z80 standalone target ;; | |
;; generated from target/z80/startup/z80_crt_0.asm.m4 ;; | |
;; ;; | |
;; flat 64k address space ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; GLOBAL SYMBOLS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
include "config_z80_public.inc" | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; CRT AND CLIB CONFIGURATION ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
include "../crt_defaults.inc" | |
include "crt_config.inc" | |
include(`../crt_rules.inc') | |
include(`z80_rules.inc') | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; SET UP MEMORY MAP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
include(`crt_memory_map.inc') | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; INSTANTIATE DRIVERS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; The embedded target has no device drivers so it cannot | |
; instantiate FILEs. | |
; It can use sprint/sscanf + family and it can create | |
; memstreams in the default configuration. | |
include(`../clib_instantiate_begin.m4') | |
ifelse(eval(M4__CRT_INCLUDE_DRIVER_INSTANTIATION == 0), 1,, | |
` | |
include(`crt_driver_instantiation.asm.m4') | |
') | |
include(`../clib_instantiate_end.m4') | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; STARTUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
SECTION CODE | |
PUBLIC __Start, __Exit | |
EXTERN _main | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; USER PREAMBLE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
IF __crt_include_preamble | |
include "crt_preamble.asm" | |
SECTION CODE | |
ENDIF | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; PAGE ZERO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
IF (ASMPC = 0) && (__crt_org_code = 0) | |
include "../crt_page_zero_z80.inc" | |
ENDIF | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; CRT INIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
__Start: | |
include "../crt_start_di.inc" | |
include "../crt_save_sp.inc" | |
__Restart: | |
include "../crt_init_sp.inc" | |
; command line | |
IF (__crt_enable_commandline = 1) || (__crt_enable_commandline >= 3) | |
include "../crt_cmdline_empty.inc" | |
ENDIF | |
__Restart_2: | |
IF __crt_enable_commandline >= 1 | |
push hl ; argv | |
push bc ; argc | |
ENDIF | |
; initialize data section | |
include "../clib_init_data.inc" | |
; initialize bss section | |
include "../clib_init_bss.inc" | |
; interrupt mode | |
include "../crt_set_interrupt_mode.inc" | |
SECTION code_crt_init ; user and library initialization | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; MAIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
SECTION code_crt_main | |
include "../crt_start_ei.inc" | |
; call user program | |
call _main ; hl = return status | |
; run exit stack | |
IF __clib_exit_stack_size > 0 | |
EXTERN asm_exit | |
jp asm_exit ; exit function jumps to __Exit | |
ENDIF | |
__Exit: | |
IF !((__crt_on_exit & 0x10000) && (__crt_on_exit & 0x8)) | |
; not restarting | |
push hl ; save return status | |
ENDIF | |
SECTION code_crt_exit ; user and library cleanup | |
SECTION code_crt_return | |
; close files | |
include "../clib_close.inc" | |
; terminate | |
include "../crt_exit_eidi.inc" | |
include "../crt_restore_sp.inc" | |
include "../crt_program_exit.inc" | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; RUNTIME VARS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
include "../crt_jump_vectors_z80.inc" | |
IF (__crt_on_exit & 0x10000) && ((__crt_on_exit & 0x6) || ((__crt_on_exit & 0x8) && (__register_sp = -1))) | |
SECTION BSS_UNINITIALIZED | |
__sp_or_ret: defw 0 | |
ENDIF | |
include "../clib_variables.inc" | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; CLIB STUBS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
include "../clib_stubs.inc" |