# CSE 506 Lab 6

August 23, 2017
By shp

Practise #1 (Example 6.4)
If AX contains a negative number, put -1 In BX; if AX contains 0, put O In BX; if AX contains a positive number, put 1 In BX.·

```mov ax,0FFFBh
CMP AX,0
JL NEGATIVE
JE ZERO
JG POSITIVE
NEGATIVE:
MOV BX,-1
JMP END_CASE
ZERO:
MOV BX,0
JMP END_CASEPOSITIVE:
MOV BX,1
JMP END_CASE
END_CASE:
MOV AX,4CH
INT 21h
MAIN ENDP
END MAIN```

Practise #2 (example 6.5)
If AL contains I or 3, display “o”; if AL contains 2 or 4, Display “e”.

```CMP AL,1
JE ODD
CMP AL,3
JE ODD
CMP AL,2
JE EVEN
CMP AL,4
JE EVEN
ODD:
MOV DL,'o'
JMP DISPLAY
EVEN:
MOV DL,'e'
JMP DISPLAY:
DISPLAY:
MOV AH,2
INT 21h```

Practise #3 (example 6.6)
Read a character and if it is uppercase display it

``` MOV AH,1
INT 21H
CMP AL,'A'
JNGE NOT
CMP AL,'Z'
JNLE NOT
MOV DL,AL
MOV AH,2
INT 21h
NOT:```

Practise #4 (example 6.7)
Read a character. If it’s “y” or “Y”, display it; otherwise, terminate the program.

```MOV AH,1
INT 21H
CMP AL,'y'
JE THEN
CMP AL,'Y'
JE THEN
JMP ELSE
THEN:
MOV AH,2
MOV DL,AL
INT 21H
JMP EXIT
ELSE:
JMP EXIT
EXIT:```

Practise #5 (Example 6.9)
Write some code to count the number of characters In a input line.

```MOV DX,0
MOV AH,l
INT 21H
WHILE:
CMP ·AL, OOH ;CR?
JE END_WHILE ;yes, exit
INC DX ;not CR, increment count
JMP WHILE ;loop back;
END_WHILE:```

Problem #1
Write a program to display a “?”, read two capital letters, and dis-play them on the next line In alphabetical order.

Practise #6 (Example 6.10)
```MOV AH,l