For questions 1, 2, and 3 below, assume:
CS = 1246, DS = 1357, SS = 1610, IP = 0100, SI = 0200, SP = FFEE.

1. The physical address of the instruction pointed to by IP is
Remember the segment registers are shifted by 4 bits.

CS * 16d +  IP
12460 + 0100 = 12560

2. The physical address of the strorage pointed to by SI is 
Remember SI used Data Segment register

DS * 16 + SI
13570h + 0200h = 13770h

3. The physical address of the top of the stack is: 
Remember the stack builds down and the pointer points to the last
byte placed on the stack.

SS * 16 + SP
16100h + FFEEh = 260EEh 

4. Branch operations (e.g., jmp) are performed by the control unit.
The address provided by operand is the relative offset from the next 
instruction in the program (calculated from the IP) if the jmp is near. 

If the jump is far, then the segment and offset are used as address 
arguments.

5. 

6. A memory location has the physical (absolute) address 1FEDCh.  If its
offset is 123Ch, the its segment address is:

Abslolute 01FEDCh
-  Offset 00123Ch 
-----------------
  Segment XXXX00h (segment@ * 16)
          01ECA0h 

For questions 7-9 below, consider the following instructions and data:

lea  dx,Buffer
mov  ah,oah     ; write flag
int  21h

Buffer db  05, 00, 00, 00, 00, 00, 00, 00

When the above code is executed with 'abcd' as input,

7. What is the byte content of[dx+1]?

[dx+1] contains the count of characters read in (- the carridge return).

8. What is the byte content of[dx+2]?

61 or A (ascii value)

9. What is the byte content of[dx+6]?

0d or the carridge return

10.


14. Complete the machine code of the following Assembler instruction: 
(The address operand field of this Call instruction is 16 bits long.)

0d32:0200 e9 __ __  Call 0400
0d32:0203

Because the operand is 16 bits long, it is a near call or branch. Near
branches are calculated relative to the IP.  However, since the ip is 
already pointed to the next instruction when the command is executed, the
offset must be calculated from that address. 

  0400   And since Intel uses little endian ->  e9 fd 01
- 0203
------
   1FD

15. The 'ret' instruction (in a near PROCedure) is equivalent to 

pop ip

For questions 16, 17, asuem: SP = FFFC and the content on the Top of 
Stack = 34 12 (in hex). After the 'RET' in a NEAR procedure is executed:

16. What is the contents if IP

IP= 1234

17. What is the contents of SP

SP = FFFCh+ 2h = FFFEh

18. Assume: AX = 00ABh, BL = 10h.  When the instruction 'div BL' is 
executed, AX is:

00ABh / 10h = Quotient 0Ah, Remainder 0Bh

The result of a divide is AH register contains remainder and AL 
contains quotient.

0B0Ah

For questions 19-21, rewrite the "Loop 1234' instruction as a macro 

The loop instruction decrements and checks the CX register before 
branching to location 1234.  So:

sub cx,1 ; subtract literal value 1 from cx

cmp cx,0 ; compare the contents of cx to literal 0

ja  1234 ; if above zero, jump to location 1234