HELP WITH SOME Nbit MATH


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: HELP WITH SOME Nbit MATH

    This is ASM code:
    Code:
    @MOVE?BP _ARRAY[1] , TMP_32BIT
    In ASM arrays are not defined. Instead of defining each byte or word or long of array ASM use base address(like _Array) and offset.
    So if your array is byte I think that you can do it like this for array[1]
    Code:
    @MOVE?BP _ARRAY+1 , TMP_32BIT
    'TMP_32BIT=Array[2]
    @MOVE?BP _ARRAY+2 , TMP_32BIT
    For word
    Code:
    TMP_32BIT=Array[1]
    @MOVE?WP _ARRAY+2 , TMP_32BIT
    TMP_32BIT=Array[2]
    @MOVE?WP _ARRAY+4 , TMP_32BIT ;Because each word in array uses 2 bytes, you increase index by 2.
    For long index are 4,8 etc... Index must be constants!
    For variable index is much easier to use temporally variable to hold result, than to work with pointers, etc in ASM. It can be done, I think that I post somewhere i TFT topic code for that.
    Example for variable index:
    Code:
    pbpTmp VAR BYTE/ WORD/LONG
    pbpTmp = Array[i]
    @MOVE?BP _pbpTmp  , TMP_32BIT
    Last edited by pedja089; - 24th March 2016 at 10:00.

  2. #2
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: HELP WITH SOME Nbit MATH

    Here is generated array definition and macros from LST file
    Code:
    ; C:\USERS\ADMIN\DESKTOP\NEW FOLDER (5)\UNTITLED.PBP    00011   A00022  ArrayB var byte[10]
    _ArrayB                         EQU     RAM_START + 022h
    ; C:\USERS\ADMIN\DESKTOP\NEW FOLDER (5)\UNTITLED.PBP    00012   A0002C  ArrayW var word[10]
    _ArrayW                        EQU     RAM_START + 02Ch
    ; C:\USERS\ADMIN\DESKTOP\NEW FOLDER (5)\UNTITLED.PBP    00013   A00040  ArrayL var long[10]
    _ArrayL                         EQU     RAM_START + 040h
    
    ; C:\USERS\ADMIN\DESKTOP\NEW FOLDER (5)\UNTITLED.PBP    00015   Arrayb[1]=ArrayB[2]
    MOVE?BB _ArrayB + 00002h, _ArrayB + 00001h
    
    ; C:\USERS\ADMIN\DESKTOP\NEW FOLDER (5)\UNTITLED.PBP    00016   Arrayw[1]=ArrayW[2]
    MOVE?WW _ArrayW + 00004h, _ArrayW + 00002h
    
    ; C:\USERS\ADMIN\DESKTOP\NEW FOLDER (5)\UNTITLED.PBP    00017   ArrayL[1]=ArrayL[2]
    MOVE?NN _ArrayL + 00008h, _ArrayL + 00004h
    For this test code
    Code:
    ArrayB var byte[10]
    ArrayW var word[10]
    ArrayL var long[10]
    
    Arrayb[1]=ArrayB[2]
    Arrayw[1]=ArrayW[2]
    ArrayL[1]=ArrayL[2]
    I hope that my explanation are understandable, my English is not good as my PBP .
    Please, feel free to correct me.

Similar Threads

  1. some help with math
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 64
    Last Post: - 16th October 2015, 03:03
  2. Help with the math
    By Ramius in forum FAQ - Frequently Asked Questions
    Replies: 3
    Last Post: - 5th September 2014, 08:15
  3. Math help please...
    By Ioannis in forum General
    Replies: 2
    Last Post: - 20th June 2008, 11:18
  4. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 11:22
  5. math help
    By houa in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th January 2006, 17:58

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