Last active
October 28, 2018 08:48
-
-
Save vintagechips/e38dcc2cd51412259578c09bfedf9653 to your computer and use it in GitHub Desktop.
hello, world SBC8088 uPD7201 Channel A polling version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; SBC8088 terminal test program | |
; 7201 Channel A polling version | |
; Assembler: asm86.com/asm86.cmd | |
; | |
RAM equ 0000h ;0000h..7fffh | |
ROM equ 8000h ;8000h..0ffffh | |
STACK equ 8000h ;stack top | |
REGAD equ 0C0h ;7201 channel A data register | |
REGAC equ 0C1h ;7201 channel A control register | |
; | |
org ROM | |
; | |
; channel A command chain | |
chacmd db 02h ;select WR2 | |
db 01000000b ;RxINT mask | |
db 04h ;select WR4 | |
db 01000101b ;x16, 1stop bit | |
db 01h ;select WR1 | |
db 00000000b ;TxINT mask | |
db 05h ;select WR5 | |
db 11101010b ;8bit, TxD enable | |
db 03h ;select WR3 | |
db 11000001b ;8bit, RxD enable | |
chacln equ 10 | |
; | |
; message | |
hello db 13, 10, 'hello, world', 13, 10, 0 | |
; | |
; al -> 7201 | |
putch: push ax ;save data | |
pcst1: in al,REGAC ;get status | |
and al,04h ;check TxBUF enpty | |
jz pcst1 ;wait for empty | |
pop ax ;restore data | |
out (REGAD),al ;transfer | |
ret | |
; | |
; 7201 -> al | |
getch: in al,REGAC ;get status | |
and al,01h ;check TxBUF enpty | |
jz getch ;wait for empty | |
in al,REGAD ;receive | |
ret | |
; | |
; put string | |
puts: cld ;set DF for SI increment | |
ptst1: lodsb ;get data to AL and SI++ | |
cmp al,00h ;check tail | |
jz ptst2 ;if tail, return | |
call putch ;display a charactor | |
jmp ptst1 ;loop until tail | |
ptst2: ret | |
; | |
; start | |
start: cli ;desable interrupt | |
mov ax,cs ;set com model | |
mov ds,ax | |
mov es,ax | |
mov ss,ax | |
mov sp,STACK ;set stack | |
; | |
; channel A setup | |
mov dx,REGAC ;set port number | |
mov al,00011000b ;reset | |
out dx,al | |
nop | |
nop | |
nop | |
nop | |
cld ;set DF for SI increment | |
mov si,offset chacmd ;set commnd top | |
mov cx,chacln ;set commnd length | |
;rep outsb ;out commnds | |
db 0f3h,6eh ;alternate | |
; | |
; display hello, world | |
mov si,offset hello ;set message top | |
call puts ;display message | |
; | |
; keyin and echo | |
loop: call getch | |
call putch | |
jmp loop | |
; | |
; reset | |
org 0fff0h | |
db 0eah ;jmp | |
dw start ;offset | |
dw 0000h ;segment | |
; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment