CS401 Assignment # 3 Best Solution - Spring 2013
Page 1 of 1 • Share
CS401 Assignment # 3 Best Solution - Spring 2013
Assalam o alikum
Dear students
Please discuss here Idea solution
Please carefully read the following instructions before attempting assignment.
Rules for Marking
It should be clear that your assignment would not get any credit if:
1) You should concern recommended books to clarify your concepts as handouts are not sufficient.
2) You are supposed to submit your assignment in.doc format. Any other formats like scan images, PDF, zip, rar, bmp etc will not be accepted.
3) The assignment file comprises of two pages.
Note:
Assignment comprises of lectures No. 14-19.
No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file at least two days before its deadline.
For any query, feel free to email at:
[You must be registered and logged in to see this link.]
Question:
We have an array of whole numbers in the main program as follows:
ARRAY : 0,1,2,3,4,5,6,7,8,9,10
You are required to write an assembly language program having a subroutine “SUM_OF_SQUARE”. The subroutine should find out the square of each number and then add them together along with storing the result into a separate data label “SUM” as follows:
Copy “SUM” into “DX” after executing the subroutine.
Provide the final snapshot of AFD that should display the contents of data label “SUM” and “DX”.
Marking Distribution: (Total = 20 marks)
1. Writing correct subroutine. (15 marks)
2. AFD command used for showing data in data label “SUM”. (2 marks)
3. AFD snapshot showing result of “SUM” and “DX”. (3 marks)
Best of luck!
Dear students
Please discuss here Idea solution
Please carefully read the following instructions before attempting assignment.
Rules for Marking
It should be clear that your assignment would not get any credit if:
- The assignment is submitted after the due date.
- The submitted assignment does not open or file is corrupt.
- Strict action will be taken if submitted solution is copied from any other student or from the internet. Students will be punished severely in either case.
1) You should concern recommended books to clarify your concepts as handouts are not sufficient.
2) You are supposed to submit your assignment in.doc format. Any other formats like scan images, PDF, zip, rar, bmp etc will not be accepted.
3) The assignment file comprises of two pages.
Note:
Assignment comprises of lectures No. 14-19.
No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file at least two days before its deadline.
For any query, feel free to email at:
[You must be registered and logged in to see this link.]
Question:
We have an array of whole numbers in the main program as follows:
ARRAY : 0,1,2,3,4,5,6,7,8,9,10
You are required to write an assembly language program having a subroutine “SUM_OF_SQUARE”. The subroutine should find out the square of each number and then add them together along with storing the result into a separate data label “SUM” as follows:
Copy “SUM” into “DX” after executing the subroutine.
Provide the final snapshot of AFD that should display the contents of data label “SUM” and “DX”.
Marking Distribution: (Total = 20 marks)
1. Writing correct subroutine. (15 marks)
2. AFD command used for showing data in data label “SUM”. (2 marks)
3. AFD snapshot showing result of “SUM” and “DX”. (3 marks)
Best of luck!
ChIntoo- Monstars
- Posts : 92
Join date : 2011-02-13
Re: CS401 Assignment # 3 Best Solution - Spring 2013
Open the com in AFD:
On command prompt type afd filename.com
The following AFD commands will be helpful for you.
CMD> M1 DS : 100
the above mentioned command will display the contents of memory location at offset address "0x0100" in memory window 1 (the address of the location where normally your first variable is stored, if your first variable is a word then moving two bytes ahead will display the contents of next vraiable e.g. M1 DS:102)
Similarly to display data contents in memory window 2 use the following command
CMD> M2 DS : 100
For help press F4 at CMD, the help window will be appeared at the bottom now either press PageUP/PageDown keys to move back and forth or type any command at command prompt, the command that you will type, its help will appear in the help window.
Use F2 to execute the program statement by statement. E.g. press F2 to execute first statement and then see the effect of this statement in registers, or memory window (by using command M1 or M2 described above)
If you want to change the values of the registers directly in the debugger then here is the command:
register=value
For example, you want to set 1DD0 in DS register, you will write like this:
ds=1DD0
and press Enter.
Or there is also another way, you can move between these different windows (register window, memory window etc) by pressing F8 or F9 keys in the debugger and then typing the value in the respective window.
Finally use quit command to exit from the shell.
On DOS command prompt type cls and press Enter to clear the screen
On command prompt type afd filename.com
The following AFD commands will be helpful for you.
CMD> M1 DS : 100
the above mentioned command will display the contents of memory location at offset address "0x0100" in memory window 1 (the address of the location where normally your first variable is stored, if your first variable is a word then moving two bytes ahead will display the contents of next vraiable e.g. M1 DS:102)
Similarly to display data contents in memory window 2 use the following command
CMD> M2 DS : 100
For help press F4 at CMD, the help window will be appeared at the bottom now either press PageUP/PageDown keys to move back and forth or type any command at command prompt, the command that you will type, its help will appear in the help window.
Use F2 to execute the program statement by statement. E.g. press F2 to execute first statement and then see the effect of this statement in registers, or memory window (by using command M1 or M2 described above)
If you want to change the values of the registers directly in the debugger then here is the command:
register=value
For example, you want to set 1DD0 in DS register, you will write like this:
ds=1DD0
and press Enter.
Or there is also another way, you can move between these different windows (register window, memory window etc) by pressing F8 or F9 keys in the debugger and then typing the value in the respective window.
Finally use quit command to exit from the shell.
On DOS command prompt type cls and press Enter to clear the screen
modi- Monstars
-
Posts : 632
Join date : 2011-02-13
Age : 37
Location : OnLion
Character sheet
Experience:
(0/500)
Re: CS401 Assignment # 3 Best Solution - Spring 2013
org 0x100]
jmp start
ARRAY: dw 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10
SUM: dw 0
SUM_OF_SQUARE:
mainloop: mov ax, [ARRAY + bx]
mul ax
add cx, ax
add bx, 2
cmp bx, 22
jnz mainloop
mov [SUM], cx
ret
start: mov ax, 0
mov bx, 0
mov cx, 0
mov dx, 0
call SUM_OF_SQUARE
mov dx, [SUM]
mov ax, 0x4c00
int 0x21
jmp start
ARRAY: dw 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10
SUM: dw 0
SUM_OF_SQUARE:
mainloop: mov ax, [ARRAY + bx]
mul ax
add cx, ax
add bx, 2
cmp bx, 22
jnz mainloop
mov [SUM], cx
ret
start: mov ax, 0
mov bx, 0
mov cx, 0
mov dx, 0
call SUM_OF_SQUARE
mov dx, [SUM]
mov ax, 0x4c00
int 0x21
modi- Monstars
-
Posts : 632
Join date : 2011-02-13
Age : 37
Location : OnLion
Character sheet
Experience:
(0/500)
modi- Monstars
-
Posts : 632
Join date : 2011-02-13
Age : 37
Location : OnLion
Character sheet
Experience:
(0/500)
Similar topics
» CS502 Assignment # 02 Solution Spring 2013
» MGMT611 Assignment # 1 Solution Spring 2013
» CS304 Assignment #3 Solution Spring 2013
» CS403 Assignment # 3 Best Solution - Spring 2013
» MCM101 Assignment No.1 Best Solution - Spring 2013
» MGMT611 Assignment # 1 Solution Spring 2013
» CS304 Assignment #3 Solution Spring 2013
» CS403 Assignment # 3 Best Solution - Spring 2013
» MCM101 Assignment No.1 Best Solution - Spring 2013
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Yesterday at 12:21 pm by ali001
» Hemangiom'App
Tue Nov 05, 2024 11:25 am by ali001
» MindfulMe - Mental Health App
Mon Nov 04, 2024 10:50 am by ali001
» Learn Candlestick Patterns
Tue Oct 15, 2024 5:51 am by ali001
» Woh Pagal Si Episode 52 to 62 - Top Pakistani Drama
Sat Sep 21, 2024 6:26 pm by Mir Emmad Ali Khan Domki
» Nearu - share your socials
Sat Sep 21, 2024 1:12 pm by ali001
» Nightclub Tycoon: Idle Empire
Thu Sep 19, 2024 9:16 pm by ali001
» Carnivore - Meat Diet Recipes
Wed Sep 18, 2024 2:37 pm by ali001
» Eid Milad un Nabi Mubarak 2024 (Rabiʻ I 14, 1446 AH)
Tue Sep 17, 2024 3:44 pm by Mir Emmad Ali Khan Domki