Advertisement
KirillSamokhin

LB_5

Nov 28th, 2022 (edited)
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AStack  SEGMENT STACK
  2.     DB 1024 DUP(?)
  3. AStack  ENDS
  4.  
  5. DATA    SEGMENT
  6.     KEEP_CS DW 0    
  7.     KEEP_IP DW 0
  8.     MESSAGE DB 'Hello!', 0dh, 0ah, '$'
  9.     END_MES DB 'end', 0dh, 0ah, '$'
  10.     FLAG    DB 0
  11. DATA    ENDS
  12.  
  13. CODE    SEGMENT
  14.     ASSUME CS:CODE, DS:DATA, SS:AStack
  15.  
  16. WriteMsg  PROC  NEAR
  17.           mov AH, 9
  18.           int 21h
  19.           ret
  20. WriteMsg  ENDP
  21.  
  22. FUNC PROC FAR
  23.         cmp  FLAG, 0
  24.         jne  func_end
  25.         mov  FLAG, 1
  26.        
  27.         push ax
  28.         push bx
  29.         push cx
  30.         push dx
  31.         push ds
  32.        
  33.        
  34.         mov dx, OFFSET MESSAGE
  35.         mov cx, 4
  36.         lp:
  37.             call WriteMsg
  38.             loop lp
  39.            
  40.         xor  cx, cx
  41.         mov  cx, 20
  42.         update_dx:
  43.         mov  dx, 0ffffh
  44.         wait_loop:
  45.         nop
  46.         dec  dx
  47.         cmp  dx, 0
  48.         jne  wait_loop
  49.         loop update_dx
  50.        
  51.         mov dx, OFFSET END_MES
  52.         call WriteMsg
  53.        
  54.         pop ds
  55.         pop dx
  56.         pop cx
  57.         pop bx
  58.         pop ax
  59.         func_end:
  60.         mov al, 20h
  61.         out 20h, al
  62.         iret
  63. FUNC ENDP
  64.  
  65. main proc far
  66.     push ds
  67.     xor  ax, ax
  68.     push ax
  69.  
  70.     mov  ax, DATA
  71.     mov  ds, ax
  72.    
  73.     mov  ah, 35h
  74.     mov  al, 16h
  75.     int  21h
  76.     mov  KEEP_CS, es
  77.     mov  KEEP_IP, bx
  78.    
  79.  
  80.     push ds                        
  81.     mov  dx, offset FUNC
  82.     mov  ax, seg FUNC
  83.     mov  ds, ax                    
  84.     mov  ah, 25h
  85.     mov  al, 16h
  86.     int  21h
  87.     pop  ds
  88.    
  89.     input_loop:
  90.      in   al, 60h
  91.      cmp  al, 30h                  
  92.      jne  input_loop
  93.      mov al, 100
  94.      int  16h
  95.  
  96.     cli
  97.  
  98.     push ds
  99.     mov  dx, KEEP_IP
  100.     mov  ax, KEEP_CS
  101.     mov  ds, ax
  102.     mov  ah, 25h
  103.     mov  al, 16h
  104.     int  21h
  105.     pop  ds
  106.  
  107.     sti
  108.  
  109.     ret
  110.  
  111. main endp
  112.  
  113. my_code ends
  114. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement