Skip to content

Example Code

Nathan Pennie edited this page Mar 30, 2019 · 1 revision

LearnASM Examples

This is just a collection of examples that I have lying around. If you have any others, feel free to add them.

Degrees C to F converter

mov r0, #-5 ; The input in degrees C

smul r0, r0, #18 ; These two instructions multiply by 1.8...
sdiv r0, r0, #10 ; ... this allows me to use decimals without floating point types
add r0, r0, #32  ; Apply the 32 degree offset for the freezing temp

halt ; r0 is now in degrees Fahrenheit
Clone this wiki locally