6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 12, 2024 6:46 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Mar 12, 2003 1:58 am 
Offline

Joined: Wed Feb 05, 2003 11:14 pm
Posts: 3
Hi every 1
I'm from UK doing an HNC Computing course (via distance learning...ie limited tutorial support)
I've been given a copy of the TASM user manual, and need to complete the following task:
I am a novice and done no programming at all so after reding this, given that i've only been given this manual, i hope somebody can help.
This is my penultimate exercise.


Assessment Details



1. Design a program to meet the attached specification. This design must conform to the appropriate Organisational Requirements, and so should be block-structured and developed using a process of stepwise refinement. All levels of the refinement and any rough work should be submitted.
2. Implement the design by writing, testing and debugging an assembly language program for the 6502 processor. This program must :

4(b)q
· Accurately reflect the design produced above and meet the specification;

4(c)q
· Conform to Organisational Requirements for layout, content and style;

4(d)q
· Correctly and efficiently use syntax, addressing modes and constructs;

4(e)q
· Work! It must be tested and debugged effectively using the appropriate software, with Test Log sheets completed to show at least the following :
The execution of the get_7segcode function for one legal input value and one out-of-range input value.


Specification

This program will form part of the display driver for a portable metal detector. A sensor indicates the strength of the magnetic field used to detect metallic objects by an analogue voltage level which is fed into an ADC. This converts the input signal into a 7-bit value in the range 0..7910. Any reading higher than 7910 indicates that the sensor needs to be recalibrated by the user. The ADC signals that it has completed conversion and has a valid value ready for reading by setting Bit 7 of its capture register to 1. Whenever software reads the register, this bit is automatically reset to 0. While this bit remains 0, the ADC result is not yet valid.
Your task is to construct a program which monitors the ADC, detects when a conversion is complete, reads the value and scales it down by a factor of 8 for output as a single digit between 0 and 9 on a seven-segment LED mounted on the handset. (i.e. Divide the reading by 8 and ignore any remainder.) Any out-of-range input from the sensor should result in the character “C” being displayed to indicate to the user that manual calibration is required.
The ADC capture register is at address $C000.
The 8-segment LED output latch is at address $C010, and is wired as shown in the following table :
Bit 7 6 5 4 3 2 1 0
Segment N/C g f e d c b a

The LED segments are labelled in the conventional manner, i.e.






Implementation Requirements
The program should be located at address $2000, with any data required placed after the program code. You may not use any address within Page 0, but you may freely initialise and use the stack as required. The program must not terminate at any point, but must loop continually to read and display sensor readings.
You must implement and use a macro called m_div8 to scale the reading down by a factor of 8.
You must implement and use a function subroutine called get_7segcode, which has the following interface :
ENTRY: A = Reading from ADC, previously divided by eight.
EXIT : A = 7-segment bit pattern for display, or pattern to display the character “C” if the input value was greater than 9.
You must use indexed addressing mode appropriately at least once in your program.

END OF SPECIFICATION

if ne 1 can help please respond

many thanx in advance

Neil :?: :?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Mar 12, 2003 4:56 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8433
Location: Southern California
It looks pretty straight forward, except you'll need to clarify a couple of things.

#1 You mention a 7-bit value between 0 and 7910. Since 7-bit numbers can only get you up to 127, I first thought you meant that each count of the 7-bit number would correspond to 7910/127. Later however, you say you want to divide by 8 to get it into the range of 0-9. Should that first one be 79, instead of 7910?

#2 What is charcter “C&#8221? I don't know what it's showing up like on your screen, but I'm seeing 14 digits, letters, and characters here.

Garth


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Mar 12, 2003 11:57 am 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 298
Is the '7910' written 79 with a subscript 10? That would be 79 base 10. That makes sense.

I'll give hints rather than code.

Your program needs to loop, reading the ADC output until bit 7 is set. The ADC output will be mapped to a memory location somewhere. Which instruction would you use to read it? The loop will involve a branch instruction. Which branch would be suitable? Look at the flags that they test, and the flags that are changed by the load instruction. You should be able to do this loop with only two instructions.

Once you have bit 7 set, you need to display the value. The value you read has bit 7 still set, so you'll have to clear it before proceeding.

Then you want to divide by 8. Division is usually a pain on the 6502, but 8 is a special number. Write down a bunch of binary numbers, and divide them by 2. Do you notice anything unusual about the results? Can you find an instruction that will do the same thing? Dividing by 8 is just dividing by 2 three times.

Next is the display. There's no simple relationship between binary numbers and 7-segment display codes. Since there are so few possibilities (you started with 128, then divided by 8, so there are only 16), the easiest way to do it is with a look-up table. To get the code you want, you add the ADC result (divided by 8) to the address of the first entry in the table, then read from that location. This is a very common sort of operation, so the designers of the processor have provided an easy way of doing it. Have a look at what indexed addressing does.

Hopefully that's enough to get you started (without being enough for anyone to accuse you of cheating :-)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: