1 / 6

A Circular Queue Data Structure

A Circular Queue Data Structure. Lecture L4.8. A Circular Queue. empty. Containing 2 values. ; A circular queue qsize equ 16 front dw 0 rear dw 0 qmin dw 0 qmax dw 0 qbuff rmb qsize initq ldd #qbuff std front std rear std qmin addd #(qsize-1) std qmax rts.

armina
Download Presentation

A Circular Queue Data Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Circular Queue Data Structure Lecture L4.8

  2. A Circular Queue empty Containing 2 values

  3. ; A circular queue qsize equ 16 front dw 0 rear dw 0 qmin dw 0 qmax dw 0 qbuff rmb qsize initq ldd #qbuff std front std rear std qmin addd #(qsize-1) std qmax rts

  4. ; Store A in queue qstore psha ;save A ldd rear addd #1 ;inc rear cpd qmax bls qs1 ;if rear > qmax ldd qmin qs1 std rear ; rear = qmin cpd front ;if rear = front bne qs3 ; queue if full subd #1 ; dec rear cpd qmin bhs qs2 ; if rear < qmin ldd qmax qs2 std rear ; rear = qmax pula ; pop A bra qs4 ; and return qs3 pula ;else ldx rear staa 0,x ; store A at rear qs4 rts

  5. ; 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

More Related