Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; general purpose registers
  2. ; ax - accumulator
  3. ; bx - base
  4. ; cx - count
  5. ; dx - data register
  6.  
  7. ; segment registers
  8. ; cs - code segment, base location of program code
  9. ; ds - data segment, base location of variables
  10. ; ss - stack segment, base location of stack
  11. ; es - extra segment, additional base locations for variables in memory
  12.  
  13. ; index registers
  14. ; bs - base pointer, offset from SS register to locate variables on the stack
  15. ; sp - stack pointer, offset from ss register as to the location of the stack's top
  16. ; si - source index, used for copying strings, segment register varies
  17. ; di - destination index, used for destination for coping strings
  18.  
  19.  
  20. refresh:
  21.     cld                     ; clear direction flag (I guess some status register), so that when calling lodsb, we increase SI
  22.     push ax                 ; save all registers
  23.     push cx                 ; save all registers
  24.     push dx                 ; save all registers
  25.     push bx                 ; save all registers
  26.     push si                 ; save all registers
  27.     push di                 ; save all registers
  28.     push ds                 ; save all registers
  29.  
  30.     mov si,0                ; clear source index I suppose
  31.     mov ax,0b000h           ; $b00 address
  32.     mov ds,ax               ;
  33.     mov di,64               ; y = 64
  34. ref2:  
  35.     mov cx,30               ; count = 30, x=30*8 = 240
  36.     mov bx,si               ; move si to bx
  37.  
  38.     mov al,0ah              ; move $a in lower
  39.     mov dx,8011h            ; $8011 in dx, ah this is the port to the LCD controller
  40.     cli                     ; disable interrupts
  41.     out dx,al               ; send a byte from $a to the port                                   $a -> $8011 (cursor address lower)
  42.     mov al,bl               ; move bl lower to al
  43.     dec dx                  ; dx--; $8010
  44.     out dx,al               ; send bte from al to $8010                                         lower cursor count -> $8010
  45.     sti                     ; enable interrupts
  46.  
  47.     mov al,0bh              ; $b to lower                                                       $b -> $8011 (cursor adddress upper)
  48.     inc dx                  ; dx++; $8011
  49.     cli                     ; disable interrupts
  50.     out dx,al               ; send byte ($b) from al to $8010
  51.     dec dx                  ; dx--; $8010
  52.     mov al,bh               ; update a-lower with b-higher                                     
  53.     and al,7                ; lower 3 bits
  54.     out dx,al               ;                                                                   upper cursor count -> $8010
  55.     sti                     ; enable interrupts
  56. ref1:  
  57.         lodsb                   ; Load byte at address DS:(E)SI into AL.        mov al,[DS:SI] so we get a byte of grapics data %01234567
  58.         ; reverse bit order
  59.         ror al,1                ; rotate right 1 bit                    %70123456
  60.         mov ah,al               ; store lower to higher             ah= %70123456
  61.         and ah,136              ; 128+8 = %10001000                 ah= %7___3___  
  62.         ror al,1                ; rotate right 1 bit                    %67012345
  63.         ror al,1                ; rotate right 1 bit                    %56701234
  64.         mov bl,al               ; al to bl                          bl= %56701234
  65.         and bl,68               ; 64+4 = %1000100                       %_6___2__
  66.         or ah,bl                ; %76__32__
  67.         ror al,1                ; rotate right 1 bit                    %45670123
  68.         ror al,1                ; rotate right 1 bit                    %34567012
  69.         mov bl,al               ; al to bl                          bl= %34567012
  70.         and bl,34               ; 32+2 = %100010                        %__5___1_
  71.         or ah,bl                ; %765_321_
  72.         ror al,1                ; rotate right 1 bit                    %23456701
  73.         ror al,1                ; rotate right 1 bit                    %12345670
  74.         and al,17               ; 16+1 = %10001                         %___4___0
  75.         or al,ah                ; %76543210                                
  76.         mov ah,al               ;
  77.         inc dx                  ; dx = $8011
  78.         mov al,0ch              ; al = $c
  79.    
  80.         cli
  81.         out dx,al               ;                                                                   $c -> $8011 memory write
  82.         mov al,ah
  83.         dec dx                  ; dx = $8010
  84.         out dx,al               ; write byte
  85.         sti
  86.  
  87.     loop ref1                   ; dbra  cx, thus 30 times  
  88.     dec di                      ;
  89.     jnz ref2
  90.     pop ds
  91.     pop di
  92.     pop si
  93.     pop bx
  94.     pop dx
  95.     pop cx
  96.     pop ax
  97.     ret
  98.  
  99. ;The LCD on the Portfolio is controlled by a HD61830
  100. ;of Hitachi. The I/O addresses are 8010h and 8011h.
  101. ;
  102. ;8010h is the data register
  103. ;8011h is the control register
  104. ;
  105. ;To program:
  106. ;
  107. ;1. Write the register number to 8011h
  108. ;2. Write the data to register 8010h
  109. ;
  110. ;For register and data value, see table below.
  111. ;After the data values the initial values for the
  112. ;Portfolio are show in hex (set during reset)
  113. ;
  114. ;
  115. ;Reg function                      Bits                            init
  116. ;                                   7   6   5   4   3   2   1   0
  117. ;                                 +---+---+---+---+---+---+---+---+
  118. ;  0 Mode control                 | 0 | 0 |       Mode data       | 38
  119. ;                                 +---+---+-------+---+-----------+
  120. ;  1 Vertical/horizontal          |   (Vp-1)      | 0 |   (Hp-1)  | 75
  121. ;    character pitch              |               |   |           |
  122. ;                                 +---+-----------+---+-----------+
  123. ;  2 Number of characters per     | 0 |          (HN-1)           | 27
  124. ;    line/number of bytes         |   |                           |
  125. ;                                 +---+---------------------------+
  126. ;  3 Number of vertical dots      |   |          (NX-1)           | 3F
  127. ;                                 +---+---+---+---+---------------+
  128. ;  4 Cursor position              | 0 | 0 | 0 | 0 |     (CP-1)    | 07
  129. ;                                 +---+---+---+---+---------------+
  130. ;  8 Display starting address     |          Address data         | 00
  131. ;    (least significant) (Lower)  |                               |
  132. ;                                 +---+---+---+---+---------------+
  133. ;  9 Display starting address     | 0 | 0 | 0 | 0 | Address data  | 00
  134. ;    (most significant) (Upper)   |   |   |   |   |               |
  135. ;                                 +---+---+---+---+---------------+
  136. ; 10 Cursor address               |          Address data         | 00
  137. ;    (least significant) (Lower)  |                               |
  138. ;                                 +---+---+---+---+---------------+
  139. ; 11 Cursor address               | 0 | 0 | 0 | 0 | Address data  | 00
  140. ;    (most significant) (Upper)   |   |   |   |   |               |
  141. ;                                 +---+---+---+---+---------------+
  142. ; 12 Refresh memory write         |   Character code/bit data     |
  143. ;                                 +-------------------------------+
  144. ; 13 Refresh memory read          |      Refresh memory data      |
  145. ;                                 +---+---+---+---+---+-----------+
  146. ; 14 Bit clear                    | 0 | 0 | 0 | 0 | 0 |   (BN)    |
  147. ;                                 +---+---+---+---+---+-----------+
  148. ; 15 Bit set                      | 0 | 0 | 0 | 0 | 0 |   (BN)    |
  149. ;                                 +---+---+---+---+---+-----------+
  150. ;
  151. ;Mode data:
  152. ;
  153. ;1 1 1 0 0 0     Initial value for Portfolio
  154. ;
  155. ;5 4 3 2 1 0
  156. ;| | \ / | |
  157. ;| |  |  | +---  0: Internal character generator ROM
  158. ;| |  |  |       1: External character generator ROM
  159. ;| |  |  |
  160. ;| |  |  +-----  0: Character mode
  161. ;| |  |          1: Graphics mode
  162. ;| |  |
  163. ;| |  +-------- 00: Cursor OFF
  164. ;| |            01: Cursor ON
  165. ;| |            10: Cursor OFF, character blink
  166. ;| |            11: Cursor blink
  167. ;| |
  168. ;| +-----------  1: Master or slave (when multiple HD61830's)
  169. ;|
  170. ;+-------------  0: Display OFF (without clearing refresh memory)
  171. ;                1: Display ON
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement