You are on page 1of 22

Program:

section .data ;1.1 msg: db "Enter the character:" msglen: equ $-msg spcl: db "Special Character", 10 length1: equ $-spcl alphan: db " lpha !umeric", 10 length": equ $-alphan alphab: db " lphabet", 0 h length#: equ $-alphab $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss )e*+stro)e: resb 1 section .te&t global +start: +start: printstr msg, msglen mo% ea&, # mo% eb&, 0 mo% ec&, )e*+stro)e mo% ed&, " int (0h cmp b*te,)e*+stro)e-, #0. /nb chec) /b special+)e* chec): cmp b*te,)e*+stro)e-, # . /b alphanumeric cmp b*te,)e*+stro)e-, '1. /nb chec)1 /b special+)e* chec)1:cmp b*te,)e*+stro)e-, 01. /b alphabetic cmp b*te,)e*+stro)e-, 21. /nb chec)" /b special+)e* /mp stop chec)":cmp b*te,)e*+stro)e-, 31. /b alphabetic /b special+)e* special+)e*: printstr spcl, length1 /mp stop alphanumeric: printstr alphan, length" /mp stop

alphabetic: printstr alphab, length# stop: mo% ea&, 1 mo% eb&, 0 int (0h ; 420 or '1h 5461 or 01h ;a463 or 21h 741"# or 31h ;04'( or #0h 6403 or #6h ;special character 0( or # h 89 2' or '0h

Output:
Enter the character: a lphabet Enter the character: lphabet Enter the character: 1 lpha !umeric Enter the character: . Special Character

Program:
section .data ;1." msg1 : db 10,"Enter "-digit number " len : equ $-msg1 e : db 10,"8he number is e%en",10 le : equ $-e o : db 10,"8he number is odd",10 lo : equ $-o $macro displa* " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss n1 : resb " section .t&t global +start +start: displa* msg1,len mo% ea& , # mo% eb& , 0 mo% ec& , n1 mo% ed& , " int (0h displa* n1," mo% al , b*te,n1:1sub a& , #0h mo% bl , " di% bl ; h4remainder , al4quotient cmp ah,0 /ne odd;i; 7;40 e%en: displa* e , le /mp e&it odd: displa* o , lo e&it: mo% ea& , 1 mo% eb& , 0 int (0h

Output:
Enter "-digit 00 8he number is Enter "-digit 1" 8he number is number 00 odd number 1" e%en

Program:
section .data ;1.# msg : db "Enter the no : " len : equ $-msg msg" : db "Square is : " len" : equ $-msg" ne<line : db 10 nlen : equ $-ne<line $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss num : resb 1 squ : resb " section .t&t global +start +start: printstr msg, len mo% ea& , # mo% eb& , 0 mo% ec& , num mo% ed& , 1 int (0h mo% al , b*te,numsub al , #0h mo% cl , al mo% ch , 00 mo% ah , 00 mul c& ;a& and c& is multiplied mo% cl , 10 di% cl ;split into " seperate digits add a& , #0#0h mo% <ord,squ- , a& printstr msg", len" printstr squ, " printstr ne<line, nlen mo% ea& , 1 mo% eb& , 0 int (0h

Output:
Enter the no : 3 Square is : '6

Program:
section .data ;1.' msg : db "Enter a number " msg" : db 10 len : equ $-msg len" : equ $-msg" num db =0= $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss n: resb 1 section .te&t global +start +start: printstr msg, len mo% ea& , # mo% eb& , 0 mo% ec& , n mo% ed& , 1 int (0h loop: printstr num, " ; print the SC>> %al printstr msg", len" sub b*te,num- , #0h ;con%ert to he& sub b*te,n, #0h ;con%ert to he& ;or cmp mo% ah , b*te,ncmp ah , b*te,num/e e&it inc b*te,numadd b*te,num- , #0h add b*te,n, #0h /mp loop e&it: mo% ea& , 1 mo% eb& , 0 int (0h

Output:
Enter a number ' 0 1 " # '

Program:
section .data ;1.0 msg : db "Enter a 12 bit number : " len : equ $-msg msg1 : db "8he sum is : " len1 : equ $-msg1 ne<line : db 10 lenn : equ $-ne<line $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro readstr " mo% ea& , # mo% eb& , 0 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro con%ertab 1 ; binar* <ill be stored in al push c&; mo% cl , b*te,$1;cl <ill ha%e the tens place digit mo% ch , b*te,$1:1;ch <ill ha%e the ones place digit sub c& , #0#0h ;con%ert ;rom SC>> to he& mo% al , 10 mul cl add al , ch pop c&; $endmacro section .bss num1 : resb " num" : resb " temp1 : resb 1 temp" : resb 1 section .te&t global +start +start: printstr msg, len ;macro call ;or printing readstr num1, # ;macro call ;or reading printstr msg, len readstr num", # printstr msg1, len1 con%ertab num1 mo% dl , al

con%ertab num" add al , dl mo% cl , 10 di% cl ;split into " seperate digits add a& , #0#0h ;con%ert bac) to SC>> mo% b*te,temp1- , al mo% b*te,temp"- , ah printstr temp1,1 printstr temp",1 printstr ne<line,1 mo% ea& , 1 mo% eb& , 0 int (0h

Output:
Enter a 12 bit number : '" Enter a 12 bit number : 01 8he sum is : 6# Enter a 12 bit number : 1" Enter a 12 bit number : 10 8he sum is : "3

Program:
section .data ;1.2 msg: db "Enter the number?' digits@",10 dmsg: equ $-msg ne<line: db 10 inp1: d< #0h inp": d< #0h sum: d< #0h count: db #0h temp: db #0h $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro readstr " mo% ea& , # mo% eb& , 0 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .te&t con%ert: sub bl, #0h mo% ea&, 0 mo% ec&, 0 mo% al, bl mo% b*te,count-, # acon: mo% ed&,0 mo% ec&, 10 mul c& sub bh, #0h shr eb&, ( mo% ed&,0 mo% dl, bl add a&, d& sub b*te,count-,1 cmp b*te,count-,0 /ne acon ret global +start +start: printstr msg, dmsg readstr inp1, 0 mo% eb&, 0 mo% eb&, ,inp1-

