Assembly Language Absolute addresses and segment r

2019-07-19 01:19发布

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?

1条回答
地球回转人心会变
2楼-- · 2019-07-19 01:59

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.

查看更多
登录 后发表回答