IGNOU BCSL-022 Assembly Language Programming Lab, Latest Solved Assignment (July 2023 - January 2024 )

ignoustudymentor.com

Q2. Perform the following using 8086 assembly language.

(a)Write and run a program using 8086 assembly language that increments a byte valuestoredina memory location by a value 2. The result should be stored in the same memory location. For example, if a memory location contains 0101 0001, then the program will add 2 to this value and store the result 0101 0011 (after adding 2) in the same location.

Ans.

ORG 100h ; Set the origin to 100h

MOV SI, 2000h ; SI register points to the memory location where the byte is stored
MOV AL, [SI] ; Load the byte value from the memory location into AL
ADD AL, 2 ; Add 2 to AL
MOV [SI], AL ; Store the result back into the same memory location

MOV AH, 4Ch ; DOS function to exit
INT 21h         ;Call DOS

RET               ;Return to DOS

TIMES 510-($-$$) DB 0 ; Fill the rest of the boot sector with zeros
DW 0xAA55     ; Boot signature

Here’s how the program works:

ORG 100h: This sets the origin of the program to memory address 100h, which is where the program will start executing.

MOV SI, 2000h: This initializes the SI (source index) register to point to the memory location where the byte value is stored. You can replace 2000h with the actual memory address where your byte is stored.

MOV AL, [SI]: This loads the byte value from the memory location pointed to by SI into the ALregister.

ADD AL, 2: This adds 2 to the value in AL, effectively incrementing it by 2.

MOV [SI], AL: This stores the result back into the same memory location pointed to by SI, over writing the original value with the incremented value.

MOV AH, 4Ch and INT 21h: This is the DOS interrupt call to exit the program. It tells DOS that the program has finished executing.

RET: This is a return instruction, although it’s not strictly necessary in this program since it’s designed to be run as a standalone program.

The TIMES and DW directives at the end are used to fill the rest of the boot sector with zeros and add the boot signature (0xAA55) to indicate that this is a bootable program.

(b)Write and run a program using 8086 assembly language which finds the highest of four byte values stored in memory. The highest value should be left in AL register.

Ans.

ORG 100h ; Set the origin to 100h

MOV SI, 2000h ; SI register points to the memory location where the values are stored

MOV AL, [SI] ; Load the first byte value from memory into AL
MOV BL, AL ; Copy AL to BL for comparison

INC SI ; Move to the next memory location
MOV DL, [SI] ; Load the second byte value from memory into DL

CMP DL, BL ; Compare DL with BL (the current highest value)
JAE Skip1 ; Jump if DL is less than or equal to BL
MOV BL, DL ; If DL is greater, update BL with the new highest value

INC SI ; Move to the next memory location
MOV DH, [SI] ; Load the third byte value from memory into DH

CMP DH, BL ; Compare DH with BL
JAE Skip2 ; Jump if DH is less than or equal to BL
MOV BL, DH ; If DH is greater, update BL with the new highest value

INC SI ; Move to the next memory location
MOV AH, [SI] ; Load the fourth byte value from memory into AH

CMP AH, BL ; Compare AH with BL
JAE Skip3 ; Jump if AH is less than or equal to BL
MOV BL, AH ; If AH is greater, update BL with the new highest value

Skip3:
Skip2:
Skip1:
MOV AL, BL ; Copy the highest value (in BL) to AL

MOV AH, 4Ch ; DOS function to exit
INT 21h ; Call DOS

RET      ; Return to DOS

TIMES 510-($-$$) DB 0 ; Fill the rest of the boot sector with zeros
DW 0xAA55      ;Boot signature

Here’s how the program works:

Initialize SI to point to the memory location where the values are stored.

Load the first byte value from memory into AL and BL. BL is used to keep track of the highest value.

Compare the next byte value (DL) with the current highest value in BL. If DL is greater, update BL with the new highest value.

Copy the highest value in BL to AL.

The program then exits using DOS interrupt function (INT 21h).

(c) Write and run a program using 8086 assembly language that compares the values. of ALandBL registers. In case AL is more than BL, then program clears BL register otherwise it clearsALregister. You can move value '1100 1010' in AL, register and '1100 1000' in BL register, initially.

Ans.

ORG 100h ; Set the origin to 100h

MOV AL, 11001010b ; Load ‘1100 1010’ into AL register
MOV BL, 11001000b ; Load ‘1100 1000’ into BL register

CMP AL, BL ; Compare AL and BL
JA ClearBL ; Jump if AL is greater than BL
ClearAL:
XOR AL, AL ; Clear AL (set it to 0)
JMP EndProgram ; Jump to the end of the program
ClearBL:
XOR BL, BL ; Clear BL (set it to 0)

EndProgram:
MOV AH, 4Ch ; DOS function to exit
INT 21h ; Call DOS

RET        ;Return to DOS

TIMES 510-($-$$) DB 0 ; Fill the rest of the boot sector with zeros
DW 0xAA55      ;Boot signature

Here’s how the program works:

Initially, ‘1100 1010’ is loaded into the AL register, and ‘1100 1000’ is loaded into the BL register.

The program then uses the CMP (compare) instruction to compare the values in AL and BL.

If AL is greater than BL (as determined by the “JA” or “Jump if Above” condition), the program clears the BL register by XORing it with itself, effectively setting it to 0. It then jumps to the end of the program.

If AL is not greater than BL, the program clears the AL register by XORing it with itself. It then proceeds to the end of the program.

Finally, the program exits using the DOS interrupt function (INT 21h)

ignoustudymentor.com

BCSL-022

Handwriting Assignment

BCSL-022

Other Questions With Answers

Other Subjects

Click Here

Assignment Submission Last Date

The IGNOU open learning format requires students to submit study Assignments. Here is the final end date of the submission of this particular assignment according to the university calendar.

30th April (if Enrolled in the June Exams)

31st October (if Enrolled in the December Exams)

Student Quick Services

error: Content is protected !!