简体   繁体   中英

Assembly Language Absolute addresses and segment registers

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
  1. The absolute address of the next instruction to be executed is 40f0f.

     40f0f -01cf _____ 40d40 / 10 = 40d4 = cs 
  2. Is 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.

  3. For mov cx,[bx + si] , the absolute address of the source operand is 42334.

     bx = 1234 si = 0100 _________ 1334 ds = 4100 * 10 = 41000 + 1334 = 42334 
  4. For mov cx,[di - 4] , the absolute address of the source operand is 41ffc.

     di = 1000 - 4 _________ 0FFC ds = 4100 * 10 = 41000 + 0ffc = 41ffc 
  5. For 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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM