Code interpretation


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    985

    Default Code interpretation

    Hi Guys
    I’m trying to port PBP code for Tetris I wrote some years ago to C,
    and have come across this:
    Code:
    digits var byte [4]					'
    D0 var digits[0]					'
    D1 var digits[1]					'
    D2 var digits[2]					'
    D3 var digits[3]					'
    
    IF D0.0(valuea + valueb) = 1 THEN			'
    valuec = 1						'
    ENDIF							‘
    Does it do what I think it does and check any bit at offset (value + valueb) in the array?
    At some stage I knew for sure It will take more trickery to do it in C, it’s not too accommodating at accessing bits.
    Cheers, Brek.

  2. #2
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Code interpretation

    Yes
    And some text to make post longer than 10 chars...

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Code interpretation

    Thanks
    I think the code didn’t ever make it try to look outside the first byte in the array anyway,
    and the input value never added up to more than 7, but if it can look into other bytes, that’s useful.

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Code interpretation

    PBP doesn't check array limits. That is true for all variables types. So you can scan thru all pins of all ports with PORTA.0[i]...

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Code interpretation

    That was interesting.
    The Tetris was monochrome for an LED board, so the Tetris shapes and the well were all arrays of bits.
    To write the same thing in C inflates the program, but uses no more RAM.
    Rewriting it in C dealing with bytes instead of bits uses less program memory on the C platform, but much more RAM.

Similar Threads

  1. avr code to code for PIC
    By JasonMcG in forum General
    Replies: 1
    Last Post: - 11th September 2014, 00:57
  2. Serial problem between BasicStamp code and PBP code
    By AllanZilkowsky in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 6th April 2014, 02:15
  3. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 20:44
  4. Code: Why is this code greater than 2000 words?
    By DrDreas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st June 2007, 19:51

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts