Chp#3Ex: A. JG Greater B. JL Smaller C. Ja Above D. JB Below
Chp#3Ex: A. JG Greater B. JL Smaller C. Ja Above D. JB Below
Chp#3Ex: A. JG Greater B. JL Smaller C. Ja Above D. JB Below
3. If AX=8FFF and BX=0FFF and “cmp ax, bx” is executed, which of the following
jumps will be taken? Each part is independent of others. Also give the value of Z,
S, and C flags.?
a. jg greater
b. jl smaller
c. ja above
d. jb below
Instructions Jump ZF SF CF
Jg greater Not taken 0 1 0
Jl smaller Taken 0 1 0
Ja above Taken 0 1 0
Jb below Not taken 0 1 0
Umar Asghar-70076360
CHP#3EX
3. Write a program to find the maximum number and the minimum number
from an array of ten numbers.?
[org 0x0100]
jmp start
start:
mov bx, 0
mov ax, 0
mov [min], ax
Umar Asghar-70076360
CHP#3EX
mov bx, 0
mov ax, 0
mov ax, [array1+bx]
mov cx,10
mov [max], ax
mov ax, 0x4c00
int 0x21
INCLUDE io.h
Cr EQU 0ah
Lf EQU 0dh
Umar Asghar-70076360
CHP#3EX
data SEGMENT
p_n DB cr, lf, 'Enter n: ',0
p_res DB cr, lf, 'The factorial is: ',0
tmpstr DW 40 DUP (?)
data ENDS
code SEGMENT
ASSUME cs:code, ds:data
start: mov ax, data
mov ds, ax
;input n1
output p_n
inputs tmpstr, 10
atoi tmpstr
;initialize
mov bx, ax
mov ax, 01h
;factorial iterations
n_ip: imul bx
dec bx
jnz n_ip
;output factorial
Umar Asghar-70076360
CHP#3EX
output p_res
itoa tmpstr, ax
output tmpstr
Umar Asghar-70076360
CHP#3EX
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AL, SE
LEA SI, STRING1
MOV CX, 04H
UP:
MOV BL,[SI]
CMP AL, BL
JZ FO
INC SI
DEC CX
JNZ UP
PRINT MSG2
JMP END1
FO:
PRINT MSG1
END1:
Umar Asghar-70076360
CHP#3EX
INT 3
CODE ENDS
END START
Umar Asghar-70076360