0% found this document useful (0 votes)
395 views

Computer Architecture Lab Programs

CA lab programs complete sep syllabus

Uploaded by

swethashetty537
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)
395 views

Computer Architecture Lab Programs

CA lab programs complete sep syllabus

Uploaded by

swethashetty537
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/ 33
PN eT ERD aH TN ay 1. Write an 8085 Program to Swap two 8-bit Numbers, 2, @. Write a Program to Find the Largest of Two Numbers b. Write an BOBS Program to Find the Smallest of Two Numbe . Write on 8085 Program to find whether an 8-bit number is positi display EE, if negative display FF, if zero display DD, i. Write on 8085 Program to check wheth 'er 4th bit of @ number Is zero of one. If 4th bit FF, if 4th bit is O display DD. is 1 display + Write an 8085 Program to Calculate the Sum of First Ten Notural Numbers: - Write an Assembly Lon guage Program in BOBS Microprocessor to Find the Sum of Digits of Number. ‘an 8-bit 7. Write an 8085 Program to Find the Reverse of an B-bit Number 8. Write on 8085 Program to Check Whether 1 -byte Number is a Palindrome or Not. If itso Palindrome display FF otherwise display DD. 9. Write an 8085 Program to Check whether a Number is ODD or EVEN, {f it is Even then Display 00, if Isis Odd, then Display FF. 10. Write on 8085 Program to Count a Number of Ones in the given B-bit Number. Me Write an 8085 Program to Find Acldition & Subtraction of two 8 bit HEX Numbers. 12. Write on 8085 Program to Find Addition of two 16 13. 14. 15. 16. 7. 18. 19. 20. bit Numbers, Write an 8085 Program to find Subtraction of two 16-bit numbers. Write on 8085 Program for Swapping of wo 16-bit Numbers. ‘Write on 8085 Program to Implement 2 out of 5 codes Write on 8085 Program to Generate Fibonacc! Series Write en 8085 Program to Find the Firs Ten Terms of Odd andl Even Numbers. Write an 8085 Program to Find 4-Digit BCD Addition. Write an 8085 Program to Find Multiplication of 2-digit BCD Numbers. Write an 8085 Program to Find Division of two B-bit Numbers.CD comurer arcinecure OTE Write an 8085 Program to Swap two &-bit Numbers, Algorithm: 1, Load the value from memory location 2500H into Accumulator A, Store the value of Accumulator A into register B. Load the value from memory location 2501H into Accumulator A, Store the value of Accumulator A into memory location 2500H. Move the value from register B to Accumulator A. eure Store the value of Accumulator A into memory location 2501H, Halt the Program, Mnemonic Code with Hex Code and Explanation z ES in Explanation 3A 0025 si Load the value from memory location 2500H into the Accumulator A | a7 Move the value from Accumulator A to Register B to store 3A0125 it temporarily Load the value from memory location 2501H into Accumulator A. 32.00 25 | Stor the value from Accumulator A into memory location 25001, effectively swapping the values, a Nove the value from Register B Accumulator’A, (original value of memory 2500H) back to} 320125 | Store the value from Accumulator A i ‘number location). into memory location 2501H (the second 76 Halt the execution of the program, * Iusing GNU Sim 8085, type the mnemonics cod i 00 need to manually enter hi ics code directly in the code editor, as there i ex codes, During the assemb! tically converts the mnemonics DB ly process, the simulator autom: into corresponding hex codes, + fusing a Physical Mi icroprocessor Kit, the hi ually in specie Tieeatanae t, the hex codes need to be entered mani ich as storing 3A at 10001 00 at 10014, 25 at 1002H, 47 9" 1003H, and so on. After entering the hex co yenst tease cati fr locations ‘such as 2500H and 2501 Cok les, load the input data into memory loc Counter (PC) to start hold the value: the Prog Fonneae sto be swapped). Then, update location 1000H to execute the program.on Appendix C Lab Programs « GD In.GNU Sim 8085, data is entered in decimal format, and the corre: isshown in brackets. For example, 58 in decimal is equivale Indecimal is equivalent to 52H, + Input: The memory location 2500H contains the value 58 (which is 3AH in he r : 53 exadecima and memory location 2501H contains the value 82 (which is 52H in hexadeci i) ao + Output: After executing the program, the values are swapped. Memory location 2500H now contains 82 (92H in hexadecimal), and memory location 2501H containe 58 (3AH in hexadecimal). sponding hexadecimal NU to 3AH in hexadecimal, and 82 Write a Program to Find the Largest of Iwo Numbers 1, Load the first number from memory location 2500H into Accumulator A. 2 Move the value from Accumulator A into register B for temporary storage 3, Load the second number from memory location 2501H into Accumulator A 4, Compare the value in Accumulator A with the value in register 8. 5 Ifthe value in Accumulator A is greater than or equal to the value in register B, jump to hext step. Otherwise, move the value from register B back to Accumulator A. 6. Store the largest value from Accumulator A into memory location 2502H, 7. Halt the program. Mnemonic Code with Hex Code and Explanation ! Explanation |_c 3A.00 25 AT 340125 | Load the second number from memory location [ Compare the value in Accumulator A with the value in register B IEA Gs Load the first number from memory location 2500H into Accumul Move the value in Accumulator A to register B for 01H {nto Accum Compare the value in Ac greater or equal, the Carry Flag is not set (6 | IAccumulator Ais greater than or equal to the value In register 8 (CY 0 Jump to the label NEXT, as A already contains the largest value from register B back into Hf Accumulator A (s smaller (CY = 1), toad the value). (OF Ainto memory location BON |Ls Ceampumee Arehiteatore © Input: Memory locations 2500H and 25011 contain 58 and 82 respectively * Output: The largest value (82) is stored in memory location 250211 Note : [NCNEXT' stands for "Jump if No Carry to F ndieg ‘Accumulator A is greater than or equal to the value in register B. The program jumps tq ‘and skips loading a new value, If the Carry Flag is set (CY = 1), it means Accumulator 4 {s smaller so no jump occurs, and the value from register B (the larger value) is loaded ineq Accumulator A. Ifthe Carry Flagis not set (cy 255 (FFH): Indicates the input value(128) was negative. Or negative, the corresponding results are stored at memory Note: * In8-bit signed representation, numbers range from -128 to +127. ~ Positive values: Range from 0 to 127. ~ Negative values: Range from -128 to -1, * The number 128 becomes negative when Tepresented as an 8-bit value because the most ‘significant bit (MSB) acts as a sign bit: ~ Ifthe MSB is 0, the value is positive or zero, ~ Ifthe MSBis 4, the value is negative. + Inthis » 134 (86H) has its MSB set to 1, j representa _ , indicating that it is a negative value in &-bit ‘Write an 8085 Program to Chee bit is 1 display FF, if ath bit is 1. Load the 8-bit number from memory location 2500H into Accumulator A. ‘With the Value OBH to isolate the 4th bit, ins the 4th bitis 0, Jump to ZERO and store DDH in memory location ‘k whether 4th bit ofa Number is Zero or One. If th 0 display DD,Appendix € : Leb Progrems -_CE7) [memonic Gode with Hex Code and Explanation a | Hex er [ MmemonteCode | cote Explanation T | | px2500H lscaage | Load the number from memory location 2500H into Accumulator | a eaee!| Sn a ae ee | Pra | Perform AND operation with 08H to isolate the Ath bit of the | _ | number. [)22ERO __|carzoo | ifthe MVLA.OFFH [28 FF [Move the value OFFH (indicati inte Accumulator A. | JMP STORE | €3 16.00 | Jump to STOR a 1 | ZERO: MVI A, DDH al STORE: STA 25014 [Her Iuput & Outputs Input = Output | Address | Data | Address | Data 2500H 6 (06H) | | 25011 [an (oon) | 2500H soon) lk cH + Input: Memory location 2500H contains values: ~ 6 (06H): The binary value of 6 is 0000 0110and hence the 4th bitis 0 = 9 (09H): The binary value of 9 is 0000 1001 and hence the 4th bit is 1. * Output: Memory location 2501H stores the result: - 221 (DDH); Indicates that the 4th bit of the input value (6) is 0, (a ~ 255 (FFH): Indicates that the 4th bit of the input value (9) is 1. (8086 Program to Calet Algorithm: 1. Initialize Register C with OAH (decimal 10), which represents the count of numbers to be added. 2, Initialize Register A with 00H (decimal 0) to store the running sum, 3. Initialize Register D with 01H (decimal 1) to keep track of the current number. ‘4, Add the current number (from Register D) to Accumulator A, 5. Increment the current number (Register D) by 1, 6, Decrement the counter (Register C) by 1. 7, if Register Cis not zero, repeat the process of adding the next number. a “Gin Accumulator A) Into memory location 250014,CE Comer rcrinecre ‘Mnemonic Code with Hex Code and Explanation —, 1 Hex Explanation | code MVIC, OAH OE 0A Load OAH (count of 10) into Register C. MVIA,0OH |3E00 | Load 00H into Accumulator A to initialize the sum to 0, - ___ | MVID,O1H |1601 | Load 01H into Register D to start from the first natural number (1), 4 LOOP: ADD D | 82 Add the value in Register D to Accumulator A. INRD 14 Increment the value in Register D (next number) DERE oD Decrement the value in Register C by 1 =} JNZLOOP €2.06.00 If Register C is not zero, jump to LOOP to continue adding, STA2SO0H | 32.0025 HUT 76 1, Initialization: Store the final sum from Accumulator A into memory location 2500H Halt the program execution. El + Register C (OAH) keeps track ofhow many numbers are left to add (initially 10) Setto 1O(OAH in hexadecimal), indicating that there are 10 numbers to add (from 1 to 10), * Accumulator A (OOH) starts with the value 0 to hold the running sum, Set to 0 (00H),s0 that the sum starts from zero. All subsequent numbers will be added to Accumulator A, * Register D (01H) holds the current natural number to be added, Set to 1 (01H), Tepresenting the first number in the sequence of natural numbers, 2, Loop to Add the Numbers: * The LOOP label starts the iteration for a microprocessor to repeat the instructions * ADD D adds the value in Register D (current number) to Accumulator A. The' Accumulator is updated each time to maintain the running sum. Ly + INRD increments the current number by 1. * DCR C decrements the counter to keep track of how many numbers have been added. = <.._ nzhoop repeats the loop ifthe counts not zero to ensure all ten sumnbersare added. result idding numbers. this label allow within section. output: sum ofthe first naturel ww is c: tab programs="Write" an assembly language program in microprocessor find of digits number algorithm: load from memory location into accumulator a copy value register b for safekeeping mask higher nibble extract units digit by performing and operation with ofh move c store it temporarily restore original a. rotate left four times bring tens lower position. again ofh. add halt program. mnemonic code hex explanation temporary storage zeae perform retain only _ c. once. accurnulator again. accumtilator one more time fo out leaving accumulao fram execution straightforward way finding individual dea rotations isolate each decima computer architecture output adress data address nibble: binary aniofh will odh which decimal or times: after bei digit: ani results provided me represented as hexadecimal. hexadecimal should be decimal. mory ui i write reverse using rlc instruction. . rotates accumulator. aleft through carry flag. rlcshifts bits left. leftmost bit moves flag lag fed rightmost instructions z effectively swap places ul positions highe cat>

You might also like