Final Microprocessor Lab Manual 2019 Pattern
Final Microprocessor Lab Manual 2019 Pattern
INDEX
EXPERIMENT NO. 01
AIM: : Write an X86/64 ALP to accept five 64 bit Hexadecimal numbers from user and store them in
an array and display the accepted numbers.
OBJECTIVES:
ENVIRONMENT:
THEORY:
Each personal computer has a microprocessor that manages the computer's arithmetical, logical and
control activities. Each family of processors has its own set of instructions for handling various operations
like getting input from keyboard, displaying information on screen and performing various other jobs.
These set of instructions are called 'machine language instruction'. Processor understands only machine
language instructions which are strings of 1s and 0s. However machine language is too obscure and
complex for using in software development. So the low level assembly language is designed for a specific
family of processors that represents various instructions in symbolic code and a more understandable form.
Assembly language is a low-level programming language for a computer, or other programmable device
specific to particular computer architecture in contrast to most high-level programming languages, which
are generally portable across multiple systems. Assembly language is converted into executable machine
code by a utility program referred to as an assembler like NASM, MASM etc.
Installing NASM:
If you select "Development Tools" while installed Linux, you may NASM installed along with the
Linux operating system and you do not need to download and install it separately. For checking
whether you already have NASM installed, take the following steps:
Open a Linux terminal.
Type whereis nasm and press ENTER.
If it is already installed then a line like, nasm: /usr/bin/nasm appears. Otherwise, you will see
justnasm:, then you need to install NASM.
The order in which these sections fall in your program really isn’t important, but by convention the
.data section comes first, followed by the .bss section, and then the .text section.
bytes for a buffer and give the buffer a name, but you don’t say what values are to be present in the
buffer. There’s a crucial difference between data items defined in the .data section and data items
defined in the .bss section: data items in the .data section add to the size of your executable file. Data
items in the .bss section do not.
The actual machine instructions that make up your program go into the .text section. Ordinarily, no data
items are defined in .text. The .text section contains symbols called labels that identify locations in the
program code for jumps and calls, but beyond your instruction mnemonics, that’s about it.
All global labels must be declared in the .text section, or the labels cannot be ‘‘seen’’ outside your
program by the Linux linker or the Linux loader. Let’s look at the labels issue a little more closely.
Labels
A label is a sort of bookmark, describing a place in the program code and giving it a name that’s easier
to remember than a naked memory address. Labels are used to indicate the places where jump
instructions should jump to, and they give names to callable assembly language procedures.
Here are the most important things to know about labels:
Labels must begin with a letter, or else with an underscore, period, or question mark. These last
three have special meanings to the assembler, so don’t use them until you know how NASM
interprets them.
Labels must be followed by a colon when they are defined. This is basically what tells NASM
that the identifier being defined is a label. NASM will punt if no colon is there and will not flag
an error, but the colon nails it, and prevents a mistyped instruction mnemonic from being
mistaken for a label. Use the colon!
Labels are case sensitive. So yikes:, Yikes:, and YIKES: are three completely different labels.
ALGORITHM:
INPUT: ARRAY
OUTPUT: ARRAY
STEP 1: Start.
FLOWCHART:
PROGRAM:
section .data
msg1 db 10,13,"Enter 5 64 bit numbers"
len1 equ $-msg1
msg2 db 10,13,"Entered 5 64 bit numbers"
len2 equ $-msg2
section .bss
array resd 200
counter resb 1
section .text
global _start
_start:
;display
mov Rax,1
mov Rdi,1
mov Rsi,msg1
mov Rdx,len1
syscall
;accept
mov byte[counter],05
mov rbx,00
loop1:
mov rax,0 ; 0 for read
mov rdi,0 ; 0 for keyboard
mov rsi, array ;move pointer to start of array
add rsi,rbx
mov rdx,17
syscall
add rbx,17 ;to move counter
dec byte[counter]
JNZ loop1
;display
mov Rax,1
mov Rdi,1
mov Rsi,msg2
mov Rdx,len2
syscall
;display
mov byte[counter],05
mov rbx,00
loop2:
mov rax,1 ;1 for write
mov rdi, 1 ;1 for monitor
mov rsi, array
add rsi,rbx
mov rdx,17 ;16 bit +1 for enter
syscall
add rbx,17
dec byte[counter]
JNZ loop2
;exit system call
mov rax ,60
mov rdi,0
syscall
;output
;vacoea@vacoea-Pegatron:~$ cd ~/Desktop
;vacoea@vacoea-Pegatron:~/Desktop$ nasm -f elf64 ass1.asm
;vacoea@vacoea-Pegatron:~/Desktop$ ld -o ass1 ass1.o
;vacoea@vacoea-Pegatron:~/Desktop$ ./ass1
CONCLUSION:
In this practical session we learnt how to write assembly language program and Accept and display array
in assembly language.
EXP NO: 02
AIM: Write an X86/64 ALP to accept a string and to display its length.
OBJECTIVES:
ENVIRONMENT:
THEORY:
MACRO:
Procedures or subroutines are very important in assembly language, as the assembly language programs
tend to be large in size. Procedures are identified by a name. Following this name, the body of the
procedure is described which performs a well-defined job. End of the procedure is indicated by a return
statement.
Syntax
ALGORITHM:
INPUT: String
STEP 1: Start.
STEP 4: accept string from user and store it in Rsi Register (Its length gets stored in Rax register by
default).
STEP 5: Display the result using “display” procedure. Load length of string in data register.
STEP 15: Loop the statement till counter value becomes zero
STEP 16: Call macro dispmsg and pass result variable and length to it. It will print length of string.
FLOWCHART:
PROGRAM:
section .data
msg1 db 10,13,"Enter a string:"
len1 equ $-msg1
section .bss
str1 resb 200 ;string declaration
result resb 16
section .text
global _start
_start:
;display
mov Rax,1
mov Rdi,1
mov Rsi,msg1
mov Rdx,len1
syscall
;store string
mov rax,0
mov rdi,0
mov rsi,str1
mov rdx,200
syscall
call display
%macro dispmsg 2
mov Rax,1
mov Rdi,1
mov rsi,%1
mov rdx,%2
syscall
%endmacro
display:
mov rbx,rax ; store no in rbx
mov rdi,result ;point rdi to result variable
mov cx,16 ;load count of rotation in cl
up1:
rol rbx,04 ;rotate no of left by four bits
mov al,bl ; move lower byte in al
and al,0fh ;get only LSB
cmp al,09h ;compare with 39h
jg add_37 ;if greater than 39h skip add 37
add al,30h
jmp skip ;else add 30
add_37:
add al,37h
skip:
mov [rdi],al ;store ascii code in result variable
inc rdi ; point to next byte
dec cx ; decrement counter
jnz up1 ; if not zero jump to repeat
dispmsg result,16 ;call to macro
ret
OUTPUT:
CONCLUSION:
In this practical session, we learnt how to display any number on monitor. (Convesion of hex to ascii
number in ALP program).
EXP NO: 03
AIM: Write an X86/64 ALP to find the largest of given Byte/Word/Dword/64-bit numbers
OBJECTIVES:
ENVIRONMENT:
THEORY:
Datatype in 80386:
Datatypes of 80386:
The 80386 supports the following data types they are
• Bit
• Bit Field: A group of at the most 32 bits (4bytes)
• Bit String: A string of contiguous bits of maximum 4Gbytes in length.
• Signed Byte: Signed byte data
• Unsigned Byte: Unsigned byte data.
• Integer word: Signed 16-bit data.
• Long Integer: 32-bit signed data represented in 2's complement form.
• Unsigned Integer Word: Unsigned 16-bit data
• Unsigned Long Integer: Unsigned 32-bit data
• Signed Quad Word: A signed 64-bit data or four word data.
• Unsigned Quad Word: An unsigned 64-bit data.
• Offset: 16/32-bit displacement that points a memory location using any of the addressing modes.
• Pointer: This consists of a pair of 16-bit selector and 16/32-bit offset.
• Character: An ASCII equivalent to any of the alphanumeric or control characters.
• Strings: These are the sequences of bytes, words or double words. A string may contain minimum one byte and maximum 4
Gigabytes.
• BCD: Decimal digits from 0-9 represented by unpacked bytes.
• Packed BCD: This represents two packed BCD digits using a byte, i.e. from 00 to 99.
Registers in 80386:
EAX AX AH,AL
EBX BX BH,BL
ECX CX CH,CL
EDX DX DH,DL
EBP BP
EDI DI
ESI SI
ESP
ALGORITHM:
FLOWCHART:
EXP NO: 04
AIM: Write a switch case driven X86/64 ALP to perform 64-bit hexadecimal arithmetic operations (+,-
,*, /) using suitable macros. Define procedure for each operation.
OBJECTIVES:
ENVIRONMENT:
THEORY:
ALGORITHM:
FLOWCHART:
PROGRAM:
section .data
menumsg db 10,'****** Menu ******',
db 10,'1: Addition'
db 10,'2: Subtraction'
db 10,'3: Multiplication'
db 10,'4: Division'
db 10,10,'Enter your choice:: '
no1 dq 08h
no2 dq 02h
nummsg db 10
result dq 0
qmsg db 10,'Quotient::'
qmsg_len equ $-qmsg
rmsg db 10,'Remainder::'
rmsg_len equ $-rmsg
nwmsg db 10
resh dq 0
resl dq 0
section .bss
choice resb 2
dispbuff resb 16
%macro scall 4
mov rax,%1
mov rdi,%2
mov rsi,%3
mov rdx,%4
syscall
%endmacro
section .text
global _start
_start:
up:
scall 1,1,menumsg,menumsg_len
scall 0,0,choice,2
case1:cmp byte[choice],'1'
jne case2
call add_proc
jmp up
case2:
cmp byte[choice],'2'
jne case3
call sub_proc
jmp up
case3:
cmp byte[choice],'3'
jne case4
call mul_proc
jmp up
case4:
cmp byte[choice],'4'
jne caseinv
call div_proc
jmp up
caseinv:
scall 1,1, wrchmsg,wrchmsg_len
exit:
mov eax,01
mov ebx,0
int 80h
add_proc:
mov rax,[no1]
adc rax,[no2]
mov [result],rax
scall 1,1,resmsg,resmsg_len
mov rbx,[result]
call disp64num
scall 1,1,nummsg,1
ret
sub_proc:
mov rax,[no1]
subb rax,[no2]
mov [result],rax
scall 1,1,resmsg,resmsg_len
mov rbx,[result]
call disp64num
scall 1,1,nummsg,1
ret
mul_proc:
scall 1,1,mulmsg,mulmsg_len
mov rax,[no1]
mov rbx,[no2]
mul rbx
mov [resh],rdx
mov [resl],rax
scall 1,1, resmsg,resmsg_len
mov rbx,[resh]
call disp64num
mov rbx,[resl]
call disp64num
scall 1,1,nwmsg,1
ret
div_proc:
scall 1,1,divmsg,divmsg_len
mov rax,[no1]
mov rdx,0
mov rbx,[no2]
div rbx
mov [resh],rdx ;Remainder
mov [resl],rax ;Quotient
scall 1,1, rmsg,rmsg_len
mov rbx,[resh]
call disp64num
scall 1,1, qmsg,qmsg_len
mov rbx,[resl]
call disp64num
scall 1,1, nwmsg,1
ret
disp64num:
mov ecx,16
mov edi,dispbuff
dup1:
rol rbx,4
mov al,bl
and al,0fh
cmp al,09
jbe dskip
add al,07h
dskip: add al,30h
mov [edi],al
inc edi
loop dup1
scall 1,1,dispbuff,16
ret
CONCLUSION:
EXP NO: 05
AIM: Write an X86/64 ALP to count number of positive and negative numbers from the array.
OBJECTIVES:
ENVIRONMENT:
THEORY:
Mathematical numbers are generally made up of a sign and a value (magnitude) in which the sign
indicates whether the number is positive, ( + ) or negative, ( – ) with the value indicating the size of the
number, for example 23, +156 or -274. Presenting numbers is this fashion is called “sign-magnitude”
representation since the left most digit can be used to indicate the sign and the remaining digits the
magnitude or value of the number.
Sign-magnitude notation is the simplest and one of the most common methods of representing positive
and negative numbers either side of zero, (0). Thus negative numbers are obtained simply by changing
the sign of the corresponding positive number as each positive or unsigned number will have a signed
opposite, for example, +2 and -2, +10 and -10, etc.
But how do we represent signed binary numbers if all we have is a bunch of one’s and zero’s. We know
that binary digits, or bits only have two values, either a “1” or a “0” and conveniently for us, a sign also
has only two values, being a “+” or a “–“.
Then we can use a single bit to identify the sign of a signed binary number as being positive or negative
in value. So to represent a positive binary number (+n) and a negative (-n) binary number, we can use
them with the addition of a sign.
For signed binary numbers the most significant bit (MSB) is used as the sign bit. If the sign bit is “0”,
this means the number is positive in value. If the sign bit is “1”, then the number is negative in value.
The remaining bits in the number are used to represent the magnitude of the binary number in the usual
unsigned binary number format way.
Then we can see that the Sign-and-Magnitude (SM) notation stores positive and negative values by
dividing the “n” total bits into two parts: 1 bit for the sign and n–1 bits for the value which is a pure
binary number. For example, the decimal number 53 can be expressed as an 8-bit signed binary number
as follows.
ALGORITHM:
STEP 1: Initialize index register with the offset of array of signed numbers
STEP 2: Initialize ECX with array element count
STEP 3: Initialize positive number count and negative number count to zero
STEP 4: Perform MSB test of array element
STEP 5: If set jump to step 7
STEP 6: Else Increment positive number count and jump to step 8
STEP 7: Increment negative number count and continue
STEP 8: Point index register to the next element
STEP 9: Decrement the array element count from ECX, if not zero jump to step 4, else continue
STEP 10: Display Positive number message and then display positive number count
STEP 11: Display Negative number message and then display negative number count
STEP 12: EXIT
FLOWCHART:
PROGRAM:
;Write an ALP to count no. of positive and negative numbers from the array.
section .data
nwline db 10
array dw 8505h,90ffh,87h,88h,8a9fh,0adh,02h,8507h
arrcnt equ 8
pcnt db 0
ncnt db 0
section .bss
dispbuff resb 2
up1: ;label
bt word[esi],15
;bit test the array number (15th byte) pointed by esi.
;It sets the carray flag as the bit tested
jnc pnxt ;jump if no carry to label pskip
inc byte[ncnt] ;if the 15th bit is 1 it signifies it is a ;negative no and so we ;use this command to
increment ncnt counter.
jmp pskip ;unconditional jump to label skip
inc esi
loop up1 ;loop it ends as soon as the array end “count” or
exit:
mov eax,01
mov ebx,0
int 80h
disp8num:
mov ecx,2 ;move 2 in ecx ;Number digits to display
mov edi,dispbuff ;Temp buffer
dskip:
add al,30h ;Add 30h to accumulator
mov [edi],al ;Store ASCII code in temp buff (move contents ;of accumulator to the location
pointed by edi)
inc edi
;Increment destination index i.e. pointer to ;next location in temp buff
loop dup1 ;repeat till ecx becomes zero
OUTPUT:
CONCLUSION:
EXP NO: 06
AIM: Write X86/64 ALP to convert 4-digit Hex number into its equivalent BCD number and 5- digit
BCD number into its equivalent HEX number. Make your program user friendly to accept the choice
from user for: (a) HEX to BCD b) BCD to HEX (c) EXIT. Display proper strings to prompt the user
while accepting the input and displaying the
result. (Wherever necessary, use 64-bit registers).
OBJECTIVES:
ENVIRONMENT:
THEORY:
The “Hexadecimal” or simply “Hex” numbering system uses the Base of 16 system and are a popular
choice for representing long binary values because their format is quite compact and much easier to
understand compared to the long binary strings of 1’s and 0’s.
Being a Base-16 system, the hexadecimal numbering system therefore uses 16 (sixteen) different digits
with a combination of numbers from 0 to 9 and A to F.
Hexadecimal Numbers is a more complex system than using just binary or decimal and is mainly used
when dealing with computers and memory address locations.
Binary coded decimal (BCD) is a system of writing numerals that assigns a four-digit binary code to each
digit 0 through 9 in a decimal (base-10) numeral. The four-bit BCD code for any particular single base-
10 digit is its representation in binary notation, as follows:
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
Numbers larger than 9, having two or more digits in the decimal system, are expressed digit by digit.
For example, the BCD rendition of the base-10 number 1895 is
0001 1000 1001 0101
The binary equivalents of 1, 8, 9, and 5, always in a four-digit format, go from left to right.
The BCD representation of a number is not the same, in general, as its simple binary representation.
In binary form, for example, the decimal quantity 1895 appears as
11101100111
HEX to BCD
Divide FFFF by 10 this FFFF is as decimal 65535 so
Division
65535 / 10 Quotient = 6553 Reminder = 5
6553 / 10 Quotient = 655 Reminder = 3
655 / 10 Quotient = 65 Reminder = 5
65 / 10 Quotient = 6 Reminder = 5
6 / 10 Quotient = 0 Reminder = 6
and we are pushing Reminder on stack and then printing it in reverse order.
BCD to HEX
1 LOOP : DL = 06 ; RAX = RAX * RBX = 0 ; RAX = RAX + RDX = 06
2 LOOP : DL = 05 ; 60 = 06 * 10 ; 65 = 60 + 5
3 LOOP : DL = 05 ; 650 = 60 * 10 ; 655 = 650 + 5
4 LOOP : DL = 03 ; 6550 = 655 * 10 ; 6553 = 6550 + 3
5 LOOP : DL = 06 ; 65530 = 6553 * 10 ; 65535 = 65530 + 5
Hence final result is in RAX = 65535 which is 1111 1111 1111 1111 and when we print this it is
represented as FFFF.
ALGORITHM:
STEP 1: Start
FLOWCHART:
PROGRAM
section .data
msg1 db 10,10,'###### Menu for Code Conversion ######'
db 10,'1: Hex to BCD'
db 10,'2: BCD to Hex'
db 10,'3: Exit'
db 10,10,'Enter Choice:'
section .bss
arr resb 06 ;common buffer for choice, hex and bcd input
dispbuff resb 08
ans resb 01
%macro disp 2
mov rax,01
mov rdi,01
mov rsi,%1
mov rdx,%2
syscall
%endmacro
%macro accept 2
mov rax,0
mov rdi,0
mov rsi,%1
mov rdx,%2
syscall
%endmacro
section .text
global _start
_start:
menu:
disp msg1,msg1length
accept arr,2 ; choice either 1,2,3 + enter
jne l1
call hex2bcd_proc
jmp menu
exit:
mov rax,60
mov rbx,0
syscall
hex2bcd_proc:
disp msg2,msg2length
accept arr,5 ; 4 digits + enter
call conversion
mov rcx,0
mov ax,bx
mov bx,10 ;Base of Decimal No. system
l33: mov dx,0
div bx ; Divide the no by 10
push rdx ; Push the remainder on stack
inc rcx
inc byte[cnt]
cmp ax,0
jne l33
disp msg3,msg3length
l44: pop rdx ; pop the last pushed remainder from stack
add dl,30h ; convert it to ascii
mov [ans],dl
disp ans,1
dec byte[cnt]
jnz l44
ret
bcd2hex_proc:
disp msg4,msg4length
accept arr,6 ; 5 digits + 1 for enter
disp msg6,msg6length
mov rsi,arr
mov rcx,05
mov rax,0
mov ebx,0ah
conversion:
mov bx,0
mov ecx,04
mov esi,arr
up1:
rol bx,04
mov al,[esi]
cmp al,39h
jbe l22
sub al,07h
l22: sub al,30h
add bl,al
inc esi
loop up1
ret
; the below procedure is to display 32 bit result in ebx why 32 bit & not 16 ;bit; because 5 digit bcd no ranges
between 00000 to 99999 & for ;65535 ans ;is FFFF
; i.e if u enter the no between 00000-65535 u are getting the answer between
;0000-FFFF, but u enter i/p as 99999 urans is greater than 16 bit which is ;not; fitted in 16 bit register so 32 bit
register is taken frresult
disp32_num:
mov rdi,dispbuff
mov rcx,08 ; since no is 32 bit,no of digits 8
l77:
rol ebx,4
mov dl,bl
and dl,0fh
add dl,30h
cmp dl,39h
jbe l66
add dl,07h
l66:
mov [rdi],dl
inc rdi
dec rcx
jnz l77
disp dispbuff+3,5 ;Dispays only lower 5 digits as upper three are '0'
ret
;OUTPUT OF PROGRAM
;Enter Choice:1
;BCD Equivalent::65535
;Enter Choice:1
;BCD Equivalent::255
;Enter Choice:1
;BCD Equivalent::15
;Enter Choice:2
;Hex Equivalent::0FFFF
;Enter Choice:2
;Hex Equivalent::000FF
CONCLUSION:
Experiment No – 7
Write X86/64 ALP to detect protected mode and display the values of GDTR, LDTR, IDTR, TR
and MSW Registers.
Theory:
Real Mode: Real mode, also called real address mode, is an operating mode of all x86-
compatible CPUs. Real mode is characterized by a 20-bit segmented memory address space
(giving exactly 1 MiB of addressable memory) and unlimited direct software access to all
addressable memory, I/O addresses and peripheral hardware. Real mode provides no support
for memory protection, multitasking, or code privilege levels.
Protected Mode: In computing, protected mode, also called protected virtual address mode is
an operational mode of x86-compatible central processing units (CPUs). It allows system
software to use features such as virtual memory, paging and safe multi-tasking designed to
increase an operating system's control over application software. When a processor that
supports x86 protected mode is powered on, it begins executing instructions in real mode, in
order to maintain backward compatibility with earlier x86 processors. Protected mode may
only be entered after the system software sets up several descriptor tables and enables the
Protection Enable (PE) bit in the control register 0 (CR0).
Global Descriptor Table Register This register holds the 32-bit base address and 16-bit segment
limit for the global descriptor table (GDT). When a reference is made to data in memory, a
segment selector is used to find a segment descriptor in the GDT or LDT. A segment descriptor
contains the base address for a segment.
Local Descriptor Table Register This register holds the 32-bit base address, 16-bit segment
limit, and 16-bit segment selector for the local descriptor table (LDT). The segment which
contains the LDT has a segment descriptor in the GDT. There is no segment descriptor for the
GDT. When a reference is made to data in memory, a segment selector is used to find a
segment descriptor in the GDT or LDT. A segment descriptor contains the base address for a
segment
Interrupt Descriptor Table Register This register holds the 32-bit base address and 16-bit
segment limit for the interrupt descriptor table (IDT). When an interrupt occurs, the interrupt
vector is used as an index to get a gate descriptor from this table. The gate descriptor contains
a far pointer used to start up the interrupt handler.
Algorithm :
1. Start
3. Read CR0
Write X86/64 ALP to perform non-overlapped transfer (with and without string specific
instructions). Block containing data can be defined in the data segment.
Theory :
Consider that a block of data of N bytes is present at source location. Now this block of
N bytes is to be moved from source location to a destination location.
We will have to initialize this as count.
Let the number of bytes N = 05.
We know that source address is in the ESI register and destination address is in the EDI
register.
For block transfer without string instruction, move contents at ESI to accumulator and
from accumulator to memory location of EDI and increment ESI and EDI for next content
transfer.
For block transfer with string instruction, clear the direction flag. Move the data from
source location to the destination location using string instruction.
Algorithm:
1. Start
4. Using Macro display the Menu for block transfer without string instruction, block transfer
with string instruction and exit.
Algorithm for procedure for non overlapped block transfer with string instruction:
4. Move the contents from source location to the destination location using string instruction.
5. Repeat string instruction the number of times indicated in the count register.
Algorithm for procedure for non overlapped block transfer without string instruction:
3. Move contents at ESI to accumulator and from accumulator to memory location of EDI.
Experiment no -10
Write X86/64 ALP to perform multiplication of two 8-bit hexadecimal numbers. Use successive
addition and add and shift method. Accept input from the user. (use of 64-bit registers is
expected)
THEORY:
A)Multiplication of two numbers using successive addition method: Historically, computers used
a "shift and add" algorithm for multiplying small integers. Both base 2 long multiplication and base 2
peasant multiplications reduce to this same algorithm. In base 2, multiplying by the single digit of the
multiplier reduces to a simple series of logical AND operations. Each partial product is added to a
running sum as soon as each partial product is computed. Most currently available microprocessors
implement this or other similar algorithms (such as Booth encoding) for various integer and floating-
point sizes in hardware multipliers or in microcode. On currently available processors, a bit-wise shift
instruction is faster than a multiply instruction and can be used to multiply (shift left) and divide (shift
right) by powers of two. Multiplication by a constant and division by a constant can be implemented
using a sequence of shifts and adds or subtracts.
For example, there are several ways to multiply by 10 using only bit-shift and addition.
In some cases such sequences of shifts and adds or subtracts will outperform hardware multipliers and
especially dividers. A division by a number of the form 2 n or 2 n ±1 often can be converted to such a
short sequence. These types of sequences have to always be used for computers that do not have a
"multiply" instruction,[4] and can also be used by extension to floating point numbers if one replaces
the shifts with computation of 2*x as x+x, as these are logically equivalent.
Step IX : Stop.
B)Multiply Two 8 Bit Numbers using Add and Shift Method: Program should take first and second
numbers as input to the program. Now it should implement certain logic to multiply 8 bit Numbers using
Add and Shift Method. Consider that one byte is present in the AL register and another byte is present in
the BL register. We have to multiply the byte in AL with the byte in BL.
Algorithm to Multiply Two 8 Bit Numbers using Add and Shift Method:
Step VII : Check for carry, if present go to step VIII else go to step IX.