Re: Not too important asm beginner question.... (high and low
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> Apr 13, 1998
- 701 views
Eduardo Uemura Okada wrote: > What are the low and high bytes of a register ? > > Thanks. > > Eduardo Uemura Okada The low and high bytes are the lower 8-bits and upper 8-bits of a 16-bit register. Clear as mud, right? Here are some examples: say AX = #10FF the high byte AH is #10, which is the same as floor(AX/#100) and the low byte AL is #FF, which is the same as and_bits(AX,#FF) now say you have a low byte AL = #20 and high byte AH = #4C AX = AH*#100 + AL = #4C*#100 + #20 = #4C00 + #20 = #4C20 But if you're dealing with 32-bit registers, the lower byte is the same, but the upper byte isn't the upper-most anymore. If EAX=#10FF09C2, then AH=and_bits(floor(EAX/#100),#FF) = #09. As before, AL = and_bits(EAX,#FF). So, EAX = and_bits(EAX,#FFFF0000) + AH*#100 + AL To access the upper word in EAX, you may have to use a shift operation to move the bytes into AH and AL. ex. SHR EAX,16 Note: these examples also work with the other general registers (BX,CX,DX or EBX,ECX,EDX with BH,BL,CH,CL,DH,DL) I hope this helped. Ask me more questions like this and I might have enough content to put together an asm tutorial :) -- _____ _____ _____ ________ /\ \ /\ \ /\ \ / \ \ / \____\ / \____\ / \____\ / _ \____\ / / ___/_ / /____/ / / ___/_ / / \ |____|/ / /\____\ / \ \ / / /\____\ \ \_/ / / \ \/ / ___/_\ \ \ \ \/ / ___/_ \ /____/ \ / /\ \\/\ \ \ \ / /\ \ \ \ \ \ \/ \____\ \ \ \ \ \/ \____\ \ \ \ \ / / \ \____\ \ / / \ \____\ \ / / \ / / \ / / \ / / \ / / \/____/ \ / / \/____/ \/____/xseal at harborside.com\/____/