call con%ert mo% <ord,inp1-, a& readstr inp", ' mo% eb&, 0 mo% eb&, ,inp"call con%ert mo% <ord,inp"-, a& mo% ea&, 0 mo% ed&, 0 mo% a&, ,inp1mo% d&,,inp"add a&, d& push "6h mo% b*te,count-, 0 brea): mo% eb&, 10 mo% ed&, 0 di% b& add dl, #0h push d& sub b*te,count-, 1 cmp b*te,count-,0 /ne brea) mo% ea&, 0 pop a& print: mo% b*te,temp-, al printstr temp, 1 mo% ea&, 0 pop a& cmp al, "6h /ne print printstr ne<line, 1 mo% ea&, 1 mo% eb&, 0 int (0h

Output:
Enter the number?' digits@ 1'0# ("1" 06220 Enter the number?' digits@ 602' "1"0 112(6

Program:
section .data ;1.3 big : db "1ig-Endian ",10,1# lit : db "Aittle-Endian",10,1# blen : equ $-big llen : equ $-lit $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .te&t global +start +start: mo% ea& , 0&;;;;0000 push ea& pop a& pop b& cmp b& , 0&;;;; /e little bigend: printstr big, blen /mp end little: printstr lit, llen int (0h end: mo% ea& , 1 mo% eb& , 0 int (0h

Output:
Aittle-Endian

Program:
section .data ;1.( msg: db =Enter the 1st no:= len: equ $-msg msg1: db =Enter "nd no:= len1: equ $-msg1 msg": db =BCC:= len": equ $-msg" n<: db 10 lenn<: equ $-n< $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro readstr " mo% ea& , # mo% eb& , 0 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss num1: resb " num": resb " gcdno: resb " gcdno1:resb " section .t&t global +start +start: printstr msg,len readstr num1,' printstr msg1,len1 readstr num",' printstr msg",len" mo% cl,b*te,num1mo% ch,b*te,num1:1sub c&,#0#0h mo% al,10 mul cl add al,ch mo% bl,al mo% cl,b*te,num"mo% ch,b*te,num":1sub c&,#0#0h mo% al,10 mul cl

add al,ch mo% dl,al mo% dh,00 mo% bh,00 ;ndgcd: cmp dl,00 /e result push d& mo% al,bl mo% ah,00 di% dl mo% dl,ah pop b& /mp ;ndgcd result: mo% ah,00 mo% al,bl mo% cl,10 di% cl add a&,#0#0h mo% b*te,gcdno-,al mo% b*te,gcdno1-,ah printstr gcdno," printstr gcdno1," mo% ea&,1 mo% eb&,0 int (0h

Output:
Enter the 1st no:10 Enter "nd no:1" BCC:0# Enter the 1st no:13 Enter "nd no:1" BCC:01

Program:
section .data ;".1 msg: db "Enter the number?' digits@",10 dmsg: equ $-msg ne<line: db 10 inp1: d< #0h inp": d< #0h sub: d< #0h count: db #0h temp: db #0h $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro readstr " mo% ea& , # mo% eb& , 0 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .te&t con%ert: sub bl, #0h mo% ea&, 0 mo% ec&, 0 mo% al, bl mo% b*te,count-, # acon: mo% ed&,0 mo% ec&, 10 mul c& sub bh, #0h shr eb&, ( mo% ed&,0 mo% dl, bl add a&, d& sub b*te,count-,1 cmp b*te,count-,0 /ne acon ret global +start +start: printstr msg, dmsg readstr inp1, ' readstr temp, 1 mo% eb&, 0

mo% eb&, ,inp1call con%ert mo% <ord,inp1-, a& readstr inp", 0 mo% eb&, ,inp"call con%ert mo% <ord,inp"-, a& mo% ea&, 0 mo% ed&, 0 mo% a&, ,inp1mo% d&,,inp"sub a&, d& push "6h mo% b*te,count-, 0 brea): mo% eb&, 10 mo% ed&, 0 di% b& add dl, #0h push d& sub b*te,count-, 1 cmp b*te,count-,0 /ne brea) mo% ea&, 0 pop a& print: mo% b*te,temp-, al printstr temp, 1 mo% ea&, 0 pop a& cmp al, "6h /ne print printstr ne<line, 1 mo% ea&, 1 mo% eb&, 0 int (0h

Output:
Enter the number?' digits@ 1'6" 1"01 00"61 Enter the number?' digits@ "'00 1"11 0116'

Program:
section .data ;"." msg1: db "Enter ho< man* no : " si7e1: equ $-msg1 msg": db "Enter integer : ",10 si7e": equ $-msg" msg#: db "Enter number to be ;ound: " si7e#: equ $-msg# not: db "Bi%en number not ;ound" ,10 si7e': equ $-not ;ound: db "Bi%en number ;ound" ,10 si7e0: equ $-;ound ne<line: db 10 len: equ $-ne<line $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro readstr " mo% ea& , # mo% eb& , 0 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss count resb " count1 resb " data1 resb 1 data" resb 1 num res< " srchnum resb " temp resb " section .te&t global +start +start: printstr msg1,si7e1 readstr data1,1 readstr data",1 readstr temp," mo% cl,b*te,data1mo% ch,b*te,data"sub cl,#0h sub ch,#0h mo% al,10 mul cl

add al,ch mo% b*te,count-,al mo% b*te,count1-,al readarra*: mo% ea&,' printstr msg",si7e" readstr data1,1 readstr data",1 readstr temp," mo% cl,b*te,data1mo% ch,b*te,data"sub cl,#0h sub ch,#0h mo% al,10 mul cl add al,ch mo% ah,0 push a& dec b*te,countmo%7& ec&,b*te,countcmp ec&,0 /ne readarra* ;elem,ent to be search printstr msg#,si7e# readstr data1,1 readstr data",1 readstr temp," mo% cl,b*te,data1mo% ch,b*te,data"sub cl,#0h sub ch,#0h mo% al,10 mul cl add al,ch mo% b*te,srchnum-,al searchno: mo% a&,00 pop a& mo%7& b&,b*te,srchnumcmp a&,b& /e ;oundno dec b*te,count1mo%7& ec&,b*te,count1cmp ec&,0 /ne searchno /mp n;oundno ;oundno:printstr ;ound,si7e0 /mp e&it n;oundno:printstr not,si7e'

e&it:mo% ea&,1 mo% eb&,0 int (0h

Output:
Enter Enter Enter Enter Enter Enter Enter Bi%en Enter Enter Enter Enter Enter Enter Enter Bi%en ho< man* no : 00 integer : 1" integer :#2 integer : '0 integer : (6 integer : 11 number to be ;ound: "0 number not ;ound ho< man* no : 00 integer : "1 integer : #2 integer : 3( integer : '0 integer : 1# number to be ;ound: 1# number ;ound

Program:
section .data ;".# msg1: db "Enter ho< man* no : " si7e1: equ $-msg1 msg": db "Enter integer : " si7e": equ $-msg" large: db " Aargest !umber :" si7e': equ $-large ne<line: db 10 len: equ $-ne<line $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro readstr " mo% ea& , # mo% eb& , 0 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss count resb " count1 resb " data1 resb 1 data" resb 1 largeno resb " temp resb " section .te&t global +start +start: printstr msg1,si7e1 readstr data1,1 readstr data",1 readstr temp,1 mo% cl,b*te,data1mo% ch,b*te,data"sub cl,#0h sub ch,#0h mo% al,10 mul cl add al,ch mo% b*te,count-,al mo% b*te,count1-,al readarra*: printstr msg",si7e" readstr data1,1

readstr data",1 readstr temp," mo% cl,b*te,data1mo% ch,b*te,data"sub cl,#0h sub ch,#0h mo% al,10 mul cl add al,ch mo% ah,0 push a& dec b*te,countmo%7& ec&,b*te,countcmp ec&,0 /ne readarra* ;large printstr large,si7e' mo% a&,00 pop a& chec)no:pop b& cmp a&,b& /nc ne&t ;/nc or /g mo% a&,b& ne&t: dec b*te,count1mo%7& ec&,b*te,count1cmp ec&,0 /ne chec)no mo% bl,10 di% bl add ah,#0h add al,#0h mo% b*te,data1-,al mo% b*te,data"-,ah printstr data1,1 printstr data",1 printstr ne<line,len mo% ea&,1 mo% eb&,0 int (0h

Output:
Enter Enter Enter Enter Enter Enter ho< man* no : 00 integer : 1" integer : #2 integer : "" integer : '0 integer : 6(

Aargest !umber:6(

Program:
section .data ;".' as)count:db "Enter the arra* si7e:" lencount: equ $-as)count element:db "Enter the arra* element:" lenelmnt: equ $-element sort: db "Sorted list:" lensort: equ $-sort comma: db "," len: equ $-comma endl: db 10 $macro printstr " mo% ea& , ' mo% eb& , 1 mo% ec& , $1 mo% ed& , $" int (0h $endmacro $macro readstr " mo% ea& , # mo% eb& , 0 mo% ec& , $1 mo% ed& , $" int (0h $endmacro section .bss arra* resb 00 count resb 1 count1 resb 1 count" resb 1 digit0 resb 1 digit1 resb 1 temp resb 1 pos resb 1 i resb 1 / resb 1 section .te&t global +start +start: printstr as)count,lencount readstr digit0,1 readstr digit1,1 readstr temp,1 sub b*te,digit0-,#0h sub b*te,digit1-,#0h mo% cl,b*te,digit0mo% ch,b*te,digit1mo% al,10

mul cl add al,ch mo% b*te,count-,al mo% b*te,count1-,al mo% b*te,count"-,al mo% eb&,arra* rdloop: push eb& printstr element,lenelmnt readstr digit0,1 readstr digit1,1 readstr temp,1 sub b*te,digit0-,#0h sub b*te,digit1-,#0h mo% cl,b*te,digit0mo% ch,b*te,digit1mo% al,10 mul cl add al,ch pop eb& mo% b*te,eb&-,al add eb&,1 dec b*te,countcmp b*te,count-,0 /ne rdloop mo% eb&,arra* mo% b*te,i-,0 i+loop: mo% b*te,/-,0 /+loop: mo% eb&,arra* mo%7& ea&,b*te,/add eb&,ea& mo% ea&,eb& add ea&,1 mo% dl,b*te,eb&mo% dh,b*te,ea&cmp dh,dl /c s<ap /mp ne&t s<ap: mo% b*te,eb&-,dh mo% b*te,ea&-,dl ne&t: inc b*te,/mo% al,b*te,count1sub al,b*te,isub al,1 cmp b*te,/-,al /l /+loop inc b*te,imo% al,b*te,count1cmp b*te,i-,al /l i+loop

printstr sort,lensort mo% eb&,arra* prntloop: push eb& mo% al,b*te,eb&mo% b*te,pos-,al mo%7& a&,b*te,posmo% bl,10 di% bl mo% b*te,digit0-,al mo% b*te,digit1-,ah add b*te,digit0-,#0h add b*te,digit1-,#0h printstr digit0,1 printstr digit1,1 printstr comma,len pop eb& add eb&,1 dec b*te,count"cmp b*te,count"-,0 /ne prntloop e&t: printstr endl,1 mo% ea&,1 mo% eb&,0 int (0h

Output:
Enter Enter Enter Enter Enter Enter the the the the the the arra* arra* arra* arra* arra* arra* si7e: 00 element: element: element: element: element: #2 10 (( 10 #"

Sorted list: 10, 10, #", #2, ((

You might also like