# Mu - subx/050write_stderr.subx

     1 == code
     2
     3 # instruction                     effective address                                                   operand     displacement    immediate
     4 # op          subop               mod             rm32          base        index         scale       r32
     5 # 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
     6
     7 write_stderr:  # s : (address array byte) -> <void>
     8   # prolog
     9   55/push-EBP
    10   89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
    11   # save registers
    12   50/push-EAX
    13   51/push-ECX
    14   52/push-EDX
    15   53/push-EBX
    16   # write(2/stderr, (data) s+4, (size) *s)
    17     # fd = 2 (stderr)
    18   bb/copy                         .               .             .           .             .           .           .               2/imm32           # copy to EBX
    19     # x = s+4
    20   8b/copy                         1/mod/*+disp8   4/rm32/SIB    5/base/EBP  4/index/none  .           1/r32/ECX   8/disp8         .                 # copy *(EBP+8) to ECX
    21   81          0/subop/add         3/mod/direct    1/rm32/ECX    .           .             .           .           .               4/imm32           # add to ECX
    22     # size = *s
    23   8b/copy                         1/mod/*+disp8   4/rm32/SIB    5/base/EBP  4/index/none  .           2/r32/EDX   8/disp8         .                 # copy *(EBP+8) to EDX
    24   8b/copy                         0/mod/indirect  2/rm32/EDX    .           .             .           2/r32/EDX   .               .                 # copy *EDX to EDX
    25     # call write()
    26   b8/copy                         .               .             .           .             .           .           .               4/imm32/write     # copy to EAX
    27   cd/syscall  0x80/imm8
    28   # restore registers
    29   5b/pop-to-EBX
    30   5a/pop-to-EDX
    31   59/pop-to-ECX
    32   58/pop-to-EAX
    33   # end
    34   89/copy                         3/mod/direct    4/rm32/ESP    .           .             .           5/r32/EBP   .               .                 # copy EBP to ESP
    35   5d/pop-to-EBP
    36   c3/return
    37
    38 # vim:ft=subx:nowrap:tw&