0
나는 arduino 보드와 함께 일하고 있습니다. 프로그래밍 arduino (avr 어셈블리)
volatile int input1[20]={1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,4};
volatile int input2[20]={1,2,8,9,6,2,0,3,4,5,6,7,0,0,0,2,2,3,3,0};
volatile int temp[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
volatile int output[40]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
// // put your main code here, to run repeatedly:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
asm(
"statrt:;"
"ldi YL, low(input1[0]) ; " //load address of Data
"ldi YH, high(input1[0]) ; "
"ldi ZL, low(input2[0]) ; " //load address of Data
"ldi ZH, high(input2[0]) ;"
"CompareLoop:;"
"lpm r0 , Z+;"
"lpm r1 , Y+;"
"cp r1,r0;"
"brlt Change;"
"cpi Z,20;"
"breq SubLoop;"
"brne CompareLoop;"
"Change:"
"lds XL, low(temp[0]) ;" //load address of Data
"lds XH, high(temp[0]) ;"
"MoveToTempLoop:"
"lpm r3,Z+;"
"st temp+,r3;"
"cpi Z,20;"
"brne MoveToTempLoop;"
"MoveToInput1Loop:"
"lpm r3,Y+;"
"st Z+,r3;"
"cpi Z,20;"
"brne MoveToInput1Loop;"
"MoveToInput2Loop:"
"lpm r3,temp+;"
"st Y+,r3;"
"cpi Y,20;"
"brne MoveToInput2Loop;"
"statrt:;"
"add r3,r3;"
"lds XL, low(output[39]) ;" //load address of Data
"lds XH, high(output[39]) ;"
"lds YL, low(input1[19]) ;" //load address of Data
"lds YH, high(input1[19]) ;"
"lds ZL, low(input2[19]) ;" //load address of Data
"lds ZH, high(input2[19]) ;"
"SubLoop:"
"clr r2;"
"lpm r0 , Z-;"
"lpm r1 , Y-;"
"cp r1,r0;" //check kon moghe r1-r0 r1 koochiktar nabashe
"brge Label;"
"lpm r2,Z;"
"subi r2,1;"
"add r1,10;"
"st Z,r2;"
"Label:"
"sub r1,r0;"
"st X-,r1;"
"cpi ZL, -1 ;" //if i >-1 then
"brne SubLoop ;" // do it again
);
int i=0;
for (i=0; i<40;i++){
Serial.println(output[i]);
}
}
실제로 내가 20 자리 숫자이 큰 번호가 나는 INPUT1-입력 2 갖고 싶어 : 나는 C 코딩 해요하지만 난 인라인 assembly.i이 코드를 사용하고 싶습니다. 하지만 대답은 항상 0입니다 :(이는 ASM 부분을 실행하지 솔기 ...
휘발성 데이터가 프로그램 메모리에 있습니까? 또한 디버거를 사용하여 코드를 단계별로 실행하고 어디에서 잘못되었는지 확인하십시오. – Jester
실제로 나는 lpm이하는 일을 실제로 모른다. 그리고 나는 프로그램 메모리에 무엇이 있는지 모른다. 실제로 나는 arduino 및 avr 코딩을 사용하여 초보자입니다 ... –
그리고 귀하의 질문은 무엇입니까? input1-input2를 생성하는 어셈블리를 작성하는 방법은 무엇입니까? 음, 먼저 어셈블리에서 프로그래밍하는 법을 배워야합니다. 몇 주간의 학습과 연습을 마치고 돌아와이 작업을 수행하십시오. – Ped7g