Guten Abend, ich arbeite mit einem DS89C420(8051komp.) und dem Keil Demo Compiler. Für den Timer2 ist es möglich, über sfr16 Timer2 = 0xYY mit 16Bit Werten auf einmal zu rechnen. Also statt Low/HighByte einzeln zu addieren einfach Timer2 += 0xYYYY; Dasselbe geht ja für den Timer0 (im 16Bit Mode) nicht, da die Low Adresse auf 0x8Ah liegt und die High Adresse auf 0x8Ch. Nun möchte ich dies per Software lösen, also folgendes Additionsprinzip verwenden: 256's 1's 1A 44 +22 DB ============ =3D1Fh Hat jemand schon einen Code dafür geschrieben? Ich hätte folgende Assembler Lösung parat, leider weiß ich nicht wie man Assembler Code in den C-Code (Keil Compiler) implementiert um den Carry abzufragen. 256's 1's R6 R7 +R4 R5 ============ R2 R3 ; 1's MOV A,R7 ;Move the low-byte into the accumulator ADD A,R5 ;Add the second low-byte to the accumulator MOV R3,A ;Move the answer to the low-byte of the result ; 256's MOV A,R6 ;Move the high-byte into the accumulator ADDC A,R4 ;Add the second high-byte to the accumulator, plus carry. MOV R2,A ;Move the answer to the high-byte of the result Vielen Dank vorab für Eure Hilfe! Gruß Gregor
int tmp; TR0 = 0; tmp = TL0 | (TH0 << 8); tmp += xxxx; TL0 = tmp; TH0 = tmp >> 8; TR0 = 1; Peter
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.