Advertisement
Jugurtha_Hadjar

TEC 586 - TP 7 - Partie 3

Apr 25th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;                   Jugurtha Hadjar & Raouf Moualdi
  2.  
  3. ;             Vérification de nombres dans une table dans la RAM
  4. ;                et mise à zéro des éléments négatifs
  5. ;                           TP 7 - Partie 3
  6. ;               Compilateur A86 & Utilisation de Debug
  7.  
  8.  
  9.                        
  10. DATA_SEG SEGMENT
  11.  
  12.         org 2000h
  13.            
  14.         TABLE  dw 0FFh,0FAh,0A0h,0AAh,0EEh,067h,089h,0DEh,0DDh,0CFh,000h,0EFh,044h,011h,00Ch,099h
  15.                  
  16.         NBR_ELEMENTS equ 16 ; Number of elements to check.
  17.  
  18. DATA_SEG ENDS
  19.  
  20.  
  21. assume DS:DATA_SEG, CS:CODE
  22.  
  23.  
  24.  
  25.  
  26. CODE SEGMENT
  27.  
  28. org 4000h
  29.  
  30. main:
  31.        
  32.         mov ax, DATA_SEG      ; Initialize Data Segment
  33.         mov ds, ax
  34.  
  35.         mov si, offset TABLE  
  36.         mov cx, NBR_ELEMENTS  ; Initialize the counter, CX
  37.                               ;
  38.  
  39. lookup_loop:    
  40.        
  41.  
  42.         mov  ah , byte ptr[SI]
  43.         rol  ax , 1
  44.         jnc  landing_zone    ; If the number is positive, skip the call
  45.                              ; to the zeroing procedure.
  46.  
  47.         call replace_negative_element
  48.      
  49. landing_zone:
  50.  
  51.         add  si, 2           ; Go to the next Word (two bytes) in the table
  52.         loop lookup_loop
  53.  
  54.         jmp exit             ; Go to program exit
  55.  
  56.  
  57.  
  58. replace_negative_element proc near  ; Procedure replacing the negative element by 0.
  59.  
  60.        
  61.         mov byte ptr [SI], 00h
  62.         ret
  63.  
  64. replace_negative_element endp
  65.  
  66.  
  67. exit:
  68.  
  69. mov ah, 4Ch          ; Exit routine
  70. int 21h
  71.  
  72.  
  73. end main
  74.  
  75. code ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement