とてもリアルです。プロセッサに、乗算や除算などの高度な演算を実行できるALUがなかったのはそれほど昔のことではありません。
乗算は通常、シフトと加算を使用して行われます。いくつかの疑似アセンブリを次に示します。
; multiply registers a and b
; use c as high b
mov c,#0
; use d as low result
mov d,#0
; use e as high result
mov e,#0
.nextbit:
; shift low bit out of a
shr a
; skip if zero
bcc .noadd
; add b to result
add d,b
adc e,c
.noadd:
; double b
shl b
rcl c
; test a
cmp a,#0
bne .nextbit
(2バイト値を乗算した結果は2バイト値であることに注意してください。)
乗算ができたら、ループして電力を計算できます。
使用した手順:
mov x,y = move y into x
shr x = shift right one bit
shl x = shift left one bit
rcl x = rotate left one bit with carry inserted
add x,y = add y to x
adc x,y = add y to x with carry
cmp x,y = compare x to y
bcc = branch on carry clear
bne = branch on not equal
#0 = literal number zero (as opposed to 0, which would be the address zero)