Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; multi-segment executable file template.
- data segment
- sup db ' Hello the world$'
- ends
- stack segment
- dw 128 dup(0)
- ends
- code segment
- PILE SEGMENT PARA STACK
- PILE ENDS
- ASSUME CS:CODE, DS:DATA, SS:PILE
- start:
- ; set segment registers:
- mov ax, data
- mov ds, ax
- mov es, ax
- portA equ 300h
- portB equ 302h
- portC equ 304h
- cmd equ 306h
- mov dx,cmd ; DX= cmd register's adresse
- mov al,80h ; A,B,C are outputs
- out dx,al ; regis's main settings
- call lcd_init ; call proc
- mov si,offset sup
- call lcd_maintext
- ;===========sliding=========
- mov bl,0 ; bl=0 (counter)
- A: ; bl should be 0 at this point
- inc bl ; bl= bl+1
- call lcd_GTR ; slide right
- cmp bl,199
- jne A ; if bl=7 (text slided to right 7times) go B else jump back to A
- B: ; bl should be 7 at this point
- dec bl ; bl=bl-1
- call lcd_GTL ; slide left
- cmp bl,0
- jne B ; if bl=0 (text slided back to left side 7times) go A else jump back to B
- jmp A
- ;**************proc**************
- lcd_maintext proc
- ;==================
- mov bl,0
- srsly:
- mov al,[si]
- mov dx,portA ; DX= portA's adresse
- out dx,al ; send to portA's outputs AL's value
- mov dx,portB ; DX= portB's adresse
- mov al,11b ; E=1 / RS=1 typing mode
- out dx,al ; validation
- mov al,10b
- out dx,al ; end of validation
- inc si
- inc bl
- cmp bl,07h
- jne srsly
- call lcd_sec_line
- srslyy:
- mov al,[si]
- mov dx,portA ; DX= portA's adresse
- out dx,al ; send to portA's outputs AL's value
- mov dx,portB ; DX= portB's adresse
- mov al,11b ; E=1 / RS=1 typing mode
- out dx,al ; validation
- mov al,10b
- out dx,al ; end of validation
- inc si
- cmp [si],'$'
- jne srslyy
- ret
- lcd_maintext endp
- lcd_GTR proc
- ;==================
- mov dx,portA ; DX= PortA's adresse
- mov al, 01Eh ; 1Eh allows us to slide right
- out dx,al ; Send 1Eh to portA's outputs
- mov dx,portB ; DX= portB's adresse
- mov al,01b ; E=1 / RS=0 (inst)
- out dx,al ; Validation
- mov al,00
- out dx,al
- ret
- lcd_GTR endp
- lcd_GTL proc
- ;==================
- mov dx,portA ; DX= PortA's adresse
- mov al, 018h ; 18h allows us to slide left
- out dx,al ; Send 18h to portA's outputs
- mov dx,portB ; DX= portB's adresse
- mov al,01b ; E=1 / RS=0 (inst)
- out dx,al ; Validation
- mov al,00
- out dx,al
- ret
- lcd_GTL endp
- lcd_fir_line proc
- ;==================
- mov dx,portA ; DX= PortA's adresse
- mov al, 080h ; 80h allows us to select first line
- out dx,al ; Send 80h to portA's outputs
- mov dx,portB ; DX= portB's adresse
- mov al,01b ; E=1 / RS=0 (inst)
- out dx,al ; Validation
- mov al,00
- out dx,al
- ret
- lcd_fir_line endp
- lcd_sec_line proc
- ;==================
- mov dx,portA ; DX= portA's adresse
- mov al, 0c0h ; c0h allows us to select second line
- out dx,al ; Send c0 to portA's outputs
- mov dx,portB ; DX= portB's adresse
- mov al,01b ; E=1 / RS=0
- out dx,al ; Validation
- mov al,00
- out dx,al
- ret
- lcd_sec_line endp
- lcd_clearscreen proc
- ;==================
- mov dx,portA ; DX= portA's adresse
- mov al, 01h ; 01h force clear screen
- out dx,al ; validation
- mov dx,portB ; DX= portB's adresse
- mov al,01b
- out dx,al ; Validation (instruction)
- mov al,00
- out dx,al
- ret
- lcd_clearscreen endp
- lcd_init proc
- ;==================
- mov dx,portB ; DX= portB's adresse
- mov al,00h ; AL=00h
- out dx,al ; Enable=0 / RS=0
- mov dx,portA ; DX=portA's adresse
- mov al,038h ; AL= 38h
- out dx,al ; Send 38h to portA (8bits/2lines mode)
- mov dx,portB ; DX= portB's adresse
- mov al,01b ; AL= 01b
- out dx,al ; E=1 / RS=0 Validation goes to instructions
- mov al,0
- out dx,al ; E=0 / RS=0
- mov dx,portA ; DX=portA's adress
- mov al,0Eh ;
- out dx,al ; Send 0Eh to portA (cursor settings 0Ch:Vis - 0E:inv 0F:blkn)
- mov dx,portB ; DX=portB's adresse
- mov al,01b ;
- out dx,al ; E=1 / RS=0 Validation(instuction)
- mov al,0
- out dx,al ; E=0 / RS=0
- mov dx,portA ; DX=portA's adresse
- mov al,06h ; cursor setup (deplacement) 06=move right
- out dx,al ; Send 06h to portA's output
- mov dx,portB ; DX=portB's adresse
- mov al,01b
- out dx,al ; E=1 / RS=0 Validation
- mov al,0
- out dx,al
- ret
- lcd_init endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement