changeset 164:999abb01c78f

+ Change data allocation scheme
author JeanDo
date Fri, 21 Jan 2011 01:44:38 +0100
parents 144822282fa3
children 8b5b848db4cd
files code_part1/OSTC_code_asm_part1/MAIN.ASM code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/menu_custom.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_c_part2/p2_deco.c code_part1/OSTC_code_c_part2/p2_deco.o code_part1/OSTC_code_c_part2/shared_definitions.h
diffstat 7 files changed, 318 insertions(+), 386 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/MAIN.ASM	Fri Jan 21 01:44:37 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/MAIN.ASM	Fri Jan 21 01:44:38 2011 +0100
@@ -31,8 +31,9 @@
 
 	#include	definitions.asm				; Defines, I/O Ports and variables
 
+
 reset_v code     0x0000
-e		goto	start						; Start!
+        goto	start						; Start!
 
 inter_v	code	0x0008
 		bra		HighInt						;High Priority Interrups
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Jan 21 01:44:37 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Jan 21 01:44:38 2011 +0100
@@ -86,162 +86,167 @@
 ;Variable definitions
 ; arrays are in hex size!! 20 = .032
 
-	CBLOCK	0x060				;Bank 0
-	letter:.026					;letter buffer
-	win_color1
-	win_color2
-	win_top                     ; Box/text position (0..239).
-	win_height					; Box/text height (1..240)
-	win_leftx2                  ; Box/text position (0..159)
-	win_width 					; box width (1..160)
-	win_font
-	win_invert
-	win_bargraph                ; PLED_box swicth to black after this position (0..159).
-	win_flags                   ; flip_screen flag, transparent fonts, etc...
-	
-    pressureSum:2               ; Stabilize surface presure by a long averaging window [mbar]
-    pressureCount               ; Count of pressure values.
-    pressureAvg:2               ; save averaged pressure x16, for altimeter_menu
-    pressureRef:2               ; Pressure at sea level [mbar]
-    altitude:2                  ; Last computed altitude [m]
-	
-	ENDC
+;=============================================================================
+; BANK0 data
+;
+bank0           udata 0x060     ;Bank 0
+letter          res .26         ;letter buffer
+win_color1      res 1
+win_color2      res 1
+win_top         res 1           ; Box/text position (0..239).
+win_height      res 1           ; Box/text height (1..240)
+win_leftx2      res 1           ; Box/text position (0..159)
+win_width       res 1           ; box width (1..160)
+win_font        res 1
+win_invert      res 1
+win_bargraph    res 1           ; PLED_box swicth to black after this position (0..159).
+win_flags       res 1           ; flip_screen flag, transparent fonts, etc...
 
-	CBLOCK	0x100				;Bank 1
-	wreg_temp					;variables used for context saving during ISR 
-	status_temp					
-	bsr_temp					
-	prod_temp:2                 ;Trashed by isr_mult16x16, for sensor compensations
+pressureSum     res 2           ; Stabilize surface presure by a long averaging window [mbar]
+pressureCount   res 1           ; Count of pressure values.
+pressureAvg     res 2           ; save averaged pressure x16, for altimeter_menu
+pressureRef     res 2           ; Pressure at sea level [mbar]
+altitude        res 2           ; Last computed altitude [m]
 
-	secs						;realtime clock
-	mins
-	hours
-	day
-	month
-	year
+;=============================================================================
+; BANK1 data
+;
+bank1 udata 0x100               ;Bank 1
 
-	waitms_temp					;variables required for wait routines
-	wait_temp				 	; " + used to copy data to c code + used for temp/testing
-								; never use wait_temp in interrupt routines (isr) and never call any wait routine in interrupts
+wreg_temp       res 1           ;variables used for context saving during ISR 
+status_temp     res 1
+bsr_temp        res 1
+prod_temp       res 2           ;Trashed by isr_mult16x16, for sensor compensations
 
-	textnumber					;for textdisplay and textlookup
-	textlength					
-	textaddress:2				
+secs            res 1           ;realtime clock
+mins            res 1
+hours           res 1
+day             res 1
+month           res 1
+year            res 1
 
-	average_depth_hold:4		; Holds Sum of depths (Resettable)
-	average_depth_hold_total:4	; Holds Sum of depths (Non-Resettable)
-	b0_lo						; Temp (calculate_average)
-	b0_hi						; Temp (calculate_average)
-	average_divesecs:2			; Used for resetable average depth display
-	surface_interval:2			; Surface Interval [mins]
+waitms_temp     res 1           ;variables required for wait routines
+wait_temp       res 1           ; " + used to copy data to c code + used for temp/testing
+                                ; never use wait_temp in interrupt routines (isr) and never call any wait routine in interrupts
+
+textnumber      res 1           ;for textdisplay and textlookup
+textlength      res 1
+textaddress     res 2				
 
-	flag1 						;Flag register 33
-	flag2 
-	flag3 
-	flag4 
-	flag5 ; has to be exacly here, is modified by c-code (no sensor int) 
-	flag6 
-	flag7 
-	flag8
-	flag9
-	flag10
-	flag11
-	flag12
-	flag13
-	flag14
-	flag15
+average_depth_hold  res 4       ; Holds Sum of depths (Resettable)
+average_depth_hold_total res 4  ; Holds Sum of depths (Non-Resettable)
+b0_lo           res 1           ; Temp (calculate_average)
+b0_hi           res 1           ; Temp (calculate_average)
+average_divesecs    res 2       ; Used for resetable average depth display
+surface_interval    res 2       ; Surface Interval [mins]
 
-	oled1_temp					;Temp variables for display output
-	oled2_temp		
-	oled3_temp	
-	oled4_temp					; Used in "Displaytext"
+flag1           res 1           ;Flag register 33
+flag2           res 1
+flag3           res 1
+flag4           res 1
+flag5           res 1           ; has to be exacly here, is modified by c-code (no sensor int) 
+flag6           res 1
+flag7           res 1
+flag8           res 1
+flag9           res 1
+flag10          res 1
+flag11          res 1
+flag12          res 1
+flag13          res 1
+flag14          res 1
+flag15          res 1
 
-	lo							;bin to dec conversion routine
-	hi
-	lo_temp
-	hi_temp
-	temp3						;								used in valconv math
-	temp4						;								used in valconv math
-	ignore_digits
+oled1_temp      res 1           ; Temp variables for display output
+oled2_temp  	res 1
+oled3_temp      res 1
+oled4_temp      res 1           ; Used in "Displaytext"
 
-	temp1						;Multipurpose Temp variables 	used in valconv math
-	temp2						;								used in valconv math
+lo              res 1           ; bin to dec conversion routine
+hi              res 1
+lo_temp         res 1
+hi_temp         res 1
+temp3           res 1           ; used in valconv math
+temp4           res 1           ; used in valconv math
+ignore_digits   res 1
 
-	ext_ee_temp1				; External EEPROM Temp 1		used in I2C EEPROM
-	ext_ee_temp2				; External EEPROM Temp 2		used in I2C EEPROM
+temp1           res 1           ; Multipurpose Temp variables 	used in valconv math
+temp2           res 1           ; used in valconv math
 
-	isr1_temp					;ISR temp variables
-	isr2_temp	
-  	isr3_temp:2
+ext_ee_temp1    res 1           ; External EEPROM Temp 1		used in I2C EEPROM
+ext_ee_temp2    res 1           ; External EEPROM Temp 2		used in I2C EEPROM
+
+isr1_temp       res 1           ; ISR temp variables
+isr2_temp       res 1
+isr3_temp       res 2
 
-	timer1int_counter1			;Timer 1 counter
-	timer1int_counter2 			;Timer 1 counter
+timer1int_counter1  res 1       ;Timer 1 counter
+timer1int_counter2  res 1       ;Timer 1 counter
 
-	uart1_temp					;RS232 temp variables
-	uart2_temp                  ;70
+uart1_temp      res 1           ;RS232 temp variables
+uart2_temp      res 1           ;70
 
-  	divA:2						;math routines
-  	divB
-	xC:4
-	xA:2
-	xB:2
-  	sub_c:2
-  	sub_a:2
-  	sub_b:2
+divA            res 2			;math routines
+divB            res 1
+xC              res 4
+xA              res 2
+xB              res 2
+sub_c           res 2
+sub_a           res 2
+sub_b           res 2
+
+dLSB            res 1           ;Pressure sensor interface 
+dMSB            res 1
+clock_count     res 1
+ppO2_setpoint_store res 1       ; Actual setpoint
 
-	dLSB						;Pressure sensor interface 
-	dMSB
-	clock_count
-	ppO2_setpoint_store			; Actual setpoint
-	W1:2
-	W2:2
-	W3:2
-	W4:2	;100
-	C1:2
-	C2:2
-	C3:2
-	C4:2
-	C5:2
-	C6:2
-	D1:2
-	D2:2
+; Pressure/Temperatuse sensor data
+W1              res 2           ; Raw (packed) calibration data
+W2              res 2
+W3              res 2
+W4              res 2	        ; 100
+C1              res 2           ; Decoded calibration data
+C2              res 2
+C3              res 2
+C4              res 2
+C5              res 2
+C6              res 2
+D1              res 2           ; raw pressure
+D2              res 2           ; raw temperature
 
-  	isr_divA:2
- 	isr_divB
-	isr_xC:4
-	isr_xA:2
-	isr_xB:2
-  	isr_sub_c:2
-  	isr_sub_a:2
-  	isr_sub_b:2
+isr_divA        res 2           ; Data for ISR math subroutines
+isr_divB        res 1
+isr_xC          res 4
+isr_xA          res 2
+isr_xB          res 2
 
-  	xdT:2
-  	xdT2:2
-  	OFF:2
-  	SENS:2
-   	amb_pressure:2					; ambient pressure [mBar]
-   	rel_pressure:2					; amb_pressure - surface pressure [mBar]
-   	max_pressure:2					; Max. pressure for the dive [mBar]
-	avr_rel_pressure:2				; Average rel. pressure (Average depth) for the dive [mBar], Resettable
- 	avr_rel_pressure_total:2		; Average rel. pressure (Average depth) for the dive [mBar], Non-Resettable
-   	last_pressure:2
-  	temperature:2
-  	last_temperature:2
-  	temperature_temp:2
-  	Dx:2
+xdT             res 2           ; Tmp for temperature compensation (in ISR)
+xdT2            res 2
+OFF             res 2
+SENS            res 2
 
-	last_surfpressure:2			;Divemode
-	last_surfpressure_15min:2
-	last_surfpressure_30min:2
-	divemins:2					;Minutes
-	divesecs					;seconds
-	samplesecs					; counts the seconds until the next sample is stored in divemode
-	samplesecs_value			; holds the CF20 value
-	decodata:2					;Deco data
-	mintemp:2					;min temperature
-	ProfileFlagByte				; stores number of addional bytes per sample
-	EventByte					; Stores the Event type plus flags	
-	AlarmType					; 0= No Alarm
+amb_pressure    res 2           ; ambient pressure [mBar]
+rel_pressure    res 2		    ; amb_pressure - surface pressure [mBar]
+max_pressure    res 2           ; Max. pressure for the dive [mBar]
+avr_rel_pressure res 2          ; Average rel. pressure (Average depth) for the dive [mBar], Resettable
+avr_rel_pressure_total res 2    ; Average rel. pressure (Average depth) for the dive [mBar], Non-Resettable
+last_pressure   res 2
+temperature     res 2
+last_temperature res 2
+temperature_temp res 2
+Dx              res 2
+
+last_surfpressure       res 2   ; Divemode
+last_surfpressure_15min res 2
+last_surfpressure_30min res 2
+divemins                res 2   ; Minutes
+divesecs                res 1   ; seconds
+samplesecs              res 1   ; counts the seconds until the next sample is stored in divemode
+samplesecs_value        res 1   ; holds the CF20 value
+decodata                res 2   ; Deco data
+mintemp                 res 2   ; min temperature
+ProfileFlagByte         res 1   ; stores number of addional bytes per sample
+EventByte               res 1   ; Stores the Event type plus flags	
+AlarmType               res 1   ; 0= No Alarm
 								; 1= SLOW
 								; 2= DecoStop missed
 								; 3= DeepStop missed
@@ -249,110 +254,74 @@
 								; 5= ppO2 High Warning
 								; 6= manual marker
 
-	divisor_temperature			; divisors for profile storage
-	divisor_deco
-	divisor_tank
-	divisor_ppo2
-	divisor_deco_debug
-	divisor_nuy2
-
-	timeout_counter				;Timeout counter variables
-	timeout_counter2
-	timeout_counter3			;pre-menu timeout counter
+divisor_temperature     res 1   ; divisors for profile storage
+divisor_deco            res 1
+divisor_tank            res 1
+divisor_ppo2            res 1
+divisor_deco_debug      res 1
+divisor_nuy2            res 1
 
-	menupos						;cursor position
-	menupos2
-	menupos3					;used in Logbook, Set Time and divemode
+timeout_counter         res 1   ; Timeout counter variables
+timeout_counter2        res 1
+timeout_counter3        res 1   ; pre-menu timeout counter
 
-	eeprom_address:2			;external EEPROM
-	eeprom_header_address:2
-
-	divenumber					;Logbook
-
-	batt_voltage:2				;Battery voltage in mV
+menupos                 res 1   ; cursor position
+menupos2                res 1
+menupos3                res 1   ; used in Logbook, Set Time and divemode
 
-	i2c_temp					;I²C timeout counter
-	i2c_temp2;200
+eeprom_address          res 2   ; external EEPROM
+eeprom_header_address   res 2
 
-	sim_pressure:2				; hold simulated pressure in mBar if in Simulator mode
+divenumber              res 1   ; Logbook
+
+batt_voltage            res 2   ; Battery voltage in mV
 
-	profile_temp:2				; temp variable for profile view
-	profile_temp2:2				; temp variable for profile view
-	
-	nofly_time:2				; No Fly time in Minutes (Calculated after Dive)
-	
-	cf_checker_counter			; counts custom functions to check for warning symbol
-	
-	char_I_O2_ratio				; 02 ratio
+i2c_temp                res 1   ; I²C timeout counter
+i2c_temp2               res 1   ; 200
+
+sim_pressure            res 2   ; hold simulated pressure in mBar if in Simulator mode
 
-	active_gas					; Holds number of active gas
-		
-	last_diluent				; backup of diluent percentage in const ppO2 mode
-	last_ppO2_value				; last calculated ppO2 value
+profile_temp            res 2   ; temp variable for profile view
+profile_temp2           res 2   ; temp variable for profile view
 
-;	ontime_since_last_charge:2	; Ontime in minutes since last complete charge cycle
-;	sleeptime_since_last_charge:2; Sleeptime in hours since last complete charge
+nofly_time              res 2   ; No Fly time in Minutes (Calculated after Dive)
+
+cf_checker_counter      res 1   ; counts custom functions to check for warning symbol
 
-	debug_char:6				; For debugmode
-	
-	apnoe_mins					; single descent minutes for Apnoe mode
-	apnoe_secs					; single descent seconds for Apnoe mode
-	apnoe_max_pressure:2		; Max. Pressure in Apnoe mode
-	apnoe_timeout_counter		; counts minutes for apnoe timeout
-	apnoe_surface_mins			; Surface interval mins for Apnoe mode
-	apnoe_surface_secs			; Surface interval secs for Apnoe mode
-	customfunction_temp1		; start of custom function descriptors 
-	customfunction_temp2		; used in GETCUSTOM8 and GETCUSTOM15
-	
-	decoplan_page				; used in PLED_MultiGF,...
-	temp10						; used in customview
+char_I_O2_ratio         res 1   ; 02 ratio
+
+active_gas              res 1   ; Holds number of active gas
 
-	fatal_error_code			; holds error code value 
+last_diluent            res 1   ; backup of diluent percentage in const ppO2 mode
+last_ppO2_value         res 1   ; last calculated ppO2 value
 
-	logbook_temp1				; Temp used in logbook display&Divemode&Gassetup
-	logbook_temp2				; Temp used in logbook display&Divemode&Gassetup
-	logbook_temp3				; Temp used in logbook display&Divemode&Gassetup
-	logbook_temp4				; Temp used in logbook display&Divemode&Gassetup
-	logbook_temp5				; Temp used in logbook display&Divemode&Gassetup
-	logbook_temp6				; Temp used in logbook display&Divemode&Gassetup
-	
-	convert_value_temp:3		; used in menu_battery_state_convert_date
-	time_correction_value		; Adds to Seconds on midnight
-	ENDC
+debug_char              res 6    ; For debugmode
 
-	CBLOCK	0x700				;Bank 7
-; variables used exclusively in dd:
-	dd_temp_BSR ; has to be first in bank7
-	temp_pointer_row
-	temp_pointer_column
-	temp2_pointer_row
-	temp2_pointer_column
-	temp_selected_char
-	temp_font_HIGH
-	temp_font_LOW
-	temp_font_height
-	temp2_font_height
-	temp_font_width
-	temp2_font_width
-	temp_diff_font_width
-	temp2_diff_font_width
-	temp_font_offset_left
-	temp_font_offset_right
-	temp_pos
-	DDflag
-	dd_oled_brightness_offset		; value will be subtracted from "dd_grayvalue" in dd_font2display_vxxx.asm
-	dd_grayvalue
-	dd2_temp
-	dd3_temp
-	dd_pos_decpoint
-	dd_grayvalue_temp
-	dd_grayvalue_temp2
-	ENDC
+apnoe_mins              res 1   ; single descent minutes for Apnoe mode
+apnoe_secs              res 1   ; single descent seconds for Apnoe mode
+apnoe_max_pressure      res 2   ; Max. Pressure in Apnoe mode
+apnoe_timeout_counter   res 1   ; counts minutes for apnoe timeout
+apnoe_surface_mins      res 1   ; Surface interval mins for Apnoe mode
+apnoe_surface_secs      res 1   ; Surface interval secs for Apnoe mode
+customfunction_temp1    res 1   ; start of custom function descriptors 
+customfunction_temp2    res 1   ; used in GETCUSTOM8 and GETCUSTOM15
+
+decoplan_page           res 1   ; used in PLED_MultiGF,...
+temp10                  res 1   ; used in customview
 
-	CBLOCK	0x94A				;Bank 9
-	char_O_hash:.16			; MD2 hash values = d'16'
-	ENDC
+fatal_error_code        res 1   ; holds error code value 
 
+logbook_temp1           res 1   ; Temp used in logbook display&Divemode&Gassetup
+logbook_temp2           res 1   ; Temp used in logbook display&Divemode&Gassetup
+logbook_temp3           res 1   ; Temp used in logbook display&Divemode&Gassetup
+logbook_temp4           res 1   ; Temp used in logbook display&Divemode&Gassetup
+logbook_temp5           res 1   ; Temp used in logbook display&Divemode&Gassetup
+logbook_temp6           res 1   ; Temp used in logbook display&Divemode&Gassetup
+
+convert_value_temp      res 3    ; used in menu_battery_state_convert_date
+time_correction_value   res 1   ; Adds to Seconds on midnight
+
+;=============================================================================
 ; C-code Routines
 ; PART 2
     extern deco_calc_CNS_decrease_15min    
@@ -367,7 +336,9 @@
     extern deco_pull_tissues_from_vault
     extern deco_push_tissues_to_vault
 
+;=============================================================================
 ;I/O Ports (I=Input, O=Output)
+;
 #DEFINE	sensor_SDO			PORTA,1 ;O
 #DEFINE	oled_rw				PORTA,2 ;0
 #DEFINE	oled_hv				PORTA,3 ;O
--- a/code_part1/OSTC_code_asm_part1/menu_custom.asm	Fri Jan 21 01:44:37 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm	Fri Jan 21 01:44:38 2011 +0100
@@ -66,11 +66,11 @@
 
 ; Overlay our tmp data with some unused variables. But use more
 ; meaningfull labels...
-cf32_x4     EQU divemins+0      ; CF# modulus 32, time 4.
-cf_type     EQU divemins+1      ; Type of the edited CF
-cf_value    EQU divesecs
-cf_min      EQU apnoe_mins
-cf_max      EQU apnoe_secs
+#define cf32_x4     divemins+0      ; CF# modulus 32, time 4.
+#define cf_type     divemins+1      ; Type of the edited CF
+#define cf_value    divesecs
+#define cf_min      apnoe_mins
+#define cf_max      apnoe_secs
             
 GETCUSTOM8	macro	custom8
 	movlw	custom8
@@ -565,7 +565,7 @@
 
 cf_fill_line:                   ; Mattias: No flicker if u clear just what you need...
 	movf    FSR2L,W             ; How many chars lefts ?
-	sublw   (LOW letter) + .18  ; Remaining chars to fill: (letter + 18) - PTR
+	sublw   letter + .18        ; Remaining chars to fill: (letter + 18) - PTR
 	btfsc   STATUS,N            ; Add chars until none left...
 	return
 	PUTC   ' '
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Jan 21 01:44:37 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Jan 21 01:44:38 2011 +0100
@@ -1183,11 +1183,11 @@
 	movwf	wait_temp			; here: stores eeprom address for gas list
 	movlw	d'0'
 	movwf	waitms_temp			; here: stores row for gas list
-	clrf 	decoplan_index		; here: SP counter
+	clrf 	apnoe_mins          ; here: SP counter
 
 PLED_pre_dive_screen3_loop:
 	incf	wait_temp,F			; EEPROM address
-	incf	decoplan_index,F	; Increase SP
+	incf	apnoe_mins,F	    ; Increase SP
 
 	movlw	d'25'
 	addwf	waitms_temp,F		; Increase row
@@ -1195,18 +1195,18 @@
 	movff	waitms_temp,win_top ; Set Row
 	
 	STRCPY  "SP"
-	movff	decoplan_index,lo   ; copy gas number
-	output_8				; display gas number
+	movff	apnoe_mins,lo       ; copy gas number
+	output_8			        ; display gas number
 	STRCAT  ": "
-	movff	wait_temp, EEADR; SP #hi position
-	call	read_eeprom		; get byte (stored in EEDATA)
-	movff	EEDATA,lo		; copy to lo
+	movff	wait_temp, EEADR    ; SP #hi position
+	call	read_eeprom		    ; get byte (stored in EEDATA)
+	movff	EEDATA,lo		    ; copy to lo
 	clrf	hi
-	output_16dp	d'3'		; outputs into Postinc2!
+	output_16dp	d'3'		    ; outputs into Postinc2!
 	call	word_processor	
 
-	movlw	d'3'		; list all three SP
-	cpfseq	decoplan_index      ; All gases shown?
+	movlw	d'3'		        ; list all three SP
+	cpfseq	apnoe_mins          ; All gases shown?
 	bra		PLED_pre_dive_screen3_loop	;no
 
 	read_int_eeprom 	d'33'			; Read byte (stored in EEDATA)
@@ -2267,10 +2267,10 @@
 ; Inputs: char_O_deco_table (array of stop times, in minutes)
 ;         decoplan_page = page number. Displays 5 stop by page.
 ;
-decoplan_index  equ apnoe_mins          ; within each page
-decoplan_gindex equ apnoe_secs          ; global index
-decoplan_last   equ apnoe_max_pressure  ; Depth of last stop (CF#29)
-decoplan_max    equ apnoe_max_pressure+1; Number of lines per page. 7 in planning, 5 in diving.
+#define decoplan_index  apnoe_mins          ; within each page
+#define decoplan_gindex apnoe_secs          ; global index
+#define decoplan_last   apnoe_max_pressure  ; Depth of last stop (CF#29)
+#define decoplan_max    apnoe_max_pressure+1; Number of lines per page. 7 in planning, 5 in diving.
 
 PLED_decoplan_gf:
         ostc_debug	'n'		; Sends debug-information to screen if debugmode active
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Fri Jan 21 01:44:37 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Fri Jan 21 01:44:38 2011 +0100
@@ -158,20 +158,20 @@
 static float  			var2_halftimes;
 static float			pres_gtissue_limit;
 static float			temp_pres_gtissue_limit;
-static float			actual_ppO2;						// new in v.102
+static float			actual_ppO2;                // new in v.102
 
-static float			pres_tissue[32];
+static float            pres_diluent;               // new in v.101
+static float            deco_diluent;               // new in v.101
+static float            const_ppO2;                 // new in v.101
+static float            deco_ppO2_change;           // new in v.101
+static float            deco_ppO2;                  // new in v.101
 
 //---- Bank 6 parameters -----------------------------------------------------
 #pragma udata bank6=0x600
 
+static float  pres_tissue[32];
 static float  pres_tissue_limit[16];
 static float  sim_pres_tissue_limit[16];
-static float  pres_diluent;			            // new in v.101
-static float  deco_diluent;			            // new in v.101
-static float  const_ppO2;				        // new in v.101
-static float  deco_ppO2_change;	            	// new in v.101
-static float  deco_ppO2;				        // new in v.101
 
 //---- Bank 7 parameters -----------------------------------------------------
 #pragma udata bank7=0x700
@@ -190,59 +190,58 @@
 
 static char	  md_state[48];		        // DONT MOVE !! // has to be at the beginning of bank 9 for the asm code!!!
 
-// internal:
- static char            md_t;
- static char            md_buffer[16];
- static char            md_cksum[16];
- static char            md_i;
- static char            md_j;
- static char            md_temp;
- static unsigned int	md_pointer;
- static float			deco_N2_ratio;			// new in v.101
- static float			deco_He_ratio;			// new in v.101
- static float			calc_N2_ratio;			// new in v.101
- static float			calc_He_ratio;			// new in v.101
- static float			deco_gas_change;		// new in v.101
- static float			CNS_fraction;			// new in v.101
- static float			float_saturation_multiplier;		// new in v.101
- static float			float_desaturation_multiplier;		// new in v.101
- static float			float_deco_distance;	// new in v.101
- // internal, dbg:
- static unsigned char	DBG_char_I_deco_model;	// new in v.108
- static unsigned char	DBG_char_I_depth_last_deco;			// new in v.108
- static float			DBG_pres_surface;		// new in v.108
- static float			DBG_GF_low;				// new in v.108
- static float			DBG_GF_high;			// new in v.108
- static float			DBG_const_ppO2;			// new in v.108
- static float			DBG_deco_ppO2_change;	// new in v.108
- static float			DBG_deco_ppO2;			// new in v.108
- static float			DBG_deco_N2_ratio;		// new in v.108
- static float			DBG_deco_He_ratio;		// new in v.108
- static float			DBG_deco_gas_change;	// new in v.108
- static float			DBG_float_saturation_multiplier;	// new in v.108
- static float			DBG_float_desaturation_multiplier;	// new in v.108
- static float			DBG_float_deco_distance;			// new in v.108
- static float			DBG_deco_N2_ratio;		// new in v.108
- static float			DBG_deco_He_ratio;		// new in v.108
- static float			DBG_N2_ratio;			// new in v.108
- static float			DBG_He_ratio;			// new in v.108
- static char			flag_in_divemode;		// new in v.108
- static	int 			int_dbg_i;				// new in v.108
- static unsigned int 	temp_DBS;
+static char            md_t;
+static char            md_buffer[16];
+static unsigned char   md_i;
+static char            md_j;
+static char            md_temp;
+static unsigned int	md_pointer;
+static float			deco_N2_ratio;			// new in v.101
+static float			deco_He_ratio;			// new in v.101
+static float			calc_N2_ratio;			// new in v.101
+static float			calc_He_ratio;			// new in v.101
+static float			deco_gas_change;		// new in v.101
+static float			CNS_fraction;			// new in v.101
+static float			float_saturation_multiplier;		// new in v.101
+static float			float_desaturation_multiplier;		// new in v.101
+static float			float_deco_distance;	// new in v.101
 
- static float			deco_gas_change2;		// new in v.109
- static float			deco_gas_change3;		// new in v.109
- static float			deco_gas_change4;		// new in v.109
- static float			deco_gas_change5;		// new in v.109
+// internal, dbg:
+static unsigned char	DBG_char_I_deco_model;	// new in v.108
+static unsigned char	DBG_char_I_depth_last_deco;			// new in v.108
+static float			DBG_pres_surface;		// new in v.108
+static float			DBG_GF_low;				// new in v.108
+static float			DBG_GF_high;			// new in v.108
+static float			DBG_const_ppO2;			// new in v.108
+static float			DBG_deco_ppO2_change;	// new in v.108
+static float			DBG_deco_ppO2;			// new in v.108
+static float			DBG_deco_N2_ratio;		// new in v.108
+static float			DBG_deco_He_ratio;		// new in v.108
+static float			DBG_deco_gas_change;	// new in v.108
+static float			DBG_float_saturation_multiplier;	// new in v.108
+static float			DBG_float_desaturation_multiplier;	// new in v.108
+static float			DBG_float_deco_distance;			// new in v.108
+static float			DBG_deco_N2_ratio;		// new in v.108
+static float			DBG_deco_He_ratio;		// new in v.108
+static float			DBG_N2_ratio;			// new in v.108
+static float			DBG_He_ratio;			// new in v.108
+static char			    flag_in_divemode;		// new in v.108
+static	int 			int_dbg_i;				// new in v.108
+static unsigned int 	temp_DBS;
 
- static float			deco_N2_ratio2;			// new in v.109
- static float			deco_N2_ratio3;			// new in v.109
- static float			deco_N2_ratio4;			// new in v.109
- static float			deco_N2_ratio5;			// new in v.109
- static float			deco_He_ratio2;			// new in v.109
- static float			deco_He_ratio3;			// new in v.109
- static float			deco_He_ratio4;			// new in v.109
- static float			deco_He_ratio5;			// new in v.109
+static float			deco_gas_change2;		// new in v.109
+static float			deco_gas_change3;		// new in v.109
+static float			deco_gas_change4;		// new in v.109
+static float			deco_gas_change5;		// new in v.109
+
+static float			deco_N2_ratio2;			// new in v.109
+static float			deco_N2_ratio3;			// new in v.109
+static float			deco_N2_ratio4;			// new in v.109
+static float			deco_N2_ratio5;			// new in v.109
+static float			deco_He_ratio2;			// new in v.109
+static float			deco_He_ratio3;			// new in v.109
+static float			deco_He_ratio4;			// new in v.109
+static float			deco_He_ratio5;			// new in v.109
 
 // ***********************
 // ***********************
@@ -696,7 +695,6 @@
     _endasm
 #endif
 
-    
 void deco_calc_hauptroutine(void)
 {
     RESET_C_STACK
@@ -741,7 +739,6 @@
 
 void clear_tissue(void)    // preload tissues with standard pressure for the given ambient pressure
 {
-
 	flag_in_divemode = 0;
 	int_O_DBS_bitfield = 0;
 	int_O_DBS2_bitfield = 0;
@@ -752,50 +749,28 @@
     // N2_ratio = (float)char_I_N2_ratio; // the 0.0002 of 0.7902 are missing with standard air
     N2_ratio = 0.7902; // N2_ratio / 100.0;
     pres_respiration = (float)int_I_pres_respiration / 1000.0;
-    for (ci=0;ci<16;ci++)  // cycle through the 16 b"uhlmann tissues
+    
+    _asm
+        movlw 1
+        movwf TBLPTRU,0
+    _endasm
+    for(ci=0;ci<16;ci++)
     {
-        pres_tissue[ci] =  N2_ratio * (pres_respiration -  0.0627) ;
-        _asm
-        movlw	0x02
-        movwf	TBLPTRH,0
-        movlb	4 // fuer ci
-        movf ci,0,1
-        addwf	ci,0,1
-        addwf	ci,0,1
-        addwf	ci,0,1
-        addlw	0x80
-        movwf	TBLPTRL,0
-        TBLRDPOSTINC
-        movff	TABLAT,var_a+1
-        TBLRDPOSTINC
-        movff	TABLAT,var_a
-        TBLRDPOSTINC
-        movff	TABLAT,var_a+3
-        TBLRD
-        movff	TABLAT,var_a+2
-        addlw	0x80
-        movwf	TBLPTRL,0
-        incf	TBLPTRH,1,0
-        TBLRDPOSTINC
-        movff	TABLAT,var_b+1
-        TBLRDPOSTINC
-        movff	TABLAT,var_b
-        TBLRDPOSTINC
-        movff	TABLAT,var_b+3
-        TBLRD
-        movff	TABLAT,var_b+2
-        _endasm
+        overlay float p;
+        // cycle through the 16 b"uhlmann tissues
+        p = N2_ratio * (pres_respiration -  0.0627) ;
+        pres_tissue[ci] = p;
         
-        pres_tissue_limit[ci] = (pres_tissue[ci] - var_a) * var_b ;
-        // now update the guiding tissue
-        if (pres_tissue_limit[ci] < 0)
-            pres_tissue_limit[ci] = 0;
+        var_a = ((rom float*)a_N2)[ci];
+        var_b = ((rom float*)b_N2)[ci];
+        p = (p - var_a) * var_b ;
+        if( p < 0.0 )
+            p = 0.0;
+        pres_tissue_limit[ci] = p;
+
+        // cycle through the 16 b"uhlmann tissues for Helium
+        pres_tissue[ci+16] = 0.0;
     } // for 0 to 16
-    
-    for (ci=16;ci<32;ci++)  // cycle through the 16 b"uhlmann tissues for Helium
-    {
-        pres_tissue[ci] = 0.0;
-    }  // for
 
     clear_decoarray();
     char_O_deco_status = 0;
@@ -1230,8 +1205,8 @@
         _asm
         movlw	0x02
         movwf	TBLPTRH,0
-        movlb	4 // fuer ci
-        movf ci,0,1
+        movlb	5 // fuer ci
+        movf    ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
@@ -1490,8 +1465,8 @@
         _asm
         movlw	0x02
         movwf	TBLPTRH,0
-        movlb	4 // fuer ci
-        movf ci,0,1
+        movlb	5 // fuer ci
+        movf    ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
@@ -1611,8 +1586,8 @@
         _asm
         movlw	0x02
         movwf	TBLPTRH,0
-        movlb	4 // fuer ci
-        movf ci,0,1
+        movlb	5 // fuer ci
+        movf    ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
@@ -1863,8 +1838,8 @@
         _asm
         movlw	0x04
         movwf	TBLPTRH,0
-        movlb	4 // fuer ci
-        movf ci,0,1
+        movlb	5 // fuer ci
+        movf    ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
@@ -2019,8 +1994,8 @@
         _asm
         movlw	0x02
         movwf	TBLPTRH,0
-        movlb	4 // fuer ci
-        movf ci,0,1
+        movlb	5 // fuer ci
+        movf    ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
         addwf	ci,0,1
@@ -2120,10 +2095,10 @@
     RESET_C_STACK
     
     // init
-    for (md_i=0;md_i<16;md_i++)
+    for(md_i=0;md_i<16;md_i++)
     {
          md_state[md_i] = 0;
-         md_cksum[md_i] = 0;
+         char_O_hash[md_i] = 0;
     } // for md_i 16
 
     _asm
@@ -2134,7 +2109,7 @@
     movlw	0x00
     movwf	TBLPTRL,0
     _endasm;
-    for (md_i=0;md_i<127;md_i++)
+    for(md_i=0;md_i<=255;md_i++)
     {
         _asm
         TBLRDPOSTINC
@@ -2142,24 +2117,6 @@
         _endasm
         md_pi_subst[md_i] = md_temp;
     } // for md_i 256
-    _asm
-    TBLRDPOSTINC
-    movff	TABLAT,md_temp
-    _endasm;
-    md_pi_subst[127] = md_temp;
-    for (md_i=0;md_i<127;md_i++)
-    {
-        _asm
-        TBLRDPOSTINC
-        movff	TABLAT,md_temp
-        _endasm
-        md_pi_subst[md_i+128] = md_temp;
-    } // for md_i 256
-    _asm
-    TBLRD
-    movff	TABLAT,md_temp
-    _endasm
-    md_pi_subst[255] = md_temp;
     
     _asm
      movlw	0x00
@@ -2176,7 +2133,7 @@
         for (md_i=0;md_i<16;md_i++)
         {
             if(md_pointer == 9)
-                md_temp = md_cksum[md_i];
+                md_temp = char_O_hash[md_i];
             else
             {
                 _asm
@@ -2198,12 +2155,12 @@
             } // for md_j 48
             md_t = (unsigned char)(md_t+1);
         } // for md_i 18
-        md_t = md_cksum[15];
+        md_t = char_O_hash[15];
             
         for (md_i=0;md_i<16;md_i++)
         {
-            md_cksum[md_i] = (unsigned char)(md_cksum[md_i] ^ md_pi_subst[(md_buffer[md_i] ^ md_t)]);
-            md_t = md_cksum[md_i];
+            char_O_hash[md_i] = (unsigned char)(char_O_hash[md_i] ^ md_pi_subst[(md_buffer[md_i] ^ md_t)]);
+            md_t = char_O_hash[md_i];
         } // for md_i 16
     } // for md_pointer
 } // void deco_hash(void)
@@ -2332,3 +2289,4 @@
 		pres_tissue[ci] = pres_tissue_vault[ci];
 }
 
+void main() {}
\ No newline at end of file
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed
--- a/code_part1/OSTC_code_c_part2/shared_definitions.h	Fri Jan 21 01:44:37 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/shared_definitions.h	Fri Jan 21 01:44:38 2011 +0100
@@ -99,6 +99,8 @@
 VAR_UINT  (int_O_DBG_post_bitfield);
 VAR_UCHAR (char_O_NDL_at_20mtr);
 
+TAB_UCHAR (char_O_hash, 16);
+
 #ifdef __18CXX
     //---- BANK 3 DATA -------------------------------------------------------
     // Gather all data ASM-code --> C-code