Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/01/08 01:30
Read: times


 
#151702 - CJNE method
Responding to: ???'s previous message
Hi Christopher,

Below is a subroutine I have just written recently that has a couple of cases like you mention. every compare/jump has both possibilities. You do the "cjne" jump to the code to be executed if "not equal" and then the code for "equal" immediately follows, often ending with a "sjmp" to the place it should continue from, or sometimes it can just fall through to the same target as the "not equal" branch.
==========================
Write2Buff:
; Serial bits are accumulated in [KeyByte]
; This adds a complete received byte (scancode) to the ring buffer
; and manages the pointers
jb writable, rb_write
mov ErrorCode, #10h
setb ErrorFlag
jnb writable, RingBuffer_WE
rb_write:
mov R0, next_write
mov A, KeyByte
mov @r0, A ;write to the buffer
inc R0
setb readable ;must be readable - we just wrote!
cjne R0, #ring_base+RingBufSize, w2b_no_wrap
;so reset the pointer to ring_base...
mov next_write, #ring_base ;wrap back to start
sjmp w2b_check
w2b_no_wrap:
mov next_write, R0
w2b_check:
mov A, next_read
cjne A, next_write, RingBuffer_we ;not an error, just exit
clr writable ;if equal, it is full
RingBuffer_WE:
ret

List of 8 messages in thread
TopicAuthorDate
CJNE Question            01/01/70 00:00      
   CJNE method            01/01/70 00:00      
      CJNE method            01/01/70 00:00      
         Try this            01/01/70 00:00      
   Program counter            01/01/70 00:00      
   CJNE Alternatives            01/01/70 00:00      
      XOR            01/01/70 00:00      
   example            01/01/70 00:00      

Back to Subject List