CS401 Assignment No 3 Spring 2017
Dear Students, here we have CS401 - Computer Architecture and Assembly Language Programming Assignment No 3 Solution Spring 2017. Due Date 20 /July/2017. Total Marks : 20.CS401 - Computer Architecture and Assembly Language Programming Assignment No 3 Solution |
Recommended : CS401 Assignment No 2 Spring 2017 Solution and Discussion
You are supposed to submit your assignment in .doc or docx format.
Any other formats like scan images, PDF, zip, rar, ppt and bmp etc will not be accepted.
If you people find any mistake or confusion in assignment (Question statement), please consult with your instructor before the deadline. After the deadline no queries will be entertained in this regard.
For any query, feel free to email at: cs401@vu.edu.pk
The printer will be operated as under:
Your subroutine will get each character as an input from keyboard using interrupt mechanism and transmit it to the printer port according to the stated working mechanism
ORG 0x0100 ;Set code start address to 0000h
MAIN:
jmp START
DISP:
mov ah,09h ;String Print int service
int 21h
ret
OFF:
mov al,00h ;All LEDs OFF
mov dx, 378h
out dx, al
jmp MAIN
ON:
mov al,0FFh ;All LEDs ON
mov dx, 378h
out dx, al
START:
lea dx,[msg1] ;Display message
call DISP
mov ah, 01h ;keyboard interrupt
int 21h
cmp al,'1' ;press 1 to ON
je ON
cmp al,'0' ;press 0 to OFF
je OFF
END:
mov al, 00h ;OFF LEDs and motor
mov dx, 378h
out dx, al
mov ah, 4Ch ;End of program
int 21h
section .data
msg1 db 13,10,'Press 1/0(press any key to exit): ','$'
; Description : A simple example of
;parallel interfacing file programmed
bits 16 ; Set 16 bit code generation
org 0x0100 ; Set code start address to ; 100h (COM file)
MAIN:
jmp START ; Jump to label 'START'
DISPLAY: ; Subroutine program
lea dx,[msg1] ; string print
mov ah,09h ; service no 09h
int $21 ; interrupt 21h
ret
DELAY: ;Delay program
MOV CX, 01Fh ;outer loop
.NEXT: MOV BX,0FFFFH ;inner loop
.NEXT2: NOP
NOP
NOP
DEC BX
JNZ .NEXT2
LOOP .NEXT
RET
END: ;Define label 'END'
mov ah, $4C ;service no =4ch
int $21
ret ;return to calling
PATTERN:
;1st pattern
mov dx,$378 ;set data port address
mov al,$03 ;set two LEDs ON
out dx,al ;output to data port
call DELAY ;call delay subroutine
;2nd pattern
mov dx,$378 ;set data port address
mov al,$02 ;set one LED = OFF, another LED=ON
out dx,al ;output to data port
call DELAY ;call delay subroutine
;3rd pattern
mov dx,$378 ;set data port address
mov al,$01 ;set one LED = ON, another LED=OFF
out dx,al ;output to data port
call DELAY ;call delay subroutine
;4th pattern
mov dx,$378 ;set data port address
mov al,$00 ;set two LEDs = OFF
out dx,al ;output to data port
call DELAY ;call delay subroutine
ret
START:
call DISPLAY ; display message on screen
call PATTERN ; display pattern
call END ; end program
section .data
msg1 db 13,10,Program running? ','$'
BITS 16 ;Set code generation to 16 bit mode
ORG 0x0100 ;Set code start address to 0000h
[section .text]
MAIN:
jmp START
DISP:
mov ah,09h ;String Print int service
int 21h
ret
ON2:
lea dx,[msg3] ;Display message
call DISP
mov al,0F0h ;2nd 7-seg ON
mov dx, 378h
out dx, al
jmp MAIN
ON1:
lea dx,[msg2] ;Display message
call DISP
mov al,0Fh ;1st 7-seg ON
mov dx, 378h
out dx, al
START:
lea dx,[msg1] ;Display message
call DISP
mov ah, 01h ;keyboard interrupt
int 21h
cmp al,'1' ;press 1 to ON1
je ON1
cmp al,'2' ;press 2 to ON2
je ON2
END:
mov al, 00h ;LEDs OFF
mov dx, 378h
out dx, al
mov ah, 4Ch ;End of program
int 21h
section .data
msg1 db 13,10,'Press 1/0: ','$'
msg2 db 13,10,'First 7-SEG ON...','$'
msg3 db 13,10,'Second 7-SEG ON...','$'
Dear Students, Assembly ke coding simple notepad file main likhtay hain phir iss koo compile kertay hain oor uss say .com and .lst file banatay hain......
don't be confused yeah language zaror perho kiun kay yeah to basic hai hardware engineering kee
CS401 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.
You are supposed to submit your assignment in .doc or docx format.
Any other formats like scan images, PDF, zip, rar, ppt and bmp etc will not be accepted.
Topic Covered in CS401 Assignment No 3:
- BIOS and DOS interrupts
- Hardware Interrupts
- Ports
Please Note
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 closing date.If you people find any mistake or confusion in assignment (Question statement), please consult with your instructor before the deadline. After the deadline no queries will be entertained in this regard.
For any query, feel free to email at: cs401@vu.edu.pk
CS401 Assignment Question
Suppose, you are interfacing an old monochrome dot matrix printer (receipt printer) with your computer’s parallel port. The stated dot matrix printer will print receipts character wise, so the system will transmit each character parallelly.The printer will be operated as under:
- First, you should select the printer by setting “select printer” pin on your parallel port.
- Initialize printer by sending initialize signal.
- Read “acknowledge” pin.
- Transmit ASCII character data to the data port of the parallel port.
- Clear initialize signal.
- Deselect printer.
“Welcome to Virtual University of Pakistan”
Your subroutine will get each character as an input from keyboard using interrupt mechanism and transmit it to the printer port according to the stated working mechanism
CS401 Assignment No 3 Solution
BITS 16 ;Set code generation to 16 bit modeORG 0x0100 ;Set code start address to 0000h
MAIN:
jmp START
DISP:
mov ah,09h ;String Print int service
int 21h
ret
OFF:
mov al,00h ;All LEDs OFF
mov dx, 378h
out dx, al
jmp MAIN
ON:
mov al,0FFh ;All LEDs ON
mov dx, 378h
out dx, al
START:
lea dx,[msg1] ;Display message
call DISP
mov ah, 01h ;keyboard interrupt
int 21h
cmp al,'1' ;press 1 to ON
je ON
cmp al,'0' ;press 0 to OFF
je OFF
END:
mov al, 00h ;OFF LEDs and motor
mov dx, 378h
out dx, al
mov ah, 4Ch ;End of program
int 21h
section .data
msg1 db 13,10,'Press 1/0(press any key to exit): ','$'
; Description : A simple example of
;parallel interfacing file programmed
bits 16 ; Set 16 bit code generation
org 0x0100 ; Set code start address to ; 100h (COM file)
MAIN:
jmp START ; Jump to label 'START'
DISPLAY: ; Subroutine program
lea dx,[msg1] ; string print
mov ah,09h ; service no 09h
int $21 ; interrupt 21h
ret
DELAY: ;Delay program
MOV CX, 01Fh ;outer loop
.NEXT: MOV BX,0FFFFH ;inner loop
.NEXT2: NOP
NOP
NOP
DEC BX
JNZ .NEXT2
LOOP .NEXT
RET
END: ;Define label 'END'
mov ah, $4C ;service no =4ch
int $21
ret ;return to calling
PATTERN:
;1st pattern
mov dx,$378 ;set data port address
mov al,$03 ;set two LEDs ON
out dx,al ;output to data port
call DELAY ;call delay subroutine
;2nd pattern
mov dx,$378 ;set data port address
mov al,$02 ;set one LED = OFF, another LED=ON
out dx,al ;output to data port
call DELAY ;call delay subroutine
;3rd pattern
mov dx,$378 ;set data port address
mov al,$01 ;set one LED = ON, another LED=OFF
out dx,al ;output to data port
call DELAY ;call delay subroutine
;4th pattern
mov dx,$378 ;set data port address
mov al,$00 ;set two LEDs = OFF
out dx,al ;output to data port
call DELAY ;call delay subroutine
ret
START:
call DISPLAY ; display message on screen
call PATTERN ; display pattern
call END ; end program
section .data
msg1 db 13,10,Program running? ','$'
BITS 16 ;Set code generation to 16 bit mode
ORG 0x0100 ;Set code start address to 0000h
[section .text]
MAIN:
jmp START
DISP:
mov ah,09h ;String Print int service
int 21h
ret
ON2:
lea dx,[msg3] ;Display message
call DISP
mov al,0F0h ;2nd 7-seg ON
mov dx, 378h
out dx, al
jmp MAIN
ON1:
lea dx,[msg2] ;Display message
call DISP
mov al,0Fh ;1st 7-seg ON
mov dx, 378h
out dx, al
START:
lea dx,[msg1] ;Display message
call DISP
mov ah, 01h ;keyboard interrupt
int 21h
cmp al,'1' ;press 1 to ON1
je ON1
cmp al,'2' ;press 2 to ON2
je ON2
END:
mov al, 00h ;LEDs OFF
mov dx, 378h
out dx, al
mov ah, 4Ch ;End of program
int 21h
section .data
msg1 db 13,10,'Press 1/0: ','$'
msg2 db 13,10,'First 7-SEG ON...','$'
msg3 db 13,10,'Second 7-SEG ON...','$'
don't be confused yeah language zaror perho kiun kay yeah to basic hai hardware engineering kee
Please share with your friends. Thank You.
Post a Comment