/ Forside/ Teknologi / Udvikling / Delphi/Pascal / Spørgsmål
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
Delphi/Pascal
#NavnPoint
oldwiking 603
jrossing 525
rpje 520
EXTERMINA.. 500
gandalf 460
gubi 270
DJ_Puden 250
PARKENSS 230
technet 210
10  jdjespers.. 200
Hvad bruges HighNib til?
Fra : somar
Vist : 848 gange
20 point
Dato : 20-06-02 11:50

Hvad bruges HighNib til? Gerne med et eksempel.

/Omar

 
 
Accepteret svar
Fra : zonker

Modtaget 20 point
Dato : 20-06-02 19:51

Det bruges til at dekode BCD til decimaltal.

Hver byte i BCD indeholder to hex nibbles.

For at udregne hver nibble, gør du følgende :

HighNib = (ByteVal And &hF0) / 16
LowNib = ByteVal And &hF

Når du så skal konvertere til devimal, skal du bare gange hvert ciffer med 10


Kommentar
Fra : zonker


Dato : 20-06-02 19:53

og lidt mere her håber du kan bruge det ??

-----------------------------------------------

            BASIC Stamp II

          ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
         SOUT ÄÄ´1 24ÃÄÄ VIN
          SIN ÄÄ´2 23ÃÄÄ VSS
          ATN ÄÄ´3 22ÃÄÄ RES
          VSS ÄÄ´4 21ÃÄÄ VDD
          P0 ÄÄ´5 20ÃÄÄ P15
          P1 ÄÄ´6 19ÃÄÄ P14
          P2 ÄÄ´7 18ÃÄÄ P13
          P3 ÄÄ´8 17ÃÄÄ P12
          P4 ÄÄ´9 16ÃÄÄ P11
          P5 ÄÄ´10 15ÃÄÄ P10
          P6 ÄÄ´11 14ÃÄÄ P9
          P7 ÄÄ´12 13ÃÄÄ P8
          ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
          BS2-IC

Pin   Name   Description
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
1   SOUT   Serial output      Connect to pin 2 of PC serial DB9 (Rx)
2   SIN   Serial input      Connect to pin 3 of PC serial DB9 (Tx)
3   ATN   Serial attention   Connect to pin 4 of PC serial DB9 (DTR)
4   VSS   Ground         Connect to pin 5 of PC serial DB9 (GND)
5   P0   I/O pin 0
6   P1   I/O pin 1
7   P2   I/O pin 2
8   P3   I/O pin 3      Each I/O can source 20ma and sink 25ma.
9   P4   I/O pin 4
10   P5   I/O pin 5      P0-P7 and P8-P15, as groups, can each
11   P6   I/O pin 6      source a total of 40ma and sink 50ma.
12   P7   I/O pin 7
13   P8   I/O pin 8
14   P9   I/O pin 9
15   P10   I/O pin 10
16   P11   I/O pin 11
17   P12   I/O pin 12
18   P13   I/O pin 13
19   P14   I/O pin 14
20   P15   I/O pin 15
21   VDD   +5V         5V regulated output / 5V input
22   RES   Reset I/O      may be pulled low, don't drive high
23   VSS   Ground
24   VIN   Regulator input      5V-15V regulator input



Internal Perspective:

The BS2 has 2K bytes of EEPROM which holds the executable BASIC program and any
data. Memory not used by the BASIC program can be read and written at run-time
as a data bank, or initialized with data at download time. This memory is only
affected by downloading or run-time modification.

There are 32 bytes of RAM which serve as variable space and I/O pin interface
for the BASIC program. This memory can be accessed as words, bytes, nibbles,
or bits. Each time the BASIC program is run anew, this memory is cleared to
all zeroes.

So, the 2K byte EEPROM is for program and data, and only affected by initial
downloading or run-time modification. It survives power-down. The 32 bytes of
RAM are for run-time variables and I/O pin access. This memory is cleared each
time the BS2 is powered up, reset, or downloaded to.


The 2K-byte EEPROM is arranged as follows:

    byte $000 ÄÂÄ Data start
       ³ |
       ³ |
       ³ |
       ³ |
       ³ Data end
       ³
       ³
       ³
       ³
       ³
       ³
       ³ Program end
       ³ |
       ³ |
       ³ |
       ³ |
    byte $7FF ÄÁÄ Program start


The 32-byte RAM is arranged as follows:

WORD BITS Description R/W
-------------------------------------------------------------------------------
$0- x x x x x x x x x x x x x x x x Pin input states read-only
$1- x x x x x x x x x x x x x x x x Pin output latches    read/write
$2- x x x x x x x x x x x x x x x x Pin directions     read/write
$3- x x x x x x x x x x x x x x x x variable space     read/write
$4- x x x x x x x x x x x x x x x x variable space     read/write
$5- x x x x x x x x x x x x x x x x variable space     read/write
$6- x x x x x x x x x x x x x x x x variable space     read/write
$7- x x x x x x x x x x x x x x x x variable space     read/write
$8- x x x x x x x x x x x x x x x x variable space     read/write
$9- x x x x x x x x x x x x x x x x variable space     read/write
$A- x x x x x x x x x x x x x x x x variable space     read/write
$B- x x x x x x x x x x x x x x x x variable space     read/write
$C- x x x x x x x x x x x x x x x x variable space     read/write
$D- x x x x x x x x x x x x x x x x variable space     read/write
$E- x x x x x x x x x x x x x x x x variable space     read/write
$F- x x x x x x x x x x x x x x x x variable space     read/write


Word $0 always reflects the read-state of all 16 I/O pins. Whether a pin is an
input or output, it's logical state can be read in this word. Word $0 is
accessed by the following symbolic names:

   INS   the entire 16-bit word

   INL   the low byte of INS
   INH   the high byte of INS

   INA   the low nibble of INL
   INB   the high nibble of INL
   INC   the low nibble of INH
   IND   the high nibble of INH

   IN0   the low bit of INS - corresponds to pin P0
    |
    |
    |
   IN15   the high bit of INS - corresponds to pin P15


Word $1 contains the output latches for all 16 I/O pins. If a pin is in input
mode, this data is unused, but when a pin is in output mode, its corresponding
word $1 bit sets its state. The bits are all readable and writable, regardless
of pin direction. The following symbolic names access word $1:

   OUTS   the entire 16-bit word

   OUTL   the low byte of OUTS
   OUTH   the high byte of OUTS

   OUTA   the low nibble of OUTL
   OUTB   the high nibble of OUTL
   OUTC   the low nibble of OUTH
   OUTD   the high nibble of OUTH

   OUT0   the low bit of OUTS - corresponds to pin P0
    |
    |
    |
   OUT15   the high bit of OUTS - corresponds to pin p15


Word $2 contains the direction bits for all 16 I/O pins. To place a pin in
input mode, its corresponding word $2 bit must be cleared to 0. To put a pin
into output mode, its corresponding word $2 bit must be set to 1, at which
time its word $1 bit will determine whether it is high or low. Word $2 has
these symbolic names:

   DIRS   the entire 16-bit word

   DIRL   the low byte of DIRS
   DIRH   the high byte of DIRS

   DIRA   the low nibble of DIRL
   DIRB   the high nibble of DIRL
   DIRC   the low nibble of DIRH
   DIRD   the high nibble of DIRH

   DIR0   the low bit of DIRS - corresponds to pin P0
    |
    |
    |
   DIR15   the high bit of DIRS - corresponds to pin p15


Words $3-$F are for general purpose variable use and have no pre-assigned
symbolic names. The VAR statement is used to allocate this memory.



The above text has introduced the physical pin-out of the BS2 as well as
the internal EEPROM, RAM, and I/O structure.




Programming the BASIC Stamp II
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ


In the BASIC Stamp II, there are two general categories of BASIC statements:
compile-time and run-time. Compile-time statements are resolved when you
compile the program (Alt-R or Alt-M) and do not generate any executable code.
Run-time statements, on the other hand, generate code and are executed at run-
time.

There are three compile-time statements. They are used for declaring
variables, constants, and data. They are:

      VAR   CON   and   DATA



      The VAR statment - for defining variables

Your program should begin with a declaration of all of its variables. VAR
statements assign symbolic names to variable RAM (RAM not used by I/O - words
$3-$F). This is done as follows:

   'Declare the variables

   cat   var   nib      'make "cat" a nibble variable
   mouse   var   bit      'make "mouse" a bit variable
   dog   var   byte      'make "dog" a byte variable
   rhino   var   word      'make "rhino" a word variable
   snake   var   bit(10)      'make "snake" a 10-piece bit variable

The compiler will group all words, bytes, nibs, and bits, and respectively
arrange them into unused RAM. By pressing Alt-M, you can see a picture of
the RAM allocation. First, the three I/O words are shown, then all words,
bytes, nibs, and finally, bits, are seen. Empty RAM follows. Alt-M is a quick
way to assess how much RAM you've used.

The VAR usage options are as follows:

   'define unique variables

   sym1   VAR   bit      'make a bit variable
   sym2   VAR   nib      'make a nibble variable
   sym3   VAR   byte      'make a byte variable
   sym4   VAR   word      'make a word variable

      'After bit/nib/byte/word a value may be placed
      'within parentheses to declare an array size:

   sym5   VAR   nib (10)   'make a 10 nibble array

   'define variables-within-variables or alias variables

   sym6   VAR   sym4.highbit   'make a bit variable of sym4's highbit
   sym7   VAR   sym4.lowbit   'make a bit variable of sym4's lowbit
   sym8   VAR   sym2      'make an alternate name for sym2

      'When using VAR to assign non-unique variables (a variable
      'name is used in lieu of bit/nib/byte/word(size)), a period may
      'be placed after the variable name and followed by modifiers.
      'Modifiers are used to identify sub-pieces of the initially-
      'mentioned variable.

   sym9   VAR   sym4.highbyte.lownib.bit2   'picky, picky...


   Here are all the variable modifiers:

   LOWBYTE         'low byte of a word
   HIGHBYTE      'high byte of a word
   BYTE0         'byte0 (low byte) of a word
   BYTE1         'byte1 (high byte) of a word

   LOWNIB         'low nibble of a word or byte
   HIGHNIB         'high nibble of a word or byte
   NIB0         'nib0 of a word or byte
   NIB1         'nib1 of a word or byte
   NIB2         'nib2 of a word
   NIB3         'nib3 of a word

   LOWBIT         'low bit of a word, byte, or nibble
   HIGHBIT         'high bit of a word, byte, or nibble
   BIT0         'bit0 of a word, byte, or nibble
   BIT1         'bit1 of a word, byte, or nibble
   BIT2         'bit2 of a word, byte, or nibble
   BIT3         'bit3 of a word, byte, or nibble
   BIT4         'bit4 of a word or byte
   BIT5         'bit5 of a word or byte
   BIT6         'bit6 of a word or byte
   BIT7         'bit7 of a word or byte
   BIT8         'bit8 of a word
   BIT9         'bit9 of a word
   BIT10         'bit10 of a word
   BIT11         'bit11 of a word
   BIT12         'bit12 of a word
   BIT13         'bit13 of a word
   BIT14         'bit14 of a word
   BIT15         'bit15 of a word


In summary, to declare variables, VAR statements are used. VAR statements
either declare unique variables or variables-within-variables/alias-variables.

For defining unique variables:

   symbol   VAR   size (array)

   - symbol is a unique name for a variable
   - size is either WORD, BYTE, NIB, or BIT
   - (array) is an optional expression which declares an array size

For defining variables-within-variables or alias-variables

   symbol   VAR   variable.modifiers

   - symbol is a unique name for a variable
   - variable is a defined variable name
   - .modifiers are optional and used to define variables-within-variables

The compiler will group all declarations by size (in the case of unique
variables) and assign them to unused RAM. Alt-M lets you see the result of
this process. Non-unique variables are in-whole or in-part derived from unique
variables and get assigned within the unique-variable memory.

Keep in mind that you may make alias names for the pin variables:

   keyin   var   in5      'make "keyin" a way to read P5's state.



      The CON statment - for defining constants

The CON statement is similar to the VAR statement, except that it is for
defining constant values and assigning them to symbolic names. This is
handy for having a single declaration which gets accessed throughout your
program. The CON syntax is as follows:

   symbol   CON   expression   'assign expression to "symbol"

   - symbol is a unique symbolic name for a constant
   - expression is a compile-time-resolvable constant

   level   CON   10      '"level" is same as 10 in program
   limit   CON   10*4<<2      '"limit" is 160

expressions after CON can contain the following binary operators and are
resolved left-to-right:

   +   add
   -   subtract
   *   multiply
   /   divide
   <<   shift left
   >>   shift right &   logical AND
   |   logical OR
   ^   logical XOR

example:
   growth   CON   100-light/gel   '"light" and "gel" are CON's, too



      The DATA statment - for defining data

EEPROM memory not used by your BASIC program can be used for data storage.
Keep in mind that your BASIC program builds from the end of memory towards
the start of memory. This allocation is automatic. Your data, on the other
hand, builds from the start of memory towards the end. The sum of program and
data memory cannot exceed the 2K byte limit. The compiler will always tell you
when you have a conflict.

DATA statements are used to build data into unused memory. Initially, the DATA
location is set to 0. It is advanced by 1 for each byte declared. Here is an
example DATA statement:

table   DATA   "Here is a string..."

Usually, you will want to precede DATA statements with a unique symbol name.
The symbol name will be assigned a constant value (as if via CON) which is the
current data pointer. The text following 'DATA' is usually a list of bytes
which can be constant expressions. In the above example (assuming this was
the first DATA statement in the program), "table" becomes a constant symbol of
value 0; "Here is a string..." is broken into individual bytes and placed
into EEPROM memory sequentially. Alt-M and two <SPACE>s will show you the
result of this line.

The DATA pointer may be altered at any time by an @ sign followed by a new
pointer value:

list   DATA   @$100,"some data"

DATA has a few variations of use to allocate defined and undefined data.
Defined data is fully declared and known at compile time. Undefined data
is the mere allocation of data space, while not assigning values into the bytes
of EEPROM (to be done at run-time, instead). Defined and undefined data are
declared as follows:

   for defined data:

fee   DATA   0,1,2,3,4,5,6,7,8,9   'actual bytes
fie   DATA   word 1000      'make two bytes: $E8 and $03
foe   DATA   0 (256)         '256 bytes initialized as 0

   for undefined data:

fum   DATA   (1024)         'reserved 1K byte of undefined data
scratch   DATA   word (16)      'reserve 16 words of undefined data


Important concept:   Defined DATA and BASIC program memory are always
         downloaded to the BS2. Undefined data and unused
         EEPROM memory are not downloaded. This allows you
         to change programs while keeping data, assuming both
         programs defined the same stretch of memory as
         undefined DATA. Alt-M will show you maps of EEPROM
         allocation. This download/don't-download rule is
         applied to 16-byte blocks. If any byte within a 16-
         byte block is defined DATA or BASIC program, that
         whole block is downloaded. Use Alt-M to see this.


In summary, DATA is used to define EEPROM byte usage that doesn't conflict
with the BASIC program storage:

- DATA can be preceeded by a symbol which will be assigned the constant value
of the current DATA pointer.

- Byte-size data is assumed, but 'word' can be used to break a word into two
bytes of storage.

- The @ sign is used to redirect the DATA pointer. If a symbol preceeds a
DATA statement and the first thing after DATA is @, the new pointer value
is assigned to the symbol.

- Defined data is spelled out, so to speak, with numbers and letters.

- Defined data may be repeated at the byte or word level using (array).

- Undefined data may be reserved by using (array) unpreeceded by a value.

Note:   DATA can contain references to DATA symbols:

   t1      DATA   "Here's table 1...",0
   t2      DATA   "Here's table 2...",0
   t3      DATA   "Here's table 3...",0
   t4      DATA   "Here's table 4...",0

   t_starts   DATA   word t1, word t2, word t3, word t4



         Run-Time Expressions
   ----------------------------------------------------

Run-time expressions can contain constants, variables, operators, and
parentheses. They are resolved using 16-bit math.

Constants can be in several forms:

   label         - a label may be assigned a constant via CON
   $BA1F         - Hex
   %111001111      - Binary
   99         - Decimal
   "A"         - ASCII

   Note: When more than one character is within quotes, they are
   separated by the compiler as such: "DOG" becomes "D","O","G".
   "String"+$80 becomes: "S","t","r","i","n","g"+$80.

Variables can be accessed a number of ways:

   somevar         - Some variable
   wordvar.highbit      - Use modifiers to access sub-variables
   nibarray(index)      - A variable followed by an expression in
             quotes is indexed as an array (0=1st element)
   word.bit0(bitoffset)   - Scan a word, one bit at a time

   Say a variable were defined as such:

   string var byte (10)

   It could be accessed as:

   string         - the 1st byte
   string (0)      - the 1st byte
   string (1)      - the 2nd byte
   string (9)      - the 10th (last) byte
   string.lownib(nibindex)   - nibindex could be 0-19
   string.lowbit(bitindex)   - bitindex could be 0-79


There are binary, unary, and conditional expression operators.

Unary operators preceed a variable or constant or (expression) and have
highest priority. They are as follows:

   SQR   - Square root of unsigned 16-bit value
   ABS   - Absolute of signed 16-bit value
   ~   - One's complement of 16-bit value (bitwise not)
   -   - Two's complement of 16-bit value (negation)
   DCD   - 2^n decoder of 4-bit value (0...15 -> 1,2,4,8,16,...32768)
   NCD   - Priority encoder of 16-bit value
       (=>32768,=>16384,=>8192,...=1 -> 15,14,13,...1 ; 0 -> $FFFF)
   COS   - Cosine of 8-bit value. Result is in the range of +-127,
       unit circle is 0-255 radial units.
   SIN   - Sine of 8-bit value. Result is in the range of +-127,
       unit circle is 0-255 radial units.

   Examples:
         sin bytevar
         sqr 50000
         ~ in0

Binary operators take two terms and go between variables, constants, or
expressions. They are as follows:

   HYP   - Hypotenuse of 2 signed 8-bit values
   ATN   - Arctangent of 2 signed 8-bit values; x ATN y.
       0-255 radial units is returned.
   &   - Bitwise AND
   |   - Bitwise OR
   ^   - Bitwise XOR
   MIN   - limit value to minimum
   MAX   - limit value to maximum
   +   - addition
   -   - subtraction
   *   - multiply
   **   - multiply and return high 16-bits of result
   */   - multiply and return middle 16-bits of result
       (use to simultaneously multiply by a whole and a part;
       ie. 'value */ $0180' multiplies by 1 and a half)
   /   - divide
   //   - divide and return remainder
   DIG   - return decimal digit; '12345 dig 3' returns 2
   <<   - shift left
   >>   - shift right
   REV   - reverse order of bits, lsb-justified; '%100110 rev 6'
       yields %011001

   Examples:
         xpos hyp ypos
         randword // 20
         cos x atn sin x      'result same as x

Parentheses can be placed to special-order the pattern of expression
resolution. Though unary operators have highest priority and binary operators
have secondary priority, and with those rules expressions are resolved left-to-
right, parentheses can override priority:

X+1*Y-1      'something's wrong here if we need (X+1)*(Y-1)
(X+1)*(Y-1)   'do it right

Up to 8 levels of parentheses can be used.


For use within conditional expressions (IF), there is a special unary operator
and several binary operators. These conditional operators have highest
priority of all.

   NOT      - highest priority unary
   AND, OR, XOR   - highest priority binaries

   Note: These are arithmetically identical to expression operators:
          ~   &   |   ^
    though they differ in application.

Lower-priority conditional binary operators (still higher than expression ops):

   <      - less than
   <=      - less than or equal to
   =      - equal to
   =>      - equal to or greater than
   >      - greater than
   <>      - not equal

   Note: These comparison operators return 0 for false and $FFFF for true.
    Combined with NOT, AND, OR, and XOR, complex tests can be done.


To summarize, here are some examples:

   outs = ~ dcd nibarray(index)   'lookup a nibble, decode it, not it
   IF x<1 or not y>3 and (z=0 xor r=3) then loopback



            Run-Time Instructions
      ----------------------------------------------------
    Anywhere a value is requested, an expression may be placed

FOR...NEXT
----------------------------------------
The FOR...NEXT loop.

usage:   FOR variable = start TO end {STEP stepval}
   {some code}
   NEXT

STEP is for specifying a step value other than the default of 1; if specified,
stepval must be positive since whether to add or subtract stepval from variable
is determined dynamically at run-time (this allows '10 TO 0' without specifying
a negative STEP value.).

FOR...NEXT loops can be nested up to 16 deep.

Note: NEXT is stand-alone and implies the variable from the last FOR statement.


GOTO
----------------------------------------
Go to a new point in the program

usage:   GOTO joe

A branch to joe will occur, rather than execution continuing at the next
instruction.


GOSUB
----------------------------------------
Go to a subroutine (and then RETURN later).

usage:   GOSUB lightson

The execution point is remembered and then a branch to lightson occurs. When
a RETURN is encountered (in lightson), execution continues at the instruction
following the GOSUB.

GOSUB's may be nested up to 8 deep and you are allowed 255 of them in your
program.


RETURN
----------------------------------------
Return from a subroutine.

usage:   RETURN

The execution point is set to the instruction after the GOSUB that got into
the subroutine executing the RETURN.

If a RETURN is executed without a corresponding GOSUB, execution begins anew
at the start of the program. If 8 nested GOSUBs were executed and all returned
from, then a 9th RETURN will return execution to the instruction after the 8th
nested GOSUB. This is because at program initialization, all 8 GOSUB stack
elements are cleared to 0 and there is a rotary 8-position stack pointer which
increments on GOSUBs and decrements on RETURNs.


IF
----------------------------------------
Branch conditionally.

usage:   IF conditionalexpression THEN label
   ie. IF x=1 then redoit

If the result of conditionalexpression is not 0, execution will be continued
at label. Else, execution continues at the next instruction.


BRANCH
----------------------------------------
Branch according to an index.

usage:   BRANCH   index,(label0,label1,label2,...labelN)

If index=0, a GOTO label0 will be executed. If index=1, a GOTO label1 will be
executed. If the index exceeds the number of label entries, no branch will
occur and execution will proceed at the next instruction.


LOOKUP
----------------------------------------
Lookup a variable according to an index.

usage:   LOOKUP   index,(value0,value1,value2,...valueN),variable

If index=0, value0 will be written to variable. If index=1, value1 will be
written to variable. If the index exceeds the number of value entries, the
variable will not be affected.


LOOKDOWN
----------------------------------------
Lookdown a value and return an index.

usage:   LOOKDOWN value,??(value0,value1,value2,...valueN),variable

?? is a comparison operator: =,<>,>,<,<=,=>. A comparison is made between
value and value0; if the result is true, 0 is written into variable.
If that comparison was false, another comparison is made between value and
value1; if the result is true, 1 is written into variable. This process
continues until a true is yielded, at which time the index is written into
variable, or until all entries are exhausted in which case variable is
unaffected.


RANDOM
----------------------------------------
Pseudo-randomly iterate a variable.

usage:   RANDOM   wordvariable

wordvariable will be iterated.


READ
----------------------------------------
Read a byte from the EEPROM.

usage:   READ   location,variable

Location is 0-2047. Variable will receive the byte read from location.


WRITE
----------------------------------------
Write a byte into the EEPROM.

usage:   WRITE   location,byte

Location is 0-2047. Byte is 0-255. Byte will be written into location.


INPUT, OUTPUT, LOW, HIGH, TOGGLE, REVERSE
----------------------------------------
Modify a pin's input/output high/low state.

usage:   INPUT   pin

Pin is 0-15.

modified:   OUTx   DIRx
----------------------------
INPUT      same   0
OUTPUT      same   1
LOW      0   1
HIGH      1   1
TOGGLE      flip   1
REVERSE      same   flip


DEBUG
----------------------------------------
Show variables and messages for debugging purposes.

usage:   DEBUG "Here we are!"   'show message when executed

When executed, the data after DEBUG will be sent to the PC for
display. DEBUG data can be displayed in several modes. Straight
data can be relayed to the PC, or you can have values printed in decimal,
hex, binary, or ascii. In the number-printing modes, the result of an
expression can be printed or a complete relation can be shown between the
expression and its result. For example:

   DEBUG dec X      'show variable X in decimal

      will yield (if x=1):

   X = 1

   DEBUG dec# X      'show variable X in decimal

      yields:

   1

