RotateLeft3 is an assembly function that rotates an 8-bit character passed to it 3 places to the left. It uses the ROL instruction to rotate the AL register which contains the passed character. The function is defined as public to be callable from C++ code.
Write a short assembly language module to be used with C++ that rotate.docx
1. Write a short assembly language module to be used with C++ that rotates a number three places
to the left . It needs to be called RotateLeft3 and assume the number is an 8 bit char. Write this
function in C++ without the assembler.
Solution
;External function rotates a byte 3 places
left
;
.586 ;select Pentium and 32-
bit model
.model flat, C ;select flat model with
C/C++ linkage
.stack 1024 ;allocate stack space
.code ;start code segment
public RotateLeft3 ;define RotateLeft3 as a
public function
RotateLeft3 proc ;define procedure
Rotatedata:byte ;define byte
mov al,Rotatedata
rol al,3