chiark / gitweb /
Send HELLO as a result of all slaves being online. Do not crash if slave is slow...
[trains.git] / iwjpictest / syncwritehex.asm
1 ;======================================================================
2 ;
3 ; these routines all use serial_write_char which writes
4 ; bytes to the serial port synchronously
5
6         radix           dec
7         include         ../iwjpictest/insn-aliases.inc
8
9         udata_acs
10 serial_hex_temp res 1
11
12  code
13 ;----------------------------------------------------------------------
14
15 ;----------------------------------------
16 serial_write_hex
17 ;       transmits W in hex through serial port, using serial_write_char
18 ;                       Before          After
19 ; W                     value           undefined
20 ; serial_hex_temp       undefined       undefined
21         mov_wf          serial_hex_temp
22         rcall           serial_write_hex_1digit_for_both
23         rcall           serial_write_hex_1digit_for_both
24         return
25
26 ;--------------------
27 serial_write_hex_1digit_for_both
28 ;       transmits top nybble of serial_hex_temp in hex
29 ;       through serial port, as above, and swaps nybbles
30 ;               Before          After
31 ; W                     any             undefined
32 ; serial_hex_temp       BBBBaaaa        aaaaBBBB        (BBBB was sent)
33         swap_f  serial_hex_temp
34         mov_fw  serial_hex_temp
35 ;...
36 ;--------------------
37 serial_write_hex_digit
38 ;       transmits bottom nybble of W in hex
39 ; W             ????VVVV        undefined
40         and_lw  0x0f
41         sub_lw  10
42         sub_lw  0
43         bra_n   serial_write_hex_digit_ifnot_ge10
44         add_lw  'a'-('0'+10)
45 serial_write_hex_digit_ifnot_ge10
46         add_lw  '0'+10
47         bra     serial_write_char
48
49 ;======================================================================
50  include ../iwjpictest/syncwrite.inc
51  end