Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

I need help about Assembler

Status
Not open for further replies.

user0123

Newbie level 4
Joined
May 30, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
I'm adjusting RTC with keypad. Show the press key on the LCD.

Example: I compare if the press key is $5 - if it's pressed I write it to variable and show on the LCD. After that I compare if another key is pressed, write its value in second variable and show it on the next position on the LCD.

I don't know how to do the following thing: I have the value $5 in one variable and $9 in other variable. I have to write in the RTC $59. How to do this?

After the call of "keypad_wytec": if a key is down, the carry bit =1 and the accumulator B holds the key number, if no key is down the carry bit =0


adjustment:
jsr lcd_ini_blink
ldx #str3
ldab #40
jsr lcd_line1
adj21: jsr keypad_wytec
stab Oldkey
ldaa Oldkey
cmpa #$05
bne adj21
staa value1
adda #$30
jsr adj1
adj22: jsr keypad_wytec
stab Oldkey
ldaa Oldkey
cmpa #$09
bne adj22
staa value2
adda #$30
jsr adj2
rts

adj1:
staa str4
jsr show_strings1
rts

adj2:
staa str4+1
jsr show_strings1
rts

str4 fcc ' '

show_strings1:
pshx
ldx #str4
ldab #2
jsr lcd_line2
pulx
rts


This code is only for test if everything is working.


P.S. The microcontroller is MC68HC11
 

arthur0

Full Member level 2
Joined
Nov 28, 2003
Messages
131
Helped
49
Reputation
98
Reaction score
36
Trophy points
1,308
Location
Stockholm, Sweden
Activity points
1,218
Mathematically you have to do
RTC = value1*16 + value2
Programmatically you can do
value1 = value1 <SHIFT_LEFT> 4
value1 = value1 <BITWISE_OR> value2
RTC = value1
Just replace the ITALICS above with the mnemonics that best suit your needs (ASL/LSL).

Arthur
 

user0123

Newbie level 4
Joined
May 30, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
No.

I don't think you are right.

Value1 = 5

Value2 = 9

I must write 59, but not 5+9=14

P.S. I don't have BITWISE_OR operation in the command set.
 

arthur0

Full Member level 2
Joined
Nov 28, 2003
Messages
131
Helped
49
Reputation
98
Reaction score
36
Trophy points
1,308
Location
Stockholm, Sweden
Activity points
1,218
Well, that’s not what I said, just read my post again!
But let me explain this again with your words:
So you wanted to get $59 (or 89 in hexadecimal representation, which the ‘$’ sign stands for) having a value1 = $5 and a value2 = $9, right?

In my post above I wrote:

value1*16 + value2, which give 5*16 + 2 = 89, or $59.

For the sake of optimization, the same result you get by shifting $5 left 4 bit positions (gives 80 = $50), then OR-ing (ORAA/ORAB, same as adding in this case, but probably faster than ADDA) the result with $9 (giving 80+9=89, or $59).

Are we in tune now?
Arthur
 

    user0123

    points: 2
    Helpful Answer Positive Rating

user0123

Newbie level 4
Joined
May 30, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,331
Thank you very much.

It's working.

This is the last thing which I had to done, but it's now complete and I can finish my project.

Again THANK YOU VERY MUCH.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top