Free Essay

Pop and Push

In:

Submitted By muzamil4
Words 250
Pages 1
Abd ek k k k k kk kk k kk k k k kk k k kk k k kk k kk kk k kk k kk k k k k kk kk k kk k k k kk ke mewk mk k k mkm k k k k kk k kk k kketwk k kk kkekkw e kke kew ewk k k kk kk kew kkkk ekr wk kek k k kk k kk k kk kelwkf wk k kk k kk kk k kk kkk kk kk ejej jej j jej ewj jj j jej je jj eje jej jejjej je jej jej je jj j jekjwnf enf wjknjk nekj nwek ej nkj k jn kj jk kwe jk kj jk k kj kj ke jke ek kew kje jk jk jwjwekjrnwefjnwekjfwe jfwkfw ejk wkkjfwjjfwekjfnw kn kcjcw jwjk kjwej wke wkjke wkfnwkjfn wkj ke jkw kj kw jwk ekwjejk wjk wkej ewkjnfjwenfwfjwjrkwn ekj wkr wkjern wkj nwkejnrkwejrnwkjern wkjewrje ejwkr newkj newkjrn wekjrnwekjrnwejnr wkjrewknwjkernwjr jwekjrn wjekjrwe jekwnrkjewkrwejkkew kjw nkj nkj nk jk kj jk kj kj k ejwrkej kje jjk kj j kwe jrkwr kj ejr kwjr kwr jwekrwejwekrj nwkjfnsfsndfjn sdj nsdk f nsjkfnsdj nfdsjfn sjfn sjdnfksjdnf sdkjnf sjdknfsjdnf3nfjefndsjfnsdj nj njns djnsf sjnf sjn jn jnfjsd fnsjdnf sdkjfns ndjfns jnd jnfsjnfd jndskjf n jknfjksdfsdjkfnsk s ssks ks jknfsdjknfsjdfnsdjkfn ds nfjksnfskjdnfsjkdn fs ndskjfn sdjknfsj knd fknsdjkfn sdjfn sjkfnskdfnsdkfn sdkn jdn fksjnf sjk ndskjfn skjfn sdkjnf s fdsjknf jksfnsdkjnfsdkjfn s ndskjfnsjfns j ndjsfnsj kn jsnfjskdnfksfnskdfn ksdjfn ksjdfnskjdf ns jkdnsfkjsnfkjsf s skjfn sjkfnskjd nfjk ndkjs nkj

Similar Documents

Free Essay

Fhggg

...MCU Based Calculator The calculator circuit consists of an 8051 MCU that is hooked up to a keypad via port P1 and to 4 LEDs via ports P0 and P2. The keypad is an interactive part used for entering input values into the calculator. The keypad can be used by pressing keys on the keyboard that correspond to the characters on the keypad. These characters are fed into the MCU, manipulated and the resulting values are displayed on the HEX Displays from a range of 0 to 9999. Instead of building a calculator circuit using electrical components, the logic for the calculator is controlled by the 8051 MCU. The MCU can be programmed to perform virtually any operation based on the inputs that it receives from its ports. In this example, the MCU is used to keep track of input values in its memory and the current state of its operation. It also performs arithmetic operations on 16-bit numbers that include addition, subtraction, multiplication and division. ; -------------------------------------------------------------- ; Calculator Example ; ; This program performs calculations of the form: ; operand1 operator operand2 ; where the operator can be +,-,* or /. ; The operands 1 and 2 are positive integers between 0 and 9999. ; If the result of the calculations exceeds the range between ; 0 and 9999, it is considered an error. ; ; If an error occurs, "EEEE" will be applied to the output pins ; on ports P0 and P2. The operands and operator are obtained by ; reading...

Words: 2814 - Pages: 12

Free Essay

Assignment 2 Algo

