PhotoShaman

ASM.Лаба6

Mar 23rd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-----------------------------Задание 1
  2.  
  3. ; multi-segment executable file template.
  4.  
  5. data segment
  6.     ; add your data here!
  7.     type db "vvedite chislo (0-9): $"
  8.     pkey db 10, 13, "press any key...$"
  9.     endl db 10,13, "$"
  10. ends
  11.  
  12. stack segment
  13.     dw   128  dup(0)
  14. ends
  15.  
  16. code segment
  17. start:
  18. ; set segment registers:
  19.     mov ax, data
  20.     mov ds, ax
  21.     mov es, ax
  22.  
  23.     ; add your code here
  24.     lea dx, type
  25.     mov ah, 9
  26.     int 21h
  27.    
  28.     mov ah, 1
  29.     int 21h
  30.    
  31.     sub al, 2Fh
  32.     mov cx, 0
  33.     mov cl, al
  34.     mov bx, 0
  35.    
  36.     lea dx, endl
  37.     mov ah, 9
  38.     int 21h  
  39.    
  40.     loop_start:
  41.      
  42.     mov ax, bx
  43.     OutInt proc     ;output number 0 - 99
  44.         aam
  45.         add ax,3030h
  46.         mov dl,ah
  47.         mov dh,al
  48.         mov ah,02
  49.         cmp dl,48   ;is the number starts as 0
  50.         je next
  51.         int 21h
  52.         next:
  53.         mov dl,dh
  54.         int 21h
  55.     OutInt endp
  56.    
  57.     inc bx
  58.     loop loop_start
  59.            
  60.     lea dx, pkey
  61.     mov ah, 9
  62.     int 21h        ; output string at ds:dx
  63.    
  64.     ; wait for any key....    
  65.     mov ah, 1
  66.     int 21h
  67.    
  68.     mov ax, 4c00h ; exit to operating system.
  69.     int 21h    
  70. ends
  71.  
  72. end start ; set entry point and stop the assembler.
  73.  
  74.  
  75. //-----------------------------Задание 2
  76.  
  77. ; multi-segment executable file template.
  78.  
  79. data segment
  80.     ; add your data here!
  81.     pkey db 10,13, "press any key...$"
  82.     endl db 10,13, "$"
  83.     count dw -1
  84. ends
  85.  
  86. stack segment
  87.     dw   128  dup(0)
  88. ends
  89.  
  90. code segment
  91. start:
  92. ; set segment registers:
  93.     mov ax, data
  94.     mov ds, ax
  95.     mov es, ax
  96.  
  97.     ; add your code here
  98.            
  99.     loop_start:
  100.         inc count
  101.         mov ah, 1
  102.         int 21h  
  103.         cmp al, 13
  104.         jne loop_start      
  105.            
  106.     lea dx, endl
  107.     mov ah, 9
  108.     int 21h        
  109.                  
  110.     mov ax, count
  111.     OutInt proc     ;output number 0 - 99
  112.         aam
  113.         add ax,3030h
  114.         mov dl,ah
  115.         mov dh,al
  116.         mov ah,02
  117.         cmp dl,48   ;is the number starts as 0
  118.         je next
  119.         int 21h
  120.         next:
  121.         mov dl,dh
  122.         int 21h
  123.     OutInt endp
  124.          
  125.     lea dx, pkey
  126.     mov ah, 9
  127.     int 21h        ; output string at ds:dx
  128.    
  129.     ; wait for any key....    
  130.     mov ah, 1
  131.     int 21h
  132.    
  133.     mov ax, 4c00h ; exit to operating system.
  134.     int 21h    
  135. ends
  136.  
  137. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment