summaryrefslogtreecommitdiff
path: root/support/regression/tests/z80n-push-nn.c
blob: 1d999518a347a48edff64519c5ee127da7ca3ff4 (plain)
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
/* z80n-push-nn
   Invalid relocation of Z80N PUSH nn instruction value
 */
#include <testfwk.h>
#include <string.h>

int x;
typedef void* (*memcpy_p)(void *d, const void *s, size_t c);

#ifdef __SDCC_z80n
int f(void) __naked
{
    __asm
	push	#0x1234
	push	#_x
	pop	hl
	pop	de
	ld	a, (hl)
	inc	hl
	ld	h, (hl)
	ld	l, a
	add	hl, de
	ex	de, hl
	ret
;
	.db	#>_x, #<_x
	.dw	#_x
    __endasm;
}
memcpy_p g(void) __naked
{
    __asm
	push	#_memcpy
	pop	de
	ret
    __endasm;
}
#else
int f(void)
{
    return x + 0x1234;
}
memcpy_p g(void)
{
    return &memcpy;
}
#endif

void testBug3032(void)
{
    x = 0x7531;
    ASSERT (f() == 0x8765);
    ASSERT (g() == &memcpy);
}