Pastebin

From [ipdown.net]
Revision as of 00:14, 10 February 2014 by Ipdown (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This page will contain pseudo C-like code of important LH routines

Conventions:

RAM[0x55] = 0;
means set the (8-bit) byte at internal RAM address 0x55 to 0
RAM[0x54:0x55] = 0x7712;
means set the 16-bit word starting at internal RAM address 0x55 (LSB, or low byte) and 0x54 (MSB, or high byte) to

the value 0x7712; High (MSB) byte 0x77 goes to RAM[0x54], and low (LSB) byte 0x12 goes to RAM[0x55]

Below is a routine that converts raw AMM reading through the "AMM linearization" look-up table to air mass flow (kg/hr):

// CL_0913
void AMM_READ()
{
	A = RAM[0xC3]; 
 
	R6 = A;
	EXTRAM[0x49] = A;
	EXTRAM[0xFE00] = A;
 
	if (BIT_IDLE_ON)
	{
		RAM[0x54] = R6;
		RAM[0x51] = 0x10;
	}
	else
	{	
		RAM[0x51] -= 1;
		if (RAM[0x51] == 0)
		{
			RAM[0x54] -= 1;
			RAM[0x51] = 0x10;
		}
	}
 
	B = A = AMM_1x256_MAP[R6];
	R7 = 1;
 
	if (R6 > AMM_SWITCHOVER[0])
	{
		R7 = 4;
		if (R6 > AMM_SWITCHOVER[1])
			R7 = 16;
	}
 
	A = R7;
	B:A = A * B;
 
	RAM[0xA8:0xA9] += B:A;
	if (overflow)
		RAM[0xA8:0xA9] = 0xFFFF;
 
	RAM[0xAA]++;
	if (!overflow)
	{
		if (!0x24.2)
			goto CL_0DB6;
			//goto CL_0993;
		A = 0x20;
		if (0x2B.6)
		{
			0x2B.6 = 0;
			A = 0x08;
		}
 
		if (A > RAM[0xAA])
		{
			0x24.2 = 0;
			goto CL_0DB6;
		}
	}
 
	if (0x24.0)
	{
		RAM[0x47]=RAM[0xA8];
		RAM[0x48]=RAM[0xA9];
		RAM[0x49]=RAM[0xAA];
		0x24.1 = 1;
	}
 
	RAM[0xA8] = 0;
	RAM[0xA9] = 0;
	RAM[0xAA] = 0;
	0x24.2 = 0;
 
CL_0993:
	goto CL_0DB6;
	// restore DPTR, B, A, PSW
	// 0x26.4 = 0
	// return
}