DMG

Najmanji zajednicki sadrzalac (dvocifreni brojevi)

DMG
Mar 8th, 2012
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; multi-segment executable file template.
  2.  
  3. data segment
  4.     b1 db 9
  5.     b2 db 3
  6.     nzs db ?
  7.     pkey db "press any key...$"
  8. ends
  9.  
  10. stack segment
  11.     dw   128  dup(0)
  12. ends
  13.  
  14. code segment
  15. start:
  16. ; set segment registers:
  17.     mov ax, data
  18.     mov ds, ax
  19.     mov es, ax
  20.  
  21.     mov al, b1
  22.     mov bl, b2
  23.     mul bl
  24.     mov dx, ax
  25.    
  26.     mov bx, 1
  27.    
  28.     petlja:
  29.     cmp bx, dx
  30.     jl racunaj
  31.     jmp kraj
  32.    
  33.     racunaj:
  34.     mov ch, b1
  35.     mov dh, b2
  36.    
  37.     mov ax, bx
  38.     div ch
  39.     mov cl, ah
  40.    
  41.     mov ax, bx
  42.     div dh
  43.     mov dl, ah
  44.    
  45.     cmp cl, dl
  46.     je dali0
  47.     jmp uvecaj
  48.    
  49.     dali0:
  50.     cmp cl, 0
  51.     je jeste
  52.     jmp uvecaj
  53.    
  54.     uvecaj:
  55.     add bx, 1
  56.     jmp petlja
  57.    
  58.     jeste:
  59.     mov dx, bx
  60.     jmp kraj
  61.    
  62.     kraj:
  63.     mov ax, dx
  64.     mov bl, 10
  65.     div bl
  66.     mov bl, ah
  67.     mov dl, al
  68.     add dl, 48
  69.     mov ah, 2
  70.     int 21h
  71.    
  72.     mov dl, bl
  73.     add dl, 48
  74.     int 21h
  75.  
  76.            
  77.     lea dx, pkey
  78.     mov ah, 9
  79.     int 21h        ; output string at ds:dx
  80.    
  81.     ; wait for any key....    
  82.     mov ah, 1
  83.     int 21h
  84.    
  85.     mov ax, 4c00h ; exit to operating system.
  86.     int 21h    
  87. ends
  88.  
  89. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment