Re: lab help




Matthias wrote:
hey guys and gals,

i have been browsing around for a while. and i got stuck on this one
lab question. 'count from 0-50BCD, display the equivalent numbers in
hex on the monitor, and output the values in decimal to a 7-segment
display (using the parallel port)'. I was working on it on the
weekend, i got this far.

.model tiny
.486
.stack
.data
.code
.startup
mov ax, 0; clears the register

To clear the register, it is best to use XOR instead of mov. Much
faster than a mov instruction:

xor ax, ax

next: NOP

NOP is probably useless here, you can drop it.

inc al;starts the count
mov bx, 2000
mov [bx], al
mov [bx+1], ah
call displaymon; at 150, for personal reference
call output; at 160, for personal reference
call delay; at 170, for personal reference
cmp al, 0AH; compares to 10
jnz next; does the loop again, if less than 10
jz add2reg2; adds one to another register, and resets this one back to
0
cmp ah, 5; compares reg2 to 5
jnz next
;jz clear; this part is commented out so that i can see if the rest
was working

add2reg2: add ah, 1
mov al, 0
jmp next

;clear: mov ax, 0; this part is commented out so that i can see if the
rest was working
; jmp next; this part is commented out so that i can see if the rest
was working
.exit

' a friend of mine said that the procedure displaymon, can be done a
lot, simpler. what mine right now does is... well i am not quite sure
anymore.

If you're not sure, you should start from scratch with what you
understand :). I know it's tough to let go but starting afresh will
help you alot.

but i was told there is an easier way to convert numbers to
hex (from the standard main count of bcd) and display them.

BCD numbers are already coded in hex. A basic way to resolve your
project would be to keep 2 counts instead of 1 with a convertion from a
HEX count to BCD. The 2 counts idea involves keeping a HEX count like
you are doing and a BCD count. You basically wouldnt need to worry
about anything when displaying neither of them since you would have
your hex count kept in sync with your BCD count. You just output each
BCD or HEX nibbles directly. The problem with BCD is counting.

The idea is if you reach 9 on your low nibble and you're about to
increment, you reset your lowest nibble to 0 and you increment the high
nibble by 1.

When counting, your nibbles can't go over 9.

The logic goes like this for BCD:

0h, 1h, 2h, 3h, 4h, 5h, 6h, 7h, 8h, 9h, 10h, 11h, etc.

You count as you would normally in decimal notation. The hick is that
if you increment a count on an hexadecimal number, you'll bust the
number 9 limit which would result in this

0h, 1h, 2h, 3h, 4h, 5h, 6h, 7h, 8h, 9h, Ah, Bh, etc.

Just concentrate on implementing both counts and your lab will be a
breeze :).

I strongly suggest you start from scratch to build a solid
understanding based on the new idea of using 2 counts that you keep in
sync, one in BCD and the other in HEX. Does your work statement say
anywhere that you have to convert your hex count to BCD? If it doesn't,
the double count idea will be more straighforward to implement than the
conversion from hex to BCD (It will probably be faster too at the
expense of using 8 more bits to store the second count).

[SNIP]

Regards
Jean-Francois Michaud

.



Relevant Pages

  • Re: Hex Display Subcircuit
    ... LED display that I'm using is high efficiency -- it runs 16mcd@10mA -- so ... using a 16-key keypad. ... (This circuit started out using a 16F872, ... Unfortunately, I need a *hex* display, and none of these ...
    (sci.electronics.design)
  • Re: cant get ce to run with a flat panel display.
    ... Currently I have the display outputting to the VGA but I ... I see the following registry settings relating to the LCD. ... Hex - 0 ... be one that enables CRT, LCD or both LCD and CRT. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Get Statement Not Retrieving Record Correctly
    ... ascii file. ... missing "2" and the record seems to display as a character longer than ... Viewing the data file in a Hex editor for the values in question "1/2" ...
    (microsoft.public.vb.general.discussion)
  • Re: Cox of timing problem?
    ... I've encountered problem in developing a simple BCD number display. ... is the coding for my 7-segment decoder module. ... module seg7 (clock, bcd, number_segments); ...
    (comp.lang.verilog)
  • Hex Pair counting
    ... All the messages send and recieved are displyed in Hex. ... Each line should display 16 hex pairs with their starting and end ... place in Array of UDT. ... Dim thisStartIndex As Integer ...
    (microsoft.public.vb.general.discussion)