Thursday 6 September 2012

10 MARKS CHALLENGE NO.1

Anyone who gives the correct answer first will get 10 marks in lab03....

Question: In the following program, what should be the value of COUNT so that the instructions in LOOP execute maximum no. of times.


      ORG 0H  
      COUNT EQU 0X20  
      PORTB EQU 0X06  
      TRISB EQU 0X86  
      STATUS EQU 0X03  
      BSF STATUS,5  
      MOVLW B'0'  
      MOVWF TRISB  
      BCF STATUS,5  
 ;/***************************************/  
      MOVLW D'???'  
      MOVWF COUNT  
 LOOP  
      MOVLW B'0'  
      MOVWF PORTB  
      MOVLW B'1'  
      MOVWF PORTB  
      DECFSZ COUNT  
      GOTO LOOP  
 ;/**************************************/  
 HERE GOTO HERE  
 END  

In ur answer please give the value of COUNT for maximum iterations, and also state the reason why u think that a particular value will result in max iterations of the loop. Also post ur name and student id in the comments along with ur answer.




19 comments:

  1. D'255' is the value in which the loop execute Maximum times Because we have 0x20 is 8 bit register and because of this maximum 255 iterations are possible.
    Name :Faizan Faisal Wali
    SID:5422
    CID:14308

    ReplyDelete
    Replies
    1. tum wohi ho jis se kal main gate pe mulaquaat hoi thi??? i'm terrible at remembering names...

      Delete
    2. Is my answer correct or not ???
      Plz Tell sir if my answer is incorrect.
      I'll try again :)
      But in My opinion this is probably the correct answer...

      Delete
    3. DEAD LINE for submitting the correct answer is 9th Sep (sunday) 10pm.
      Before that i wont disclose the correct answer.


      @Faizan
      agar tmhara answer ghalat hoa to next lab me ZERO du ga tmhe...

      Delete
    4. Sir Now I am 63H% Sure That my answer is correct!!
      :):D

      Delete
    5. I think both your answer and reason are right:) confirmed with datasheet

      Delete
    6. Assalam o alaikum sir i think the maximum value of count should be 255 as in the above program every single count will execute instructions in loop for one time so if we want instructions of loop to be executed for maximum no. of time then the value of 8-bit count register should be maximum i.e. 255(FFH)..........
      Name:Madiha Razzaq
      ID:5682
      CID:14308

      Delete
  2. 8 bit register gives 2^8=256 or from 0 to 255 so D'255' should be the maximum value for maximum number of loops to be executed.
    SAAD RABBANI (5680)
    CID:14308

    ReplyDelete
  3. Since everyone else is doing it too:

    The value of COUNT will be 255 (D'255') because the general purpose register 0x20 is an eight bit register which can hold up to 255.
    The datasheet also states that the MOVLW instruction uses literal values (0-255).

    Muhammad Ammar Hassan (5501)
    CID: 14308

    ReplyDelete
    Replies
    1. The answer might actually be 00H instead because in a register it corresponds to 256. 00H will decrement to FFH.

      Delete
  4. the count will be executed to 255 times starting with 0. the gpr can handle values uptill 8 bit
    Name: Asad Jabbar
    Sid: 5459
    cid: 14308

    ReplyDelete
  5. 0xFF should be the value of COUNT in order to get maximum iterations.. because the COUNT register is a 8-bit register so it can store 256 values. i.e 0-255
    255=FFh

    SAJID BALOCH(5448)
    14308

    ReplyDelete
  6. 5434- HAFIZ DANYAL HUSSAIN
    C.ID: 14308

    255 must be the maximum value because of the 8-bit register having 256 possible values to store. that is 0-255 so the maximum value of COUNT must be 255.

    ReplyDelete
  7. The maximum value for count will be 255 because of 8 bit register.
    S.Imbisat Hussain(5542)
    CID: 14308

    ReplyDelete
  8. Note: The "first" one to give the CORRECT answer would be awarded marks so if u have an answer other than FFh (0-255) then please try otherwise , enjoy

    ReplyDelete