x86 - How do I use CMP in assembly to test a segment and offset address? -


i want leave loop if current address i'm looking @ at least 0xffff0. here portion of code wrote, not work:

cmp ds:[bx], ffff0h jge leaveloop 

i'm new assembly , have not used cmp more simple number comparisons.

this sounds xy problem, should have specified wanted achieve ultimately.

anyway, ffff0h 20 bit address, can't compare directly if limited 16 bits. can use 2 16 bit registers calculate physical address, , 32 bit comparison using those.

    mov ax, ds     mov dx, ds     shl ax, 4     shr dx, 12    ; dx:ax has segment base     add ax, bx    ; add offset     adc dx, 0     ; dx:ax has full address     cmp dx, 0fh   ; high word has @ least f     jb  false     ja  true      ; if it's more ok     cmp ax, fff0h ; low word has @ least fff0h     jae true false:     ... true:     ... 

Comments

Popular posts from this blog

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -