My Youtube Channel

Please Subscribe

Flag of Nepal

Built in OpenGL

Word Cloud in Python

With masked image

Showing posts with label 8086 Programming. Show all posts
Showing posts with label 8086 Programming. Show all posts

Monday, August 7, 2017

CONVERSION FROM LOWER TO UPPERCASE IN 8086 PROGRAMMING

TITLE LOWER TO UPPERCASE
.MODEL SMALL
.STACK 64
.DATA
MAXCHR DB 20
ACTCHR DB ?
ACTSTR DB 20 DUP(?)
RESULT DB 20 DUP(?)
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

MOV DX,OFFSET MAXCHR
MOV AH,0AH
INT 21H

LEA SI,ACTSTR
LEA DI,RESULT
MOV CX,0000H
MOV BX,0000H
LEA BX,ACTCHR
MOV CX,[BX]

L2:
MOV AL,[SI]
CMP AL,61H
JB L1
CMP AL,7AH
JA L1
SUB AL,20H
L1:
MOV [DI],AL
INC SI
INC DI
LOOP L2

MOV DL,0AH
MOV AH,02H
INT 21H

LEA DX,RESULT
MOV AH,09H
INT 21H

MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN

CONVERSION FROM UPPER TO LOWERCASE IN 8086 PROGRAMMING

TITLE UPPER TO LOWER CASE
.MODEL SMALL
.STACK 64
.DATA
MAXCHR DB 20
ACTCHR DB ?
ACTSTR DB 20 DUP(?)
RESULT DB 20 DUP('$')
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

MOV DX,OFFSET MAXCHR
MOV AH,0AH
INT 21H

LEA SI,ACTSTR
LEA DI,RESULT
MOV CX,0000H
MOV BX,0000H
LEA BX,ACTCHR
MOV CX,[BX]

L2:
MOV AL,[SI]
CMP AL,41H
JB L1
CMP AL,5AH
JA L1
ADD AL,20H
L1:
MOV [DI],AL
INC SI
INC DI
LOOP L2

MOV DL,0AH
MOV AH,02H
INT 21H

LEA DX,RESULT
MOV AH,09H
INT 21H

MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN

Friday, July 14, 2017

8086 Programming

How to display a string terminated by $?

TITLE DISPLAY A STRING
.MODEL SMALL
.STACK 32
.DATA
STR1 DB ".....THE KING OF JUNGLE......$"
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS,AX

MOV AH,09
MOV DX, OFFSET STR1
INT 21H

MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN

8086 programming

How to display a string using character reading function?

TITLE DISPLAY STRING USING CHARACTER READING FUNCTION
.MODEL SMALL
.STACK 32
.DATA
STR1 DB "....THE KING OF JUNGLE...."
LEN DW $-STR1
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

MOV CX,LEN
MOV AH,02
MOV BX,OFFSET STR1
L1: MOV DL,[BX]
INC BX
INT 21H
LOOP L1

MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN

8086 Programming

How to add numbers stored in consecutive memory?

TITLE ADD THE DATA OF TABLE
.MODEL SMALL
.STACK 32
.DATA

TABLE DW 1234H,4563H,7944H,1234H
SUM DW ?
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

MOV CX,04H
MOV SI,OFFSET TABLE
MOV AX,0000H
L1:ADD AX,[SI]
INC SI
INC SI
DEC CX
JNZ L1


MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN

8086 Programming

How to get string and display the string in a new line?

TITLE READ AND WRITE STRING
.MODEL SMALL
.STACK 32
.DATA
MAXCHR DB 20H
ACTCHR DB ?
STR1 DB 20 DUP('$')
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

MOV AH,0AH
MOV DX,OFFSET MAXCHR
INT 21H

MOV AH,02H
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H

MOV CL,ACTCHR
MOV CH,00H
MOV BX,OFFSET STR1
L1: MOV DL,[BX]
INC BX
INT 21H
LOOP L1

MOV AX,4C00H
INT 21H
END MAIN

8086 Programming

How to get sentence as input and display each word in new line?

TITLE MULTILINE
.MODEL SMALL
.STACK 32
.DATA
MAXCHR DB 50H
ACTCHR DB ?
STR1 DB 50 DUP(?)
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

MOV AH,0AH
MOV DX,OFFSET MAXCHR
INT 21H

MOV AH,02H
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H

MOV CL,ACTCHR
MOV CH,00H
MOV BX,OFFSET STR1
 
L1:CMP BYTE PTR [BX],20H
JNZ L2
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H
INC BX
L2:MOV DL,[BX]
INT 21H
INC BX
LOOP L1

MOV AX,4C00H
INT 21H
MAIN ENDP

END MAIN

8086 Programming

How to add two numbers?

TITLE ADD
.MODEL SMALL
.STACK 32
.DATA
VAL1 DW 1234H
VAL2 DW 4321H
SUM DW ?
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

MOV AX,VAL1
ADD AX,VAL2
MOV SUM,AX

MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN