Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/simulator.asm @ 593:46e9ccd0eca7
pSCR CNS in simulator
author | heinrichsweikamp |
---|---|
date | Mon, 28 May 2012 18:02:07 +0200 |
parents | cda5b45b953f |
children | d7eeaffd8fc1 |
comparison
equal
deleted
inserted
replaced
592:cda5b45b953f | 593:46e9ccd0eca7 |
---|---|
381 movff sim_pressure+1,amb_pressure+1 | 381 movff sim_pressure+1,amb_pressure+1 |
382 | 382 |
383 call divemode_check_decogases ; Checks for decogases and sets the gases | 383 call divemode_check_decogases ; Checks for decogases and sets the gases |
384 call divemode_prepare_flags_for_deco | 384 call divemode_prepare_flags_for_deco |
385 call set_first_gas ; Set current N2/He/O2 ratios. | 385 call set_first_gas ; Set current N2/He/O2 ratios. |
386 call set_actual_ppo2 ; Then configure char_I_actual_ppO2 | 386 call set_actual_ppo2 ; Then configure char_I_actual_ppO2 (For CNS) |
387 | 387 |
388 read_int_eeprom d'34' ; Read deco data | 388 read_int_eeprom d'34' ; Read deco data |
389 movlw .6 | 389 movlw .6 |
390 cpfseq EEDATA | 390 cpfseq EEDATA |
391 bra simulator_calc_deco1 | 391 bra simulator_calc_deco1 |
392 ; in PSCR mode, compute fO2 into char_I_O2_ratio | 392 ; in PSCR mode, compute fO2 into char_I_O2_ratio |
393 call compute_pscr_ppo2 ; pSCR ppO2 into sub_c:2 | 393 call compute_pscr_ppo2 ; pSCR ppO2 into sub_c:2 |
394 ; tstfsz sub_c+1 ; Is ppO2 > 2.55bar ? mH | |
395 ; setf sub_c+0 ; yes: bound to 2.55... better than wrap around. | |
396 movff sub_c+0,char_I_actual_ppO2 ; copy last ppO2 to buffer register | |
397 | |
394 movff sub_c+0,xA+0 | 398 movff sub_c+0,xA+0 |
395 movff sub_c+1,xA+1 | 399 movff sub_c+1,xA+1 |
396 movlw LOW .10 | 400 movlw LOW .10 |
397 movwf xB+0 | 401 movwf xB+0 |
398 movlw HIGH .10 | 402 movlw HIGH .10 |
399 movwf xB+1 | 403 movwf xB+1 |
400 call mult16x16 ;xA*xB=xC -> xC:4 = ppO2*1000 | 404 call mult16x16 ;xA*xB=xC -> xC:4 = ppO2*1000 |
401 | 405 |
402 tstfsz xA+1 ; Is ppO2 > 2.55bar ? | |
403 setf xA+0 ; yes: bound to 2.55... better than wrap around. | |
404 movff xA+0, char_I_actual_ppO2 ; copy last ppO2 to buffer register | |
405 | |
406 SAFE_2BYTE_COPY amb_pressure, xB | 406 SAFE_2BYTE_COPY amb_pressure, xB |
407 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | 407 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
408 ; xC+0 has O2 in percent | 408 ; xC+0 has O2 in percent |
409 movff xC+0,char_I_O2_ratio | 409 movff xC+0,char_I_O2_ratio |
410 | |
410 | 411 |
411 simulator_calc_deco1: | 412 simulator_calc_deco1: |
412 ; First minute is special: init everything. | 413 ; First minute is special: init everything. |
413 movlw d'3' ; Begin of deco cycle (reset table). | 414 movlw d'3' ; Begin of deco cycle (reset table). |
414 movff WREG,char_O_deco_status ; Reset Deco module. | 415 movff WREG,char_O_deco_status ; Reset Deco module. |