BITS 16;Set code generation to 16 bit mode
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...','$'