Docsity

4 Problems in Electronics - Assignment 9 | PHY 116B, Assignments of Basic Electronics

Toggle sidebar
bg1
Physics 116B Winter 2005: Problem Set 9
1. Write a MAS program as follows based on the example in the M68000 programming notes.
(a) Start with an array of 40 ASCII characters in the array msg (use the dc.b directive to
set up the 40 character array rather than reading it from the keyboard). The idea is to
form a sum of any characters that can be interpreted as hex digits. Thus A-F (or a-f)
are also considered numbers.
(b) Recognize the characters with a subroutine (name it cnvhx). When you call the sub-
routine, the character to be tested should be in the register d0. On return from the
subroutine, d0 should contain the numerical value of the character for a valid hex char-
acter (range 0-15) or 0 if the character is not a valid hex character.
(c) The main program will step through the msg array, call the subroutine for each character
and total the sum.
(d) At the end of the main program, display the sum on the screen.
A table of ASCII characters is included below (example: ‘A’ = $41):
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download 4 Problems in Electronics - Assignment 9 | PHY 116B and more Assignments Basic Electronics in PDF only on Docsity!

Physics 116B Winter 2005: Problem Set 9

1. Write a MAS program as follows based on the example in the M68000 programming notes.

(a) Start with an array of 40 ASCII characters in the array msg (use the dc.b directive to

set up the 40 character array rather than reading it from the keyboard). The idea is to

form a sum of any characters that can be interpreted as hex digits. Thus A-F (or a-f)

are also considered numbers.

(b) Recognize the characters with a subroutine (name it cnvhx). When you call the sub-

routine, the character to be tested should be in the register d0. On return from the

subroutine, d0 should contain the numerical value of the character for a valid hex char-

acter (range 0-15) or 0 if the character is not a valid hex character.

(c) The main program will step through the msg array, call the subroutine for each character

and total the sum.

(d) At the end of the main program, display the sum on the screen.

A table of ASCII characters is included below (example: ‘A’ = $41):

2. Consider the attached M68000 MAS program. The lines are numbered in the left column.

(a) Does line 6 translate directly into M68000 assembly language (like line 10, for exam-

ple)? If not, why is it there?

(b) The M68000 has many addressing modes. What mode of addressing is used for the

destination address in the move.b instruction in line 32?

i. Explain how this mode of addressing works to achieve the desired result of enter-

ing successive characters into memory.

ii. Is there any reason not to use register A5 for this purpose throughout this Mac

program instead of A1? Explain what A5 is used for. Would the instruction in line

37 use A5 in some manner?

(c) What kind of addressing is used for the source address in line 38? Where does this

information (the number 37) reside prior to the execution of the instruction (i.e., in the

data area, one of the registers or in the program area)? explain briefly.

(d) Explain how the instruction on line 33 works to control the loop. Under what specific

circumstance will the instruction on line 37 be executed?

(e) Does any branch instruction perform a logic test which makes use of the Z bit in the

condition code register? If so, which one(s)? (Hint: see Table 3-19 in the M

writeup).

(f) Is the run-time stack used by this program? If so, how or why? At any time, how is the

last occupied memory location in the stack indicated?

(g) Modify the program so it changes lower case letters to upper instead of vice versa. Just

list the lines which you change. (An ASCII chart is given in Prob. 1.)

(h) Modify the program to store the original characters in msg and the message with possi-

bly changed characters in a new array called newmsg. You will have to add some lines.

Indicate what they are and where they go (i.e., “insert xxx after line yy” etc.).

Prog_Prob_SolnEx.a Page 2 of 2 Printed: Wednesday, March 9, 2005 7:24:49 PM

58 ; If it is an upper case letter, changes it to lower case 59 ; Lower case letter or number is returned in d 60 61 addch: and.b #$7F,d0 ; mask off parity bit of character 62 cmp.b #$30,d0 ; see if it is less than $ 63 blt skip ; if so, skip 64 cmp.b #$39,d0 ; see if it is greater than $ 65 bgt skip ; if so, skip 66 move.w d0,d3 ; is a number - put in d3 (don't change d0) 67 and.w #$000F,d3 ; get the number by masking off upper bits 68 add.w d3,d2 ; add to sum in d 69 rts ; return from subroutine 70 skip: cmp.b #$41,d0 ; see if it is less than $41 (A) 71 blt skip1 ; if so, skip 72 cmp.b #$5A,d0 ; see if it is greater than $5A (Z) 73 bgt skip1 ; if so, skip 74 add.w #$20,d0 ; upper case letter - convert to lower 75 skip1: rts 76 77 data 78 msg1: dc.b 'Enter the number of characters to read (100 max): ' 79 msg2: dc.b 'Your entry was too big. Enter 100 characters: ' 80 msg3: dc.b 'Now enter the characters: ' 81 msg4: dc.b 'Here is the string (all lower case): ' 82 msg5: dc.b 'The sum of numbers entered is: ' 83 msg: ds.b 100 ; set aside 100 bytes of storage 84 nchar: dc.w 20 ; number of characters to read 85 even 86 end

3. Diagrams below from Horowitz and Hill show connections of an input register and an output

register to an M68008 microprocessor. Also shown is a write cycle timing diagram with

R/W , VALID ADDRESS (lumped together as usual), etc. Specifications for the 74HCT

octal D latch are attached.

(a) On the timing diagram, show the address decoder output, AD, and the OE signal on

the input register octal D latch when it is accessed with its valid address during a read

cycle. Also show the data bus signals from the register (D0-7 lumped together like

A0-19).

(b) Explain why the input register must have tri-state output lines.

 

        

    SCLS177E − MARCH 1984 − REVISED AUGUST 2003

2 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265

description/ordering information (continued)

OE does not affect the internal operations of the flip-flops. Old data can be retained or new data can be entered while the outputs are in the high-impedance state.

FUNCTION TABLE (each flip-flop) INPUTS (^) OUTPUT OE CLK D

OUTPUT Q L ↑ H H L ↑ L L L H or L X Q H X X Z

logic diagram (positive logic)

OE

CLK

1D

1Q

1

11

2

19

To Seven Other Channels

1D

C

absolute maximum ratings over operating free-air temperature range (unless otherwise noted)†

Supply voltage range, V (^) CC.......................................................... −0.5 V to 7 V Input clamp current, IIK (VI < 0 or VI > VCC ) (see Note 1).................................... ±20 mA Output clamp current, I (^) OK (VO < 0 or VO > VCC ) (see Note 1)................................ ±20 mA Continuous output current, IO (VO = 0 to VCC ).............................................. ±35 mA Continuous current through V (^) CC or GND.................................................. .±70 mA Package thermal impedance, θJA (see Note 2): DB package................................. 70 °C/W DW package................................. 58 °C/W N package................................... 69 °C/W NS package................................. 60 °C/W PW package................................. 83 °C/W Storage temperature range, Tstg.................................................. .−65°C to 150°C

† Stresses beyond those listed under “absolute maximum ratings” may cause permanent damage to the device. These are stress ratings only, and functional operation of the device at these or any other conditions beyond those indicated under “recommended operating conditions” is not implied. Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability. NOTES: 1. The input and output voltage ratings may be exceeded if the input and output current ratings are observed.

  1. The package thermal impedance is calculated in accordance with JESD 51-7.

4. A block diagram of a successive approximation ADC is shown above. Bit 1 is the least

significant bit of the output binary number. The voltage to be measured is vin.

(a) Consider a 3 bit ADC as an example (n=3 in the diagram above). What is the first

binary number sent to the DAC by the successive approximation control register?

i. If the comparator output is low, what 3 bit number is sent next?

ii. As a result, if the comparator output is now high, what number is sent next?

iii. Now the comparator output is low. What is the 3 bit ADC value for this input

voltage?

(b) What is the main advantage of this ADC over a simple counting (or counter-ramp)

ADC?

(c) Suppose the number of bits is 8 instead of 3. What advantage does a flash ADC have

over this design? What is the main disadvantage? Explain briefly.