.include "main.pir"

.sub _main2
	# this will at some point do the stuff we repeat for restart/restore
	_rtn1260()
.end

#.macro z_get_global (RESULT, GLOBAL_NUM)
#	.loadw_indexed(.RESULT, 768, .GLOBAL_NUM)
#.endm
#
#.macro z_set_global (VALUE, GLOBAL_NUM)
#	.storew_indexed(.VALUE, 768, .GLOBAL_NUM)
#.endm

#############################################

.sub _set_machine_info
	$P0 = new .PerlInt
	$P1 = new PerlString
	$P0 = 66
	global "abbrev_table_address" = $P0
	$P0 = 6
	global "attribute_bytes" = $P0
	$P0 = 1251
	global "dictionary_address" = $P0
	$P0 = 9
	global "encoded_word_length" = $P0
	$P0 = 18604
	global "file_checksum" = $P0
	$P0 = 1364
	global "file_length" = $P0
	$P0 = 1261
	global "first_instruction_address" = $P0
	$P0 = 768
	global "global_variable_address" = $P0
	$P0 = 65535
	global "max_objects" = $P0
	$P0 = 63
	global "max_properties" = $P0
	$P0 = 14
	global "object_bytes" = $P0
	$P0 = 266
	global "object_table_address" = $P0
	$P0 = 4
	global "packed_multiplier" = $P0
	$P0 = 1260
	global "paged_memory_address" = $P0
	$P0 = 2
	global "pointer_size" = $P0
	$P0 = 1
	global "release_number" = $P0
	$P0 = 0
	global "routines_offset" = $P0
	$P1 = "040910"
	global "serial_code" = $P1
	$P0 = 1249
	global "static_memory_address" = $P0
	$P0 = 0
	global "strings_offset" = $P0
	$P0 = 5
	global "version" = $P0
.end

.sub _rtn1260
	.local int result
	.local pmc memory
	memory = global "_Z_Memory"
	L1261:	$I100 = _rtn1268()
	.storew_indexed($I100, 768, 239)
	L1266:	end
.end

.sub _rtn1268
	.local int result
	.local pmc memory
	memory = global "_Z_Memory"
	L1269:	print "Hello, world!^"
	L1282:	.pcc_begin_return
	.return 0
	.pcc_end_return
.end

.sub _read_memory
	$P0 = new .Array
	$P0 = 1536
	global "_Z_Memory" = $P0
	#         Address    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
	_mem_add(0x000000, " 05 00 00 01 04 ec 04 ed 04 e3 01 0a 03 00 04 e1")
	_mem_add(0x000010, " 00 00 30 34 30 39 31 30 00 42 01 55 48 ac 00 50")
	_mem_add(0x000020, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 e0")
	_mem_add(0x000030, " 00 00 00 00 00 00 01 02 00 00 00 00 36 2e 33 30")
	_mem_add(0x000040, " 80 00 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x000050, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x000060, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x000070, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x000080, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x000090, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x0000a0, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x0000b0, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x0000c0, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x0000d0, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x0000e0, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x0000f0, " 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20")
	_mem_add(0x000100, " 00 20 00 03 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000110, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000120, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000130, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000140, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000150, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000160, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000170, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000180, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000190, " 00 00 00 00 01 c0 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0001a0, " 00 00 01 d0 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0001b0, " 01 e2 00 00 00 00 00 00 00 00 00 00 00 00 01 f4")
	_mem_add(0x0001c0, " 02 11 11 9b 18 00 00 00 00 00 00 00 42 00 01 00")
	_mem_add(0x0001d0, " 03 12 87 3d 48 e4 a5 00 00 00 00 00 00 00 42 00")
	_mem_add(0x0001e0, " 02 00 03 12 f4 6b 2e cd 45 00 00 00 00 00 00 00")
	_mem_add(0x0001f0, " 42 00 03 00 03 13 19 5d d3 b0 a5 00 00 00 00 00")
	_mem_add(0x000200, " 00 00 42 00 04 00 00 01 00 02 00 03 00 04 00 00")
	_mem_add(0x000210, " 00 48 01 47 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000220, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000230, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000240, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000250, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000260, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000270, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000280, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000290, " 01 48 01 49 01 4b 01 4d 01 4f 01 50 01 51 01 52")
	_mem_add(0x0002a0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0002b0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0002c0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0002d0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0002e0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0002f0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000300, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000310, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000320, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000330, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000340, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000350, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000360, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000370, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000380, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000390, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0003a0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0003b0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0003c0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0003d0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0003e0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0003f0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000400, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000410, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000420, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000430, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000440, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000450, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000460, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000470, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000480, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000490, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0004a0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0004b0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0004c0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0004d0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0004e0, " 00 00 00 03 2e 2c 22 09 00 00 00 00 00 e0 3f 01")
	_mem_add(0x0004f0, " 3d ff ba 00 00 b2 11 aa 46 34 16 60 72 97 45 25")
	_mem_add(0x000500, " d0 a7 b0 00 02 b1 00 00 14 c1 73 53 42 74 72 60")
	_mem_add(0x000510, " 1b 39 5d c7 6b 2a 14 c1 f8 a5 00 00 4c d2 a8 a5")
	_mem_add(0x000520, " 22 ea 9b 2a 5d 48 5d 46 e5 45 00 00 25 58 66 f4")
	_mem_add(0x000530, " f8 a5 00 00 5d 52 19 d3 ba 6c 00 00 22 95 f8 a5")
	_mem_add(0x000540, " 20 d1 c4 a5 56 ee cf 25 56 ee 4f 25 5b 34 16 c6")
	_mem_add(0x000550, " 5e e6 f8 a5 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000560, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000570, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000580, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x000590, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0005a0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0005b0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0005c0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0005d0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0005e0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
	_mem_add(0x0005f0, " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
.end