Difference between revisions of "CSC231 Homework 4 Fall 2017"
(→Problem 1) |
(→Problem 1) |
||
Line 11: | Line 11: | ||
cs231a@aurora ~/ $ ld -melf_i386 hw4a.o 231Lib.o -o hw4a | cs231a@aurora ~/ $ ld -melf_i386 hw4a.o 231Lib.o -o hw4a | ||
cs231a@aurora ~/ $ ./hw4a | cs231a@aurora ~/ $ ./hw4a | ||
− | > | + | > 12345 |
− | + | 0...030071 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | I used ellipsis in the output above to mask the number of leading 0s actually output by the program. It's part of your assignment to figure this out. Be resourceful! | ||
+ | |||
<br /> | <br /> | ||
==Details== | ==Details== | ||
Line 42: | Line 23: | ||
* Your program gets the input using the _getInput() function in the 231Lib.asm library | * Your program gets the input using the _getInput() function in the 231Lib.asm library | ||
* Your program outputs the octal equivalent, padded with leading 0s. | * Your program outputs the octal equivalent, padded with leading 0s. | ||
− | |||
<br /> | <br /> | ||
Revision as of 15:22, 13 October 2017
--D. Thiebaut (talk) 15:15, 13 October 2017 (EDT)
Problem 1
Write an assembly language program called hw4a.asm that translate a decimal unsigned integer into its octal equivalent.
Here is an example of how it should behave:
cs231a@aurora ~/ $ nasm -f elf hw4a.asm cs231a@aurora ~/ $ ld -melf_i386 hw4a.o 231Lib.o -o hw4a cs231a@aurora ~/ $ ./hw4a > 12345 0...030071
I used ellipsis in the output above to mask the number of leading 0s actually output by the program. It's part of your assignment to figure this out. Be resourceful!
Details
- Your program must be linked with the 231Lib.asm library
- Your program will print a prompt ( "> " ) first, then the user enters a positive number (it will never be negative)
- Your program gets the input using the _getInput() function in the 231Lib.asm library
- Your program outputs the octal equivalent, padded with leading 0s.
Submission
Submit your program on Moodle. Make sure you test it well before submitting it. In particular, if you add comments to your program just before submitting it, you should assemble, link and run it at least once to make sure you didn't change the logic of your program by adding comments.
Problem 2
Problem 3