Difference between revisions of "CSC231 Homework 1 2015"
(→Problem 1) |
(→Problem 2) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 50: | Line 50: | ||
* Observe the output. | * Observe the output. | ||
<br /> | <br /> | ||
+ | |||
==Part 2== | ==Part 2== | ||
<br /> | <br /> | ||
Line 104: | Line 105: | ||
<br /> | <br /> | ||
* Write an assembly language program called '''hw1a.asm''' that displays the following message. | * Write an assembly language program called '''hw1a.asm''' that displays the following message. | ||
− | |||
<br /> | <br /> | ||
<source lang="text"> | <source lang="text"> | ||
Line 114: | Line 114: | ||
</source> | </source> | ||
<br /> | <br /> | ||
− | * | + | * Make the code section (''text section'') of your program contain as few instructions as possible. |
+ | <br /> | ||
+ | ==Submit your program on Moodle== | ||
+ | <br /> | ||
+ | # Login to Moodle with your Smith account. | ||
+ | # Select the CS course for which you want to select work. | ||
+ | # Select the homework or lab corresponding to the program you are submitting. | ||
+ | # Click on '''Submission'''. | ||
+ | # Click on the '''Choose a File''' button, or drag your program to the drop area. | ||
+ | # Click on '''Submit'''. If the name of the file you are submitting is not the same as the name expected, your file will be rejected. | ||
+ | # Click on '''Edit'''. | ||
+ | # Click on '''Evaluate'''. | ||
+ | :: You should see the evaluation of your program in the right column, along with a grade. | ||
<br /> | <br /> | ||
Line 121: | Line 133: | ||
* Same question as for Problem 1, but this time using as few characters in the data section, as possible. You are not limited for the size of your code section any longer. Just the size of the data section should be as small as possible. | * Same question as for Problem 1, but this time using as few characters in the data section, as possible. You are not limited for the size of your code section any longer. Just the size of the data section should be as small as possible. | ||
<br /> | <br /> | ||
− | Call your program '''hw1b. | + | *Call your program '''hw1b.asm'''. |
+ | <br /> | ||
+ | ==Submit your program on Moodle== | ||
+ | <br /> | ||
+ | # Login to Moodle with your Smith account. | ||
+ | # Select the CS course for which you want to select work. | ||
+ | # Select the homework or lab corresponding to the program you are submitting. | ||
+ | # Click on '''Submission'''. | ||
+ | # Click on the '''Choose a File''' button, or drag your program to the drop area. | ||
+ | # Click on '''Submit'''. If the name of the file you are submitting is not the same as the name expected, your file will be rejected. | ||
+ | # Click on '''Edit'''. | ||
+ | # Click on '''Evaluate'''. | ||
+ | :: You should see the evaluation of your program in the right column, along with a grade. | ||
+ | <br /> | ||
<br /> | <br /> | ||
<br /> | <br /> |
Latest revision as of 14:48, 12 September 2015
--D. Thiebaut (talk) 16:08, 8 September 2015 (EDT)
This homework assignment is concurrent with Lecture 1, which took place on 9/9/15. It is due Sunday night 9/20/15, at 11:55 p.m. It is fully understood that we haven't had a chance to fully dig into assembly and understand what instructions do, and how they work. What is asked of you today is simply to use the typical hello world! program in assembly, and modify it in various ways to get it to print a particular message. You are asked to use your programmer's logic in figuring out how to modify a program rather than creating a new one from scratch.
Contents
Preparation
Part 1
- Login to your 231a-xx account on aurora.smith.edu.
- Create the following assembly program, assemble it, link it, and run it (the commands are in the header):
;;; ; hw1prep1.asm ;;; ; D. Thiebaut ;;; ; ;;; ; ;;; ; To assemble, link, and run: ;;; ; nasm -f elf hw1prep1.asm ;;; ; ld -melf_i386 -o hw1prep1 hw1prep1.o ;;; ; ./hw1prep1 ;;; ; section .data msg1 db "The quick red fox jumped over the dog", 10 msg1Len equ $-msg1 section .text global _start _start: ;;; print message mov eax, 4 ; write mov ebx, 1 ; stdout mov ecx, msg1 ; address of message to print mov edx, msg1Len ; # of chars to print int 0x80 ;;; exit mov ebx, 0 mov eax, 1 int 0x80
- Observe the output.
Part 2
- Same question, but with a different program. Make sure you study the code of both programs and see how they differ. Then see how their output compare.
;;; ; hw1prep2.asm ;;; ; D. Thiebaut ;;; ; ;;; ; ;;; ; To assemble, link, and run: ;;; ; nasm -f elf hw1prep2.asm ;;; ; ld -melf_i386 -o hw1prep2 hw1prep2.o ;;; ; ./hw1prep2 ;;; ; section .data msg1 db "The quick red fox jumped" msg1Len equ $-msg1 msg2 db " over the dog", 10 msg2Len equ $-msg2 section .text global _start _start: ;;; print message, part 1 mov eax, 4 ; write mov ebx, 1 ; stdout mov ecx, msg1 ; address of message to print mov edx, msg1Len ; # of chars to print int 0x80 ; get Linux to print the message ;;; print message, part 2 mov eax, 4 ; write mov ebx, 1 ; stdout mov ecx, msg2 ; address of message to print mov edx, msg2Len ; # of chars to print int 0x80 ; get Linux to print the message ;;; exit mov ebx, 0 mov eax, 1 int 0x80
Problem 1
- Write an assembly language program called hw1a.asm that displays the following message.
====================
====================
= CSC231 FALL 2015 =
====================
====================
- Make the code section (text section) of your program contain as few instructions as possible.
Submit your program on Moodle
- Login to Moodle with your Smith account.
- Select the CS course for which you want to select work.
- Select the homework or lab corresponding to the program you are submitting.
- Click on Submission.
- Click on the Choose a File button, or drag your program to the drop area.
- Click on Submit. If the name of the file you are submitting is not the same as the name expected, your file will be rejected.
- Click on Edit.
- Click on Evaluate.
- You should see the evaluation of your program in the right column, along with a grade.
Problem 2
- Same question as for Problem 1, but this time using as few characters in the data section, as possible. You are not limited for the size of your code section any longer. Just the size of the data section should be as small as possible.
- Call your program hw1b.asm.
Submit your program on Moodle
- Login to Moodle with your Smith account.
- Select the CS course for which you want to select work.
- Select the homework or lab corresponding to the program you are submitting.
- Click on Submission.
- Click on the Choose a File button, or drag your program to the drop area.
- Click on Submit. If the name of the file you are submitting is not the same as the name expected, your file will be rejected.
- Click on Edit.
- Click on Evaluate.
- You should see the evaluation of your program in the right column, along with a grade.