0% found this document useful (0 votes)
25 views16 pages

Coal Labs

computer orgainzation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
25 views16 pages

Coal Labs

computer orgainzation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 16
RCL (Rot B is shifted Into the bs = words. RCL wo $ 's shifte wonts, RCL works fi cra ged Sma is: RCL AN RCL destination to the lef. into the rightmost bit, the citcle of bits being, destination, | destination, CL, sty Right (RCR): Hon RCR (Rotate throu; ‘gh Carry Right) Works just like RCL, ‘except that the bits are * she Hight See Figure. The symtan ee RCR destination, | AND RCR destination, CL Task 7.1 Programming Practice Q.1 Wa s ssembly language code to Print whether the number is ev odd negative. ample Executio} ENTER NUMBER: 8 IT IS EVEN POSITIVE boos Bt ee ah cUch 3, Lt i Int Ath 3, °Tt ie Main end P a Mov AX of fsct'v END Maiyy ot Pee ‘a int ah & data SMP Exit tod BIL bx, C ONEG SMP OPOS aPac. ue. Q.2 Write an assembly language code that will display number of O's and 1°s in a charac, by a user. oy \P ADDON = INC CONT LOOP Check. bo wd“ : 2; Numbes gy Osarnt mel’ CONT dB oo ADD dO,Ug Moy @ah,b Proc NT yh 0X @dola Moy ah 4 ds, ax mou dy offs v3 mov ah, 4 INT ath mou dy offset wh mev CLicoNnT iad sth Mov b2Q,.8 muy SLB bic 9 ah | mov do, b0 doth App dd, 4s roy bho Mow ah, 2 mov cx, TNT alh Check : ce abu ach , int alh Rol BL, | biog ech tec SC ADDN TNT ath LOOP Ey chypce Maw supp LAB #8 | Theory: Number System Conversions Practice the code of Binary Input, Binary Output, Hexa Input, Hexa Output and Petr tg following tasks. Task 8.1: Programming Practice O.1 Write an assembly language code that wil input a hex digit fom user and wil ony binary and will also display it in binary. 4 Sample Execution: ENTER A HEX DIGIT: A IN BINARY IT IS: 01000010 print s «model small Mov dQ, ‘o * Stack ooh sdalan test bY soocodoob ae. Enter a Hex digh B Posey A Main Proce int all ™ev ax, @deda She Rt ™ov ds, ay Oop pint mov ahiq mov al, “Vy mov dx opfcet WL int Wh Int Uh mov ah Yeh mov al, | int uh \nt ath ‘ Main end bi, | ee Ehd Main . mov dx lO mev ah, v PONE int 2} mov AK) |3 MoV ah) 2d int ah Bamov cx 2. ~avbly language code that will input a binary number from user and will convert it ‘will also display it in hex digit, ENTER BID RY: 01000010, IN HEXA IT IS: A ocel smal! Jooh lata UL db “Enter Biro .¢ 2 dle TIS“TN Heya tt ised” JeRINT s veo mov alibh Main Proc sue lly | mov ax, @dota oR al! mov ds,ax SiR dl, | mov ah, SHR hy _ mov dx offset vi cMP Al, 4 | iat th TLE Numbes. | OR bx bx add all, SS mov ah, | SMe Dispky Y Numba « INPUT: . |) int ay add al, 4g ie Display : LL CMP od \\ ‘ott ad, , SE END ROL bx, | i” - | SHL bx, Rot bx, | , Rol bx) Sub ol 4? Ro. A) PRINT OR bh, al Loe PENT Assignment # 2 Qu Write a program that will take binary input from user and will also display it emodal small Rol bx, ) ose lool, ie ie 7 y|rmov 0,'o vt ab lor", You Typed = Ven gy ah) 2 Main Pyoc moy ax, Odata op pint Mou ds ay as XOR by, bx Ne mov ah, ] Ney ahi INPUT: ne Ah a i, Int alh CMP al, 13 2? Print SE END. exie SL lox, | MoV ahi Uch SUB al 4g mes é, bial Main Endp | P T Endl Hain END—+ mov cx )S& mov ahi4 mov dx, offset vi = ae - i ; ; b 5 wnte an assembly language code that will take Hexa input from user and will also display it. (go . * | vedel small nsext 2 q ar eon ot bhial . job et TMP In put . » JEN D-: vi db 10,13;"You TXPED:§ scode - Voc, Main mt ah Mev ax, Odaba mov cx, Y mov ds, ax Mov ah, 2 X b Print = ns mov olf, bh pmo chy SHR at, | bo mov ahi SHR ALT | Tnpubs HR AQ, | | et ah R Avy © MP ab 13 CMP lt 4 JE ENDL ye DispNumber add ds ¢ SHU bevel SMP dis CMP al, q? ispNumber' mov ah ch SLE Number dat Aue "|e Sub ah, € disp Wl lh po S6 ‘int’ alh Main Endlp SMe Inset RoL bx, End Num, RL box, | a | Sub al, ug Rol. ba, { Comments/Signature (Student & Teacher): 1 5 af ek 30. LAB #9 Theory: Stack A stack is one-dimensional data structure. Items are added and removed fiom one, addin’ structure; that is, itis processed in a “last-in, first-out" manner. The most recent Ie is a stack of dishes; the k my stack is called the top of the stack. A familiar example is the last it the stack isthe top one, and it's the only one that can be removed easily. ‘\ program must set aside a block of memory to hold the stack. We have been doing declaring a stack segment For example: STACK 100H / Task 9.1: Programming Practice Qu Write an assembly language code that will input a string from user and will display itin reverse order on next line, Sample Execution: ‘ABCDEFGH mov dl, \3 HGFEDCBA ‘ ; ic emodel gmeall now A *Stack look » dota Ld: ° code fee a ° Mev ah,L Main Proc int alh mov ch,7 Loop LL } ie Mov ah ch mov ah)) int alh int ah Main End p mov ahiO End Mai push ax “uN Loop U4 mov ah,2 mov dl,\o i h Tats 21. signature (Student & Teacher): <31- | Q.1 Write an assembly language code that will display 10x10 boxes of asterisks (*) by sig procedures. , ' F) Moy real 7 '* prot: int alh (oop py ole pop a & Moan Py yet 3 P int 57k endp O eyo ax @date mov ds, ax nl prot OV ah,4F [f teh vb mov 6X10 mov Ax, 2 Call print stay Fink alh cad) nl yet , loop oulet ne end P ancl yairy , Gudea ovtes mov ab,Ych ant ath main GndP prindstac pre push CX ww ov CX/10 MOV ah, | Comments /Signature (Student & Teacher): i LAB #14, Theory: Decimal Vo Decimal Input and Output Procedures: Even though the computer represents everythin, input and output expressed in decimal tn this vo. Seaieit@t¥, its more convenient for the user to see Stction, we write procedures for handling decimal Task 11.1: Programming Practice Hint: Use Procedures of DECIN and DECOUT smodel smal) — | CUP al“? > stack looh SE minvs aba > code . Ale Main Proc PE plus call Dec} ehG REPEAT Ql Call Decout TAY S's mov ahi ch May ex, | [ine erp lus- an ty Decin Proc int ah push bx Repeat as push cx CNP alfa! Push Ax - : INGE Nor Begins > [OHP ALS? mov i “5% JSNLE Not _O pac At 2 AND Ax 000FH int ath push ay 5 mov ax, lo Xor x tbx Boe be XOR cx, cx [pop be PA bx,ax Moy ah || -M- 2 Write assembly language code that will calculate LCM of two numbers and will ¢; a Sample Execution: ENTER FIRST NUMBER: 2 mov ax, @data WOV dasjax ENTER SECOND NUMBERS mov x lad ailah mov ay vi While_: meclel smal mov bx,v2 estack woh v XOR Ax dy s dada MUL bx div by ico Niv cx ree dx Pm VL dw us prey LeM 1 ax ae “ CALL X10 Duce ee 2 i oe INE while mov ah Ul of LCN dw 2 int ath Mov ahr -code Main fad Mev ete to Main Proc | iat alh Ruste ov ah 4 mov axl push Cx prints mov byx,v 2 op dx : ™ eee DD all, 4g mov aX,0 CMP Ax, 0 int alb ov : vnos oe sq Alpha —(fL&eP._ Pint div b ‘ Push Ax PAP oly iv bx Moy dtc! Pop cA mov bx dx pep bx vy ar, cx ev ah,d mo 1 Kut ath Pop ax CMP bx,0 Pop Ay RET JNE While _ Neq ax Pecopt endp mov HWCF 1a Ng\ana, End Main as. A Wate assembly language code ‘hat Will calculate SCD of mode! Smath estack look ePala vi db “Ember Nanbey yo ab & Gen 28" Code Main Prog wmev ax, @dada MOV as, ns Moy Ax, 0 PF seb vA OV ah, 9 Of two numbers and b E Xene, Div by Push dy a “40. Task 12.1: Programming Practice ‘Task L. Write a code that will add clements of an array and will display their sum, “Mocel smatl > stack lool A » WA dus 00,200) 390 400,600 600 700 code Main Proc mov ax, @daka mov dsjaq x Mov Si) Offset ary cx,T AxK,O moy mov ee Mov ax, Usi | ADD svi Loop LU Call Decout mov als Uch int ath Main Enel p Decev t Pree push ax push bx Push cx cmp ax,O mov US ‘wt al JG Alpha ay af Push Ax Print ~ ov dl pap ax ov ah, 2 JAPD OL,4g Int lh INT alh Pop ax leop print Neg ax por ax Aha: (Pep Xr Cx Cy pep lox Mov Bx lop Pep 9x While_s RET Yor Dx Dx Decovt Endp Div Bx End Main Push Dx INC Ch CMP ax,o SNE While, Mov ah, L Mov Al jo Mat al L oH — Fann 2c that will eleulte average of an ray and wil alo di odd srnolJ Push cx J oack \coh Push ds dota dd ax,66Sd wer AY 106 , 200,200 , 409 UP ax d code. vain Prog cov ax, @daba mov ds ,qQxr moy dt’) mov ah mov si, offsel oxy wet aie Mov CK Yy a an rp ax x Lis 6 * add ax {si | fella add si) > X0x cx cx loop uo Mov bx lo¢l Yor A whilee_+ ae Maer Axel mov bx, 7 e los n div bx ay bx call decout Posh chy gee! ah Yoh No CX mt nm 2th emp any Main End G NE whilee _ Recouk Proc . ov ah, 2 Push ay Task 3.Write an Assembly Language code to search a number in an Array. emodel small Leap Searchin sstack 00h mov dx offset 43 odata Mev ah, avy db 12,3,5,11,89,7, int a\h WOIET4 NS IMP Ende vi Ab “Entey Number $” : , [Num Pound V2 db 10,13, Number Found $ ‘ mov dx offset vey ba V3 Ab "0113; Number Not Faondg mov ah) 4 1D) valve dl n int ah * code End_: Main Pyoc mov ah, Uch mov ax ,@data int ath mov ds,ar Main Enel p MoV Ax joffset vb GrelEMalral- int alh mov ah,\ int ah Sub ab, ‘o? mov value, of mov si,offset ary mov cyx,\O mov al, valve Searchin - mov bors) CMP al, bd Ho hlam POO) -43- Task 41WRite an Assembly Language code o print umber of occu rmodel Smaff decast rstack \ooh ov. ah) Yeh, dota Mt ath count alu 0 Maing x dw \oo Recout Proc any dw ae ooh pan code Push cx Moin Py Ge Push dx Mov AX @ dada ™p ax, 0 mov als. qx SG Alphoy evs} ) Offset arr] push ax MOV ex ov Al, MoV ax, y Ynoy ah, li: int ath SOP Ox, TS} Ppop ax JE v2 ay Kdd si ,2 Shas leop L4 KoR CK Gy IMP ext “Mov bx 102) ecovl Endp Whe Nee. C Me count XR Bx Dy eka $i,2 DIV Bx bmp Ls eras ee. <4: | ye code to print minimum and maximum number in Array, Assignment # 3 Qu1.Write an Assembly Langu «model smatl Barge * + stack Jooh yoy LQ, Vsi] . -dlata + 7 mA ate avy db 10S 4, \1yX gmp camp * code p main endP Main Proc - End man: Mov ax @doto mov ds; &X& mov Si »of fset ary mov Cx, S mov bl, Tsil loop looptt add b8,48 mov Al, b mov al: 2 int ah smalls mov bafsi] Jyap ympare Comments/Signature (Student & Teacher):

You might also like