about summary refs log tree commit diff stats
path: root/003trace.test.cc
Commit message (Expand)AuthorAgeFilesLines
* 5485 - promote SubX to top-levelKartik Agaram2019-07-271-0/+7
* 5001 - drop the :(scenario) DSLKartik Agaram2019-03-121-1/+3
* 3547Kartik K. Agaram2016-10-221-1/+0
* 3294Kartik K. Agaram2016-09-021-3/+3
* 3267Kartik K. Agaram2016-08-281-2/+0
* 2547Kartik K. Agaram2015-12-241-0/+6
* 2258 - separate warnings from errorsKartik K. Agaram2015-10-061-4/+4
* 1844 - explicitly end each trace lineKartik K. Agaram2015-07-251-17/+17
* 1669 - now it fails in the right placeKartik K. Agaram2015-06-271-0/+5
* 1414 - traces now robust to new recipes/typesKartik K. Agaram2015-05-211-0/+21
* 1413Kartik K. Agaram2015-05-211-39/+12
* 1412 - starting to clean up trace formatKartik K. Agaram2015-05-211-47/+0
* 1299 - stop using [] in any vectorKartik K. Agaram2015-05-071-10/+10
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-0/+169
f0 } /* 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 */
# Add the first 10 numbers, and return the result in the exit code.
#
# To run:
#   $ ./subx translate init.linux examples/ex3.subx -o examples/ex3
#   $ ./subx run examples/ex3
# Expected result:
#   $ echo $?
#   55

== 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:
    # result: ebx = 0
    bb/copy-to-ebx  0/imm32
    # counter: ecx = 1
    b9/copy-to-ecx  1/imm32

$loop:
    # if (counter > 10) break
    81          7/subop/compare     3/mod/direct    1/rm32/ecx    .           .             .           .           .               0xa/imm32         # compare ecx
    7f/jump-if-greater  $exit/disp8
    # result += counter
    01/add                          3/mod/direct    3/rm32/ebx    .           .             .           1/r32/ecx   .               .                 # add ecx to ebx
    # ++counter
    41/increment-ecx
    # loop
    eb/jump  $loop/disp8

$exit:
    # exit(ebx)
    e8/call  syscall_exit/disp32

# . . vim:nowrap:textwidth=0