问题
a review problem lists these registers in hex:
cs = ???? sp = 0300 ax = a66a ip = 01cf
ds = 4100 bp = 0003 bx = 1234
ss = 48ee si = 0100 cx = 00ff
es = 4cee di = 1000 dx = 0000
The absolute address of the next instruction to be executed is 40f0f.
40f0f -01cf _____ 40d40 / 10 = 40d4 = csIs the size of the data segment in bytes always equal to the stack segment minus the data segment * 10? 48ee - 4100 = 7ee0. Likewise, is the code segment in bytes always equal to the data segment minus the code segment * 10? 48ee - 40d4 = 81a0.
For
mov cx,[bx + si], the absolute address of the source operand is 42334.bx = 1234 si = 0100 _________ 1334 ds = 4100 * 10 = 41000 + 1334 = 42334For
mov cx,[di - 4], the absolute address of the source operand is 41ffc.di = 1000 - 4 _________ 0FFC ds = 4100 * 10 = 41000 + 0ffc = 41ffcFor
mov cx,[bp + si - 3], the absolute address of the source operand is 48fe0.bp = 0003 si = 0100 - 3 _________ 0100 ss = 48ee * 10 = 48ee0 + 0100 = 48fe0
Am I going about solving these the right way? How do I know when to use the stack segment for these calculations and when to use the data segment?
回答1:
For address calculations involving bp or sp or stack operations like push or pop the segment register is implicitly ss, for other addresses ds. Exception: If you use a string instruction, the destination segment register is implicitly es.
来源:https://stackoverflow.com/questions/8486780/assembly-language-absolute-addresses-and-segment-registers