# I need help about Assembler

Status
Not open for further replies.

#### user0123

##### Newbie level 4
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

ldx #str3
ldab #40
jsr lcd_line1
stab Oldkey
ldaa Oldkey
cmpa #$05 bne adj21 staa value1 adda #$30
stab Oldkey
ldaa Oldkey
cmpa #$09 bne adj22 staa value2 adda #$30
rts

staa str4
jsr show_strings1
rts

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
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
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
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

#### user0123

##### Newbie level 4
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.