# top source file of Ha3sm. 

.	global/memory       	# IDT, BDA (BIOS data area) ...
.	global/event		# firstIRQ
.	global/macro		# wiperegs dismisso othersize

#    system init flow of control

# Canonical Wake-up Real Mode

			cell=2
. 16/PE0/floppyboot
IRQsoff

wiperegs

setGDT IGDTRpointer		# in IPL, dual address of use16 far pointer
= 0xb800 to A
= A to DS

= 3476 to A
= A to @ 304			

zero A				# assuming hi A is 0, 1 to CR0, PE
1+  A
= A to CR0
jump 		hvfnvkfv
L 	hvfnvkfv

# Veal Mode for one instruction

HL 
	ab 0xea
        ad use32CS
        ad 0x10	
L use32CS					# pmode 32
			cell=4

. 32/init/kernelsegments
. 32/init/a20
#. 32/init/megs

. global/PIC/init
. global/init/legvex

= $((0xeff0)) to SP	# very small. Lets not recurse in ring0, eh?

. 32/PE0/IDTinit				#	Forreal Mode

setIDT IDT32unPpointer





. global/flipPE			# Welcome to Forreal Mode
				# cell still 4

ab 0xea				# set CS to 0
aq kbkjnbkfgbkfjngbkfng
ad 0
L kbkjnbkfgbkfjngbkfng




= 4 to A			# 32-bit schmegmented addressing demo
= A to ES			# proving we got PE = to 0.
= 9348539 to A
= A to @ $((0xb8a00))
ES
= A to @ $((0xb8a00))
zero A
= A to ES			# ES back to 0

# CS is 0x10?



IRQson

L theloop
	= @ $((0xb8688)) to A
	1+ A
	= A to @ $((0xb8688))
	  submit 33
	nop
	nop
	nop
	nop
jump theloop

halt

#############################################################
	# outside main/init flow-of-control. Data and subroutines.

. global/init/makedescriptor
. global/init/IGDT		# initial, small, in IPL, pre-processes GDT
. global/NMI/routine		# nosurprises NMIoff/on  EISAsoftNMIenable

. global/soft/patternmove	#  patternfill spreadcopy
. global/soft/schmegment

. 32/init/installunP		
#. 32/keypointer/routine	# sendHID HIDblinkenlightzen  enableaux
				# setscanset HIDmakebreakonly resetbox
				# auxscale2 auxresolution HICIRQSon

. 32/PE0/demoreflexes		# twitch32unP...
#. 32/PE0/NMI/reflex		# ticksincrement32unP
#. 32/PE0/keypointer/auxreflex	# auxreflex32unP
#. 32/PE0/keypointer/reflex	# keyreflex32unP

#. global/soft/text		# digit  spewage

L Cat
