Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Circular Queue Data Structure Lecture L4.8. A Circular Queue empty Containing 2 values.

Similar presentations


Presentation on theme: "A Circular Queue Data Structure Lecture L4.8. A Circular Queue empty Containing 2 values."— Presentation transcript:

1 A Circular Queue Data Structure Lecture L4.8

2 A Circular Queue empty Containing 2 values

3

4 ;A circular queue qsizeequ16 frontdw0 reardw0 qmindw0 qmaxdw0 qbuffrmbqsize initq ldd#qbuff stdfront stdrear stdqmin addd#(qsize-1) stdqmax rts

5 ;Store A in queue qstore psha;save A lddrear addd#1;inc rear cpdqmax blsqs1;if rear > qmax lddqmin qs1stdrear; rear = qmin cpdfront;if rear = front bneqs3; queue if full subd#1; dec rear cpdqmin bhsqs2; if rear < qmin lddqmax qs2stdrear; rear = qmax pula; pop A braqs4; and return qs3pula;else ldxrear staa0,x; store A at rear qs4rts

6 ;Check queue ;if queue is empty, carry = 1 ;else, carry = 0 and A = value taken from queue checkq lddfront cpdrear;if front = rear bnecq0; queue is empty orcc#$01; set carry flag bracq2 cq0lddfront;else addd#1; inc front cpdqmax blscq1; if front > qmax lddqmin cq1stdfront; front = qmin ldxfront ldaa0,x; A andcc#$fe; clear carry flag cq2rts


Download ppt "A Circular Queue Data Structure Lecture L4.8. A Circular Queue empty Containing 2 values."

Similar presentations


Ads by Google