“Assembly Language”, 3rd Edition by Wang Shuang
Chapter 14: Ports
Checkpoint 14.2 (Page 269)
Programming to calculate (ax) = (ax) * 10 using addition and shift instructions.
Hint: (ax) * 10 = (ax) * 2 + (ax) * 8.
===============Reference Answer Although the examples in the book use 8-bit registers, 16-bit registers can also be used. Example code:
assume cs:codecode segment start: mov bx, ax shl ax, 1 ; Shift left by 1 bit, equivalent to calculating (ax) * 2 mov cl, 3 shl bx, cl ; Shift left by 3 bits, equivalent to calculating (ax) * 2^3 add ax, bx ; (ax) = (ax) * 2 + (ax) * 8 mov ax, 4c00H int 21Hcode endsend start