...implemented using arrays where the data is stored in continuous memory locations. We have two operations in a stack push and pop. Since it has continuous memory allocated, if we try inserting data it gets saved in that free space present in either of the stacks. This is not a space wise efficient implementation because data is stored statically. In this case one stack can be full while the other is empty. 2. Using the basic queue and stack operations, write an algorithm to reverse the elements in a queue. Create an empty stack While the queue is not empty Remove a value from the queue and push it onto the stack While the stack is not empty Pop a value from the stack and add it to the queue. 3. Assume that 'Stack' is the class described in this section with 'StackType' set to into and STACK_CAPACITY or myCapacity set to 5. Give the value of 'myTop' and the contents of the array referred to by 'myArray' in the Stack s afer the code segment is executed, or indicate why an error occurs. Stack s; s.push(1); s.push(2); s.push(3); s.pop(); s.push(4); s.push(5); s.pop(); s.pop(); In a stack it is last in first out so When we push items on to it we have 1 first then 2 and then 3 We have pop so, we pop 3 since it is the last element Then again we have 4 then 5 Now we have two pops   Push 1,2,3 pop 3, push 4,5 pop 5,4 | | | | 5 | | 3 | 4 | | 2 | 2 | 2 | 1 | 1 | 1 | Now we have 1 and 2 in the...

Words: 351 - Pages: 2

Free Essay

Aouch; Adsf

... Basic Operations   Push inserts the data item at the top of the stack, returns the modified stack.  Pop  retrieves and removes the element at the top of the stack, returns the top element of the stack and the modified stack    Make Null Empty Full Representation: char STACK[10]; { void Push (char ch) if (Top >= (MaxStack - 1)) Success = False; //no room on stack else { Top++; //increment stack top pointer STACK[Top] = ch; //copy X to stack Success = True; }} } char Pop ( ) { if (Top < 0) Success = False; //empty stack else { ch = STACK[Top]; //pop top of stack into X Top--; //decrement top of stack pointer Success = True; return ch; } void Make Null ( ) { Top = -1; } int Empty Stack ( ) { return (Top < 0); } int Full Stack ( ) { return(Top >= MaxStack); } Array Implementation for a Stack of ints public class ArrayStack { int store[]; int top; static final int MAX = 100; public ArrayStack() { store = new int[MAX]; top = 0; } // ... } top 4 top = index of the first FREE slot 12 24 37 17 ... ArrayStack class, continued public class ArrayStack { // ... public boolean empty() { return (top == 0); } public void push(int entry) { if (top < MAX) store[top++] = entry; } // ... } // in the code that uses // the stack … stack.push( 95 ); Remember: top = index of the first FREE slot top 5 4 37 17 95 ... 12 24 ArrayStack class, continued public class ArrayStack { // ... public int pop() throws Exception {...

Words: 654 - Pages: 3

Free Essay

First Upload

...Exercises For Exercises 1-10, indicate which structure would be a more suitable choice for each of the following applications by marking them as follows: A. Stack B. Queue C. Tree D. Binary search tree E. Graph |1. |A bank simulation of its teller operation to see how waiting times would be affected by | | |adding another teller. | | |B | |2. |A program to receive data that is to be saved and processed in the reverse order | | |A | |3. |An electronic address book ordered by name | | |D | |4. |A word processor to have a PF key that causes the preceding command to be redisplayed. | | |Every time the PF key is pressed, the program is to show the command that preceded the | | |one currently displayed | | |A | |5. |A dictionary of words used by a spelling checker to be built and maintained. | | |D ...

Words: 2128 - Pages: 9

Free Essay

Computer

...Assembly Language Programming Lecture Notes Delivered by Belal Hashmi Compiled by Junaid Haroon Preface Assembly language programming develops a very basic and low level understanding of the computer. In higher level languages there is a distance between the computer and the programmer. This is because higher level languages are designed to be closer and friendlier to the programmer, thereby creating distance with the machine. This distance is covered by translators called compilers and interpreters. The aim of programming in assembly language is to bypass these intermediates and talk directly with the computer. There is a general impression that assembly language programming is a difficult chore and not everyone is capable enough to understand it. The reality is in contrast, as assembly language is a very simple subject. The wrong impression is created because it is very difficult to realize that the real computer can be so simple. Assembly language programming gives a freehand exposure to the computer and lets the programmer talk with it in its language. The only translator that remains between the programmer and the computer is there to symbolize the computer’s numeric world for the ease of remembering. To cover the practical aspects of assembly language programming, IBM PC based on Intel architecture will be used as an example. However this course will not be tied to a particular architecture as it is often done. In our view such an approach...

Words: 85913 - Pages: 344

Free Essay

Et2640

...memory space then C and files are generally shorter. 13. Compiler 14. true 15. lst file 23. (a) MOV A, #55H - 2 bytes (b) MOV R3, #3 2 bytes (c) INC R2- 1 byte (d) ADD A, #0 -2 bytes (e) MOV A, R1 -1 byte (f) MOV R3, A -1 byte (g) ADD A, R2 -1 byte 37. (a) MOV A, #54H , ADD A, #0C4h CY=1 (b) MOV A, #00, ADD A, #0FFh CY=0 (c) MOV A, #250, ADD A, #05 CY=0 38. Add 25H and 70H and find the contents of the AC, CY, and P flags. 25h 70h 95h AC=0 CY=0 P=0 42. 8 bits 43. bank 0 48. MOV SP, #52H stack starts at MOV A, #04 move 4 into acc MOV R0, #05H move value to r0 ADD A, R0 add and store to acc PUSH 0E0H push the value of acc.on the stack PUSH 0 push value of r0 on the stack SET PSW.4 select reg bank 2 POP 10H pop value at r0 0E0H pop the value.of 00 ------------------------------------------------- Chapter 3 4. Short jump; 2 byte 5. long jump; 3 bytes 6. The LJMP instruction is 3-bytes in which the first byte is the opcode, and the second and third bytes represent the 16-bit address of the target location from 0000 to FFFFH. The SJMP is a 2-byte instruction where the first byte is the opcode and the second byte is the address location FFH 7. true 8. false 9. (c)LJMP 10. A short jump is a 2-byte instruction. Why? The first byte is the opcode (e.g MOV, ADD, etc.) and the second byte is the relative address of the target location. 0-FFH MAX 11. true 14. The loop is executed 200x100...

Words: 477 - Pages: 2

Free Essay

C++ Linkedlist Problems

...are a way to develop your ability with complex pointer algorithms. Even though modern languages and tools have made linked lists pretty unimportant for day-to-day programming, the skills for complex pointer algorithms are very important, and linked lists are an excellent way to develop those skills. The problems use the C language syntax, so they require a basic understanding of C and its pointer syntax. The emphasis is on the important concepts of pointer manipulation and linked list algorithms rather than the features of the C language. For some of the problems we present multiple solutions, such as iteration vs. recursion, dummy node vs. local reference. The specific problems are, in rough order of difficulty: Count, GetNth, DeleteList, Pop, InsertNth, SortedInsert, InsertSort, Append, FrontBackSplit, RemoveDuplicates, MoveNode, AlternatingSplit, ShuffleMerge, SortedMerge, SortedIntersect, Reverse, and RecursiveReverse. Contents Section 1 — Review of basic linked list code techniques Section 2 — 18 list problems in increasing order of difficulty Section 3 — Solutions to all the problems 3 10 20 This is document #105, Linked List Problems, in the Stanford CS Education Library. This and other free educational materials are available at http://cslibrary.stanford.edu/. This document is free to be used, reproduced, or sold so long as this notice is clearly reproduced at its beginning. Related CS Education Library Documents Related Stanford CS Education library documents... • Linked...

Words: 7907 - Pages: 32

Free Essay

Student

...source code into machine code. The more difficult programming errors to find and remove are functional bugs that can be identified during execution, when the program does not perform as expected. Error messages are meant to be self-explanatory. 5. MOV A,#55H ADD A,#55H ADD A,#55H ADD A,#55H ADD A,#55H 6. The size of stack pointer in 8051 is 8 bit. 7. When 8051 is power up it use register bank 0. 8. Line program | Stack | Stack pointer | ORG 0 | | | MOV R0,#66H | 00 | 07 | MOV R3,#7H | 00 | 07 | MOV R7,#5DH | 00 | 07 | PUSH 0 | 66 | 08 | PUSH 3 | 7F | 09 | PUSH 7 | 5D | 0A | CLR A | 5D | 0A | MOV R3, A | 5D | OA | MOV R7, A | 5D | 0A | OP 3 | | | POP 7 | 5D | 09 | POP 0 | 66 | | 9. The times of loop is: 100x200=20,000 times. 10. The reason is that the stack keeps track of where the CPU should return after completing the subroutine and must be balanced if push and pop are used. 11. 200 (times) x 1/16,000,000 = 12.5 x 10-6 second. 12. MOV A,#0FFH ;A=FF Hex MOV P1,A ;make P1 an input port by writing all 1 s to it BACK MOV P1,A :GET DATA FROM P0 MOV P0,A ; SEND IT TO P0...

Words: 348 - Pages: 2

Free Essay

Bla Bla : )

...without popping it. Let a few people have a try – they will invariably try to insert the skewer fairly slowly through the side, and the balloon will pop. 3. Show them how physics can make the trick work: i. Start by lining up the skewer point with the darker patch on the balloon, opposite the tie end. Gently push the skewer through. You may find that a twisting motion works best. ii. Once the skewer is through one side, push it gently through the balloon until the point of the skewer is at the opposite end – the darker area around the tie. iii. Insert the skewer tip gently through the soft part of the balloon where the tie is – again use the twisting motion if it helps. Voila! – you have made a balloon kebab! How does it work? This trick works through an understanding of surface properties. A balloon is formed by inserting air into a flexible thin rubber sheet. Most of the balloon is stretched evenly, but there are two points where the rubber is least stretched – and thus there is the lowest surface tension. These correspond to the tied section and the darker patch at the opposite side of the balloon – in fact the darker colour indicates that the balloon is less stretched over that region. Most of the balloon is under high tension, so attempting to push the skewer through just makes the balloon pop. But at the low tension sections it is possible to make a small hole without breaking the overall surface of the balloon. Tips for Success ...

Words: 496 - Pages: 2

Premium Essay

Computer Science

...A REPORT ON INTELLIGENT HUMIDISTAT BY Rohan Mehta 2011B5A3376P Aditya Pillai 2011B3A3530P Shantanu Maharwal 2011B2A3700P Gaurav Dadhich 2011B3A8513P AT BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI A REPORT ON INTELLIGENT HUMIDISTAT BY Rohan Mehta 2011B5A3376P Aditya Pillai 2011B3A3530P Shantanu Maharwal 2011B2A3700P Gaurav Dadhich 2011B3A8513P Prepared in Partial fulfilment of the requirements of the course “Microprocessors and Interfacing” Course Number: EEE F241 AT BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI (April 2014) ACKNOWLEDGEMENT We would like to express our gratitude to all those who have helped us directly or indirectly to complete this report. Firstly, we would like to express our gratitude towards the Instructor-in-Charge (IC) of this course, Dr. K. R. Anupama (from Goa Campus) and Dr. Pawan Sharma (from Pilani Campus) for giving us this opportunity to work on such an interesting assignment. Their teachings and support during the program were greatly valuable to all of us. We would also like to thank our tutorial professors, viz., Dr. Rajiv Ranjan Singh, Mr. Tulsi Ram Sharma, for their excellent personal guidance, help and teachings throughout the project, and further. Last, but not the least, we would like to thank our Lab Instruction Mr. V. Balaji and his team of assistants for all the help and knowledge imparted to us related to the assembly language programming in the...

Words: 2608 - Pages: 11

Free Essay

Data Structures

...complexity. Time complexity in singly linked list take more time because we have to move from head to the node before x Q2. (b) RedBlueStack implements Stack{ protected Object A[]; Int capacity; int top = -1; RedBlueStack(int cap) { A = new Object [capacity]; capacity = cap; } int size() { return (top + 1); } void push(Object obj) throws FullStackException { if (size() == capacity) throws new FullStackException("Stack is full."); A[++top] = obj; } Object top() throws EmptyStackException { if (isEmpty()) throws new EmptyStackException("Stack is empty."); return A[top]; } Boolean isEmpty() { return (top < 0); } Object top() throws EmptyStackException { if (isEmpty()) throws new EmptyStackException("Stack is empty."); return A[top]; }  Object pop() throws EmptyStackException { Object elem; if (isEmpty()) throws new EmptyStackException("Stack is empty."); elem = A[top]; A[top--] = null return elem; } } Q3. (a) To implement the Stack ADT using two queues, assume we have q1 and q2, we can simply enqueue elements into q1 when a push call is made. When a pop call is made, we can dequeue all elements of q1 and enqueue them inside q2 except for the last element which we set in a temp variable. Then we...

Words: 551 - Pages: 3

Premium Essay

Microcontrollers

...within -128 to +127 bytes of the current PC. True 8. True or false. All 8051 jumps are short jumps. False 9. Which of the following instructions is (are) not a short jump? C. LJMP 3:2: Call Instructions 17. LCALL is a 3 -byte instruction. 18. ACALL is a 2 -byte instruction. 19. The ACALL target address is limited to 2k bytes from the present PC. 20. The LCALL target address is limited to 64k bytes from the present PC. 21. When LCALL is executed, how many bytes of the stack are used? 64k 22. When ACALL is executed, how many bytes of the stack are used? 2k 23. Why do the PUSH and POP instructions in a subroutine need to be equal in number? The number needs to be equal because with the use of every PUSH there has to be a POP to match. 24. Describe the action associated with the POP instruction. The action associated with the POP instructions is the simply the reverse of the PUSH instruction used to reverse a command to be able to continue with a loop in the subroutine. Chapter 4: I/O Port Programming 4:2: I/O Bit-Manipulation Programming 17. What is the advantage of bit-addressability for 8051 ports? The advantage is their...

Words: 686 - Pages: 3

Premium Essay

Data Structure

...the contents of the stack at every step. Question 4 Use a stack to evaluate the following postfix expression and show the content of the stack after execution of each operation. Don't write any code. Assume as if you are using push and pop member functions of the stack. AB-CD+E*+ (where A=5, B=3, C=5, D =4, and E=2) Question 5 Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation : 50,40,+,18, 14,-, *,+ Question 6 Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation : TRUE, FALSE, TRUE, FALSE, NOT, OR, TRUE, OR, OR, AND Question 7 Write a program for creating polynomial using linked list? Question 8 Each node of a STACK contains the following information, in addition to required pointer field : i) Roll number of the student ii) Age of the student Give the structure of node for the linked stack in question TOP is a pointer which points to the topmost node of the STACK. Write the following functions. i) PUSH() - To push a node to the stack which is allocated dynamically ii) POP() - To remove a node from the stack and release the memory. Question 9 Write a function in C to perform a DELETE operation in a dynamically allocated link list considering the following description : struct Node ...

Words: 308 - Pages: 2

Premium Essay

Articles

...contents of the stack at every step. Question 4 Use a stack to evaluate the following postfix expression and show the content of the stack after execution of each operation. Don't write any code. Assume as if you are using push and pop member functions of the stack. AB-CD+E*+ (where A=5, B=3, C=5, D =4, and E=2) Question 5 Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation : 50,40,+,18, 14,-, *,+ Question 6 Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation : TRUE, FALSE, TRUE, FALSE, NOT, OR, TRUE, OR, OR, AND Question 7 Write a program for creating polynomial using linked list? Question 8 Each node of a STACK contains the following information, in addition to required pointer field : i) Roll number of the student ii) Age of the student Give the structure of node for the linked stack in question TOP is a pointer which points to the topmost node of the STACK. Write the following functions. i) PUSH() - To push a node to the stack which is allocated dynamically ii) POP() - To remove a node from the stack and release the memory. Question 9 Write a function in C to perform a DELETE operation in a dynamically allocated link list considering the following description : struct...

Words: 357 - Pages: 2

Free Essay

Asdsad

...COMPLETE 8086 INSTRUCTION SET Quick Reference: AAA AAD AAM AAS ADC ADD AND CALL CBW CLC CLD CLI CMC CMP CMPSB CMPSW CWD DAA DAS DEC DIV HLT IDIV IMUL IN INC INT INTO IRET JA JAE JB JBE JC JCXZ JE JG JGE JL JLE JMP JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LDS LEA LES LODSB LODSW LOOP LOOPE LOOPNE LOOPNZ LOOPZ MOV MOVSB MOVSW MUL NEG NOP NOT OR OUT POP POPA POPF PUSH PUSHA PUSHF RCL RCR REP REPE REPNE REPNZ REPZ RET RETF ROL ROR SAHF SAL SAR SBB SCASB SCASW SHL SHR STC STD STI STOSB STOSW SUB TEST XCHG XLATB XOR Operand Types: REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. SREG: DS, ES, SS, and only as second operand: CS. Memory: [BX], [BX+SI+7], variable, etc… Immediate: 5, -24, 3Fh, 10001101b, etc... Notes: • When two operands are required for an instruction they are separated by comma. For example: REG, memory • When there are two operands, both operands must have the same size (except shift and rotate instructions). For example: AL, DL DX, AX m1 DB ? AL, m1 m2 DW ? AX, m2 • Some instructions allow several operand combinations. For example: memory, immediate REG, immediate memory, REG REG, SREG • Some examples contain...

Words: 5786 - Pages: 24