Implement 8086 Assembly program to sort a list of number in an array
data segment
string1 db 05h, 13h, 2Ch, 63h, 58h, 50h
data ends
code segment
assume cs:code, ds:data
start:
mov ax, data
mov ds, ax
lea si, string1
; Initial setup for outer loop
mov cl, 6 ; Number of elements in string1
repeat1:
; Setup for inner loop
mov ch, cl
dec ch
repcmp1:
; Compare and swap adjacent elements if needed
mov al, [si]
inc si
cmp al, [si]
jbe next
xchg al, [si]
xchg al, [si-1]
next:
dec ch
jnz repcmp1
dec cl
jnz repeat1
hlt
code ends
end start
Implement 8086 Assembly program for performing any two 16 bit arithmetic
operations
PROGRAM FOR MULTIPLICATION:
MOV SI, 1100H
MOV AX, [SI]
MOV BX, [SI + 21
MUL BX
MOV [SI + 41,AX
MOV [SI + 61, DX
MOV SI, 1100H
MOV AX, [SI]
MOV BX, [SI + 21
MUL BX
MOV [SI + 41,AX
MOV [SI + 61, DX
HLT
DIVISION :
mov ax, data
mov ds, ax
mov si, 1100h
mov ax, [si]
mov dx, [si + 2]
mov bx, [si + 4]
div bx
mov [si + 6], ax
mov [si + 8], dx
hlt
Implement 8086 Assembly program to performing any two string Manipulation
Display the string
Program:
ASSUME CS : CODE, DS : DATA
CODE SEGMENT
MOV AX, DATA
MOV DS, AX
MOV AH, 09H
MOV DX,OFFSET MSG
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
DATA SEGMENT
MSG DB 0DH, 0AH, "WELCOME TO MICROPROCESSORS LAB", 0DH, 0AH, "$"
DATA ENDS
END
Reverse the string
Program:
ASSUME CS : CODE, DS : DATA
CODE SEGMENT
MOV AX, DATA
MOV DS, AX
MOV CL, COUNT
MOV SI, OFFSET STR1
MOV DI, COUNT - 1
BACK:MOV AL, [SI]
XCHG [DI], AL
MOV [SI], AL
INC SI
DEC DI
DEC CL
JNZ BACK
HLT
CODE ENDS
DATA SEGMENT
STR1 DB ‘MPMC$’
COUNT EQU 04H
STR2 DB DUP (0)
DATA ENDS
END
Implement 8086 Assembly program to find sum and average of an array.
MOV SI, 500
MOV DI, 600
MOV AX, 150
MOV CL, AL
MOV BL, CL
INC SI
L1: ADD AL, [SI]
ADC AH, 00
INC SI
DEC CL
JNZ L1
DIV BL
MOV [DI], AX
HLT
Implement 8086 Assembly program to control traffic lights motor
#start=Traffic_Lights.exe#
name "traffic"
mov ax, all_red
out 4, ax
mov si, offset situation
next:
mov ax, [si]
out 4, ax
; wait 1 seconds (1 million microseconds)
mov cx, 0FH ; 004C4B40h = 5,000,000
mov dx, 4240H
mov ah, 86h
int 15h
mov cx, 0FH ; 004C4B40h = 5,000,000
mov dx, 4240H
mov ah, 86h
int 15h
add si, 2 ; next situation
cmp si, sit_end
jb next
mov si, offset situation
jmp next
; FEDC_BA98_7654_3210
situation dw 0000_0011_0000_1100b
s1 dw 0000_0110_1001_1010b
s2 dw 0000_1000_0110_0001b
s3 dw 0000_1000_0110_0001b
s4 dw 0000_0100_1101_0011b
sit_end = $
all_red equ 0000_0010_0100_1001b
Implement 8086 Assembly program to control stepper motor
org 100h
#start=stepper_motor.exe#
jmp start
datain db 0000_0011b
datain db 0000_0110b
datain db 0000_1100b
datain db 0000_1001b
start:
MOV BX, offset datain
MOV SI, 0h
next_step:
wait:
IN AL, 02h
TEST AL, 10000000b
JZ wait
MOV AL, [BX][SI]
OUT 7, AL
CALL delay
INC SI
CMP SI, 4
JC next_step
MOV SI, 0
JMP next_step
ret
delay PROC
MOV DX, 0FFh
loop:
DEC DX
NOP
JNZ loop
RET
delay ENDP
END