bcd

How do I get the same result as I get with bcdedit /enum ALL using wmi?

老子叫甜甜 提交于 2019-12-11 18:31:20
问题 I'm trying to get the same information as I get with the bcdedit command "bcdedit /enum ALL" but using wmi and C#. I know how to get the bootmgr entries (see code) but I can't get all entries, especially the device options is the information I'm looking for. Does anyone have an idea how to achieve that? This is the code I'm using to get the standard and legacy os boot entries. public class BCDWMI { public static readonly UInt32 BCDE_STANDARD_OS_ENTRY = 0x10200003; public static readonly

How to convert decimal back BCD?

我只是一个虾纸丫 提交于 2019-12-10 10:55:16
问题 I am able to convert BCD to decimal, for example I can convert 0x11 to 11 instead of 17 in decimal. This is the code I used. unsigned char hex = 0x11; unsigned char backtohex ; int dec = ((hex & 0xF0) >> 4) * 10 + (hex & 0x0F); Now I want to convert dec back to BCD representation. I want 11 to be converted back to 0x11 not 0x0B. I am kind of confused as how to go back. Thanks! 回答1: Assuming your input is always between 0 and 99, inclusive: unsigned char hex = ((dec / 10) << 4) | (dec % 10);

Converting an Int to a BCD byte array

倾然丶 夕夏残阳落幕 提交于 2019-12-09 18:06:24
问题 I want to convert an int to a byte[4] array using BCD. The int in question will come from an device id and his needed to speak to an device via serialport. Is there any pre-made function that does this or can you give me a simple way of doing this? example: int id= 29068082 would output: byte[4]{0x82, 0x80, 0x06, 0x29}; 回答1: Use this method. public static byte[] ToBcd(int value){ if(value<0 || value>99999999) throw new ArgumentOutOfRangeException("value"); byte[] ret=new byte[4]; for(int i=0

汇编语言之期末复习

让人想犯罪 __ 提交于 2019-12-09 13:57:45
复习时整理的小点 奇地址单元 存放2个读写周期 Cpu与存储器之间的任何信息交换使用的都是 物理地址 16位相对位移的范围是 8000H-7FFFH 段地址左移4位加偏移地址 PA=16DX2356+1000= 2456F0HPA=12345H 逻辑地址 为1200H :0345H 状态寄存器用来存放状态信息 一个字节有8位二进制数 8086cpu的内部数据总线是16位的 外部数据总线是16位的 机器语言是可执行指令 [BX+si+8]相对基址变址寻址 pa=bx+si+8 ,即 2000+3000+8 =5008 MEM 补码 寄存器间接寻址 有4个 bx BP SI DI 其中bp 默认段ss [bx+si] 使用ds段寄存器 [bp+5] 使用ss寄存器 段内间接寻址 只改变ip寄存器的值 段间间接寻址 改变cs和IP寄存器的值 PSW 状态寄存器 。不改变PSW的指令是 mov ax,bx 不影响cf标志位 的是inc dec 两个整数补码相加运算后 会产生无溢出但有进位 Jmp word ptr [bx] 段内间接近转移 二-十进制(BCD):用二进制编码的十进制压缩的BCD码:用四位二进制表示一个十进制数码非压缩的BCD码:用8位二进制表示一个十进制位 十进制数字74所对应的压缩型BCD码的形式是 74H 十进制数字85所对应的非压缩型BCD码的是 0805H CMP

How can i store 2 numbers in a 1 byte char?

限于喜欢 提交于 2019-12-08 07:54:15
问题 I have the question of the title, but If not, how could I get away with using only 4 bits to represent an integer? EDIT really my question is how. I am aware that there are 1 byte data structures in a language like c, but how could I use something like a char to store two integers? 回答1: You can store two 4-bit numbers in one byte (call it b which is an unsigned char). Using hex is easy to see that: in b=0xAE the two numbers are A and E. Use a mask to isolate them: a = (b & 0xF0) >> 4 and e =

C# Byte[] to BCD and BCD to INT

余生长醉 提交于 2019-12-07 06:21:31
问题 I have a Hex file created by CashRegister Machine. I have to read this file in. File uses formatting detailed below. It is like socket packets. Code Data : 2 Byte PLU Code Data: 7 Byte Unit Price Data: 5 Byte Quantity Data: 5 Byte Total Amount Data: 5 Byte PLU Name Data: 18 Byte Tax Rate Data: 1 Byte Length: 24 + 19 Byte PLU code format is BCD Unit price 1-9999999999 (BCD) quantity 1-9999999999 (BCD last 3 numbers should be decimal) total amount 1-9999999999 (BCD) I read in the hex file with

PAT基础编程练习

烂漫一生 提交于 2019-12-05 14:18:54
7-1 厘米换算英尺英寸 (15 分) 如果已知英制长度的英尺 f o o t和英寸 i n c h的值,那么对应的米是 (。现在,如果用户输入的是厘米数,那么对应英制长度的英尺和英寸是多少呢?别忘了1英尺等于12英寸。 输入格式: 输入在一行中给出1个正整数,单位是厘米。 输出格式: 在一行中输出这个厘米数对应英制长度的英尺和英寸的整数值,中间用空格分开。 输入样例: 170 输出样例: 5 6 #include<stdio.h> int main(){ int cm = 0; int foot,inch; scanf("%d",&cm); foot = cm/30.48; inch = (cm/30.48-foot)*12; printf("%d %d",foot,inch); return 0; } 7-2 然后是几点 (15 分) 有时候人们用四位数字表示一个时间,比如1106表示11点零6分。现在,你的程序要根据起始时间和流逝的时间计算出终止时间。 读入两个数字,第一个数字以这样的四位数字表示当前时间,第二个数字表示分钟数,计算当前时间经过那么多分钟后是几点,结果也表示为四位数字。当小时为个位数时,没有前导的零,即5点30分表示为530。注意,第二个数字表示的分钟数可能超过60,也可能是负数。 输入格式: 输入在一行中给出2个整数,分别是四位数字表示的起始时间

BCD Adder in Verilog

為{幸葍}努か 提交于 2019-12-05 11:00:15
I am trying to write a BCD Adder in Verilog, but I am having trouble with one of the modules. Specifically, the adder that takes two BCD digits and adds them. So, the idea is if the sum of the two digits is less than or equal to nine, then it is correct. However, if it is greater, then an offset of 6 has to be added. Here is my Verilog code so far: module DIGITADD( input [3:0] IN_A, input [3:0] IN_B, input CIN, output reg COUT, output reg [3:0] SUM ); wire s2, c2; always @ ( * ) begin assign {c2, s2} = IN_A + IN_B + CIN; if(s2 <= 9 && c2 == 0) begin assign {COUT, SUM} = {c2, s2}; end else if(

C# Byte[] to BCD and BCD to INT

故事扮演 提交于 2019-12-05 10:41:00
I have a Hex file created by CashRegister Machine. I have to read this file in. File uses formatting detailed below. It is like socket packets. Code Data : 2 Byte PLU Code Data: 7 Byte Unit Price Data: 5 Byte Quantity Data: 5 Byte Total Amount Data: 5 Byte PLU Name Data: 18 Byte Tax Rate Data: 1 Byte Length: 24 + 19 Byte PLU code format is BCD Unit price 1-9999999999 (BCD) quantity 1-9999999999 (BCD last 3 numbers should be decimal) total amount 1-9999999999 (BCD) I read in the hex file with a binary reader and then insert int the Unit Price byte array. byte[] bytes = { data[21], data[22],

Binary coded decimal (BCD) to Hexadecimal conversion

≡放荡痞女 提交于 2019-12-04 01:15:11
问题 can someone explain to me how to convert BCD to Hexadecimal? For example how can i convert 98(BCD) to Hexadecimal. Thanks. 回答1: I don't quite understand your question, but I'm guessing that e.g. someone gives you a number 98 encoded in BCD, which would be: 1001 1000 and you are supposed to get: 62H What I would propose: 1) convert BCD-encoded value to decimal value (D) 2) convert D to hexadecimal value. Depending on which programming language you choose, this task will be easier or harder.