# CSE 322 Lab 3

February 12, 2018

#### Problem#1

Write an assembly code to display a 11*11 hollow box of stars

//Solution

```.MODEL SMALL
.STACK 100H
.DATA ;
CR EQU 0DH ;
LF EQU 0AH ;

MSG db '***********', cr, lf, '\$'
MSG2 db '* *', cr, lf, '\$'

.CODE ;

MAIN PROC ;MAIN PROCEDURE ; CODE SEGMENT
MOV AX,@DATA ;
MOV DS, AX ;

LEA DX, MSG
MOV ah,9
INT 21h
LEA DX, MSG2
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
LEA DX, MSG
INT 21h

; MOV AH, 4CH ;Exit code
; INT 21H
MAIN ENDP

END MAIN```

#### Problem#2

Write· a program to read one of the hex digits A-F, and display it on the next line in decimal.
Sample execution:
EnTER A HEX DIGIT: C
IN DECIMAL IT IS 12
//Solution

```.MODEL SMALL
.STACK 100H
.DATA ;
CR EQU 0DH ; Data segment
LF EQU 0AH ;

MSG db 'Enter A HEX DIGIT(A-F): \$'
MSG2 DB CR, LF, 'IN DECIMAL IT IS: \$'

.CODE ;

MAIN PROC ;MAIN PROCEDURE ; CODE SEGMENT
MOV AX,@DATA ;
MOV DS, AX ;

LEA DX, MSG
MOV ah,9
INT 21h

MOV AH, 1
INT 21h
MOV BL,AL

LEA DX, MSG2
MOV ah,9
INT 21h

MOV AH, 2
MOV DL, '1'
INT 21H

SUB BL,'A'
MOV DL,BL
INT 21H

MOV AH, 4CH ;Exit code
INT 21H
MAIN ENDP

END MAIN```

#### Problem#3 (Eg 6.1)

Write a code to find the greater signed number of the numbers stored in AX and BX

//Solution

```top:
mov ah, 1
int 21h
mov bl, al

mov ah, 1
int 21h
mov bh, al

mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h

cmp bl, bh
jg label1
jl label2
je label3

label1:
mov ah, 2
mov dl, '>'
int 21h
jmp end

label2:
mov ah, 2
mov dl, '<'
int 21h
jmp end

label3:
mov ah, 2
mov dl, '='
int 21h
jmp end

end:
mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h

jmp top```

#### Problem #4

Print 80 star using condition

//Solution

```mov cx, 10
point1:
mov ah, 2
mov dl, '*'
int 21h
loop point1
mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h

mov bl, 10
point2:
mov ah, 2
mov dl, '*'
int 21h
dec bl
cmp bl, 0
jne point2

mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h

mov bl,0
mov bh, 80
point3:
mov ah, 2
mov dl, '*'
int 21h
inc bl
cmp bl, bh
jne point3
```

#### Problem #5

Replace a number with absolute number
//Solution

```mov ah, -100

cmp ah, 0
jl point1
jmp end

point1:
neg ah

end:
```

#### Problem #6

Suppose AL and BL contain extended ASCII characters. Display the one that comes first in the character sequence.

//Solution

```mov ah, 1
int 21h
mov bh, al

int 21h
mov bl, al

mov ah, 2
cmp bl, bh
jae printbl

mov dl, bl

jmp print

printbl:

mov dl, bh

print:
int 21h
```