| TA: | Jade Cheng 成玉 (yucheng@hawaii.edu) | |
| Instructor: | David Pager (pager@hawaii.edu) | |
| Course: | Machine-Level and Systems Programming | |
| TA Office: | POST Building Room 303-3 (cubicle 3) | |
| TA Hours: | Tuesday 11:00 to 12:00 | |
| Thursday 11:00 to 12:00 | ||
TBD
If you do not complete homework assignments sufficently, you would automatically fail the course. Otherwise, homework does not affect your grades. Homework submissions will be recorded and posted on this site using the student codes provided by the TA.
Please submit your homework assignments by 11:59 pm on the posted due date. Homework received on time will receive 10 points. One point will be deducted for late submissions. After one week homework will not be accepted.
To facilitate the grading process, please try to follow the following guidelines when submitting assignments.
Assignments should be submitted via email using your UH UNIX email account. The TA will not accept any other form of submissions.
Assignments should be submitted to yucheng@hawaii.edu. Please do not send the assignments to the professor.
Please cc the email to youself. That way, if the TA doesn’t get your email for some reason, you have proof that it was sent.
Please use the following pattern for the subject of your email.
[312] homework number
For example: [312] homework 1
Please copy and paste the contents of the homework in the email body. That way, the TA will receive your work even if the attachment is rejected.
Plain text files are preferred. PDF, JPG, and PNG files are also accepted. Please do not send Microsoft Office documents.
You may submit an assignment more than one time. Only the most recent assignment submitted will be evaluated.
The grades for homework assignments, programming projects, in-class quizzes, and the exams will be posted using the student codes provided by the TA. If you lose or forget your code, please contact the TA.
Click your student ID to view your grades.
The solutions of some of the homework assignments and the in-class quizzes will be posted in this section. Since late submmisions are allowed, the solutions will not be available until a couple of weeks after the due date.
;; Program construct a text file which contains:
;; Humpty Dumpty sat on the wall.
;; Humpty Dumpty had a great fall.
;; Then, program uses the function 3fh to read this file into a buffer, and then
;; use function 40h to write the buffer out to the screen.
include pcmac.inc
.model small
.stack 100
.data
fname db 'myfile.txt', 0
handle dw ?
msg db 'Humpty Dumpty sat on the wall.', 0dh, 0ah,
'Humpty Dumpty had a great fall.'
buffer db 100 dup (?)
create_error_found db 0dh, 0ah, 'create error found.$'
write_error_found db 0dh, 0ah, 'write error found.$'
read_error_found db 0dh, 0ah, 'read error found.$'
close_error_found db 0dh, 0ah, 'close error found.$'
seek_error_found db 0dh, 0ah, 'seek error found.$'
.code
prog proc
extrn putdec : near ; compile it with util.lib
extrn getdec : near
mov ax, @data
mov ds, ax
mov ah, 3ch ; create file function
lea dx, fname ; copy address to dx
mov cl, 0 ; normal file attributes
int 21h ; create the file
jc create_error ; jump if error
mov handle, ax ; store file handle
mov ah, 40h ; write file
mov bx, handle ; file handle for the opened file
mov cx, 63 ; length of message
lea dx, msg ; copy offset to dx
int 21h ; write the msg to the file
jc write_error ; jump if error
mov ah, 42h ; move file pointer
; mov bx, handle ; (still the file handle)
mov cx, 0 ; clear cx
mov dx, 0 ; 0 bytes to move
mov al, 0 ; relative to the beginning
int 21h ; move the file pointer
jc seek_error ; jump if error
mov ah, 3fh ; read the file
; mov bx, handle ; (still the file handle)
mov cx, 63 ; set count to read
lea dx, buffer ; move offset of buffer to dx
int 21h ; read to buffer, ax = bytes read
jc read_error ; jump if error
mov ah, 3eh ; close file function
; mov bx, handle ; (still the file handle)
int 21h ; close the file
jc close_error ; jump if error
mov ah, 40h ; write to screen
mov bx, 1 ; file handle for the stdout
mov cx, 63 ; length of message
lea dx, buffer ; copy offset to dx
int 21h ; display msg
jc write_error ; jump if error
_putch 0ah ; prints a blank line
jmp done
create_error: ; error handles
_putstr create_error_found
jmp done
write_error:
_putstr write_error_found
jmp done
read_error:
_putstr read_error_found
jmp done
close_error:
_putstr close_error_found
jmp done
seek_error:
_putstr seek_error_found
jmp done
done:
mov al, 0 ; return code of 0
mov ah, 4ch ; function code for exit to os
int 21h
prog endp
end prog The course textbook — William Jones’ Assembly Language Programming for the IBM PC Family, 3rd Edition