Download as pdf
Download as pdf
You are on page 1of 29
__ List of Practicals SESSA actical 1 : Wdentity various pins of the aoa | Exercise? Microprocessor. PinNo | _ Name Min | Max, Funetion 351039 26 2 28 > Practical Use assembly language programming tools and functions. Solution = ‘Assembly language program is normally writen in assembly | tanguage using tools like editor, assembler, linker and for debugging debugger. ditor : An editor is a program used to create assembly tanguage program in proper format so thatthe assembler can translate it appropriately to machine language. So, you can type your program called as source program using editor such asthe DOS based editor ie. EDIT. B.Assembler = Exercise 1 ‘An assembler is a program that translate assembly language program to the appropriate binary code for each instruction in program ie. machine code and generate the fle called as object file with extension .obj ‘Assembler may be TASM Borland’s Turbo Assembler and 18 -MASM Microsoft Macro Assemble etc 21016 Ww Fr e. Linker + A tinker is a program that combines one or more vo L_| separately assembled program module into one exccutable program and generate exe module, and initializes it with \ a_| | 4 special insuctions to enable iS stbsequent loading. the [2 | 1 + “execution. Linker available are TLINK Botland’s Tas \ ‘Linker and LINK Microsofts Linker, ° ¥F Microprocessors (MSBTE - Sem 4- Comp.) a Fz: \>HOUNT E ¢:\TASH Drive E is mounted as local director Some NEE SN oTASH HASH ‘bo Assembler ers: Hast None None 1 472k 2.0. Copyright Cc) 1987, fon 3.1 Copyright (c) 13 List of Practicals 190, 1992 Borland International 41988 Borland International Debugger : Debugger is @ program is used fo: execute program in single step mode under the contol of the user. ‘The method of locating and comecting errs using & debugger is called as debugeing. Debugger availabe are DOS Debug command, Borland turbo Debugger TD, Microsoft Debugger known as Code View CV ete. > Practical 3(a): Use different addressing mode Instruction in program - Write an ‘Assembly Language Program (ALP) to add two given 8 bit and 16 bit numbers. Solution = Addition of two & bit Numbers Le. FFH and FFH. Algorithin 1. Initialize data segment [Load first number from memory in AL. ‘Add Second number with fist umber. 4. Check CPif result is greater then 8 Bitif not goo 6 5) Increment MSB counter 6. Store result in memory locaton. 5. Stop. Flowchart sur Indaise MSB Counter Toad frat pub in AL 7d second number wath AL Pesitie> 8b ? Tnerement MSS Gountor Sieve Rest Program “modal small data “uml db 60H First Number num2 db O8H Second Number res db? Result Variable msb db 0 MSB result scode mov ax,@data mov da, ax sTnitielization of data segment z mum] load Ist number in AL, oor a eijal num add 2nd no.with Isto, in AL joedn | ine meb | povres,al _;Store result from al to memory ; location exis ead dation of two 16 bit Numbers Le, FFFFH and FFFFH. Algorithm . Initialize data segment, 1 1, Load first number in register. 3, Add second number with first number. 4k Check result> 16 bit if yes, then goto step 5 else step 6. 5, Increment MSB counter. 6 1 Store esl Sip Flowchart Taaaedis apee Tonais ge Comer ~ otter ne s ¢ Ta NS Ca ae Program “aol sil in : puml dw fit ‘num2_— dw Of resleb dw. 0 ‘ res_msbdw 0 seode * mov ax,@diatasaitialize data segment mov dsax mov axa, add ax,num2. jad mul to AX inc res_msb _jincrement carry counter exit: oy res_Isb,ex_sstore result ends | end > Practical (t): Use different addressing mode Instruction In program - Write an [ALP to subtract two given 8 bit and 16 bit numbers. Solution : Subtraction of two 8 bit Numbers Le. F1H and OFH. ‘Algorithm 1. Intalize ata segment 2. Land fst number from memory in ester 4. jSubict 2% number from 1 number. 44, Store result in memory location. 4 5. *Stop rch Thialze data sogment tT 5 Toad fret number in AL. [tester ‘Subtract sécond number from AL, . 2 ‘Sore result to memory uml db OH First Number Second Number $Reqult Variable «code mov ax,@uata Initialization of ane tialization of data segment 1 ‘mov al, numl sload 1 sload Ist number in AL sub al, nam2 jsubtract 2nd no fom Ist no, “mov res, al Store res = ult to. memory ‘end location RE Microprocessors (MSBTE - Sem 4- Comp) La Subtractlon of two 16 bit Numbers Le, FFFIH and OOFFH. Algorithm 1, Inititize data seprmem, Load first aumber frors memory'in register 3. Subtract 2nd mumber from Ist number. 4. Stote result ia mentary focation, 5. Stop. Flowchart Sat Triatze data gent Lose rst umber AX ‘Strat sas number rom AK Sep ° Program ‘model small dw 8AG4H ;First Number uml res dw ? Result Variable scode mov ax@data :Initialization of data segment mov do,ax. ” x ‘mov ax, num sload Ist number in AL sub ax, num? sublract 2nd no. from Ist no. = mov res, ax ;Store esull to memory location ends : end > Practical 4(a) : Write an ALP to multiply two given 8 bit and 16 bit unsigned numbers. Solution : Multiplication of two given 8 bit unsigned numbers FFH x FFH Algorithm, Initialize data segment, Load first mbes Multiply frst number with stcond number Store result. Stop. List of Practica’s Flowchart Truce Data Segment ad ea paint AL am namo) 4 Tay Ac aooone Nomar Tore real am NLtO MOTE Program eee onal ‘data ‘num ab Offs num2 db Offh Eau de 0 Fossa: pov a@date iline damanement Ere ov alnum :Mahiphymao} bynam2 fla ‘mov result,ax, ;Store result ie ‘Multiplication of two given 16 bit unsigned numbers. Le. FFFFH x FFFFH Algorithm 1. Iniialize data segment. 2 Load first number, 3. Multiply frst number with second number. 4. Store result 5. Stop. Flowchart ‘Sat Tratise Data Gopment Load tet humbar in AK rom memony rt ‘Multply AX by second Numbor ‘Stora rosult rom AX and OXto mano] aostel snl data numl dw OFT mm? dw OMT. relsh dw 0 reemsh dw 0 ode mov ax@data itialize data segment rome dias | mov asim), Multiply num by num nl mam | ror res Iebyax Sore LSB of reel raoy resireb dx Store MSBofreautt, 9 ends Sees od SO SR > Practical 4(b) : Write an ALP to multiply two given 8 bit and 16 bit signed numbers, Solution : Multiplication of two given 8 bit signed numbers Le.-SHx-4H Algorithm 1. Initialize data segment ‘Lood first number. “Multiply first number with second number. Store result. Stop. Flowchart 3 4 Tnitialise Data Segment Toad frat signed number n AL rom memoy ee db Sh db ay a) num], ‘num? result weode | mov ax,@deta mov ds,ax slnitialize data segment mov alum) Muliply num) by num | imul num2. + mov result,ax ;Store result ends end Multiplication of two given 8 bit signed numbers Le.— 12H x- 10H Algorithm Teitilize data segment, Load first number. Malkply first number with second number, Store result Stop. Flowchart Tniialise Data Segment I ‘Load frst signed number in AX trom memory ‘Mutiply AX by second signed Number Using IMUL Instruction q ‘Store result from AX and DX to memory Program ‘ited mall wdata : nl dw -121 | mum2 dw —011 res_low dv 0 © rem. dw 0 «cole | mov ax@data — slnitilize data seginemt * 5 da,ex x Ls | any aaa yaa 7 | mov res lsbat Store LSB of result | Roveimbge Sore IS ore ends Lend > Practical S(a): Write an ALP to perform block transfer data using string instruction. Solution : Algorithm 1, Initialize data and extra segment ie. DS and ES. 2. Initialize word counter. 3. Initialize memory pointers for source and destination array. 4. Read number from source array. 5. Copy itto destination array. 6. Increment memory pointers for source and destination array for next number. 7. Decrement word counter by one. 8. If word counter # 0 then go to step 4, 9 Stop. Flowchart ‘Star Tnitiaize Data Segment ! Initialize Word Counter in CX Initialize Memory Pointer for Source array in SI Intiaze Memory Pointer for Destination Array in DT a Road Numbor from Source Array Using Memory Pointor SI 0 AX ‘Copy Number from AX to Destination Array Using Memory Pointer Of Increment Source Memory Pointor S| by 2 ‘Increment Destination Memory Pointar Of by 2 Decrement Word Counter By 4 Program [model small data dw 1234h,4321h,7894h,9658b,45ABh ; Emply array ‘ero_ar ‘dstardw 5 dup |code i mov ax, @data j Initialize data segment mov ds,ax mov es,0x + Initialize extra segment mov 6x,5 + Initialize word counter j mov si, offset sre_arr + Initialize memory pointeé for + source mov di, offset dst_arr + Initialize memory pointer for ; destination ‘up : movsw sTransfer word from source to + destination loop up ends end > Practical 5(b): Write an ALP to perform block transfer data without using. string instruction. Solution : Algorithm 1. Initialize data segment 2. Initialize word counter. Initialize memory pointers for source and destination array 4. Read number from source array. 5. Copy it to destination array. 6. Increment memory pointers for source and destination array for next aumber. 7. Decrement word counter by one 8 _Ifword counter #0 then go to step 4. 9. Stop. Flowehart : Refer Flowchart in Practica Program -model small data ste_arrdw 12saHlfaorh, 700s, 9esoh samy Qaarrdw 5 dup(0) Empty array vcode moy.ax,@data Initialize data segment mov ds,ax ‘mov cx,5, slnitialize word counter mov si, offset sro_ert sli lize memory $ pointer for source mov di, offset det_arr_:Initiolize memory pointer 5 forde up: : | mov ax,[si) jread number from source array “mov [di}ax write number to destination array add si2 jincrement soureé memory point ‘add di,2 sinerement destination memory wees 5 pointer | oop next sehéck word counter for 2ero, 4 ifnot zero then read next umber from the army. > Practical 6(a) : Write an ALP to compare two strings without using string instruction. Solution : Algorithm 1, niiatize data segment. 2, Find the length of source string. 43, Find the length of destination string 44. Compare length ofboth the strings. 5, tflengthof bot string are nt same then got ste? 10 «6. Compare string character by character. 7. characters of both the strings ae not sue then BO 1° SP 10. Display message ‘Strings are same. 9. Stop. 10, Display message ‘Sting re not same’. 11. Stop. Flowchart naize Data Segment q Itai mamory pointer in Stand length S counter with O for Source sting ee ead character trom source sting ie characte ='$'Lo. Endof sting? Therement length_S counterby 1 _Tyerment Mamory Pointer by 1 LC 1 natze memory porter Ip DI and lengthD counter with O yor Destination sing ‘aad character rom Destination sng] Tnererant length_D counter by} Teremant mamory painter by 1 | 4} Flowchart contd... Microprocessors (MSBTE - Sem 4- Comp.) Iniializo Memory Pointar tor Souree array in $1 Intalize Memory Pointor for Dostination In DI [intalize Byte Countar with Iongth of Source / Destination| — ead Character from Source. I [Compare Source Character with Destination Charector] Increment Memory pointer for Source ‘and Destination by 1 respectively Decrement Byte Counter by 1 Is Byte Counter =0 7 Flowchart Program tes db ‘COMPUTERS! py atta db ‘computers? = count_sdb..9 countd ~ db 9 mag) Ab Stein are Sari msg? db ‘Strings are Not Sameg! mov ax,@daia Initialize data segment mov ds,ax oe Ls. ‘next! mov al, (i) | emp aly! je exit ine count_s jmp next “moy al.count_s. mov si,offset str_s up: mov alj(si] emp al,{ci) jne exit? ine ine di 5: dee count_s | o ineup. [5 mov ab,0dh Count lengih ofthe souoes string mov divoffset sted List of Practicals Initialize memory pointer for source string read character from the source setting scompare with $ jif equal then go to exit to read + destination string else increment memory pointer sinerement counter to count s length of string sjump to read next character slnitialize memory ptr for 3 destination string i stead character from the 3 destination string " jcompare with sif equal then go to exit] to j compare - length of sboth strings selse increment memory pointer “sincrement counter to count length of string jump to read next character Conran length ofboth the string ——~ same then ;g0 to exit2 else compare sstrings byte by byte “ilitialize memory pointer for source string © initialize memory pointer for sdestination jstring : jread character from source string ‘compare it with character of sdestination string iif character are not equal then: 3 g0 to exit selse increment source memory. inter increment destination memory spointer sdecrement byte counter: ‘sifbyte counter # 0 then go to $ up for next characters $ comparison sDisplay string are same message ww RE_Microprocessors (MSBTE - Sem 4 - Comp) — Lo Tea dx,msgl List of Practicals int 21h ine a zelse increment memory pointer jmp exit8 ine count_s increment counter to co exit2: slength of string mov ah,09h Display string are not saime message Sey: hnbtemalren tore lea dx,msg2_ wy Count length of the Destination string int 21h exit: + mov ah,teh. int 20h ends end Terminate program & Exit © DOS » Practical 6(b) : Write an ALP to compare two stfings using string Instruction. Solution : Algorithm, 1. Initialize data and extra segment ie. DS and ES, 2. Find the length of source string. 3. Find the length of destination string, 4. Compare length of both the strings. 5. If length of both string are not same then go to step 10. 6. Compare string character by character. 7... Af characters of both the strings are not same then go to step 10. 8. Display message ‘Strings are same’ 9. Stop. 10. Display message ‘String are not same’. Flowchart : Refer Flowchart in Practical 6(a). Program {model small 2 Fe me . ss db COMPUTERS) ! sud db ‘computer8" a counts db 0 | count_d db 0 magl db ‘Strings are Same" meg, db. ‘Strings are Not Same$! alize data segment 20 extra segment sini _.---Count length of the sources atin {lize memory pointer for ‘mov €8,0X peneeeecm nov siolfectatr_d—sTnitialize memory ptr for idlestination string next mov ali) scead character from the mn string cemp al" jeompare with & jecxitL if equal then go to oxitl to compare {length of both strings ] nerement memory pointer count_d_ increment counter to count length of string sjump to read next character ine sels jmp next] exitl: Compare length of both the string ——— mov aleount_s . i comp alycount_d je ext2 If length ofboth strings are not <> tge then go to exit? else é = {ehue compare strings byte by byte “eld “clear direction flag mov ch,0 mov cl,count_s sInitialize byte counterie. ~ moy sijoffset str_s Tnitialize memory pointer for” ‘mov dioffset str : ‘destination string SI up: Compare character of source: S| sstring with : empsh character of destination string jorexit2 —sif character are not equal then i 5g to exit2 Toop up _sdecrement byte counter if byte eounter # 0 then go to up for | snextcharacter comparison mov ah,09h ;Display string are same message Jen dxymsgl . int 21 jmp exit3 mov ah,09h" mov si,offset str_s [niti ve source ating rex: mov alfoi] szeed character from the irae Ba source otring. otk i fs it3: ‘gt jeompoze with § ee a ae ji equal then go to exitoread “rmoy.ah Ach »sTerminate program & Exit to DOS 2 ‘destination string Witenes [SF Microprocessors (MSBTE -Som4-Comp) _L-10 se [tian - 2. Division (92/16) double word by word division of ends: unsigned numbers. Lend Sod | atgoritm 1. Tlie data segment > Practical 7(2): Write an ALP to divide two alven |} [iaee Oat ot unsigned numbers. 3. Divide ist number with second number Solutio Store quotient and remainde 41. Division (16/6) word by byte division of unsigned | 5. Stop. 27 numbers. Flowehart Algorithm 1. ial dt segment en 2, Load first number. Inisaiee Dat 3. Divide fist number by second number. I A. Store quotet and remand. Coed didn OKAK Stop. q Flowchart Divide DX: AX by divisor i Sore Gator apd Rowand ‘em ea OX ts mary Trifaioe Oia Sogront oad onan AK y God Si : 3 ie AK aicor ae r ‘Gvidend A OOOLFEFFH. Dividend Sire Quotontand onainder io memony divisor aw OF trom At and AL fies a0 I pone ae 0 CSre) seode — mov ax, @iata “nile data segneat Giada tall aap z povide at ee : ‘mov x, won! pir dividend load LSW of Dividend sae Moe mov ds, word ptr dividend+2 Load MSW of ‘Dividend ‘db 12h: M Ses who Ah divine Divide Double Word by word a Lee ‘mov quo, a ‘Store quotient ie ino rem, dx Sore remainder y el ‘mov ax@data _, ;[nitialize data segment ‘ mov daax = end s wer nd DiS wo y ne > Practical 7(b): Write an ALP to divide two given slgned numb: mov quoal Store Quotient Solution : . . mmovremah Sore Reisner ena 1. Division (16/8) word by byte division of unsigned as ; | numbers. ; = | atgorthm Initialize data segment, seer Load first number. Divide first number with second number. Store quotient and remainder, Stop. weer ig Flowchart : Initialise Data Segment _{ Load signed dividend in AX [a= ivide AX by signed divisor by using IDIV instruction | ‘Store Signed Quotiont and Signed remainder ‘to memory from AH and AL moy dex - : ‘Divide word bit by b ‘mov ax, dividend ‘Sios Quotient ee ‘Store Remainder 16) double word by word division of 2, Division (32/ unsigned numbers Algorithm 1. Initialize data segment: ‘Load first number. Divide first number wi ‘Store quotient and rem: th second number. 2. 3. jinder. A a & List of Practicais Flowchart Inialoo Data Bepnont i {oad signed dividend In DXAK I ‘Divido DX:AX by signed dvior by oing IDIV instruction I ‘ior Signed Quotiont and Signed remainder Hrom AX and DX to memory dw 0 dw 0 “mov. @datt movds,ax ov ax, word ptr dividend ‘mov dx, word ptr dividend +2 Load MSW of ; Dividend 3 Practical: Write an ALP to add, subtract, multiply and divide two given BCD numbers. solution: 4. Addition of two-BCD 16 bit numbers Algorithm 1. Initialize data segment and MSB byte counter with 0. 2, Load lower byte of first 16 bit BCD number. ‘Add lower byte of fist BCD number with lower byte of, second BCD number. 4, Adjust result to BCD. =F Microprocessors (MSBTE - Sem 4 - Comp.) Liz List of Practicals 5. Store result of lower byte's addition ©. Load higher byte of first 16 bit BCD number. 7. Add higher byte of first BCD number with higher byte of Second BCD number, 8. Adjust resultto BCD, 9. Store result of higher byte’ addition, 10. Ifresult> 16 bit then goto step 11 else 12. 11. Increment MSB result counter. 12. Stop. Flowchart Initialize Data Segment Initialize MSB counter by 0 q Load LSB of fst 18 bit BCD number in AL] L ‘Add LSB of second 18 bit BCD number with Al] ‘Adjust Result to BCD by Using DAA instruction ‘Store LSB of BCD result to memory Load MSB of frst 16 bit BCD number in AL ‘Add MSB of second 16 bit BCD number with AL ‘Adjust Result to BCD by Using DAA instruction [Store MSB of BCD result to memory] 1s Resut > 16 bi Thorement MSB countor ‘Store MSB rosultio memory Program {model smati (daw LP rum. dv | num2 dw t slew dw roa_mab db sInitialise data segment ov al,byte ptr num], jAdd LSB first seonvert result to BCD d al,byte ptr mum2 Store LSB of result ;Add MSB "next _ sConvert result to BCD Check result>lobit Algorithm, 1. Initialize data segment, 2. Load lower byte first 16 bit BCD number. 3+ Subtract lower byte of second BCD number from lower byte of fist BCD number. 4. “Adjust result to BCD. . 5. Store result of lower byte’s subtraction, 6. Load higher byte of first 16 bit BCD number, 2 Subiract higher byte of second BCD number from higher byte of first BCD number, 8. Adjust result to BCD, Store result of higher byte’s subtraction, 10. Stop. S¥_Microprocessors (MSBTE - Sem 4 - Comp.) L13 J List of Practicals. Flowchart 4. Result = result + multiplicand, 5. Adjust result to BCD. 6, Ifresult> 16 bit then go to step 6 else step 7. Triiaize data segment 7. Increment MSW result counter. 8. Decrement addition counter by one. 9. Ifaddition counter # 0 then goto step 4. Load LSB of first 16 bit BCD numborin AL 10. Store result. ‘Subtract LSB of Second 16 bit BCD number from AL 1h Stop. T Flowchart Using DAS instruction Initialize data segment ‘Store LSB of BCD result tomemory Thitalize result and MSB counter with © Initialize addition counter with muftiplior Load MSB of first 16bit BCD number with AL ‘Subtract MSB of Second 16 bit BCD number form AL lesult = Result + Muttiplicand ‘Adjust Result to BCD by J Using DAS instruction Adjust Result to BCD ‘Store MSB of BOD result to memory i Result > 16 bit 2 Stop Tncrement MSB counter by 1 ———+ Deorement addition counter by 1 Is ‘Addition counter = 0 ? ‘Program Convert result to BCD data Bomrut 2) 00| | (eau! de 9h : Multiplier sees oe num2 dw» 99998 +; Muhiplicand Multiplication of two BCD 16 bit numbers gorithm Initialize data segment and MSB counter with 0. Load multiplier in Addition counter register. Initialize result with 0. Derr awawpe S_Microprocessors (MSBTE - Sem 4 - Comp.) “mov a0) 4 method 4. Division of two BCD 16 bit numbers Algorithm Initialize data segment. Initialize quotient counter with 0. Initialize result variable with dividend. ‘Result = Result Divisor. Adjust result to BCD. ‘Increment quotient counter by 1. If result of subtraction > divisor then go to step 4. ‘Store quotient and remainder available in result Stop. wehart Resi «Row Oren ‘ajo Roast BC "Trea Oven Couto ‘St Gaston and Romande a namo Ge ed abe penn : Multiply two BCD numbors : mv byl pl a Asw.Al j Successive Addition List ol rracucals ‘model small | Bein dw 0009h sDIVISOR | | m2 dw 0099h :DIVIDEND | que db 0 | tem dw 0 veode mov ax,@data data Segment | mov dax | mov bh,o oy ax,num2 vide two BCD numbers ‘ub ab,byte pte numl das ‘Successive Subtraction + methods “mov byte ptr rem,cl aan mov axyrem ‘emp exynuml ‘Compare result with divisor Jee up “end cend > _ Pfactlcal 9(a) : Imploment loop in assembly Y language program - Write an ALP to tind the sum of series of hexadecimal numbers, Solution : Algorithm, 1. Initialize data segmei 2. Initialize word counter and memory pointer to read number from array. 3. Initialize sum variable with 0, 4. Sum = sum-+ number from array 5. Ifsum > 16 bit then goto step 6 else step 7, 6. Increment MSB result counter, 7. Increment memory pointe 8. Decrement word counter. 9. word counter = 0 then step 10 else step 4, 10 Stop. rd Flowchart ‘Sum of Series of Word Inaizo word count GX and memory pl 19 Sito red numbers om any Ina SUM ——— ‘SUM = SUM + Number from Aray Increment MSB Countor —— Tnerement memory pointer by One ‘Decrement word counter by One > Practical 9(b) : Implement loop in assembly language program - Write an ALP to the sum of series of BCD numbers. Solution : Algorithm 1. Initafize data segment. 2. Initialize byte counter and memory from array. : Initialize sum variable with O. ‘Sum = sum + number from array. ‘Adjust result to BCD Ifsum > 8 bit then goto step 6 else step 7. Increment MSB result counter. Increment memory pointer. Decrement byte counter. 10. Ifbyte counter =O then step 10 else step 4. 11, Stop. Flowchart Sum of Series of Byte Initialize byte counter in CX and memory pointer in SIto read numbers from array Initialize SUM = 0 pointer to read nuimber er aya ° ‘SUM= SUM + Number from Array Increment memory pointer by One Decrment byte counter by One Is Byte Counter = 0 2 List of Practicals > Practical 10(a): Write an ALP to find the smallest numbers from array of n numbers. Solution = Algorithm i Ini : : from aay. Reale tenmemacy | | 5 Rad mtr th say. » sAdd with sum) 1 | 4, Increment memory pointer to read next number. a : ‘Decrement word counter. Compare two numbers. If first number < second number then go to step 8. Replace first number with second which is smallest. Tncrement memory pointer to read next umber the say, Decremént word counter by 1. ‘If word counter # 0 then go to step 6. Stor result Stop. Initialize byte counter Initialize memory pointer. ize data segment. ize word counter and memory pointer to read numbers Traine data sogrert T Intalio Byte Courtor OX and Memory Pointer Sito road number from array ] oad number from the aray| Tnrement Memory Polniar to point naxt number by 1 and decremont Bye Countor by 7 £ ‘Compare number with naxt numborin array RF_ Microprocessors (MSBTE - Sem 4 - Comp.) Laz Program siioy small {Store salle number from AL mood aN a : i data, end! sated i = = as INIaASE ct wee | > Practical 10(b) : peels = nels fsraite largest -eode + : numbers. mov ax@data —-_sInitialize data segment Solution : ae | Algorithm how ex Initialize byte counter to read, 1, Initialize data segment. ee ee «| 2) tnititize word counter and memory pointer to real numbers i mov sioflset array. Initialize memory pointer aa ee deo ex Sirens Wa oak bel 44, Increment memory pointer to read next number. up: ine si ‘pceasent atiory POLS 5, Decrement word counter. ee ;point next number in afray 6. Compare two numbers. comp al,[e] Fouspaze nimbers to find +. tent number > second number then oto step 8. smallest number 8. Replace first mimber with socond which is largest. jenext ‘if first number next number then gotodn | | solution : | Schganjsi+2] —sioterchango numbers pee | acheante 1] 1 inti data segment fin: addsi2 increment memory poinier | 9" Find ength of source sting. | oop up —_sdeorement word counter #Othen wp | 5, Copy source string to destination string in reverse order | desbe decrement pass eounteri#Othen upl | 4. pisplay bo source and destination string. jaz vpl 5. Stop. ser) Tritaliza Data Sogmont L Thializo Memory Pointor for Source String in St Inializo Memory Pointor for Destination String in DI Tnifaze Count S to Count Character in Sting Road Gharactor from Source Sting 10 AL Tnerement Count_S Increment Memory Pointer of Source SI by 1 1 Decrement Memory Pointor of Source String SI by 1 + ‘Read Charactor from Source String in ALU s in { Momory Pointor SI Copy AL to Destination Siting using Memory Pointor DI q Increment Dastinatlon Memory Pointor DI by 1 “" Docromant Counts by 1 Y ‘Display Destination Sting Which Ia Rovorse of Source Sting wat Program smiodel small wdata ‘sts db ~ ‘COMPUTER DEPARTMENTS’ sted db 50dup(s}) ©. Msg] db" 10,13,The source String: $',10,13 msg2 db 10,13,The String After Reverse :$10,13. . count db 0 scode mov ax,@data tialize data segment moy dex ;Caleulate length of aourte string mov sijoffeet sts slniti next: mov asi] jie memory pointer sread first character from source string emp aly$" check for end of string, ifyes then exit jecsit selec : ine si sIncrement memory pointer ine count increment length counter ‘ jmp next" sjump toread next character exit: sCopy Source String to Destination jstring in reverse order ‘mov di,offset str_d ;initialize memory pointer for destination string {Practical 42(b): Write an ALP to find string length. Solution : Algorithm eee Initialize length counter. 1 data segment. 2 3, Initialize memory pointer to read character from string. 4 5 Read character from the string. I characteris ‘S* then goto step 9. 6. Increment length counter. 7. Increment memory pointer to next character. 8. Gotostep4. 9. Stop. Flowchart @ Inidaizo data cogent Initatize memory pointrin SI and length S courtor wih O Tor source sting up: desi decrement memory pointer for _ jsource string = mov al{si] read character from source str in reverse onder mov [dial ;copy it to destination string in sforward order ine di Jinerement memoty pointer for sdestinaton sting © dee count —;decrement length counter il jozup {if length counter # 0 then ‘jump up to copy next scharacter display both string i pee ees pamela On sereen using j ? 09h function of INT 21h Ce mov ah09h —;Display Source string on screen lea dx, msg} int 21h | mow ab,09h pee (=) eer | iota iat “mov ‘Display Dest. string on soreen ia ae suern sDiaeley Det see sis db ‘COMPUTERS’ int 21h beat abo vende ee + mov ax,@data slnitiatize data segment int 2h + mov ds,ax © mov ah,tch Exit w DOS roy sioffsetstr_s _ sinitialize memory pointer int 21h next; mov al,fsi) yread character ‘ends ‘emp al'$" jeheck for end of string end te 1 jeexit 3 ifnot end of string then qiferement memory painter “ GIncrement length c jump to read next character ine si ine length = = ‘jmp next > Practical 12(c): Write an ALP to concatenation of two strings. Algorithm 1, Initialize data segment. 2 1 memory pointers for source and destination. 3. Move memory pointer of source string to end of string. 4. Copy characters from destination string to source string. S. Stop. Flowchart Tae da sae i Initialize memory ponntorin SI for source sting — ‘Read charactor trom source sting Tnorement memory pointer SI by 4 —_ aaa! Initialize memory point in DI for Destination string ‘Road charactor trom Destination String in AL Cony Character from AL to Sourea String N Jnctement memory pointors STand Diby 1 Program model small data : str_s db ‘COMPUTER ENGINEERINGS' ‘ind db ‘LINFORMATION TECHNOLOGYS' imgl db ‘After Concatenation...:: $ condo mov ax,@data Initialize data segment move memory pointer to the last f character of the source string 1 gov ai,otTne slnitialize memory pointer mov dyn sfor source string, next: mov al, ‘emp al,'$' je exit sls memory pointer is at last character if yes then jump to concatenate string {jmp next initialize memory pointer for destination string sread character ‘mov dijoffset str_d ‘up : mov al,[di] ‘emp al'$' seheck end of string je exit] sifyes then exit mov [si}al selse copy character to source ie sstring ine si sinerement memory pointers for ine di ssource and destination _ impu * srepeat process till end of ' 5 destination string vex: “mov al,§! jend the source string by inserting $ | mow [sat ‘mov ah,0Dh display concatenate strings | Ten dx, msg int 21h .nlov ah,Ooh lea d,str_d | im aan | toy abel ‘erminate the program & exit | sto DOS } iain } ends ened Qe i ¥& Microprocessors (MSBTE - Sem 4 - Comp.) L-23 > Practical 13(a): Write an ALP to check given 16-bit number is odd or even. Solution : Algorithm 1, Initialize data segment. Load number in resister. 3. Check number is odd or even. 4, Ifnumber is odd then store result to odd. * 5. Store result to even. 6 Stop. Flowchart Trivatza data sogment ‘Load number in AX : Rotate AX toward Right by 1 bit to Check number w Y ‘Glow EVEN Number to |f Store ODD Number to ‘memory memory Sop Initialize data segment © load number in AX” j ‘fotale number by bit toward Jef Practical 13(b): Weite an ALP to count ODD and EVEN numbers from the array of five 16-bit numbers. Solution : Algorithm 1, Initialize data segment. Initialize ODD_counter and EVEN_counter to 0. 2 3, Increment word counter. 4, Initialize memory pointer to read number. 5. Read number. 6. Check number for ODD or EVEN. 7. Ifnumber # ODD then goto step 10. 8, Increment ODD_counter by 1 9, Goto Step 11 10, Increment EVEN_counter by 1 11. Increment memory pointer to read next number. 12, Decrement word counter by one. 13, If word counter # 0 then go to step 5. 14, Stop. Flowchart Tiitaize data coor 5 _ Tritaize ODD EVENCouzer Cou ‘od een mbersin the eray Thitiaizo word countorin OX ‘and memory pontarin ST F Fad Norbert array © AX. r Rotate AXby 1 itto Right <> Trerement ODD countorby 1 Treroment EVEN courtor by 1 Therement momory paler by 2 DDeoromant won! pointer by Is Wont Countor=0 ? Wists XE Microprocessors (MSBTE - Sem 4 - Comp) L24 List of Practicals Practical 14(a): Write an ALP to check given is positive or negative. Solution : .| Algorithm 1. Initialize data segment. 2 Load number in resister. 3. Check number is positive or negative. 4. If numbers postive then store result to positive and goto step 6. 5. Store result to negative, 6 Stop. Flowchart Tnidalize data segment Load numborin AX Riotato AX toward Left by 1 bit to Chock number ‘Store Positive Number to memory Initialize data segment sload number in AX : sotate number by 1 bit toward left scheck number positive or negative iif negative, then restore the number jstore in memory vatiable neg. sjump to end the program se restore number jstore in memory variable pos. bend > Practical 14(b): Write an ALP to count Positive and Negative numbers in an array. Solution = Algorithm 1. Initialize data segment. 2. Initialize POS_counter & NEG_counter to 0. 3. Initialize word counter. 4. Initialize memory pointer to read number. '¥_ Microprocessors (MSBTE - Sem 4 - Comp.) L25 List of Practica 5. Read number. 6. Check number for POSITIVE or NEGATIVE 7. If number # POSITIVE then go to step 10. 8 Increment POS_counter by 1. 9. Goto Step 11 Increment NEG_counter by 1 Increment memory pointer to read next number. Decrement word counter by one. If word counter # 0 then go to step 5. Flowchart Initialize data segment Tnitialize POS & NEG Counter to Count} positive & negative numbers in the array Initialize word counter in CX and memory pointer in SI Read Number from array to AX Fotate AX by 1 bit to Right Increment memory pointer by 2 Decrement word pointer by 1 Is Word Counter=0 Program 7 ‘model small 5 data TE Z dw. 5;8/6)-1,8%; s ° array: pos_no db {nego db “0 Lode mov ax,@data data segment shi mov ds,ax mov ex,5 Initialize word counter mov sioffset array Initialize memory pointer. jextemov ax[si] Read number from array - ;Check number for positive or negative number is negative got to da. ” Practical 15(a): Write an ALP to count numbers ¢ “1 in given number. Solution = Algorithm 1. Initialize data segment. Initialize rotation counter by 16. 3. _ Initialize ones_counter to count number of 1's. 4, Load number. Rotate number left or right by.1. 6. IfCF# 1 then goto sep 8. 7. Increment ones_counter by 1. 8. Decrement rotation counter by 1. If rotation counter ¢ 0 then go to step 5. Stop. ¥ Microprocessors (MSBTE - Sem 4- Comp.) L26 Uist of Practicals Flowchart > Practical 15(b): Write an ALP to count numbers of ‘0" In given number. Solution : Thitalze Data Sogmont Algorithm, 1. Initialize data segment. oe 2. Initialize rotation counter by 16, nlalize | untor to Count 9 ? Initialize Rotation Countor with 16 3. Initialize zeros counter to count number of O's. 4. Load numberin AX I 5. Rotate number lf or right by 1. Load numbor in AX 6. IFC + O then go to step 8. _-—___ 7, Increment zeros counter by 1. f 8. Decrement rotation counter by 1 Rotate AX toward Right by 1 9, Ifrotation counter # 0 then go to step 5. 10. Stop. Flowchart Gan N Initialize Data Segment Y T 7 Increment ONES Counter by 1 Initialize ZEROS Counter to Count’0's = Initialize Rotation Counter with 6 Decrement Rotation Counter by 1 - Load number in AX ‘num div Offeahi ‘ a [cones ab 0 i ode ‘ i 5 Mov a@data Initialize data segment fe or dea: Yo mov ex16 ¢ rotation counter.” F mov ax mum sload number in AX ‘up moran] sRotate number by 1 bit right: jmedn sifbit # Lthen gotodn | inc ones else increment ones by one ‘da :loop up | decremest rotation counter. ‘ends ¥ Rotate AX toward Right by 1 a Ler List of Practicals Program © mov axnum] model small R na moe sub axynum2 ‘data 3 | | mov res_sub,ex | pum ~ dw Oanash || eet | zeros db 0 \ | 5 endp : | ‘ode “| mul_num pre; Procedure for multiplication | mov ax,@data slnitialize data segment 3) || mov axnum] mov dsyax © | mi aune tov ex 16 Sinialize rotation counter | ||? mov word pe res_ mules ‘mov axnum sload number in AL. © | | © mov word prrres_mul-+2,dx up: reral,. sRotate number by Lbitright. | | ret, jedn HUI Othen giodn | | endp a fui neros Ss elas inesenieal ves by se Aix_tum prot; Procedure for division ‘dn Eloop up. decrement rotation counter om ends 5if rotation counter # O then go to up ead stop Patio 161): An assembly language program > using procedure - Write an ALP Addition, subtraction, multiplication and division. Practical 16(b): An assembly language program using procedure - Write an ALP using procedure to solve equation such as Z = (A+B)*(C+D), (25 Quotient of division 2; Remainder of division 3Calll procedure for addition 3Calll procediire for ‘subtraction : Call procedure for multiplication = 5 3Call procedure for divi Mov ax,@data; Initialize data segment = ;Exit to DOS Mov dsyax * ‘mov ala ; load al with a mov bl,b ; load bl with b "i -calladl_ byte jal procedure for addon ( “MOY asumal_ store result of addition 4 omovale ;loid al withe Mov bl jtoad bl with a © alladd bye 5 Procedure for addition seall, ‘Procedure for addition 3mnultiply the result of 2 sum store final Fesult rR & Microprocessors (MSBTE - Som 4- Comp.) 28 Se | 1 mov ax, @data | moy dsax j add_num numl,num2,res a unum num] jaum2,reas {num num]jnum2,res_ml,res_mm. v_num nur jnum2,res_5yrea_q - ends iy Paes Practical 17a): An assembly language program using Macros - Write an ALP addition, subtraction, multiplication | | and division. Solution : > Practical 17(b): An assembly language program using Macros - Write an ALP using MACRO to solve equation such as Z=(A+B)*(C+D). 2° div_num maero nll, n2, x; q mov ax, nl mov bx, n2: div bl ‘mov rah sTnitilize data segment % mov q, al mov da,ax, : = © endm ©] 52) mma aubyet 5 Bind (ab) vl ody; Find (+d) cesta | moval, rt [5 mum dw -1234h 1 mul 3 Perform (atb)*(o+d) i num? dw, 99h | mov z, 0x. I ‘ends, \ 1 eid a Solved MSBTE Question Paper of Summer 2019 | Appendix A a. 4() @.1(b) Q.1(¢) 1¢) a1) a1 2.149) Q.2(a) 0. 2b) Q.2(¢) @..2(¢) 1. 3(a) @..3(b) . 3c) @.3(¢) Sate the function of BHE and Ao pins of 8086 ,(Section 1.3) (Chap. 1, 2 Marks) How single stepping or tracing is implemented in 80867(Section 1.4.1) (Chap. 1, 2 Marks) State the role of Debugger in assembly language programming. (Section 2.3.4) (Chap. 2, 2 Marks) Define Macro & Procedure. (Sections 5.1 and 5.3) (Chap. 5, 2 Marks) Write ALP for addition of two 8 bit numbers. Assume suitable data. (Section 4.3.1) (Chap. 4, 2 Marks) st any four instructions from the Bit manipulation instructions of 8086. (Section 3.4.3) (Chap. 3, 2 Marks) Stato the use of REP in string related instructions. (Section 3.4.7) (Chap. 3,2 Marks) Explain the concept of pipelining in 8086. State the advantages of pipelining (any two) (Section 1.7) (Chap. 1, 4 Marks) Compare Procedure and Macros.(4 points). (Sections 5.4.3) (Chap. 5, 4 Marks) Explain any two assembler directives of 8086. (Section 25) (Chap. 2, 4 Marks) Write classification of instruction set of 8086. Explain any one type out of them (Section 3.4. and 3.4.1) (Chap. 3, 4 Marks) Explain memory segmentation in 8086 and list its advantages. (Section 1.5) (Chap. 1, 4 Marks) Write on ALP to count the number of positive and negative numbers in array. (Section 4.3.12(c)) (Chap. 4, 4 Marks) ‘Write ALP to find the sum of series. Assume series, of 10 numbers. (Section 4.3.3) (Chap. 4, 4 Marks) With the neat sketches demonstrate the uso of ro- entrant and recursive procedure. (Chap. 5, 4 Marks) Ans. : Reentrant Procedure: = A reentrant procedure is one in which a single copy of the program code can be shared by multiple users during the same period of time. = Reentrant has two key aspects: The program code ‘cannot modify itself and the local data for each user must be stored separately. THAN PROGRAM, L Pa a li x(a) Recursive procedures: — A recursive procedure is a procedure, which calls within itself and are used to work with complex data structures called as trees. = Arecursive procedure is one that calls itself. =» There are two Kinds of recursion: direct and indirect. In direct recursion, the procedure calls itself and in indirect recursion, the first procedure calls a second procedure, which in turn calls the first procedure. tone SERS ET ea a can can Cau] Preaure REY Ree nen Fig2- Q3(@) Q.4(a) Describe the mechanism for generation of physical address in 8086 with suitable example. (Section 1.6) (Chap. 1, 4 Marks) Q.4(b) Write an ALP to count ODD and EVEN numbers in array. (Section 4.3.11(c))_ " (Chap. 4, 4 Marks) Write an ALP to perform block transfer operation of » 10 numbers. (Section 4.3.13) (Chap. 4, 4 Marks) Q.4(4) Write an ALP Procedure to solve equation such as Z=(A+B)* (C+D). ID > Geetion 5.5.7) (Chap. 5, 4 Marks) S€_twicroprocessor (MSBTE-Sem.4-Comp) Ag Appendix A Q.4(e) us ‘an ALP using macro to perform multiplication | 2. Multiply contents of AX by O5H. of two 8 bit unsigned numbers. : MOV BX, 061 (Chap. 5, 4 Marks) ae Ans. : MUL BX -model small 3. Load 4000 H in SP register. muLnum — macro not,no2,result MOV SP, 400011 mov alnot 4. Copy the content of BX register to CS. (CS cannot be copied mul noz hence operation cannot be performed) mov resultax MOVCS, Dx endm 5. Signed division of BL and AL. data in numtdbazh a num2 db 43h IDIv BL res dw?” 6. Rotate Ax register to right through carry 3 times. code: : MOVCL.3 mov ax@data netics mov ds,ax @.6(c) Write an ALP to arrange numbers in array in .6(¢) Write an i eS descending order. (Chap. 4,6 Marks) = Ans.: end : -model small @.5(a) Draw architectural block diagram of 8086 and || data describe its register organization, sae fon) (ena. 1,8 marke) || 20% dw 9,6,8,2,6,7,3,4.2. @.5(b) Demonstrate in detail the program development | |" a aisal steps agsombly language progresnming: mov ax,@data _Initialize data segment (Section 22) (Chap. 2, 6 Marks) ‘mov ds,ax = @.5(c) Illustrate the use of any three Branching mov bx,10 Initialize pass counter instructions. (Section 3.4.4) (Chap. 3, 6 Marks) | |up1: @.6(a) Describe any six addressing modes of 8086 with || movsioffset array Initialize memory pointer suitable diagram. (Section 3.3) (Chap. 3, 6 Marks) || mov cx.9 slnitialize word counter @.6(b) Select an appropriate instruction for each of the | Jup: following & write: mov ax,[si] (Chap. 3,6 Marks) |] cmp ax,{si¢2] ‘ompare two number (@ Rotate the Ocontents of DX to write 2 times |] ne dn ‘if number nest umber | without carry. to dn | (i) Multiply contents of Ax by 06H. xchg ax,[si#2]__ sinterchange numbers Load 4000 H in SP register. xchg ax.(si] | Copy the contents of Bx register to CS. ldn: add si2 sincrement memory pointer | Signed division of BL and AL. loop up sdecrement word counter if # 0 then | (iv) Rétate Ax register to right through carry 3 | |UP | times, dec bx decrement pass counter if # 0 then Ans. upd jnz upt 1 RetletesonmserDxtowie2tine vides. || St MOVCL.2 0» ed ROR DX, CL [ara ae aaa

You might also like