about summary refs log tree commit diff stats
path: root/apps/factorial2.subx
Commit message (Collapse)AuthorAgeFilesLines
* 7032Kartik Agaram2020-10-141-49/+51
|
* 6507 - use syscall names everywhereKartik Agaram2020-06-101-2/+1
|
* 6089Kartik Agaram2020-03-061-2/+2
|
* 5924Kartik Agaram2020-01-271-3/+3
|
* 5897 - rename comparison instructionsKartik Agaram2020-01-161-2/+2
| | | | | | | Signed and unsigned don't quite capture the essence of what the different combinations of x86 flags are doing for SubX. The crucial distinction is that one set of comparison operators is for integers and the second is for addresses.
* 5880Kartik Agaram2020-01-101-1/+1
|
* 5809Kartik Agaram2019-12-091-4/+4
|
* 5782 - fix a widespread bug with Heap-sizeKartik Agaram2019-11-301-1/+1
|
* 5707Kartik Agaram2019-10-191-0/+3
|
* 5706 - example at different levels of syntax sugarKartik Agaram2019-10-191-0/+115
Thanks Mateusz Czapliński for the feedback: https://lobste.rs/s/xtxlec/mu_minimal_hobbyist_computing_stack#c_1mzq94
#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 */
# Multiply 2 numbers.
#
# To run:
#   $ ./bootstrap translate init.linux apps/ex14.subx -o apps/ex14
#   $ ./bootstrap run apps/ex14
# Expected result:
#   $ echo $?
#   6

== 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:
    b8/copy-to-eax  1/imm32
    b9/copy-to-ecx  2/imm32
    bb/copy-to-ebx  3/imm32

    69/multiply                     3/mod/direct    1/rm32/ecx    .           .             .           3/r32/ebx                   3/imm32           # ebx = ecx * 3

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

# . . vim:nowrap:textwidth=0