To print numbers, there are several words which can preceed expressions:

   STR      'print string from byte array, 0=end of string
   DEC      'print in decimal
   SGN      'print in signed decimal
   HEX      'print in hexadecimal (4 digits)
   HEX1 - HEX4   'print in hex, 1-4 digits
   BIN      'print in binary (16 digits)
   BIN1 - BIN16   'print in binary, 1-16 digits
   ASC      'print in ascii, 1 character

To print only the resultant value of an expression, without the redundant text:

   STR#      'print string
   DEC#      'print in decimal
   SGN#      'print in signed decimal
   HEX#      'print in hexadecimal (4 digits)
   HEX1# - HEX4#   'print in hex, 1-4 digits
   BIN#      'print in binary (16 digits)
   BIN1# - BIN16#   'print in binary, 1-16 digits
   ASC#      'print in ascii, 1 character (this is the default)

DEBUG statements can contain many strings and numbers, separated by commas. In
addition, there are several special control characters which are interpreted by
the DEBUG screen:

   name   value   effect
   ------------------------------------------------------
   CLS   0   clears the screen and homes the cursor
   HOME   1   homes the cursor
   BELL   7   beep the PC speaker
   BKSP   8   backspace - backs up the cursor
   TAB   9   advances to the next 8th column
   CR   13   carriage return - down to next line

   DEBUG   cls,dec ina," "   'cls, print ina in decimal, spaces too

Example program using DEBUG:

   count   var   byte

   loop:   debug sgn sin count   'show the signed-decimal sine of count
      count = count + 1   'increment count
      if count <> 0 then loop   'loop until count rolls over


STOP
----------------------------------------
Stop execution.

usage:   STOP

Execution is frozen, but low-power mode is not entered. This is like
END, except that the I/O's never go high-z; they remain driven. Reset
will end STOP.


NAP
----------------------------------------
Nap for a short period.

usage:   NAP x

Enter low-power mode for a short period. When the period is over, the I/O's
will go high-z for ~18ms and execution will continue at the next instruction.

The x values for NAP are as follows:

   x   seconds
   ---------------
   0   .018
   1   .036
   2   .072
   3   .14
   4   .29
   5   .58
   6   1.2
   7   2.3


SLEEP
----------------------------------------
Sleep for x seconds (x=0 to 65535)

usage:   SLEEP x

Enter low-power mode and keep I/O's updated. Every ~2.3 seconds the I/O's
will go high-z for ~18ms. Approximately 50ua average current will be consumed.
When x seconds have been accrued in SLEEP mode, execution continues at the next
instruction.


END
----------------------------------------
End program.

usage:   END

Enter low-power mode and keep I/O's updated. Every ~2.3 seconds the I/O's
will go high-z for ~18ms. Approximately 50ua average current will be consumed.
END is terminated only by a hardware reset.

Kommentar
Fra : Nyhedsbruger


Dato : 20-06-02 20:27

"somar" <somar.news@kandu.dk> wrote in
news:2uhQ8.72191$N46.2135928@news010.worldonline.dk:

> Hvad bruges HighNib til? Gerne med et eksempel.
>
> /Omar
>

Et bud kunne være at få den høje nibble (4 bit) af en byte

byte: 142d = 10001110
highNib(142) = 1000 = 8
lowNib(142) = 1110 = 14

PS: Hvilket sprog har du fundet metoden i?? (Min Delphi har den f.eks.
ikke, og jeg har ingen erindring om at en sådan skulle findes i de Pascal
compilere jeg har været i nærheden af - men hukommelsen kan jo svigte :)
)

/Claus

--
Claus Christiansen, <mailto:cch@unipeople.dk>

personal: http://www.bigfoot.com/~kruc/; pythia: http://www.pythia.dk
============================================--------------------------
"Computers are useless. They can only give you answers."
- Pablo Picasso (1881-1973)

Du har følgende muligheder
Eftersom du ikke er logget ind i systemet, kan du ikke skrive et indlæg til dette spørgsmål.

Hvis du ikke allerede er registreret, kan du gratis blive medlem, ved at trykke på "Bliv medlem" ude i menuen.
Søg
Reklame
Statistik
Spørgsmål : 177563
Tips : 31968
Nyheder : 719565
Indlæg : 6408969
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste