Anda di halaman 1dari 11

;PROGRAM THAT DISPLAYS ASCII CHARACTER SET: STANDARD AND EXTENDED ASCII CHARACTERS

.model medium .stack AscInfo segment LastAsc equ 255d AScCount equ 256d SAscCount equ 128d EAscCount equ 128d NewLine equ 10d Space equ 255d msg1 db 'Below is the full ascii character set in its two categories: $' msg2 db '(1) Standard ascii characters: $ ' msg3 db '(2) Extended ascii characters: $' AscInfo ends AscCoding segment assume cs: AScCoding ,ds :AscInfo org 100h start: mov ax, AscInfo mov dx, ax lea dx,msg1 mov ah, 09h int 21h mov dl , LastAsc mov cx, AScCount StoreASc: push dx dec dl loop StoreAsc mov dl, Newline mov ah, 02h int 21h lea dx, msg2 mov ah, 09h int 21h mov ah,02h mov cx,SAscCount OutSAsc: pop dx int 21h mov dl,Space int 21h loop OutSAsc mov ah, 02h mov dl, Newline int 21h lea dx, msg3 mov ah, 09h int 21h mov ah, 02h mov cx,EAscCount OutEAsc: pop dx int 21h mov dl,Space int 21h loop OutEAsc mov ah, 04ch int 21h AscCoding ends end start

Sorting numbers in ascending oreder (signed) using 8086 in assembly language


assume cs:code,ds:data data segment org 2000h series db 81h,82h,93h,95h,10h,56h,33h,99h,13h,44h count dw 10d data ends code segment start:mov ax,data mov ds,ax mov dx,count dec dx go:mov cx,dx lea si,series nxt_byte:mov al,[si] cmp al,[si+1] jl next xchg al,[si+1] xchg al,[si] next:inc si loop nxt_byte dec dx jnz go mov ah,4ch int 21h code ends end start

Program to sort numbers in ascending order using 8086 (unsigned numbers)


assume cs:code,ds:data data segment org 2000h series db 81h,82h,93h,95h,10h,56h,33h,99h,13h,44h count dw 10d data ends code segment start:mov ax,data mov ds,ax mov dx,count dec dx go:mov cx,dx lea si,series nxt_byte:mov al,[si] cmp al,[si+1] jb next xchg al,[si+1] xchg al,[si] next:inc si loop nxt_byte dec dx jnz go mov ah,4ch int 21h code ends end start

Following is the Assembly language program for a real time clock

LCALL 061D AGAIN MOV DPTR, #2845 REPEAT DEC82 ; Decrement DPL MOVX A,@DPTR MOV R3,A MOV R5,#02 LCALL 059E MOV A,20 LCALL 2006 MOVA,82 CJNE A,#42; REPEAT (ED) MOVA,#OD ; OD = ASCII FOR ENTER LCALL 2006 LJMP; AGAIN ( 6003 ) To change the RTC 2844-hrs 2843-minutes 2842-seconds

WAVEFORM GENERATING PROGRAM


Aim : Program for Digital to Analog conversion Apparatus : 8086 Microprocessor kit with D/A converter Module. MOVW DX #CMD55 MOVB AL #MODE OUTB DX MOVB AL #00H LOOP: MOVW DX, #PORTA OUTB DX MOVW DX, #PORTB OUTB DX INCW AX JMP LOOP OPCODE: 8000 BA E7 FF BO 80 EE BO 00 BA 00 BA E1 FF EE BAA E3 FF EE 40 EB F5

12. BCD ADDITION 2 nos


Aim : Program to implement BCD Addition Apparatus : PC with masm Software data segment v1 dw 0009h v2 dw 0008h total dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,v1 add ax,v2 daa int 3 code ends end start

8 bit unpacked bcd addition


data segment a db 07h b db 03h c db ? data ends code segment assume cs:code,ds:data start:mov ax,data mov ds,ax mov ax,0000h mov al,a add al,b mov c,al aaa int 3h code ends end start

8 bit packed bcd addition


data segment a db 45h b db 55h data ends code segment assume cs:code,ds:data start:mov ax,data mov ds,ax mov ax,0000h mov al,a add al,b daa int 3h code ends end start

8086 ASSEMBLY PROGRAM TO SEARCH A CHARACTER IN A ENTERED STRING


DATA SEGMENT MSG1 DB 10,13,'CHARACTER FOUND :) $' MSG2 DB 10,13,'CHARACTER NOT FOUND :($' MSG3 DB 10,13,'ENTER THE STRING : $' MSG4 DB 10,13,'ENTER THE CHARACTER TO BE SEARCHED : $' NEW DB 10,13,'$' INST DB 10 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX LEA DX,MSG3 MOV AH,09H INT 21H MOV BX,00 UP: MOV AH,01H INT 21H CMP AL,0DH JE DOWN MOV [INST+BX],AL INC BX JMP UP DOWN:LEA DX,NEW MOV AH,09H INT 21H LEA DX,MSG4 MOV AH,09H INT 21H MOV AH,01H INT 21H MOV CX,BX MOV DI,0 UP1: CMP AL,[INST+DI] JE DOWN1 INC DI LOOP UP1 LEA DX,MSG2 MOV AH,09H INT 21H JMP FINISH DOWN1: LEA DX,MSG1 MOV AH,09H INT 21H FINISH: INT 3 CODE ENDS END START END

Pack 2 unpacked BCD nos= ACCII to BCD


.model small .data a db 09H b db 02H .code mov ax,@data ; Initialize data section mov ds,ax mov al,a ; Load number1 in al mov bl,b ; Load number2 in bl rcl al,4 ; rotate first number 4 times to make it 90h add al,bl ; add numbers and result in al mov ch,02h ; Count of digits to be displayed mov cl,04h ; Count to roll by 4 bits mov bh,al ; Result in reg bh l2: rol bh,cl ; roll bl so that msb comes to lsb mov dl,bh ; load dl with data to be displayed and dl,0fH ; get only lsb cmp dl,09 ; check if digit is 0-9 or letter A-F jbe l4 add dl,07 ; if letter add 37H else only add 30H l4: add dl,30H mov ah,02 ; Function 2 under INT 21H (Display character) int 21H dec ch ; Decrement Count jnz l2 mov ah,4cH ; Terminate Program int 21H end

Unpack 2 packed BCD nos= BCD to ASCII


.model small .data a db 92H .code mov ax, @data ; Initialize data section mov ds, ax mov al, a ; Load number1 in al and al, 0f0h ; mask lower nibble rcr al, 4 ; rotate it 4 times to right to make it 09h mov bh, al ; store result in bh call disp ; display the upper nibble mov al, a ; Load number1 in al and al, 0fh ; mask upper nibble mov bh, al ; store result in bh call disp ; display the lower nibble mov ah, 4cH ; Terminate Program int 21H disp proc near mov ch, 02h ; Count of digits to be displayed mov cl, 04h ; Count to roll by 4 bits l2: rol bh, cl ; roll bl so that msb comes to lsb mov dl, bh ; load dl with data to be displayed and l, 0fH ; get only lsb cmp dl, 09 ; check if digit is 0-9 or letter A-F jbe l4 add dl, 07 ; if letter add 37H else only add 30H l4: add dl, 30H mov ah, 02 ; Function 2 under INT 21H (Display character) int 21H dec ch ; Decrement Count jnz l2 mov ah, 02h mov dl, ' ' int 21h endp ret end

Anda mungkin juga menyukai