A Circular Queue Data Structure - Oakland University

A Circular Queue Data Structure Lecture L4.8 A Circular Queue qbuff front = rear qbuff min front min 38 rear 45 max (a) empty max (b) Containing 2 values inc rear if rear > max then rear = min if front = rear then queue is full dec rear if rear < min then rear = max

else store value at rear Algorithm to store a value in the circular queue if front = rear then queue is empty (set false flag) else inc front if front > max then front = min read byte at front set true flag Algorithm to check queue for a value ; A circular queue qsize front rear qmin qmax qbuff equ dw dw dw dw rmb 16 0 0 0 0 qsize ldd std

std std addd std rts #qbuff front rear qmin #(qsize-1) qmax qbuff front = rear qbuff min front min 38 rear 45 initq max (a) max (b) ; Store qstore psha

ldd addd cpd bls ldd qs1 std cpd bne subd cpd bhs ldd qs2 std pula bra qs3 pula ldx staa qs4 rts A in queue ;save A rear #1 qmax qs1 qmin rear front qs3 #1 qmin qs2 qmax rear

qs4 rear 0,x ;inc rear ;if rear > qmax ; rear = qmin ;if rear = front ; queue if full ; dec rear ; if rear < qmin ; rear = qmax ; pop A ; and return ;else ; store A at rear ; Check queue ; if queue is empty, carry = 1 ; else, carry = 0 and A = value taken from queue checkq ldd front cpd rear ;if front = rear bne cq0 ; queue is empty

orcc #\$01 ; set carry flag bra cq2 cq0 ldd front ;else addd #1 ; inc front cpd qmax bls cq1 ; if front > qmax ldd qmin cq1 std front ; front = qmin ldx front ldaa 0,x ; A = @front andcc #\$fe ; clear carry flag cq2 rts

Recently Viewed Presentations

• Commerce and Transportation (C&T) Synthesis and Future Directions Presented by Pablo Clemente-Colón C&T Highlights & Threads from presentations & posters Science Challenges Sensor/Data Limitations The resolution and accuracy of products is limited by sensor calibration, observing capabilities, and physical constraints...
• to help you deliver AQA Art and Design qualifications. Subject expertise: courses for all teachers, from newly-qualified teachers who are just getting started to experienced teachers looking for fresh inspiration.
• Bodies of Water and Landforms Oceans Large bodies of SALT water the surround a continent. Seas Large bodies of SALT water that is often connected to an ocean. May be partly or completely surrounded by land. Rivers Large, flowing bodies...
• primary (1°) consumer, first-order consumer or herbivore. 3rd TL = secondary (2°) consumer, second-order consumer or carnivore. FOOD CHAINS & WEBS. Food chains represent a linear relationship between organisms. Food webs represent . interconnected .
• Other parts face the courtyard. The roof is generally supported by columns or by a wall. The living areas were usually oposite the entrance. Fragment A: height 17.7 cm (7 in.) / length 3 cm (1 3/16 in.) Fragment B:...
• Effortful Processing. Novel information committed to memory requires effort, like learning a concept from a text. Such processing leads to durable and accessible memories…the adage of "practice makes perfect" rings VERY true when it comes to memory. Through enough rehearsal,...
• Kawasaki Eco-Town where . ... Eco-towns such as Kawasaki, Kitakyushu and others where economy and environment are integrated to create sustainable business opportunities . progressively build . strong . science-policy-business link and interdependency.
• Qu'est-ce qu'une langue créole ? Marie-Christine Hazaël-Massieux Université de Provence [email protected] Les principaux créoles français dans le monde (ZAC puis OI) Louisiane 4 000 000 habitants (mais peu de créolophones) Haïti 7 000 000 habitants Guadeloupe 422 496 habitants La...