04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SWAP<br />

<strong>Syntax</strong><br />

swap variable1, variable2<br />

• Variable - is any variable defi ned in the program.<br />

Supported<br />

• BA - Supported<br />

• BAN - Supported<br />

• BAP - Supported<br />

• BAP40 - Supported<br />

Description<br />

The SWAP command is a convenient way to switch the value of one variable with another.<br />

Commands<br />

Notes<br />

1. SWAP will truncate a value if it is larger than the destination variable is setup for. If a WORD value<br />

is loaded into a BYTE variable it will truncate and load the low byte of the WORD.<br />

Examples<br />

Connect to the following program with the terminal window set to 9600 baud. Variable1 and variable2<br />

values will be printed to the screen. The variables are then printed again, after the SWAP command is<br />

issued. You can see values of the variables have been swapped.<br />

;ALL - all_swap.bas<br />

Variable1 var word<br />

Variable2 var word<br />

Variable1 = 256<br />

Variable2 = 512<br />

Main<br />

Pause 500<br />

Serout s_out, i9600, [0, “Variable1 = “, dec variable1, 13]<br />

Serout s_out, i9600, [“Variable2 = “, dec variable2,13 ]<br />

End<br />

Pause 1000<br />

Serout s_out, i9600, [13, “Swapping Variables”, 13]<br />

Pause 1000<br />

swap variable1, variable2 ;lets swap var1 with var2<br />

;Lets see what happened<br />

Serout s_out, i9600, [13, “Variable1 = “, dec variable1, 13]<br />

Serout s_out, i9600, [“Variable2 = “, dec variable2]<br />

199

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!