set_return_code.icl 933 Bytes
Newer Older
John van Groningen's avatar
John van Groningen committed
1 2
implementation module set_return_code

3
import StdInt
John van Groningen's avatar
John van Groningen committed
4

5
set_return_code_world :: !Int !*World -> *World
6
set_return_code_world i world = IF_INT_64_OR_32 (set_return_code_world_64 i world) (set_return_code_world_32 i world)
7

8 9
set_return_code_world_64 :: !Int !*World -> *World
set_return_code_world_64 i world = code {
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
	pushI 0xffffffff
	and%
	pushLc return_code
	:xxx
| assume 4 byte aligned, little endian
| i<<32 if 8 byte misaligned
	pushI 3
	push_b 1
	pushI 4
	and%
	shiftl%
	push_b 2
	shiftl%
	update_b 0 2
	pop_b 1
| pointer and not 4
	pushI -5
	and%
| or 8 bytes
	pushI -8
	addI
	push_b_a 0
	pop_b 1
	pushI_a 0
	or%
	fill1_r _ 0 1 0 0
.keep 0 2
	fill_a 1 2
	pop_a 2
}

41 42
set_return_code_world_32 :: !Int !*World -> *World
set_return_code_world_32 i world = code {
43 44 45 46 47 48 49 50 51 52 53
	pushI -4
	pushLc return_code
	addI
	:xxx
	push_b_a 0
	pop_b 1
	fill1_r _ 0 1 0 0
.keep 0 2
	fill_a 1 2
	pop_a 2
}