Advertisement
Axel2099

Untitled

Mar 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. ; multi-segment executable file template.
  2.  
  3. data segment
  4. sup db ' Hello the world$'
  5. ends
  6.  
  7. stack segment
  8. dw 128 dup(0)
  9. ends
  10.  
  11. code segment
  12.  
  13.  
  14. PILE SEGMENT PARA STACK
  15.  
  16. PILE ENDS
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. ASSUME CS:CODE, DS:DATA, SS:PILE
  24.  
  25.  
  26.  
  27. start:
  28. ; set segment registers:
  29. mov ax, data
  30. mov ds, ax
  31. mov es, ax
  32.  
  33.  
  34.  
  35.  
  36. portA equ 300h
  37. portB equ 302h
  38. portC equ 304h
  39. cmd equ 306h
  40.  
  41.  
  42. mov dx,cmd ; DX= cmd register's adresse
  43. mov al,80h ; A,B,C are outputs
  44. out dx,al ; regis's main settings
  45.  
  46.  
  47. call lcd_init ; call proc
  48.  
  49.  
  50. mov si,offset sup
  51.  
  52. call lcd_maintext
  53.  
  54.  
  55. ;===========sliding=========
  56.  
  57. mov bl,0 ; bl=0 (counter)
  58.  
  59. A: ; bl should be 0 at this point
  60. inc bl ; bl= bl+1
  61. call lcd_GTR ; slide right
  62. cmp bl,199
  63. jne A ; if bl=7 (text slided to right 7times) go B else jump back to A
  64.  
  65. B: ; bl should be 7 at this point
  66. dec bl ; bl=bl-1
  67. call lcd_GTL ; slide left
  68. cmp bl,0
  69. jne B ; if bl=0 (text slided back to left side 7times) go A else jump back to B
  70. jmp A
  71.  
  72.  
  73.  
  74.  
  75.  
  76. ;**************proc**************
  77.  
  78. lcd_maintext proc
  79. ;==================
  80.  
  81. mov bl,0
  82.  
  83. srsly:
  84.  
  85. mov al,[si]
  86. mov dx,portA ; DX= portA's adresse
  87. out dx,al ; send to portA's outputs AL's value
  88.  
  89. mov dx,portB ; DX= portB's adresse
  90. mov al,11b ; E=1 / RS=1 typing mode
  91. out dx,al ; validation
  92. mov al,10b
  93. out dx,al ; end of validation
  94. inc si
  95. inc bl
  96. cmp bl,07h
  97. jne srsly
  98.  
  99. call lcd_sec_line
  100.  
  101.  
  102. srslyy:
  103. mov al,[si]
  104. mov dx,portA ; DX= portA's adresse
  105. out dx,al ; send to portA's outputs AL's value
  106. mov dx,portB ; DX= portB's adresse
  107. mov al,11b ; E=1 / RS=1 typing mode
  108. out dx,al ; validation
  109. mov al,10b
  110. out dx,al ; end of validation
  111. inc si
  112. cmp [si],'$'
  113. jne srslyy
  114.  
  115.  
  116. ret
  117. lcd_maintext endp
  118.  
  119.  
  120.  
  121.  
  122. lcd_GTR proc
  123. ;==================
  124.  
  125. mov dx,portA ; DX= PortA's adresse
  126. mov al, 01Eh ; 1Eh allows us to slide right
  127. out dx,al ; Send 1Eh to portA's outputs
  128.  
  129. mov dx,portB ; DX= portB's adresse
  130. mov al,01b ; E=1 / RS=0 (inst)
  131. out dx,al ; Validation
  132. mov al,00
  133. out dx,al
  134. ret
  135. lcd_GTR endp
  136.  
  137.  
  138.  
  139. lcd_GTL proc
  140. ;==================
  141.  
  142. mov dx,portA ; DX= PortA's adresse
  143. mov al, 018h ; 18h allows us to slide left
  144. out dx,al ; Send 18h to portA's outputs
  145.  
  146. mov dx,portB ; DX= portB's adresse
  147. mov al,01b ; E=1 / RS=0 (inst)
  148. out dx,al ; Validation
  149. mov al,00
  150. out dx,al
  151. ret
  152. lcd_GTL endp
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. lcd_fir_line proc
  160. ;==================
  161.  
  162. mov dx,portA ; DX= PortA's adresse
  163. mov al, 080h ; 80h allows us to select first line
  164. out dx,al ; Send 80h to portA's outputs
  165.  
  166. mov dx,portB ; DX= portB's adresse
  167. mov al,01b ; E=1 / RS=0 (inst)
  168. out dx,al ; Validation
  169. mov al,00
  170. out dx,al
  171. ret
  172. lcd_fir_line endp
  173.  
  174.  
  175.  
  176.  
  177.  
  178. lcd_sec_line proc
  179. ;==================
  180.  
  181. mov dx,portA ; DX= portA's adresse
  182. mov al, 0c0h ; c0h allows us to select second line
  183. out dx,al ; Send c0 to portA's outputs
  184.  
  185. mov dx,portB ; DX= portB's adresse
  186. mov al,01b ; E=1 / RS=0
  187. out dx,al ; Validation
  188. mov al,00
  189. out dx,al
  190. ret
  191. lcd_sec_line endp
  192.  
  193.  
  194.  
  195.  
  196. lcd_clearscreen proc
  197. ;==================
  198.  
  199. mov dx,portA ; DX= portA's adresse
  200. mov al, 01h ; 01h force clear screen
  201. out dx,al ; validation
  202.  
  203.  
  204. mov dx,portB ; DX= portB's adresse
  205. mov al,01b
  206. out dx,al ; Validation (instruction)
  207. mov al,00
  208. out dx,al
  209. ret
  210. lcd_clearscreen endp
  211.  
  212.  
  213.  
  214.  
  215.  
  216. lcd_init proc
  217. ;==================
  218.  
  219. mov dx,portB ; DX= portB's adresse
  220. mov al,00h ; AL=00h
  221.  
  222. out dx,al ; Enable=0 / RS=0
  223.  
  224. mov dx,portA ; DX=portA's adresse
  225. mov al,038h ; AL= 38h
  226. out dx,al ; Send 38h to portA (8bits/2lines mode)
  227.  
  228. mov dx,portB ; DX= portB's adresse
  229. mov al,01b ; AL= 01b
  230. out dx,al ; E=1 / RS=0 Validation goes to instructions
  231.  
  232. mov al,0
  233. out dx,al ; E=0 / RS=0
  234.  
  235. mov dx,portA ; DX=portA's adress
  236. mov al,0Eh ;
  237. out dx,al ; Send 0Eh to portA (cursor settings 0Ch:Vis - 0E:inv 0F:blkn)
  238.  
  239. mov dx,portB ; DX=portB's adresse
  240. mov al,01b ;
  241. out dx,al ; E=1 / RS=0 Validation(instuction)
  242.  
  243. mov al,0
  244. out dx,al ; E=0 / RS=0
  245.  
  246.  
  247. mov dx,portA ; DX=portA's adresse
  248. mov al,06h ; cursor setup (deplacement) 06=move right
  249. out dx,al ; Send 06h to portA's output
  250.  
  251. mov dx,portB ; DX=portB's adresse
  252. mov al,01b
  253. out dx,al ; E=1 / RS=0 Validation
  254.  
  255. mov al,0
  256. out dx,al
  257. ret
  258. lcd_init endp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement