Build .deb package, try to fix endianness issues
diff --git a/.build.yml b/.build.yml
index 12d430e..226a344 100644
--- a/.build.yml
+++ b/.build.yml
@@ -12,11 +12,16 @@
       cd 6502
       mkdir build
       cd build
-      cmake ..
+      cmake .. -DCMAKE_BUILD_TYPE=Release
   - build: |
       cd 6502/build
       make -j
       ./6502 -h
+  - pack: |
+      cd 6502/build
+      cpack
+      dpkg -I 6502.deb
 artifacts:
   - 6502/build/6502
   - 6502/build/as/6502-as
+  - 6502/build/6502.deb
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c57c91..732aa4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,21 @@
 		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 endif()
 
+find_library(readline SDL2 GL GLU GLEW m rt pthread)
+
 add_executable(6502 main.c cpu.c cpu.h dbg.c dbg.h 
 	instructions.h gui.h gui.c screen.h screen.c common.h common.c)
 target_link_libraries(6502 readline SDL2 GL GLU GLEW m rt pthread)
+
+install(TARGETS 6502)
+
+set(CPACK_GENERATOR "DEB")
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "swissChili")
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl2-dev, libreadline-dev, libglew-dev")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "6502 emulator, debugger, and assembler")
+set(CPACK_PACKAGE_VERSION_MAJOR 0)
+set(CPACK_PACKAGE_VERSION_MINOR 1)
+set(CPACK_PACKAGE_VERSION_PATCH 0)
+set(CPACK_PACKAGE_FILE_NAME "6502")
+
+include(CPack)
diff --git a/as/CMakeLists.txt b/as/CMakeLists.txt
index 7a7b6a5..f5e3989 100644
--- a/as/CMakeLists.txt
+++ b/as/CMakeLists.txt
@@ -14,3 +14,5 @@
 
 
 add_executable(6502-as main.c as.h as.c map.h map.c hash.c hash.c)
+
+install(TARGETS 6502-as)
diff --git a/as/as.c b/as/as.c
index 1d72d97..989b83c 100644
--- a/as/as.c
+++ b/as/as.c
@@ -21,6 +21,7 @@
 };
 
 #define ERR "\033[31m"
+#define GREEN "\033[32m"
 #define RESET "\033[0m"
 #define MAX_LEN (0xFFFF - 0x600)
 #define MAX_INSTS (MAX_LEN / 2)
@@ -534,7 +535,8 @@
 			if ((no_argument && (_mn == AM_IMP || _mn == AM_ACC))		\
 				 || (mnemonic == _mn && parse_arg(line, am, arg)))		\
 			{															\
-				printf("AM_ succeeded: %s\n", #am);						\
+				printf(GREEN "AM_ succeeded: %s at pc=$%x\n" RESET,		\
+					   #am, pc);										\
 				arg->opcode = op;										\
 				pc += len;												\
 				print_inst(arg);										\
@@ -599,21 +601,21 @@
 			}
 			curr_pc += 2;
 			int16_t diff = lbl - curr_pc;
-			printf("ARG_REL, pc (after) == %x, diff = %d\n", curr_pc, diff);
+			printf("ARG_REL, pc (after) == %x, diff = %hx\n", curr_pc, (uint8_t) diff);
 			if ((diff < 0 ? -diff : diff) > 0xFF)
 			{
 				printf(ERR "Error on line %d: label '%s' is too far away for a relative jump" RESET "\n", insts[i]->line, insts[i]->label);
 				printf("pc == %hx, label is at %hx\n", curr_pc, lbl);
 				goto cleanup;
 			}
-			putshort((uint8_t) diff, out);
+			putc((uint8_t) diff, out);
 			break;
 		}
 		default:
 			curr_pc++;
 		}
 	}
-	
+
 cleanup:
 	printf("-----\n");
 	printf("At end, there are %d instructions\n", num_insts);
diff --git a/as/test/disco.s b/as/test/disco.s
new file mode 100644
index 0000000..7b0e00d
--- /dev/null
+++ b/as/test/disco.s
@@ -0,0 +1,22 @@
+; Taken from 6502asm.com
+
+
+start:
+	inx							; 600
+	txa							; 601
+	sta $200, y					; 602
+	sta $300, y					; 605
+	sta $400, y					; 608
+	sta $500, y					; 60b
+	iny							; 60e
+	tya							; 60f
+	cmp 16						; 610
+	bne do						; 612
+	iny							; 614
+	jmp start					; 615
+do:
+	iny							; 618
+	iny							; 619
+	iny							; 61a
+	iny							; 61b
+	jmp start					; 61c
diff --git a/cpu.c b/cpu.c
index 6363fe6..ce9c5cc 100644
--- a/cpu.c
+++ b/cpu.c
@@ -40,20 +40,22 @@
 uint16_t le_to_native(uint8_t a, uint8_t b)
 {
 #ifdef LITTLE_ENDIAN
+	//printf("Little Endian\n");
 	return b << 8 | a;
 #else
-	return le16toh(a << 8 | b);
+	//printf("Big Endian\n");
+	return a << 8 | b;
 #endif
 }
 
 void native_to_le(uint16_t n, uint8_t *a, uint8_t *b)
 {
 #ifdef LITTLE_ENDIAN
-	*a = n >> 8;
-	*b = n & 0xFF;
-#else
-	*a = n & 0xFF;
 	*b = n >> 8;
+	*a = n & 0xFF;
+#else
+	*b = n & 0xFF;
+	*a = n >> 8;
 #endif
 }
 
@@ -80,7 +82,7 @@
 {
 	uint8_t a = stack_pop(cpu);
 	uint8_t b = stack_pop(cpu);
-	return le_to_native(a, b);
+	return le_to_native(b, a);
 }
 
 void free_cpu(cpu_t *cpu)
diff --git a/disco.dat b/disco.dat
index b004f7a..d8b838c 100644
--- a/disco.dat
+++ b/disco.dat
Binary files differ