It is necessary for example from F0 1A (two-byte code) to get an array

0F 00 01 0А 

I do not know how to implement this in TASM

  • shr and and to help you. Run on your bytes in a loop, allocate the youngest tetrad and al, 0Fh, the oldest - shr al, 4 - Mike
  • @Mike I did it like this, and I did the right thing. Thanks - papalimer

1 answer 1

For example, something like the following code (the initial number is in ax , the result is in eax ).

 mov ecx, eax ;eax = 0000F01A ecx = 0000F01A and eax, 0000ff00H ; 0000F000 0000F01A shl eax, 8 ; 00F00000 0000F01A and ecx, 000000ffH ; 00F00000 0000001A or eax, ecx ; 00F0001A 0000001A mov ecx, eax ; 00F0001A 00F0001A shl eax, 4 ; 0F0001A0 00F0001A or eax, ecx ; 0FF001BA 00F0001A and eax, 0f0f0f0fH ; 0F00010A 00F0001A 

I used 9 lines and 2 registers :)

  • It is better to write that the original number is in AX, the upper two bytes are not used - Mike
  • @Mike Used - on exit. Then I am the first thing to do - to null the senior word eax . So, as it seems to me, fewer gestures ... No, I lied, you are right: the first one and it will be reset. - Harry
  • @Harry Thank you, now I understand - papalimer
  • @papalimer Please :) Then mark the answer as accepted :) - Harry
  • one
    The first 5 lines can be replaced by movzx eax, ax; shl eax, 8; shr ax, 8; And the first instruction can be replaced with the download of 2 bytes of raw data from memory - Mike