bit

bit电信专业汇编上机考试三星题开源

放肆的年华 提交于 2019-12-04 16:26:09
北理的汇编期末题其实也没太大难度,很多三星题都是C里面写过的非常容易的题目,而且因为允许提前准备,所以难度又降低了很多,我下面的代码基本上都是自己敲得(不排除有一些算法去网上搜了一下借鉴了一下别人的),另外不完全排除留有bug的可能性,因为我也不是每个用例都测试过了。 也可以看出我这个人的风格,就是喜欢疯狂开堆栈,疯狂写子程序,能封装的东西就一直封装到祖坟里去,毕竟我搞嵌入式软件搞得比较多,那种能封装就封装的工程思想就算是写这种百来行的代码也很难改掉习惯。 在多模块设计中,主模块中调用内部模块buf1,buf2,buf3,buf4。主模块根据键盘输入的指令(如:a,b,c,d)调用上述对应的子程序,每个子程序的任务是显示其入口地址。调用后继续等待调用,若输入ESC键(ASCII码为1BH)则结束程序的执行。请编写完成该任务的程序。 没有什么特别难的地方,主要是得注意一下DISPLAY那边的写法 MOV CL,04H ROL BX,CL ;只能用CL做循环移位,每次移动4位 AND AX,0FH ;取低4位,然后单独打印 打印字母要用到ADD 07H 入口获取就直接在DATA SEGMENT里面声明DW的几个变量,然后声明PROC的时候用它们就行了 DATA SEGMENT BUF DB 10 DB ? DB 10 DUP('$') NEWLINE DB 0DH,0AH,'$'

Bit Array in C++

自古美人都是妖i 提交于 2019-12-04 15:46:47
问题 When working with Project Euler problems I often need large (> 10**7) bit array's. My normal approach is one of: bool* sieve = new bool[N]; bool sieve[N]; When N = 1,000,000 my program uses 1 MegaByte (8 * 1,000,000 bits). Is there a more efficient way to use store bit arrays than bool in c++? 回答1: Use std::bitset (if N is a constant) otherwise use std::vector<bool> as others have mentioned (but dont forget reading this excellent article by Herb Sutter) A bitset is a special container class

FAQ-JVM【官方版】

强颜欢笑 提交于 2019-12-04 15:35:24
General What command-line options does the Java HotSpot VM provide for performance tuning? Are there any resources for troubleshooting HotSpot issues? I can't get profiling to work, what should I do? I keep running out of file descriptors, what should I do? Memory and Garbage Collection Pause times are unnecessarily long, what parameters can I use to tune this? How do I profile heap usage? The VM prints "OutOfMemoryError" and exits. Increasing max heap size doesn't help. What's going on? Why can't I get a larger heap with the 32-bit JVM? Should I pool objects to help GC? Should I call System

Why isn't the size of a bool data type only 1 bit in C#?

巧了我就是萌 提交于 2019-12-04 15:33:51
问题 I am just learning C# and looking deeper into data types. Why isn't a bool data type 1 bit in size? It seems it can only hold one of two values (true or false), so wouldn't that only take up 1 bit of space to represent that value? Is it because the smallest 'addressable' size of a value is a byte (8 bits) as referred to in this post? My overall aim was to logically envisage the different size of each data type in C# so I was trying to create a list of all data types and their allocated bit

Python - Decimal to Hex, Reverse byte order, Hex to Decimal

时间秒杀一切 提交于 2019-12-04 14:06:56
问题 I've been reading up a lot on stuct.pack and hex and the like. I am trying to convert a decimal to hexidecimal with 2-bytes. Reverse the hex bit order, then convert it back into decimal. I'm trying to follow these steps...in python Convert the decimal value **36895** to the equivalent 2-byte hexadecimal value: **0x901F** Reverse the order of the 2 hexadecimal bytes: **0x1F90** Convert the resulting 2-byte hexadecimal value to its decimal equivalent: **8080** 回答1: >>> x = 36895 >>> ((x << 8) |

C - Get a bit from a byte [duplicate]

我与影子孤独终老i 提交于 2019-12-04 13:43:58
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: how to get bit by bit data from a integer value in c? I have a 8-bit byte and I want to get a bit from this byte, like getByte(0b01001100, 3) = 1 回答1: Firstoff, 0b prefix is not C but a GCC extension of C. To get the value of the bit 3 of an uint8_t a , you can use this expression: ((a >> 3) & 0x01) which would be evaluated to 1 if bit 3 is set and 0 if bit 3 is not set. 回答2: First of all C 0b01... doesn't have

Why does this function count the number of set bits in an integer

情到浓时终转凉″ 提交于 2019-12-04 13:20:45
I was asked the following question in an interview: int foofoo(unsigned int u) { unsigned int foo = u; do{ u = u/2; foo -= u; }while(u > 0); return foo; } I was asked to tell what does this function do and I was able to find that it counts the number of set bits in an unsigned int value, but I was not able to prove that, maybe someone can? I was able to find that it counts the number of set bits in an unsigned int value, but I was not able to prove that, maybe someone can? Look at a single bit m inside U . That bit contributes to the value of U like: U = ...... + U m 2^m + ..... (where the ...

Can a public key have a different length (encryption) than the private key?

孤者浪人 提交于 2019-12-04 11:09:20
问题 I have a 1024 bits private key, and use it to generate a public key. Does that automatically mean that my public key also has 1024 encryption? Or can it be of a lesser encryption size? (512, 256...) PS: What i'm mostly interested in, and talking about, is the size of the modulus ("n") in RSA keys. The size is typically 1024 or 2048 bits. But I'm glad to see that this sparked a discussion, and all this is feeding my interest in cryptography. 回答1: No. The public key in a key pair always matches

2BIT

让人想犯罪 __ 提交于 2019-12-04 09:00:45
bit是比特,是英文 binary digit的缩写。而Byte是字节又叫bait。 bit是表示信息的最小单位,是二进制数的一位包含的信息或2个选项中特别指定1个的需要信息量。一般来说,n比特的信息量可以表现出2的n次方种选择。 来源: https://www.cnblogs.com/hshy/p/11851525.html

Algorithm for bit expansion/duplication?

社会主义新天地 提交于 2019-12-04 06:57:30
Is there an efficient (fast) algorithm that will perform bit expansion/duplication? For example, expand each bit in an 8bit value by 3 (creating a 24bit value): 1101 0101 => 11111100 01110001 11000111 The brute force method that has been proposed is to create a lookup table. In the future, the expansion value may need to be variable. That is, in the above example we are expanding by 3 but may need to expand by some other value(s). This would require multiple lookup tables that I'd like to avoid if possible. There is a chance to make it quicker than lookup table if arithmetic calculations are