0

Kinda new to assembly language. I spent hours trying to find the answer to this alone, but I couldn't find it, so I ended up asking here.

What I was trying to do is this : There is a single DWORD data defined, like test01 DWORD 0A0E82095h. And this can be written in binary as 10100000 11101000 00100000 10010101.

And I have a pre-defined byte string type data for decompress this DWORD.

CODE_A BYTE '1'
CODE_B BYTE '01'
CODE_C BYTE '000'
CODE_D BYTE '0011'
CODE_E BYTE '0010'

As a expected result, binary can be separated into something like this :

1 01 000 0011 1 01 000 0010 000 01 0010 1 01 , which can be decompressed as ABCDABCEDBEAB.

The things I thought I should know are:

1. The process of determining whether it is 1 or 0 (up to 32 loops will be done?) through MSB to LSB at a given total of 32 bits.
2. To recognize variables declared as BYTE strings as numbers
3. Other Conditional Statement

And the main problem is first one. I know I have to use cmp introduction, and various jumps, but I have no idea how to compare this in single bit units.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
SinonOW
  • 101
  • 2
  • 1
    You don't need `cmp`, you can just `shr edx,1` in a loop which shifts a low bit into CF (where you can branch on it or `adc eax, '0'` or `setc al` or whatever.) – Peter Cordes Jun 07 '20 at 09:59
  • @PeterCordes Thank you so much! I read the explanation about SHR, is it right to use SHL to compare highest bit first? That's similar to the function I wanted. – SinonOW Jun 07 '20 at 10:04
  • Oh, yes if you want bits in MSB-first printing order, then yes you'd want `shl`. Or `add edx,edx` to left-shift by 1 even more efficiently (on some CPUs). – Peter Cordes Jun 07 '20 at 10:08

0 Answers0