mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
bd1465ca50
Conflicts: SConstruct doc/en/arch_platform.html doc/en/comunity.html doc/en/overview.html doc/en/refman.html doc/en/refman_gen.html doc/en/status.html doc/en/tut_bootstick.html doc/images/lng_pt.png doc/images/minusnode.png doc/images/next.png doc/images/node.png doc/images/nodelast.png doc/images/plusnode.png doc/images/plusnodelast.png doc/images/previous.png doc/images/showall.png doc/images/sync.png doc/images/vertline.png doc/pt/arch.html doc/pt/arch_coding.html doc/pt/arch_con_term.html doc/pt/arch_newport.html doc/pt/arch_overview.html doc/pt/arch_platform.html doc/pt/arch_tcpip.html doc/pt/building.html doc/pt/comunity.html doc/pt/dl_binaries.html doc/pt/dl_old.html doc/pt/dl_sources.html doc/pt/downloads.html doc/pt/examples.html doc/pt/faq.html doc/pt/installing_i386.html doc/pt/installing_lm3s.html doc/pt/news.html doc/pt/overview.html doc/pt/refman_dep.html doc/pt/refman_gen.html doc/pt/status.html doc/pt/tc_386.html doc/pt/toolchains.html doc/pt/tut_openocd.html doc/pt/using.html romfs/LM3S.lua romfs/led.lua romfs/morse.lua romfs/pong.lua src/lua/linit.c src/modules/auxmods.h src/platform/lm3s/platform.c src/platform/lm3s/platform_conf.h src/platform/sim/platform_conf.h
277 lines
9.0 KiB
Lua
277 lines
9.0 KiB
Lua
-- eLua reference manual - bit module
|
|
|
|
data_en =
|
|
{
|
|
|
|
-- Title
|
|
title = "eLua reference manual - bit module",
|
|
|
|
-- Menu name
|
|
menu_name = "bit",
|
|
|
|
-- Overview
|
|
overview = [[Since Lua doesn't have built-in capabilities for bit operations, the $bit$ module was added to eLua to fill this gap. It is based on the ^http://luaforge.net/projects/bitlib^bitlib^
|
|
library written by Reuben Thomas (slightly adapted to eLua) and provides basic bit operations (like setting and clearing bits) and bitwise operations.]],
|
|
|
|
-- Functions
|
|
funcs =
|
|
{
|
|
{ sig = "number = #bit.bit#( position )",
|
|
desc = "Generate a number with a 1 bit (used for mask generation). Equivalent to %1 <<<< position% in C.",
|
|
args = "$position$ - position of the bit that will be set to 1.",
|
|
ret = "$number$ - a number with only one 1 bit at $position$ (the rest are set to 0."
|
|
},
|
|
|
|
{ sig = "flag = #bit.isset#( value, position )",
|
|
desc = "Test if a given bit is set.",
|
|
args =
|
|
{
|
|
"$value$ - the value to test.",
|
|
"$position$ - bit position to test."
|
|
},
|
|
ret = "$number$ - 1 if the bit at the given position is 1, 0 otherwise."
|
|
},
|
|
|
|
{ sig = "flag = #bit.isclear#( value, position )",
|
|
desc = "Test if a given bit is cleared.",
|
|
args =
|
|
{
|
|
"$value$ - the value to test.",
|
|
"$position$ - bit position to test."
|
|
},
|
|
ret = "$number$ - 1 if the bit at the given position is 0, 0 othewise."
|
|
},
|
|
|
|
{ sig = "number = #bit.set#( value, pos1, pos2, ..., posn )",
|
|
desc = "Set bits in a number.",
|
|
args =
|
|
{
|
|
"$value$ - the base number.",
|
|
"$pos1$ - position of the first bit to set.",
|
|
"$pos2$ - position of the second bit to set.",
|
|
"$posn$ - position of the nth bit to set."
|
|
},
|
|
ret = "$number$ - the number with the bit(s) set in the given position(s)."
|
|
},
|
|
|
|
{ sig = "number = #bit.clear#( value, pos1, pos2, ..., posn )",
|
|
desc = "Clear bits in a number.",
|
|
args =
|
|
{
|
|
"$value$ - the base number.",
|
|
"$pos1$ - position of the first bit to clear.",
|
|
"$pos2$ - position of the second bit to clear.",
|
|
"$posn$ - position of thet nth bit to clear.",
|
|
},
|
|
ret = "$number$ - the number with the bit(s) cleared in the given position(s)."
|
|
},
|
|
|
|
{ sig = "number = #bit.bnot#( value )",
|
|
desc = "Bitwise negation, equivalent to %~~value% in C.",
|
|
args = "$value$ - the number to negate.",
|
|
ret = "$number$ - the bitwise negated value of the number.",
|
|
},
|
|
|
|
{ sig = "number = #bit.band#( val1, val2, ... valn )",
|
|
desc = "Bitwise AND, equivalent to %val1 & val2 & ... & valn% in C.",
|
|
args =
|
|
{
|
|
"$val1$ - first AND argument.",
|
|
"$val2$ - second AND argument.",
|
|
"$valn$ - nth AND argument.",
|
|
},
|
|
ret = "$number$ - the bitwise AND of all the arguments."
|
|
},
|
|
|
|
{ sig = "number = #bit.bor#( val1, val2, ... valn )",
|
|
desc = "Bitwise OR, equivalent to %val1 | val2 | ... | valn% in C.",
|
|
args =
|
|
{
|
|
"$val1$ - first OR argument.",
|
|
"$val2$ - second OR argument.",
|
|
"$valn$ - nth OR argument."
|
|
},
|
|
ret = "$number$ - the bitwise OR of all the arguments."
|
|
},
|
|
|
|
{ sig = "number = #bit.bxor#( val1, val2, ... valn )",
|
|
desc = "Bitwise exclusive OR (XOR), equivalent to %val1 ^^ val2 ^^ ... ^^ valn% in C.",
|
|
args =
|
|
{
|
|
"$val1$ - first XOR argument.",
|
|
"$val2$ - second XOR argument.",
|
|
"$valn$ - nth XOR argument."
|
|
},
|
|
ret = "$number$ - the bitwise exclusive OR of all the arguments."
|
|
},
|
|
|
|
{ sig = "number = #bit.lshift#( value, shift )",
|
|
desc = "Left-shift a number, equivalent to %value << shift% in C.",
|
|
args =
|
|
{
|
|
"$value$ - the value to shift.",
|
|
"$shift$ - positions to shift.",
|
|
},
|
|
ret = "$number$ - the number shifted left",
|
|
},
|
|
|
|
{ sig = "number = #bit.rshift#( value, shift )",
|
|
desc = "Logical right shift a number, equivalent to %( unsigned )value >>>> shift% in C.",
|
|
args =
|
|
{
|
|
"$value$ - the value to shift.",
|
|
"$shift$ - positions to shift.",
|
|
},
|
|
ret = "$number$ - the number shifted right (logically)."
|
|
},
|
|
|
|
{ sig = "number = #bit.arshift#( value, shift )",
|
|
desc = "Arithmetic right shift a number equivalent to %value >>>> shift% in C.",
|
|
args =
|
|
{
|
|
"$value$ - the value to shift.",
|
|
"$shift$ - positions to shift."
|
|
},
|
|
ret = "$number$ - the number shifted right (arithmetically)."
|
|
}
|
|
}
|
|
}
|
|
|
|
data_pt =
|
|
{
|
|
|
|
-- Title
|
|
title = "eLua reference manual - bit module",
|
|
|
|
-- Menu name
|
|
menu_name = "bit",
|
|
|
|
-- Overview
|
|
overview = [[Since Lua doesn't have built-in capabilities for bit operations, the $bit$ module was added to eLua to fill this gap. It is based on the ^http://luaforge.net/projects/bitlib^bitlib^
|
|
library written by Reuben Thomas (slightly adapted to eLua) and provides basic bit operations (like setting and clearing bits) and bitwise operations.]],
|
|
|
|
-- Functions
|
|
funcs =
|
|
{
|
|
{ sig = "number = #bit.bit#( position )",
|
|
desc = "Generate a number with a 1 bit (used for mask generation). Equivalent to %1 <<<< position% in C.",
|
|
args = "$position$ - position of the bit that will be set to 1.",
|
|
ret = "$number$ - a number with only one 1 bit at $position$ (the rest are set to 0."
|
|
},
|
|
|
|
{ sig = "flag = #bit.isset#( value, position )",
|
|
desc = "Test if a given bit is set.",
|
|
args =
|
|
{
|
|
"$value$ - the value to test.",
|
|
"$position$ - bit position to test."
|
|
},
|
|
ret = "$number$ - 1 if the bit at the given position is 1, 0 otherwise."
|
|
},
|
|
|
|
{ sig = "flag = #bit.isclear#( value, position )",
|
|
desc = "Test if a given bit is cleared.",
|
|
args =
|
|
{
|
|
"$value$ - the value to test.",
|
|
"$position$ - bit position to test."
|
|
},
|
|
ret = "$number$ - 1 if the bit at the given position is 0, 0 othewise."
|
|
},
|
|
|
|
{ sig = "number = #bit.set#( value, pos1, pos2, ..., posn )",
|
|
desc = "Set bits in a number.",
|
|
args =
|
|
{
|
|
"$value$ - the base number.",
|
|
"$pos1$ - position of the first bit to set.",
|
|
"$pos2$ - position of the second bit to set.",
|
|
"$posn$ - position of the nth bit to set."
|
|
},
|
|
ret = "$number$ - the number with the bit(s) set in the given position(s)."
|
|
},
|
|
|
|
{ sig = "number = #bit.clear#( value, pos1, pos2, ..., posn )",
|
|
desc = "Clear bits in a number.",
|
|
args =
|
|
{
|
|
"$value$ - the base number.",
|
|
"$pos1$ - position of the first bit to clear.",
|
|
"$pos2$ - position of the second bit to clear.",
|
|
"$posn$ - position of thet nth bit to clear.",
|
|
},
|
|
ret = "$number$ - the number with the bit(s) cleared in the given position(s)."
|
|
},
|
|
|
|
{ sig = "number = #bit.bnot#( value )",
|
|
desc = "Bitwise negation, equivalent to %~~value% in C.",
|
|
args = "$value$ - the number to negate.",
|
|
ret = "$number$ - the bitwise negated value of the number.",
|
|
},
|
|
|
|
{ sig = "number = #bit.band#( val1, val2, ... valn )",
|
|
desc = "Bitwise AND, equivalent to %val1 & val2 & ... & valn% in C.",
|
|
args =
|
|
{
|
|
"$val1$ - first AND argument.",
|
|
"$val2$ - second AND argument.",
|
|
"$valn$ - nth AND argument.",
|
|
},
|
|
ret = "$number$ - the bitwise AND of all the arguments."
|
|
},
|
|
|
|
{ sig = "number = #bit.bor#( val1, val2, ... valn )",
|
|
desc = "Bitwise OR, equivalent to %val1 | val2 | ... | valn% in C.",
|
|
args =
|
|
{
|
|
"$val1$ - first OR argument.",
|
|
"$val2$ - second OR argument.",
|
|
"$valn$ - nth OR argument."
|
|
},
|
|
ret = "$number$ - the bitwise OR of all the arguments."
|
|
},
|
|
|
|
{ sig = "number = #bit.bxor#( val1, val2, ... valn )",
|
|
desc = "Bitwise exclusive OR (XOR), equivalent to %val1 ^^ val2 ^^ ... ^^ valn% in C.",
|
|
args =
|
|
{
|
|
"$val1$ - first XOR argument.",
|
|
"$val2$ - second XOR argument.",
|
|
"$valn$ - nth XOR argument."
|
|
},
|
|
ret = "$number$ - the bitwise exclusive OR of all the arguments."
|
|
},
|
|
|
|
{ sig = "number = #bit.lshift#( value, shift )",
|
|
desc = "Left-shift a number, equivalent to %value << shift% in C.",
|
|
args =
|
|
{
|
|
"$value$ - the value to shift.",
|
|
"$shift$ - positions to shift.",
|
|
},
|
|
ret = "$number$ - the number shifted left",
|
|
},
|
|
|
|
{ sig = "number = #bit.rshift#( value, shift )",
|
|
desc = "Logical right shift a number, equivalent to %( unsigned )value >>>> shift% in C.",
|
|
args =
|
|
{
|
|
"$value$ - the value to shift.",
|
|
"$shift$ - positions to shift.",
|
|
},
|
|
ret = "$number$ - the number shifted right (logically)."
|
|
},
|
|
|
|
{ sig = "number = #bit.arshift#( value, shift )",
|
|
desc = "Arithmetic right shift a number equivalent to %value >>>> shift% in C.",
|
|
args =
|
|
{
|
|
"$value$ - the value to shift.",
|
|
"$shift$ - positions to shift."
|
|
},
|
|
ret = "$number$ - the number shifted right (arithmetically)."
|
|
}
|
|
}
|
|
}
|
|
|