Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What language is this

Status
Not open for further replies.

Airskout

Member
Hello people of electro tech online. I present you this bit of code. I need to know what language is this so i learn it , see this code was written from my brother who has passed away and I need to modify it for the family business .Any help would be apreciated . e.g I am not much of a programmer worked pascal c# and VB.
meiwntriamh2:
in inputabcd,pinb
andi inputabcd,0b00001111 ;ksefortwnomai ta bit twn eisodwn up/down
ldi r16,15
sbc r16,inputabcd
ldi zh,high(2*dispmehmi)
ldi zl,low(2*dispmehmi)
add zl,r16
lpm
out portd,r0
rjmp getinput
 
I thought it was assembly as well but not all of the commands in my program can be found in assembly command lists :/
 
It is assembler but I can't tell you what processor it is for. I can guess what some of the instructions do.

meiwntriamh2: This will be a symbolic location in the code. (It will translate to a physical address in memory.)

in inputabcd,pinb This will input from an I/O port. inputabcd will be a symbolic memory or register address where the data from the I/O port is copied to.

ldi zh,high(2*dispmehmi) Load the high 8 bits of twice the value of dispmehmi to the top 8 bits of 16 bit register Z

ldi zl,low(2*dispmehmi) Same as above but for the the lower 8 bits

add zl,r16 Add zl to register r16 (zl may be a symbolic memory location

lpm I don't know what this will be. (You would need to know what processor the code was written for.

out portd,r0 Copy the contents of register r0 to I/O port d

rjmp getinput Relative jump to a symbolic location in program memory. (From the name "getinput" it is probable the start of some code to get some kind of input from a keyboard.

Another membr of the forum might recognize the instruction set and be able to tell you what processor it is for.

Les.
 
As you don't have any experieince in assembler, to the extent you can't even recognise what processor it is, you might be better off rewriting the entire application in C++ on an Arduino, as you already have high level language experience. Learning assembler from scratch to try and modify someone elses existing code is going to be a long and difficult process.
 
As you don't have any experieince in assembler, to the extent you can't even recognise what processor it is, you might be better off rewriting the entire application in C++ on an Arduino, as you already have high level language experience. Learning assembler from scratch to try and modify someone elses existing code is going to be a long and difficult process.
I know it's hard to learn from scratch and especially on someone's code but i dont have such options since these go on an Atmega8 16U and the whole pcb is sold . any way for me to write the code in a familiar language and revert it to assembly? I can see it's really different to other languages
 
It is assembler but I can't tell you what processor it is for. I can guess what some of the instructions do.

meiwntriamh2: This will be a symbolic location in the code. (It will translate to a physical address in memory.)

in inputabcd,pinb This will input from an I/O port. inputabcd will be a symbolic memory or register address where the data from the I/O port is copied to.

ldi zh,high(2*dispmehmi) Load the high 8 bits of twice the value of dispmehmi to the top 8 bits of 16 bit register Z

ldi zl,low(2*dispmehmi) Same as above but for the the lower 8 bits

add zl,r16 Add zl to register r16 (zl may be a symbolic memory location

lpm I don't know what this will be. (You would need to know what processor the code was written for.

out portd,r0 Copy the contents of register r0 to I/O port d

rjmp getinput Relative jump to a symbolic location in program memory. (From the name "getinput" it is probable the start of some code to get some kind of input from a keyboard.

Another membr of the forum might recognize the instruction set and be able to tell you what processor it is for.

Les.
The program is loaded in an Atmega8 16U if this helps in any way . The board has 8inputs +.-.A.B.C.D,↑↓
and is used in elevators with a display witch is mounted on it , it shows -3to9 with a half floor +- are standar and the other inputs go with the program to the display
 
I know it's hard to learn from scratch and especially on someone's code but i dont have such options since these go on an Atmega8 16U and the whole pcb is sold . any way for me to write the code in a familiar language and revert it to assembly? I can see it's really different to other languages

Yes, that's exactly what a compiler does - it takes a high level language are converts it to assembler.
 
So can i write a normal script in c# for example and compile it to work for assembly? how does the bit/bit allocation ,high ,low , get transferred cause i can have an A input and write if a true ,power those segments or smth?
 
So can i write a normal script in c# for example and compile it to work for assembly? how does the bit/bit allocation ,high ,low , get transferred cause i can have an A input and write if a true ,power those segments or smth?
Not really.... Arduino uses C++ I very much doubt you'll find a C# compiler You may find a Pascal compier, but support will be turd..

Have you any C or C++ experience... If not, use AVR basic.. It's the easiest, but very different to VB..
 
All the instructions in your sample of code match the ATmega8 instruction set in the data sheet. The fact that you have the source listing makes it easier than if you had disassembled the .hex file by reading the the code in the ATmega8. You can assign meaningful names to memory location or I/o port pins.
For example the line " in inputabcd,pinb " inputabcd could be a meaningful name given to a register at the beginning of the program. And pinb would be a meaningful name you had given to portc. In line ldi zh,high(2*dispmehmi) dispmehmi is likely to be a 16 bit variable that has something to do with the display.
You don't say what you are trying to do. are you trying to write new code from scratch or modify the existing code to make it behave differently ?
Although Nigel says it is easier to understand high level languages than assembler I find it the other way round. There is no complex syntax to learn and all the information is in the datasheet for the device.

Les.
 
So basically atm i dont understand any of the code.I run two codes on and i use different boards i want to make it run either for example write a big if at the start and envelope all of it copy the other code and put is as an or else i could make it run both
 
There are people on this forum capable of disassembling all of your brothers code... The part you show is only a miniscule of the complete code..

The Atmel mega has 2k of memory and that snippet would be a few bytes... Do you have the hex file from the chip?
 
Yeah i have the hex file this comes from an asm file which i opened with atmel studio i will attach the files in 1 sec
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top