Sei sulla pagina 1di 5

1 The TASM Assembly program given can be used to find the largest number among the numbers entered

to an array.The Complete Source Code is given Below. print macro msg mov ah,09h mov dx,offset msg int 21h endm read macro num mov ah,01h int 21h sub al,'0' mov bh,0ah mul bh mov num,al mov ah,01h int 21h sub al,'0' add num,al endm data segment cr equ 0dh lf equ 0ah msg1 db 'Enter the limit ',cr,lf,'$' msg2 db cr,lf,'Enter the no:',cr,lf,'$' msg3 db cr,lf,'$' msg4 db cr,lf,'largest no is',cr,lf,'$' num db ? n db ? arr db 100 dup(0) larg db 8 dup('$') data ends code segment assume cs:code,ds:data start:mov ax,data mov ds,ax print msg1 read n mov ch,00h mov cl,n mov si,00h print msg2 rept1:read num mov bl,num mov arr[si],bl inc si print msg3 loop rept1 mov si,00h mov ch,00h mov cl,n-1 mov al,arr[si] rept2:inc si mov bl,arr[si] cmp bl,al jb exit mov al,bl exit:loop rept2 mov ah,00h mov si,offset larg

call hextoasc print msg4 print larg mov ah,4ch mov al,00h int 21h hextoasc proc near push ax push bx push cx push dx push si mov cx,00h mov bx,0ah rept3:mov dx,00 div bx add dl,'0' push dx inc cx cmp ax,0ah jge rept3 add al,'0' mov [si],al rept4:pop ax inc si mov [si],al loop rept4 inc si mov al,'$' mov [si],al pop si pop dx pop cx pop bx pop ax ret hextoasc endp code ends end start 2The TASM Assembly Program given below can be used to find the factorial of a nu mber.The Complete Source Code is given below.Check it out and do respond to the post if you have any doubts. readnum macro num mov ah,01h int 21h sub al,'0' mov bh,0ah mul bh mov num,al mov ah,01h int 21h sub al,'0' add num,al endm printstring macro msg mov ah,09h mov dx,offset msg int 21h endm

data segment cr equ 0dh lf equ 0ah msg1 db 'enter the number',cr,lf,'$' msg2 db 'the factorial is','$' num db ? result db 20 dup('$') data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax printstring msg1 readnum num mov ax,01h mov ch,00h mov cl,num cmp cx,00 je skip rpt1: mov dx,00 mul cx loop rpt1 skip: mov si,offset result mov bl,[si] call hex2asc printstring msg2 printstring result mov ah,4ch mov al,00h int 21h hex2asc proc near push ax push bx push cx push dx push si mov cx,00h mov bx,0ah rpt2: mov dx,00 div bx add dl,'0' push dx inc cx cmp ax,0ah jge rpt2 add al,'0' mov [si],al rpt3:pop ax inc si mov [si],al loop rpt3 inc si mov al,'$' mov [si],al pop si pop dx

pop cx pop bx pop ax ret hex2asc endp code ends end start 3 password .model small .stack 100h .data USRNM PWRD Ara ULIT E PASSACC .Code start:

DB"Enter Username:$" DB "Enter Password:$" DB 30h DB 30h DB "Username and Password did not match!$" DB"Username and Password Accepted!$"

mov ax,1h mov ds,ax ULIT2: mov ax,2h int 10h mov ah,2h mov dx,0405h int 10h mov ah,9h mov dx,offset USRNM int 21h mov ah,1h int 21h cmp al,61h int 21h cmp al,74h int 21h cmp al,75h int 21h cmp al,73h int 21h jle OK ULIT1: jne ULIT2 ERR1: mov cx,20 int 21h cmp al,1fh jle PASSWORD OK: inc Ara PASSWORD: mov ah,2h mov int mov mov int mov int cmp jne ERR2 int 21h cmp al,4fh dx,650h 10h ah,9h dx,offset PWRD 21h ah,1h 21h al,43h

jne ERR2 int 21h cmp al,41h jne ERR2 int 21h cmp al,52h jne ERR2 int 21h cmp al,43h jne ERR2 int 21h cmp al,1fh jle OK2 ERR2: mov cx,20h int 21h cmp al,1fh jle OKNBA loop ERR2 OK2: inc Ara OKNBA: cmp Ara,32h je OKNA inc ULIT mov ah,2h mov dx,080ah int 10h mov ah,9h mov dx,offset E int 21h cmp ULIT,3 jne ULIT1 mov ah,4ch int 21h ret OKNA: mov ah,2h mov dx,080ah int 10h mov ah,9h mov dx,offset PASSACC int 21h int 20h end 4 start

Potrebbero piacerti anche