public void loadHexFile(String hexFile) throws Exception {

		String strLine;
		int lineNumber = 0;
		FileInputStream fstream = new FileInputStream(hexFile);
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		
		while ((strLine = br.readLine()) != null) {
			
			// Intel Hex Format
			// < : 1b> <data length 1b> <offset 2b> < type 1b > <data nb> <checksum 1b>
			// 

			switch(Integer.parseInt(strLine.substring(7,9))) { // RECTYPE

			case 0:
				int datalen = Integer.parseInt(strLine.substring(1,3), 16); //RECLEN

				byte data[] = BinaryFunctions.hexStringToByteArray(strLine.substring(9, 9+datalen*2));

				// Switch every two bytes - fix Endianness
				for (int i = 0; i < data.length-1; i+=2 ) {
					byte b = data[i];
					data[i] = data[i+1];
					data[i+1] = b;
				}

				
				for (int i = 0; i< data.length; i++) {
					
				
					this.i_mem[lineNumber + i] = (byte) (data[i] & 0xff);
					if (i %2 == 0) this.i_count++;
				
				
				}
				
				
				
				/*
				for (int i = 0; i < data.length/2; i+=2) {
					
					this.i_mem[i] = data[i];
					
					//this.i_mem[this.i_count] = (byte) (data[i] << 8 | data[i+1]);
					//this.i_count++;
				}
				*/
				
				
				
				break;
				

			case 1: // EOF
				break;
			
			}
		
			lineNumber += 0x10;
		}

	}