How to extract bits from interger in python

Introduction

LoLe provides Uint plgin which can extract bits from integer.

Example

If there is an integer 0x87654321....

The value from bit 4 to bit 7 is 0x02

The value from bit 8 to bit 15 is 0x43

>>> from LoLe.UintPy import UintPy
-----------------------------------
LoLe version: 00.01.005
Author MaxWu (EfiPy.Core@gmail.com)
===================================
>>> from LoLe.Uint import Uint
>>> foo = Uint(0x87654321)
>>> foo[4:7]
UINT[0x0:0x0].bit[4:7]: 0x2
>>> foo[8:15]
UINT[0x0:0x0].bit[8:15]: 0x43
>>> 

Comments

Popular posts from this blog

Waht is LoLe?

EXAMPLE - Bitwise operation