Sponsored Links


Results 1 to 2 of 2

Thread: CS401 Computer Architecture and Assembly Language Programming Assignment No. 01

  1. #1
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578

    CS401 Computer Architecture and Assembly Language Programming Assignment No. 01

    Sponsored Links1


    CS401 Computer Architecture and Assembly Language Programming Assignment No. 01 Discussion and Solution Fall 2014 Due Date Nov 24, 2014


    We have the following register values:

    AX = 420AH,

    BX = A12EH,

    DS = 22EAH,

    CS = 0100H,

    ES = 0FEAH,

    SS = 0FE0H,

    SI = 0010,

    BP = 02ACH and

    DI = 0300H.



    You are required to calculate the physical address generated by each of the following instructions?



    mov [bx+si+di],ax
    ADD AX,[BP+12]


    Note: Every instruction is independent of others.





    Question No. 2: (10 marks)



    Assemble the given program using NASM.
    [ORG 0X0100]

    MOV CX, 5

    XOR AX, AX

    MOV BX, NUM



    L1: ADD AX, [BX]

    ADD BX, 2

    SUB CX, 1

    JNZ L1



    MOV [SUM], AX

    MOV AX, 0X4C00

    INT 0X21



    NUM: DW 0, 1, 2, 3, 4.

    SUM: DW 0

    CS401ComputerArchitectureandAssemblyLanguageProgrammingAssignment1SolutionFall2014.jpg







    After that load the Debugger by typing AFD in the command prompt like in Fig 1.




    Fig 1: Loading debugger.



    The AFD window will be opened. The complete description is given below in fig 2
    Fig 2: AFD description.



    When the program is loaded in the debugger, it is loaded at offset 0100, which displaces all memory accesses in our program. Execute the program step by step and examine how the memory is read and the registers are updated, how the instruction pointer moves forward.


    Now we execute the program with F2 key (instruction will move one by one) and write down the contents of the specified registers in the given table





    Instruction
    Register current value after the instruction execution
    IP

    (Instruction Pointer)
    Flags

    OF
    CF
    ZF
    PF
    SF
    AF
    1


    [ORG 0X0100]
    AX









    BX


    CX


    DX


    2


    MOV CX, 10


    AX









    BX


    CX


    DX


    3


    XOR AX, AX


    AX









    BX


    CX


    DX


    4


    MOV BX, NUM


    AX









    BX


    CX


    DX


    5


    ADD AX, [BX]


    AX











    BX


    CX


    DX


    6


    ADD BX, 2


    AX









    BX


    CX


    DX


    7


    SUB CX, 1


    AX









    BX


    CX


    DX


    8


    JNZ L1


    AX









    BX


    CX


    DX


    9


    ADD AX, [BX]


    AX











    BX


    CX


    DX


    10


    ADD BX, 2


    AX









    BX


    CX


    DX


    11


    SUB CX, 1

    Sponsored Links


    AX









    BX


    CX


    DX


    12


    JNZ L1


    AX









    BX


    CX


    DX


    13


    ADD AX, [BX]


    AX











    BX


    CX


    DX


    14


    ADD BX, 2


    AX









    BX


    CX


    DX


    15


    SUB CX, 1


    AX









    BX


    CX


    DX


    16


    JNZ L1


    AX









    BX


    CX


    DX


    17


    ADD AX, [BX]


    AX











    BX


    CX


    DX


    18


    ADD BX, 2


    AX









    BX


    CX


    DX


    19


    SUB CX, 1


    AX









    BX


    CX


    DX


    20


    JNZ L1


    AX









    BX


    CX


    DX


    21


    ADD AX, [BX]


    AX











    BX


    CX


    DX


    22


    ADD BX, 2


    AX









    BX


    CX


    DX


    23


    SUB CX, 1


    AX









    BX


    CX


    DX


    24


    JNZ L1


    AX



    BX


    CX


    DX


    25


    MOV [SUM], AX


    AX





    BX

    CX

    DX

    26


    MOV AX, 0X4C00


    AX





    BX

    CX

    DX

    27


    INT 0X21


    AX






    BX

    CX

    DX


    Table: Register contents after the execution of each instruction.

  2. #2
    Senior Member
    Join Date
    Dec 2013
    Posts
    607
    We have the following register values:
    AX = 420AH,
    BX = A12EH,
    DS = 22EAH,
    CS = 0100H,
    ES = 0FEAH,
    SS = 0FE0H,
    SI = 0010,
    BP = 02ACH and
    DI = 0300H.

    You are required to calculate the physical address generated by each of the following instructions?

    mov [bx+si+di],ax
    ADD AX,[BP+12]

    Solution:
    1.mov [bx+si+di],ax
    EA= A12EH+0010+ 0300
    =AF24H
    Physical address = segment*0x10+EA
    = DS +EA
    =22EAH + AF24H
    =0x321934



    ADD AX,[BP+12]
    EA = 420AH , [02ACH+12]
    = ADD 420AH, 02424
    = 44434

    Physical address = segment*0x10+EA
    =SS+EA
    = 0FE0H+44434
    =0x45948
    is it rite?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 11-24-2014, 02:31 PM
  2. Replies: 0
    Last Post: 07-22-2014, 01:32 AM
  3. Replies: 2
    Last Post: 05-22-2014, 02:48 PM
  4. CS401 Assignment No: 2 Computer Architecture and Assembly Language Programming
    By vuassignments in forum Assignments & Solutions
    Replies: 0
    Last Post: 12-05-2013, 04:28 PM
  5. Replies: 11
    Last Post: 01-20-2011, 03:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft