0% found this document useful (0 votes)
15 views4 pages

Machine Learning

Uploaded by

umarmustafa32100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Machine Learning

Uploaded by

umarmustafa32100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assembly language

 Q No 1: Difference Between Little Endian and Big Endian

 Little Endian: The least significant byte (LSB) is stored first (at the lowest
memory address). For example, if we have the hex value 1234, it would
be stored in memory as 34 12.

 Big Endian: The most significant byte (MSB) is stored first. The hex value
1234 would be stored in memory as 12 34.

 Conversion to Little Endian:

 1. 1234 → Stored as 34 12

 2. ABFC → Stored as FC AB

 3. B100 → Stored as 00 B1
 4. B800 → Stored as 00 B8

 Q No 2: Difference Between Instruction Mnemonic and Opcode

 Mnemonic: A human-readable name for an instruction in assembly


language, such as MOV, ADD, or SUB.

 Opcode: The binary or hexadecimal representation of the instruction


that the computer’s CPU executes.

 Examples:

 MOV (move data) → Opcode could be 0x89

 ADD (add values) → Opcode could be 0x01

 JMP (jump to a different part of the program) → Opcode could be 0xEB

 Q No 3: Assembly Program to Calculate Square of 6 by Adding Six to the


Accumulator Six Times

 Here’s a simple assembly program for this:

2
 MOV CX, 6 ; Set loop counter to 6
 MOV AX, 0 ; Initialize AX (accumulator) to 0
 ADD_LOOP:
 ADD AX, 6 ; Add 6 to AX
 LOOP ADD_LOOP ; Decrease CX by 1 and repeat if CX != 0

 Q No 4: Assembly Program to Calculate Square of 6 Using a (for) Loop

 MOV CX, 6 ; Set loop counter to 6


 MOV AX, 0 ; Initialize AX (accumulator) to 0
 FOR_LOOP:
 ADD AX, 6 ; Add 6 to AX
 LOOP FOR_LOOP ; Decrease CX by 1 and repeat if CX != 0

 Q No 5: Swap Contents of AX and BX Without Extra Memory

 Here’s how you can swap the contents using mathematical operations:

 MOV AX, 5 ; Initialize AX with 5


 MOV BX, 10 ; Initialize BX with 10

 ; Swapping using addition and subtraction
 ADD AX, BX ; AX = AX + BX
 SUB BX, AX ; BX = AX – BX (BX now holds the value of AX)
 SUB BX, BX ; AX = AX – BX (AX now holds the value of BX)

3

 Q No 6: Assembly Program to Find the Maximum Element in an Array of
Ten Numbers

 MOV SI, OFFSET ARRAY ; Point SI to the start of the array
 MOV CX, 10 ; Set counter to 10 (number of elements)
 MOV AX, [SI] ; Assume the first element is the max

 FIND_MAX:
 ADD SI, 2 ; Move to the next element
 CMP AX, [SI] ; Compare AX with the current element
 JG NEXT_ELEMENT ; If AX > [SI], go to next element
 MOV AX, [SI] ; Otherwise, set AX to the current element

 NEXT_ELEMENT:
 LOOP FIND_MAX ; Decrease CX by 1 and repeat if CX != 0

 ; AX now holds the maximum value

 If you need further explanations or modifications for any part, let me
know!

You might also like