Compile-time calculation: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 123: | Line 123: | ||
LEA tenfactorial,A1 ;load into A1 the memory address 10! = 0x375F00 |
LEA tenfactorial,A1 ;load into A1 the memory address 10! = 0x375F00 |
||
ADD.L #tenfactorial,D2 ;add 10! to whatever is stored in D2 and store the result in D2</lang> |
ADD.L #tenfactorial,D2 ;add 10! to whatever is stored in D2 and store the result in D2</lang> |
||
=={{header|8086 Assembly}}== |
|||
Since 10! is bigger than 16 bits, I'll use 8! instead to demonstrate. Most assemblers only support the standard C operators for compile-time calculation, so we're going to need to multiply out the factorial manually. |
|||
<lang asm>mov ax,8*7*6*5*4*3*2 ;8! equals 40,320 or 0x9D80 |
|||
call Monitor ;unimplemented routine, displays the register contents to screen</lang> |
|||
{{out}} |
|||
<pre>ax:9D80</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |