OpenBoot 3.x Command Reference Manual

Changing the Number Base

You can print numbers in a specific number base or change the operating number base using the commands in Table 4-19.

Table 4-19 Changing the Number Base

Command  

Stack Diagram 

Description 

.d

( n -- ) 

Display n in decimal without changing base.

.h

( n -- ) 

Display n in hex without changing base.

base

( -- addr ) 

Variable containing number base. 

decimal

( -- ) 

Set the number base to 10. 

d# number

( -- n ) 

Interpret number in decimal; base is unchanged.

hex

( -- ) 

Set the number base to 16. 

h# number

( -- n ) 

Interpret number in hex; base is unchanged.

The d# and h# commands are useful when you want to input a number in a specific base without explicitly changing the current base. For example:


ok decimal       (Changes base to decimal)
ok 4 h# ff 17 2
4 255 17 2 ok 

The .d and .h commands act like "." but display the value in decimal or hexadecimal, respectively, regardless of the current base setting. For example:


ok hex
ok ff .  ff .d
ff 255