最近在研究ID卡读写请问有什么好方法能实现将 五个字节的十六进制每半个字节计算出其对应的奇偶位,然后将每半个字节加奇偶位共 5BIT排列成十行再对每列奇偶位计算,
最后在得到的55BIT前面加上 9个1 共得到 64BIT再每8BIT为一个字节分成8个字节的十六进制数呢?谢谢!
例子:
//如下为 ID = 3000F94989 转码过程
111111111 --->九个头
0011 0 3
0000 0 0
---------------------------------------
0000 0 0
0000 0 0
------------------------------------------
1111 0 F
1001 0 9
--------------------------------------------------
0100 1 4
1001 0 9
-------------------------------------------------
1000 1 8
1001 0 9
---------------------------------------------
1001 0 --->列奇偶位
转换结果为:0XFF / 0X98 / 0X00 / 0X07 / 0XA4 / 0X99 / 0X46 / 0X52
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
;**********************************************
; subroutine:
; name: Convert_Hex2EMcode
; function:
; convert hex data to em code
; input:
; gvUserBuf
; output:
; gvBuffer
;**********************************************
Convert_Hex2EMcode:
mov gvBuffer,#0ffh
mov r0,#gvBuffer+1
mov @r0,#01h
mov r1,#gvUserBuf
mov a,@r1
mov b,a
mov bitcount,#07h
mov bytecount,#05h
mov r4,#04h
ConvertEMcode_Loop1:
mov a,b
rlc a
mov b,a
mov a,@r0
rlc a
mov @r0,a
djnz bitcount,ConvertEMcode_Loop11
mov bitcount,#08h
inc r0
ConvertEMcode_Loop11:
djnz r4,ConvertEMcode_Loop1
mov a,@r1
anl a,#0f0h
swap a
mov c,PSW.0
mov a,@r0
rlc a
mov @r0,a
djnz bitcount,ConvertEMcode_Loop12
mov bitcount,#08h
inc r0
ConvertEMcode_Loop12:
mov r4,#04h
ConvertEMcode_Loop2:
mov a,b
rlc a
mov b,a
mov a,@r0
rlc a
mov @r0,a
djnz bitcount,ConvertEMcode_Loop21
mov bitcount,#08h
inc r0
ConvertEMcode_Loop21:
djnz r4,ConvertEMcode_Loop2
mov a,@r1
anl a,#0fh
mov c,PSW.0
mov a,@r0
rlc a
mov @r0,a
djnz bitcount,ConvertEMcode_Loop22
mov bitcount,#08h
inc r0
ConvertEMcode_Loop22:
inc r1
mov a,@r1
mov b,a
mov r4,#04h
djnz bytecount,ConvertEMcode_Loop1
mov a,gvBuffer+7
swap a
rlc a
mov gvBuffer+7,a
ConvertEMcode_Loop3:
mov r1,#gvUserBuf
mov r3,#00h
mov r5,#05h
ConvertEMcode_Loop31:
mov a,@r1
swap a
anl a,#0fh
xrl a,r3
mov r3,a
mov a,@r1
anl a,#0fh
xrl a,r3
mov r3,a
inc r1
djnz r5,ConvertEMcode_Loop31 ; get colume parity
clr c ; last bit is zero
mov a,r3
rlc a
mov r3,a ; get last parity
mov a,@r0
anl a,#11100000b
orl a,r3
mov @r0,a
ret
一周热门 更多>