Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- .data
- writeerr db "Error: can't send byte",0Dh,0Ah,'$'
- readerr db "Error: can't read byte",0Dh,0Ah,'$'
- .code
- jmp start
- initialize proc
- xor ax,ax
- mov al,10100011b ; 8 bits in symbol ; 1 stop bit ; no parity ; 2400 bod
- mov dx,0 ; COM1 address 0000h
- int 14h
- ret
- initialize endp
- sendByte proc
- mov al,'D' ; byte to send
- mov ah,1 ; write function 01h of 14h
- mov dx,0 ; COM1 address 0000h
- int 14h
- test al,80h ; catch error
- jnz writeError
- ret
- sendByte endp
- writeError proc
- mov ah,9
- mov dx,offset writeerr
- add dx,2
- int 21h
- ret
- writeError endp
- readByte proc
- mov ah,2 ; read function 02h of 14h
- mov dx,1 ; COM2 address 0001h
- int 14h
- test al,80h ; catch error
- jnz readError
- ret
- readByte endp
- readError proc
- mov ah,9
- mov dx,offset readerr
- add dx,2
- int 21h
- ret
- readError endp
- print proc
- mov ah,02h
- mov dl,al ; moving read byte from al to dl
- int 21h
- ret
- print endp
- exit proc
- mov ax,4C00h
- int 21h
- ret
- exit endp
- start:
- call initialize ; Initializing COM Port for writing
- call sendByte ; Send byte
- call readByte ; Read byte
- call print ; Write a byte to stdout
- call exit
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement