0% found this document useful (0 votes)
12 views5 pages

Assignment 4 COAL

It is the fourth assignment of coal

Uploaded by

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

Assignment 4 COAL

It is the fourth assignment of coal

Uploaded by

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

Assignment no.

04
(Computer Organization & Assembly Language)

Total Points: 40
Submission Date: 11 Jan, 2025
Assignment Type: Hard Copy (Code with output performed at VS code)

Question no. 01 (Marks: 10)


Given the initial values of registers and variables, find the status of the registers and variables
after the execution.
a.) Initial values of registers:
AX= 4040 BX= 01234 CX= 0003 DX= 0002
BP= 0000 SI= 0000 DI= 0000 SP= 0000
ZF= 0 SF= 0 DF= 0 CF= 0
.DATA (starts at 073F:0020 h)
STR1 DB “ABCDE$”
STR2 DB “FGHIJ$”
. CODE
.
.
CLD
SCASB
.
.
Values after execution of given instruction:
AX= BX= CX= DX=
BP= SI= DI= SP=
ZF= SF= DF= CF=

b.) Initial values of registers:


AX= 00FB BX= FFFF CX= 0003 DX= 0002
BP= 0000 SI= 0000 DI= 0000 SP= 0000
ZF= 0 SF= 0 DF= 0 CF= 0

.DATA (starts at 073F:0020 h)


. CODE
.
.
DIV BL
.
.
Values after execution of given instruction:
AX= BX= CX= DX=
BP= SI= DI= SP=
ZF= SF= DF= CF=

c.) Initial values of registers:


AX= 0ABC BX= ABCD CX= DC03 DX= 0002
BP= 0000 SI= 0000 DI= 0000 SP= 0000
ZF= 1 SF= 1 DF= 1 CF= 0
.DATA (starts at 073F:0020 h)
. CODE
.
.
SAR BX, CL
.
.
Values after execution of given instruction:
AX= BX= CX= DX=
BP= SI= DI= SP=
ZF= SF= DF= CF=

d.) Write a program to draw the box of 20x40 dimension. (Note: Your only task is to set the
dimension. Forget about the other parameters. )
Question # 1: (12 Marks)
Write an assembly language program to concatenate the two strings. You need to write two
procedures, first one is STRIN and the other one is STRCONC. Main program should print the
output as given in the box.
STRIN: Procedure must have initial address of string as the input. Then Ask the user to input
the string of characters terminated by “Enter” key. Save the string at the specified address in
memory.
STRCONC: Procedure must have initial addresses of three strings in AX, BX, and DX. Where
AX and BX represent the addresses of two source strings and DX represent the address of
concatenated string.

Question # 2: (8 marks)
For the given code and its relevant data, find the asked values in the table.
.MODEL SMALL @NEXT:
.STACK 100H LOOP @LOOP

.DATA MOV CX, AX


PROMPT_1 DB 'Enter the 16-
charcter(0/1) input : $' LEA DX, PROMPT_2
PROMPT_2 DB 0DH,0AH,'The output MOV AH, 9
value : $' INT 21H

.CODE MOV AH, 2


MAIN PROC CMP CL, 10
MOV AX, @DATA
MOV DS, AX JAE @LABEL1

LEA DX, PROMPT_1 OR CL, 30H


MOV AH, 9 MOV DL, CL
INT 21H
JMP @DISPLAY
XOR BX, BX
MOV CX, 16 @LABEL1:
MOV AH, 1 MOV DL, 31H
INT 21H
@LOOP1:
INT 21H SUB CL, 10
CMP AL, 0DH OR CL, 30H
JE @END MOV DL, CL
AND AL, 0FH
SHL BX, 1 @DISPLAY:
OR BL, AL INT 21H
LOOP @LOOP1
MOV AH, 4CH
@END: INT 21H
MAIN ENDP
MOV CX, 16 END MAIN
XOR AX, AX

@LOOP:
ROL BX, 1
JNC @NEXT
INC AX
Question # 3: (8
marks)
For given program, write the output and fill the asked values of registers in the given boxes.

.MODEL SMALL
.STACK 100H
.DATA
VAR1 DW 45H, 56H, 67H,
Write values after the execution.
78H, 89H, 90H

.CODE
AX BX CX DX SP
MOV AX,@DATA
MOV DS,AX 0000 0000 0000

1234 0000 0000 0100


MOV AX,1234H
1234 3456 0000 0100
MOV BX,3456H
1234 3456 5678 0100
MOV CX,5678H

MOV DX,7890H
AX BX CX DX SP
CALL UNKNOWN Will not be executed as CALL returns to 1234 address.
Address is not the same as was expected. POP one more
MOV AH,4CH element from the stack.

INT 21H Fill loop portion for the last iteration.


AX BX CX DX SP
MAIN ENDP 1234 3456 5678 7890

UNKNOWN PROC 1234 3456 5678 7890


PUSH AX 1234 3456 5678 7890
PUSH BX 1234 3456 5678 7890
PUSH CX 0004
PUSH DX
MOV CX,04 45 3456 0001 7845 00F6
@LOOP: 0245 3456 0001 78 00F6
MOV AH,02 0245 3456 0001 7845
MOV DL,BYTE PTR 0245 3456 7845 00F6
VAR1 3456 0000
INT 21H 7890 0000 7845
LOOP @LOOP 7890 5678 3456 7845 00FC
POP AX
POP BX
POP CX
RET
UNKNOWN ENDP
END MAIN

You might also like