Difference between revisions of "CSC103 2011 Assembly Language Examples"
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] 11:37, 15 February 2011 (EST) | --[[User:Thiebaut|D. Thiebaut]] 11:37, 15 February 2011 (EST) | ||
---- | ---- | ||
− | + | <onlydft> | |
=Program 1= | =Program 1= | ||
Line 49: | Line 49: | ||
image: data ;the image starts here | image: data ;the image starts here | ||
</pre></code> | </pre></code> | ||
+ | |||
+ | =Program #3= | ||
+ | * Add 4 numbers together. No loops. | ||
+ | |||
+ | <code><pre> | ||
+ | start: lod data1 | ||
+ | add data2 | ||
+ | add data3 | ||
+ | add data4 | ||
+ | sto sum | ||
+ | hlt | ||
+ | |||
+ | |||
+ | @14 | ||
+ | data1: 1 | ||
+ | data2: 2 | ||
+ | data3: 3 | ||
+ | data4: 4 | ||
+ | sum: data | ||
+ | </pre></code> | ||
+ | |||
+ | =Program 4= | ||
+ | * Add all the numbers between 1 and 10 in a loop | ||
+ | <code><pre> | ||
+ | start: lod count | ||
+ | add sum | ||
+ | sto sum | ||
+ | lod count | ||
+ | sub-c 1 | ||
+ | sto count | ||
+ | jmz done | ||
+ | jmp start | ||
+ | done: hlt | ||
+ | |||
+ | |||
+ | @14 | ||
+ | count: 10 | ||
+ | sum: data | ||
+ | </pre></code> | ||
+ | </onlydft> | ||
<br /> | <br /> | ||
<br /> | <br /> |