Remote-processing CAMBASIC Manuale Utente Pagina 42

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 208
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 41
Commands - 9
BIN
Numeric Fun ction
SYNTAX: n = BIN(m)
PURPOSE: To return a number from a packed BCD number.
REMARK S: This function assumes that the BCD digits are packed. That is, there are four BCD digits per
16– bits.
EXAMPLE: A = BIN(B)
Normally, the only way BCD data can enter the system is through an I/O port like those on the
82C55 (e.g. reading a two digit BCD thum b wheel switch).
Each of the two switches has four outputs. Together, the eight lines are connected to an I/O port
input. Assuming the thumb wheel switches are set to 98 and connected to I/O port &18, the port
input would look as follows (where D0 through D7 are the eight data bits):
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 1 1 0 0 0
The example below appears wrong at first. However, CAMBASIC assumed that this was a binary
number and gave you the de cimal equivalent.
PRINT INP(&18)
152
To get the corre ct result:
PRINT BIN(INP(&18))
98
ERROR: < Illegal argument> if any BCD digit > 9
< Data negative > for m
Vedere la pagina 41
1 2 ... 37 38 39 40 41 42 43 44 45 46 47 ... 207 208

Commenti su questo manuale

Nessun commento