IntroCS |
![]() |
Introduction to Computer, Fall 2013
|
Jump to...
assignment #1
|
Assignment #2: TOY assemblyAssigned: 2012/10/18Due: 2012/11/7 2:20pm DescriptionIn this project, you will have a chance to practice TOY assembly programming by writing a program to count number of 1-bit in an array and display the count in the BCD format. Note that you can only submit TOY assembly code but not TOY machine code. We provide an assembler and a linker for the TOY machine. You can download either Windows version or Linux version. In case that you need to compile them yourself, you can download the source codes toyasm.c and toylink.c. TOY simulator can be downloaded from here (a local copy). This file also contain a README file and several examples. The below is a summary for toyasm and toylink.* Comments begin with semicolons. Please avoid Chinese characters and Big-5 encoding. * Only support decimal literals or hexadecimal literals. Hexadecimal literals must begin with 0x * Two assembly directives for data declararion DUP for declaring array DW for defining a number Examples: A DUP 5 ; define an array of five words B DW 10 ; declare a variable B, initialized with 10 * Labels must start with a letter. It can contain letters and numbers. No colons after labels. * It is case-insensitive. * Program will start from the first instruction that the assembler meets * Instructions 0 hlt 1 add RD, RS, ST 2 sub RD, RS, ST 3 and RD, RS, ST 4 xor RD, RS, ST 5 shl RD, RS, ST 6 shr RD, RS, ST 7 lda RD, addr 8 ld RD, addr 9 st RD, addr A ldi RD, RT B sti RD, RT C bz RD, addr D bp RD, addr E jr RT F jl RD, addr * To use assembler toyasm < reverse.asm > reverse.toy * To generate an object file toyasm -o < mul.asm > mul.obj * To link several object files together to make an executable file toylink multest.obj mul.obj stack.obj > multest.toy Program will start from the first instruction of the first object file.Wei-Ning Huang has provided a console-mode TOY virtual machine simulator which also supports GDB-like debug mode. It can be downloaded here. SpecificationThe program is divided into three parts.
SubmissionSubmit your project online through the submission system submission system which will be available soon. |
|||||||
![]() |
![]() |