C2ASM

C2ASM - EXIT STOP #$2700 END START Var_A = (int*) 0x0F00;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
C to ASM translation samples Result = (int*) 0x0F00; *Result = 0; for (i=1; i<100; i++) *Result += i; ORG $0F00 Result DC.L 0 ORG $1000 START MOVE.L #1, D0 CLR.L Result LOOP ADD.L D0, Result ADD.L #1, D0 CMP #100, D0 BNE LOOP STOP #$2700 END START Result = (int*) 0x0F00; *Result = 0; int i = 1; while (i<100) { *Result += i; i++; } ORG $0F00 Result DC.L 0 ORG $1000 START MOVE.L #1, D0 CLR.L Result LOOP CMP #100, D0 BEQ EXIT ADD.L D0, Result ADD.L #1, D0 BRA LOOP
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EXIT STOP #$2700 END START Var_A = (int*) 0x0F00; Var_B = (int*) 0x0F04; Abs = (int*) 0x0F08; *Var_A = 0x40; *Var_B = 0x20; if (*Var_A&lt;=*Var_B) *Abs = *Var_B *Var_A; else *Abs = *Var_A *Var_B; ORG $0F00 Var_A DC.L 0 Var_B DC.L 0 Abs DC.L 0 ORG $1000 START MOVE.L #$40, Var_A MOVE.L #$20, Var_B MOVE.L Var_A, D0 MOVE.L Var_B, D1 CMP.L D0, D1 BLE L0 SUB.L D0, D1 MOVE.L D1, Abs BRA EXIT L0 SUB.L D1, D0 MOVE.L D0, Abs EXIT STOP #$2700 END START...
View Full Document

Ask a homework question - tutors are online