summaryrefslogtreecommitdiff
path: root/misc/sims/z80sim/example/example.asm
blob: ae0fc4f419352af057e62722f1f3d590255a0d97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;************************************************************************
; example.s
;************************************************************************

	.title	z80sim Test
	.module	example

;************************************************************************
; Constants
;************************************************************************

	STACKBASE		==    0xFFFF

;************************************************************************
; Data
;************************************************************************

	.area	DATA	(ABS,OVR)
	.org    0x8000
hello:
	.ascii "Hello, World!\n\0"

;************************************************************************
; Reset entry point
;************************************************************************

	.area	TEXT	(ABS,OVR)
	.org	0x0000
	di				; Disable interrupts
	ld	SP, #STACKBASE		; Set stack pointer
	im	1			; Set interrupt mode 1
	jp	start			; jump to start of program

;************************************************************************
; Interrupt handler
;************************************************************************

	.org   0x0038			; Int mode 1
	reti				; return from interrupt

;************************************************************************
; NMI interrupt handler
;************************************************************************

	.org   0x0066
	retn

;************************************************************************
; Start of program
;************************************************************************

	.org   0x0100
start:
	;ei				; Enable interrrupts
	ld	hl, #hello		; Say hello
	call   print 

forever:				; Then stop execution
	jp	forever

;******************************************************************
;        print    *
;        Funktion....: Sen tekst and data with serielport *
;        Input.......: hl points at text start adr   *
;        Output......: Text to serielport    *
;        uses........: a,hl*
;        call........: TX_BUSY         tst 28-4-1994 *
;******************************************************************

print:
	push   af
loop:
	ld	a, (hl)			; Get character to print
	cp	#0			; Null terminates the string
	jp	z, done

	out	(0xbe), a		; Send character
	inc    hl			; Increment to next character
	jp	loop			; Loop til done
done:
	pop    af
	ret