Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IDEAL
  2. MODEL small
  3. STACK 100h
  4. org 100h                ; code starts at offset 100h   
  5. DATASEG
  6.  
  7.  
  8. Clock equ es:6Ch    ;Memory location of timer
  9. ran db 0 ;האיחסון של המספר הרנדומלי
  10. user_choice db 0 ;המספר הרנדומלי שהמשתמש בחר
  11. computerscore db 0 ; ניקוד המחשב
  12. userscore db 0  ;ניקוד המשתמש
  13. userw db 'you win$'
  14. computerw db 'you lost$'
  15.  
  16. CODESEG
  17.  
  18. MACRO Random_Generator maxval
  19.     mov ax,40h
  20.     mov es,ax
  21.     mov ax,[Clock]
  22.     mov ah,[byte cs:bx]
  23.     xor al,ah
  24.     xor ah,ah
  25.     and al,maxval
  26. endm Random_Generator
  27. start:
  28.     mov ax, @data
  29.     mov ds, ax
  30.     Random_Generator 9
  31.     mov [ran],al
  32.     mov ah,1
  33.     int 21h
  34.     sub al,30h
  35.     ;mov [user_choice],al
  36.     mov ah,[ran]
  37.     cmp ah,al
  38.     jne computerpoint
  39.     inc [userscore]
  40.     mov dl,'*'
  41.     mov ah,2
  42.     int 21h
  43.     cmp [userscore],1
  44.     jb start
  45.     je userwin
  46.     computerpoint:
  47.     inc [computerscore]
  48.     cmp [computerscore],1
  49.     jb start
  50.     je computerwin
  51.     userwin:
  52.     MOV dl, 10
  53.     MOV ah, 02h
  54.     INT 21h
  55.     MOV dl, 13
  56.     MOV ah, 02h
  57.     INT 21h
  58.     mov dx, offset userw
  59.     mov  ah, 9
  60.     int  21h   ;problem
  61.     computerwin:
  62.     MOV dl, 10
  63.     MOV ah, 02h
  64.     INT 21h
  65.     MOV dl, 13
  66.     MOV ah, 02h
  67.     INT 21h
  68.     mov dx,offset computerw
  69.     mov  ah, 9
  70.     int  21h ;problem
  71. exit:
  72. mov ax, 4c00h
  73. int 21h
  74. END start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement