Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Express the following, base 2 number, in decimal (base 10) format. 01011011 (

ID: 3549778 • Letter: 1

Question

1.   Express the following, base 2 number, in decimal (base 10) format.

            01011011 ( base 2 ) =

2.  Express the following, decimal number (base 10), in binary (base 2)

         

3.  Comment the function associated with every line of the following PICBASIC program:

'

'                        START OF MAIN LOOP

'

led_rb0 = 0

led_rb1 = 0

led_rb2 = 0

led_rb3 = 0

x2=1     

main_loop:

IF x2 > 20 THEN

   x2=1

ENDif

IF x2> 10 and x2 <15 THEN

   led_rb1 = 1

ELSE

   led_rb1 = 0

ENDIF

x2=x2+1

pause 100

    goto main_loop

Explanation / Answer

1)

01011011 = 1+2+8+16+64 = 91


2)

197 = 11000101


3)

'

' START OF MAIN LOOP

'

'led_rb0 = 0

'led_rb1 = 0

'led_rb2 = 0

'led_rb3 = 0

'x2=1

'main_loop:

'IF x2 > 20 THEN

'x2=1

'ENDif

'IF x2> 10 and x2 <15 THEN

'led_rb1 = 1

'ELSE

'led_rb1 = 0

'ENDIF

'x2=x2+1

'pause 100

'goto main_loop