tag:blogger.com,1999:blog-86251351724733129252024-03-08T01:38:20.161-08:008086 MICROSOFT MACRO ASSEMBLER(MASM) PROGRAMS8086 MASM IMPORTANT QUESTIONS AND PROGRAMS FOR ENGINEERS AND STUDENTSQuiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8625135172473312925.post-49650996632781163492010-01-21T20:06:00.000-08:002010-01-21T20:07:29.384-08:008086 or MASM PROGRAM to input 9 digits and display the second biggest number that can be formed using those digitsassume ds:data1,cs:code1,ss:stack1<br />stack1 segment<br />store1 db 10,0,10 dup('$')<br />stack1 ends<br />data1 segment<br />msg db 0ah,0dh,'enter the 9 digit number$'<br />number db 12,0,12 dup('$')<br />msg1 db 0ah,0dh,'the rearranged order is=$'<br />data1 ends<br />stack1 segment<br />store db 10,0,10 dup('$')<br />stack1 ends<br />code1 segment<br />start;mov ax,seg data1<br />mov ds,ax<br />lea dx,msg<br />mov ah,09h<br />int 21h<br />lea dx,number<br />mov ah,0ah<br />int 21h<br />mov cx,0008h<br />pass:push cx<br />mov cx,0008h<br />lea dx,number+2<br />mov si,dx<br />again:mov al,[si]<br />cmp al,[si+1]<br />jnc down<br />xchg al,[si+1]<br />xchg al,[si]<br />down:<br />inc si<br />loop again<br />pop cx<br />loop pass<br />mov al,[si]<br />xchg al,[si-1]<br />xchg al,[si]<br />lea dx,msg1<br />mov ah,09h<br />int 21h<br />lea dx,number+2<br />mov ah,09h<br />int 21h<br />mov ah,4ch<br />int 21h<br />code1 ends<br />end startQuiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com0tag:blogger.com,1999:blog-8625135172473312925.post-54280142069015253702010-01-21T20:04:00.000-08:002010-01-21T20:06:09.851-08:008086 or MASM PROGRAM to display the multiplication table (first 10 values) for a number N(<10d)assume ds:data1,cs:code1<br />data1 segment<br />msg db 0ah,0dh,'enter the number$'<br />number db 2,0,2 dup('$')<br />decimal db '0','1','2','3','4','5','6','7','8','9'<br />ans db 0ah,'0','*','0','=','0','0','$'<br />data1 ends<br />code1 segment<br />start;mov ax,seg data1<br />mov ds,ax<br />lea dx,msg<br />mov ah,09h<br />int 21h<br />mov cx,000ah<br />mov dl,0ah<br />mov ah,02h<br />int 21h<br />lea dx,number<br />mov ah,0ah<br />int 21h<br />lea dx,number<br />inc dx<br />inc dx<br />mov di,dx<br />mov bl,[di]<br />and bl,0fh<br />lea dx,ans<br />inc dx<br />mov si,dx<br />mov dl,[di]<br />mov [si],dl<br />lea dx,ans<br />inc dx<br />mov di,dx<br />lea dx,decimal<br />mov si,dx<br />again:lea dx,ans<br />inc dx<br />mov di,dx<br />mov al,[si]<br />inc di<br />inc di<br />mov [di],al<br />mov bh,[si]<br />mov ax,0000h<br />and bh,0fh<br />mov al,bh<br />mul bl<br />aam<br />add ax,03030h<br />inc di<br />inc di<br />mov [di],ah<br />inc di<br />mov [di],al<br />lea dx,ans<br />mov ah,09h<br />int 21h<br />inc si<br />loop again<br />mov ah,4ch<br />int 21h<br />code1 ends<br />end startQuiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com1tag:blogger.com,1999:blog-8625135172473312925.post-87820520714139421402010-01-21T20:02:00.000-08:002010-01-21T20:03:58.802-08:008086 OR MASM PROGRAM TO CONVERT THE Given temperature in Centigrade(<100°C) to Fahrenheit and Kelvin and display it (i/p and o/p as Decimal numbers)<span style="font-family:times new roman;font-size:130%;">assume ds:data1,cs:code1<br />data1 segment<br />msg db 0ah,0dh,'enter the temperature in degree celsius',0ah,'$'<br />msg1 db 0ah,0dh,'error! enter a temperature less than 99 degree C$'<br />msg2 db 0ah,0dh,'the temperature in kelvin scale is=$'<br />msg3 db 0ah,0dh,'the temperature in farenheit scale is approximately=$'<br />msg4 db 0ah,0dh,'the temperature in celsius scale is=$'<br />temp db 6,0,6 dup('$')<br />result db 20,0,20 dup('$')<br /><br />data1 ends<br />code1 seg<br />start:mov ax,seg data1<br />mov ds,ax<br /><br />lea dx,msg<br />mov ah,09h<br />int 21h<br /><br />mov ch,02h<br /><br />ask:<br />lea dx,temp<br />mov ah,0ah<br />int 21h<br /><br />lea dx,msg4<br />mov ah,09h<br />int 21h<br /><br />lea dx,temp+2<br />mov ah,09h<br />int 21h<br /><br />do:<br />lea bx,temp+1<br />mov cl,[bx]<br />inc bx<br />mov ah,[bx]<br />dec cl<br />jz down<br />mov al,[bx+1]<br />dec cl<br />jz down1<br />lea dx,msg1<br />mov ah,09h<br />int 21h<br />jmp ask<br /><br />down:<br />mov al,ah<br />mov ah,00h<br />down1:<br />and ax,0f0fh<br />aad<br />dec ch<br />jz second<br />add ax,0111h;273 addition<br />call display<br />lea dx,msg2<br />call show<br />jmp do<br />second:<br />mov cl,09h<br />mul cl<br />mov cl,05h<br />div cl<br />mov ah,00h<br />add al,20h;hex equivalent of 32<br />call display<br />lea dx,msg3<br />call show<br />jmp over<br /><br />display:lea bx,result+4<br />mov dl,03h<br />mov cl,0ah<br />again:<br />div cl<br />add ah,30h<br />mov [bx],ah<br />dec bx<br />mov ah,00h<br />dec dl<br />jnz again<br />ret<br /><br />show:<br />mov ah,09h<br />int 21h<br />lea dx,result+2<br />mov ah,09h<br />int 21h<br />ret<br />over:<br />mov ah,4ch<br />int 21h<br />code1 ends</span>Quiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com2tag:blogger.com,1999:blog-8625135172473312925.post-65744094976129312672010-01-21T19:58:00.000-08:002010-01-21T20:01:42.378-08:008086 OR MASM PROGRAM TO Count and display the number of occurrances of (i) vowels (ii) a given word from a given string<span style="font-family:trebuchet ms;font-size:130%;">assume ds:data1,cs:code1<br />data1 segment<br />msg db 0ah,0dh,'enter the word in small letters',0ah,'$'<br />msg1 db 0ah,0dh,'the number of vowels in the given string is=$'<br />msg2 db 0ah,0dh,'the number of occurance of the word in the given string is=$'<br />vowel db 'a','e','i','o','u'<br />enter db 'is is is$'<br />get db 20,0,20 dup('$')<br />data1 ends<br />code1 segment<br />start:mov ax,seg data1<br />mov ds,ax<br />lea dx,msg1<br />mov ah,09h<br />int 21h<br />lea bx,enter<br />mov si,bx<br />mov bl,00h<br />check:<br />lea dx,vowel<br />mov di,dx<br />mov dx,0005h<br />mov al,[si]<br />repeat1:cmp al,[di]<br />jz down<br />inc di<br />dec dl<br />jnz repeat1<br />jmp have<br />down:inc bl<br />have:inc si<br />mov dh,'$'<br />cmp [si],dh<br />jnz check<br />mov dl,bl<br />add dl,30h<br />mov ah,02h<br />int 21h<br /><br />lea dx,msg<br />mov ah,09h<br />int 21h<br /><br />lea dx,get<br />mov ah,0ah<br />int 21h<br /><br />lea dx,msg2<br />mov ah,09h<br />int 21h<br /><br />lea dx,enter<br />mov si,dx<br />mov dx,0000h<br />again:<br />lea bx,get+1<br />mov cl,[bx]<br />inc bx<br />mov di,bx<br />again1:<br />mov al,[si]<br />cmp al,[di]<br />jnz under<br />inc si<br />inc di<br />loop again1<br />mov bl,20h<br />cmp [si],bl;ASCII OF SPACE<br />jz found<br />mov bl,24h<br />cmp [si],bl;ASCII of $<br />jz found<br />under:inc si<br />mov bl,20h<br />cmp [si],bl<br />jz do<br />mov bl,24h<br />cmp [si],bl<br />jz over<br />jmp under<br />found:<br />inc dl<br />do:inc si<br />mov bl,24h<br />cmp [si],bl<br />jz over<br />jmp again<br />over:add dl,30h<br />mov ah,02h<br />int 21h<br />mov ah,4ch<br />int 21h<br />code1 ends</span>Quiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com0tag:blogger.com,1999:blog-8625135172473312925.post-28085061942554288242010-01-21T19:54:00.000-08:002010-01-21T19:58:26.815-08:008086/MASM PROGRAM TO CHECK WHETHER THE MOBILE NUMBER ENTERED THROUGH KEYBOARD IS DIVISIBLE BY NINE<span style="font-size:130%;color:#006600;">assume ds:data,cs:code<br />data segment<br />msg db 0ah,0dh,'enter the mobile number$'<br />number db 20,0,20 dup('$')<br />yes db 0ah,0dh,'YES$'<br />no db 0ah,0dh,'NO$'<br />data ends<br />code segment<br />start:mov ax,seg data<br />mov ds,ax<br /><br />lea dx,msg<br />mov ah,09h<br />int 21h<br /><br />lea dx,number<br />mov ah,0ah<br />int 21h<br /><br />lea dx,number<br />mov sl,dx<br />inc si<br />inc si<br />mov cx,000ah<br /><br />again:mov al,[si]<br />and al,0fh<br />mov [si],al<br />inc si<br />loop again<br /><br />lea dx,number<br />mov si,dx<br />inc si<br />inc si<br />mov cx,0009h<br />mov ax,0000h<br />mov ai,[si]<br />adding:add al,[si+1]<br />inc si<br />loop adding<br />mov bl,03h<br />div bl<br />and ah,0ffh<br />jz yess<br /><br />lea dx,no<br />mov ah,09h<br />int 21h<br />jmp down<br /><br />yess:lea dx,yes<br />mov ah,09h<br />int 21h<br /><br />down: mov ah,4ch<br />int 21h<br />code ends<br /></span>Quiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com0tag:blogger.com,1999:blog-8625135172473312925.post-29371280453259876082009-12-20T03:17:00.000-08:002009-12-20T03:22:26.091-08:008086 PROGRAM TO CONVERT THE TEMPERATURE IN DEGREE CELCIUS TO FAHRENHEIT AND KELVIN SCALE<span style="font-family:trebuchet ms;font-size:130%;">;Q.Given a temperature in Centigrade(<100°C), WAP to convert it to Fahrenheit and Kelvin and display it (i/p and o/p as Decimal numbers)<br /></span><br /><span style="font-family:trebuchet ms;font-size:130%;">assume ds:data1,cs:code1<br />data1 segment<br />msg db 0ah,0dh,'enter the temperature in degree celsius',0ah,'$'<br />msg1 db 0ah,0dh,'error! enter a temperature less than 99degree C$'<br />msg2 db 0ah,0dh,'the temperature in kelvin scale is=$'<br />msg3 db 0ah,0dh,'the temperature in farenheit scale is approximately=$'<br />msg4 db 0ah,0dh,'the temperature in celsius scale is=$'<br />temp db 6,0,6 dup('$')<br />result db 20,0,20 dup('$')<br /><br /><br />data1 ends<br /><br />code1 segment<br />start:mov ax,seg data1<br />mov ds,ax<br /><br />lea dx,msg<br />mov ah,09h<br />int 21h<br /><br />mov ch,02h<br /><br />ask:<br />lea dx,temp<br />mov ah,0ah<br />int 21h<br /><br />lea dx,msg4<br />mov ah,09h<br />int 21h<br /><br />lea dx,temp+2<br />mov ah,09h<br />int 21h<br /><br />do:<br />lea bx,temp+1<br />mov cl,[bx]<br />inc bx<br />mov ah,[bx]<br />dec cl<br />jz down<br />mov al,[bx+1]<br />dec cl<br />jz down1<br />lea dx,msg1<br />mov ah,09h<br />int 21h<br />jmp ask<br /><br />down:<br />mov al,ah<br />mov ah,00h<br />down1:<br />and ax,0f0fh<br />aad<br />dec ch<br />jz second<br />add ax,0111h;273 addition<br />call display<br />lea dx,msg2<br />call show<br />jmp do<br />second:<br />mov cl,09h<br />mul cl<br />mov cl,05h<br />div cl<br />mov ah,00h<br />add al,20h;hex equivalent of 32<br />call display<br />lea dx,msg3<br />call show<br />jmp over<br /><br />display:lea bx,result+4<br />mov dl,03h<br />mov cl,0ah<br />again:<br />div cl<br />add ah,30h<br />mov [bx],ah<br />dec bx<br />mov ah,00h<br />dec dl<br />jnz again<br />ret<br /><br />show:<br />mov ah,09h<br />int 21h<br />lea dx,result+2<br />mov ah,09h<br />int 21h<br />ret<br />over:<br />mov ah,4ch<br />int 21h<br />code1 ends<br />end start</span>Quiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com1tag:blogger.com,1999:blog-8625135172473312925.post-75070961251244042432009-12-20T03:09:00.000-08:002009-12-20T03:16:25.058-08:008086 MASM PROGRAM TO Read in a binary string through keyboard and Display it in the reverse order.Also display its Parity.<span style="font-family:trebuchet ms;"><span style="font-size:130%;"><span style="color:#ff0000;">assume ds:data1,cs:code1</span><br /><span style="color:#ff6600;">data1 segment<br />msg db 0ah,0dh,'enter the binary number$'<br />number db 20,0,20 dup('$')<br />msg2 db 0ah,0dh,'the number in reversed order is$',0ah,0dh<br />odd db 0ah,0dh,'the number has odd parity$'<br />evenpar db 0ah,0dh,'the number has even parity$'<br />data1 ends</span><br /><span style="color:#3333ff;">code1 segment<br />start:mov ax,seg data1<br />mov ds,ax<br /><br />lea dx,msg<br />mov ah,09h<br />int 21h<br /><br />lea dx,number<br />mov ah,0ah<br />int 21h<br /><br />mov bx,0000h<br />mov cx,bx<br />mov cl,number+1<br />lea si,number+2<br /><span style="color:#33cc00;">again:</span>mov ax,0001h<br />and al,[si]<br />jz skip<br />inc bx<br /><span style="color:#000066;">skip:</span>inc si<br />loop <span style="color:#33cc00;">again<br /></span><br />lea dx,msg2<br />mov ah,09h<br />int 21h<br /><br />mov cx,0000h<br />mov cl,number+1<br />dec si<br /><span style="color:#336666;">do:</span><br />mov dl,[si]<br />mov ah,02h<br />int 21h<br />dec si<br />loop <span style="color:#336666;">do </span><br /><br />mov ax,bx<br />mov bl,02h<br />div bl<br />and ah,01h<br />jnz <span style="color:#996633;">oddpar </span><br />lea dx,<span style="color:#990000;">evenpar </span><br />mov ah,09h<br />int 21h<br />jmp down<br /><span style="color:#cc33cc;">oddpar:</span><br />lea dx,odd<br />mov ah,09h<br />int 21h<br /><span style="color:#993399;">down:</span> mov ah,4ch<br />int 21h<br />code1 ends<br /></span><span style="color:#006600;">end start</span></span><br /><br /><br /><br /><br /><br /></span>Quiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com0tag:blogger.com,1999:blog-8625135172473312925.post-18443448418949198962009-12-05T07:57:00.001-08:002009-12-05T08:04:20.538-08:008086 MASM PROGRAM TO FIND OUT WHETHER THE GIVEN YEAR IS A LEAP YEAR OR NOT<span style="font-family:trebuchet ms;font-size:130%;">assume ds:data1,cs:code1</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#000099;">data1 segment</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#000099;">msg db 0ah,0dh,'enter the year$'</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#000099;">number db 6,0,6 dup('$')</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#000099;">ys db 0ah,0dh,'yes,it is a leap year$'</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#000099;">n db 0ah,0dh,'no,it is not a leap year$'</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#000099;">data1 ends</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">code1 segment</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">start:mov ax,seg data1</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov ds,ax<br />lea dx,msg</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov ah,09h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">int 21h<br /></span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">lea dx,number</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov ah,0ah</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">int 21h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">lea bx,number+4</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov ah,[bx]</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov al,[bx+1]</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">aad</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov bl,04h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">div bl</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">and ah,0ffh</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">jz yes</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">lea dx,n</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov ah,09h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">int 21h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">jmp down</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">yes:lea dx,ys</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">mov ah,09h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">int 21h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">down: mov ah,4ch</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">int 21h</span><br /><span style="font-family:trebuchet ms;font-size:130%;color:#006600;">code1 ends</span><br /><span style="font-family:trebuchet ms;font-size:130%;">end start</span>Quiz Championhttp://www.blogger.com/profile/02620551722534111143noreply@blogger.com3