about summary refs log tree commit diff stats
path: root/js/games/nluqo.github.io/~bh/v1ch10/fingers.gif
blob: b27adf4334e2c3f8e4b2619b0ce9570000e1f7db (plain)
ofshex dumpascii
0000 47 49 46 38 37 61 4e 00 59 00 f0 00 00 00 00 00 ff ff ff 2c 00 00 00 00 4e 00 59 00 00 02 fe 84 GIF87aN.Y..........,....N.Y.....
0020 8f a9 cb ed 0f 5b 88 60 c2 60 5f d6 14 6d f7 31 58 14 8a dd 51 2e 69 32 5e d4 2a bd 24 8c ca 67 .....[.`.`_..m.1X...Q.i2^.*.$..g
0040 65 6b b4 b1 f3 37 7e e9 b5 74 a4 db 64 77 0c ba 90 40 19 13 f9 5c 9e 92 1c a8 b4 3a 6d c6 ac d8 ek...7~..t..dw...@...\.....:m...
0060 ae f3 0a 8a 7a 8b e2 30 78 9b 2d 4b d4 a6 5e 8d ad 82 2b a8 df b1 48 ce d2 9e db 4a bb 4a ef 97 ....z..0x.-K..^...+...H....J.J..
0080 07 28 48 63 51 38 88 06 e2 a3 88 58 d3 e8 e3 d6 04 93 31 b9 68 62 f9 87 c9 f8 48 c9 58 a9 29 f8 .(HcQ8.....X......1.hb....H.X.).
00a0 e8 e1 78 c9 09 3a 7a 4a ea d6 19 93 ba f8 69 ea 1a 0a fb 49 bb b9 4a 9a 19 6b db 2a aa 7a eb 09 ..x..:zJ......i....I..J..k.*.z..
00c0 dc 8b 2b cb 7a c9 5b 4a 1c bb 2b 9c 9c b3 b2 01 8d aa db 68 cc e1 1a dd 5b 3d 3d 97 db dc ed cd ..+.z.[J..+........h....[==.....
00e0 2d 1d fe 5b 84 cd 1d ba 4d 6e 29 94 8e 9e 92 4d 8d f8 c1 84 ee 0d 6f af 89 9f ef be bf 1e 0f ee -..[....Mn)....M......o.........
0100 9f 3b 79 fe 52 01 ec 57 4a 96 be 84 f3 f8 d1 63 58 4f a0 c3 89 14 d7 bd 83 98 b0 60 43 fe 7e 17 .;y.R..WJ......cXO.........`C.~.
0120 03 92 0b 51 02 24 41 17 f9 44 7a 3c 65 12 e1 b5 8f 27 41 85 6c a9 27 22 4a 98 29 ed bd e4 78 4f ...Q.$A..Dz<e....'A.l.'"J.)...xO
0140 de a0 9a e1 6e 5a 9c 39 10 10 cf 9d 34 37 d9 d4 39 d4 27 4b 6d 3d 91 b6 54 0a 94 a1 4b a7 03 a1 ....nZ.9....47..9.'Km=..T...K...
0160 12 65 3a f5 a9 d6 ad 41 97 4a fc 6a 30 28 ac 8e 27 35 9a d5 59 b2 eb c3 91 6c bb 46 0d 5b 11 ae .e:....A.J.j0(..'5..Y....l.F.[..
0180 57 b4 6b cb 62 6c 8b 13 ea 59 bc 64 f3 f2 cd f9 77 21 cc 73 16 0f 8a d3 36 6e b0 96 c4 1b 09 3b W.k.bl...Y.d....w!.s....6n.....;
01a0 76 6b f8 30 35 c6 8c 39 46 ce 55 90 32 56 c7 c8 74 75 56 3b ec 5b c0 cf 71 67 89 36 1d 5a 2a e7 vk.05..9F.U.2V..tuV;.[..qg.6.Z*.
01c0 d3 d3 48 83 45 ed 2c 75 6c b4 ea 96 b9 2e 47 3b f1 6d 76 ac e5 8e ee cd 5b f6 60 dd c0 25 01 b7 ..H.E.,ul.....G;.mv.....[.`..%..
01e0 4a e8 5a 2d e5 2b 7f 02 39 c4 2c 98 51 85 74 12 29 c2 d3 f4 fa 9e 3f d8 b3 5a ff ce 27 d0 51 ed J.Z-.+..9.,.Q.t.).....?..Z..'.Q.
0200 e2 47 75 17 5a fe cd f6 6e d0 71 e2 38 ff 7e fd 78 f0 dc e5 9b 6f 4e dd 57 f5 f0 e4 42 b1 1e 82 .Gu.Z...n.q.8.~.x....oN.W...B...
0220 bf 5f 7d d3 89 12 20 7b f6 a9 37 9d 10 0a f6 41 04 49 0a 3d 08 a1 2f 10 5e a6 98 5b 16 ba 87 49 ._}....{..7....A.I.=../.^..[...I
0240 3b e6 38 88 5f 46 1b 76 a8 1a 6d e9 68 c8 e1 80 21 8e f8 a1 89 22 5e 18 e1 0f 2e be d8 40 01 00 ;.8._F.v..m.h...!...."^......@..
0260 3b ;
nt-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Example reading commandline arguments: compute length of first arg.
#
# To run:
#   $ ./bootstrap translate init.linux apps/ex8.subx -o apps/ex8
#   $ ./bootstrap run apps/ex8 abc de fghi
# Expected result:
#   $ echo $?
#   3  # length of 'abc'
#
# At the start of a SubX program:
#   argc: *esp
#   argv[0]: *(esp+4)
#   argv[1]: *(esp+8)
#   ...
# Locals start from esp-4 downwards.

== code
#   instruction                     effective address                                                   register    displacement    immediate
# . op          subop               mod             rm32          base        index         scale       r32
# . 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

Entry:
    # . prologue
    89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
    # eax = ascii-length(argv[1])
    # . . push args
    ff          6/subop/push        1/mod/*+disp8   5/rm32/ebp    .           .             .           .           8/disp8         .                 # push *(ebp+8)
    # . . call
    e8/call  ascii-length/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/imm32           # add to esp

    # exit(eax)
    89/copy                         3/mod/direct    3/rm32/ebx    .           .             .           0/r32/eax   .               .                 # copy eax to ebx
    e8/call  syscall_exit/disp32

ascii-length:  # s: (addr array byte) -> n/eax
    # edx = s
    8b/copy                         1/mod/*+disp8   4/rm32/sib    4/base/esp  4/index/none  .           2/r32/edx   4/disp8         .                 # copy *(esp+4) to edx
    # var result/eax = 0
    b8/copy-to-eax  0/imm32
$ascii-length:loop:
    # var c/ecx = *s
    8a/copy-byte                    0/mod/*         2/rm32/edx    .           .             .           1/r32/CL    .               .                 # copy byte at *edx to CL
    # if (c == '\0') break
    81          7/subop/compare     3/mod/direct    1/rm32/ecx    .           .             .           .           .               0/imm32/null      # compare ecx
    74/jump-if-=  $ascii-length:end/disp8
    # ++s
    42/increment-edx
    # ++result
    40/increment-eax
    # loop
    eb/jump  $ascii-length:loop/disp8
$ascii-length:end:
    # return eax
    c3/return

== data

# . . vim:nowrap:textwidth=0