| ??? 04/08/02 12:33 Read: times |
#21555 - RE: data segment variables wont work? |
Hi Philip,
Sorry, I didn't realise you were using Metalink. You might try the following: DSEG AT 30h ; Select the DATA segment, starting at location 30h Your_Var: DS 8 ; Reserve 8 bytes for your variable Stack: DS 1 ; Dummy variable to mark the beginning of the stack space CSEG AT 0 ; Select the CODE segment at the beginning of the code space LJMP Program_Start ; Jump over the interrupt table ORG 40h ; Let the next bit of code start at address 40h Program_Start: MOV SP,#STACK ; Set the stackpointer ; Do some more initialisation, as required MOV R0,#Your_Var ; Let R0 point to the first byte of Your_Var MOV @R0,#data1 ; Fill the byte with the desired data INC R0 ; Point to the next byte MOV @R0,#data2 ; Fill with data INC R0 ; On to the next byte, etc. until all bytes are written ; The main of your program goes here Function: MOV R0,#Your_Var ; Let R0 point to the first byte of Your_Var MOV R7,#4 ; Set up R7 as counter Label1: MOV A,@R0 ; Get the byte JNZ Label2 ; Continue if the byte <> 0 RET ; Else, leave the function Label2: ACALL Other_Function INC R0 MOV A,@R0 ; Get the next byte CLR C ; Clear the Carry flag RLC ACC ; The 8051 doesn't have a shift, so we rotate through the ; Carry instead. This has the same effect, provided you ; clear the Carry first. MOV @R0,A ; Save the new value ACALL Yet_Another_Function INC R0 DJNZ R7,Label1 ; Repeat this for all 8 bytes AJMP Function ; If all bytes have been processed, start all over again END I hope this will make things a bit easier for you to understand (if it doesn't, I'm afraid you are beyond hope... :-D Just kidding! ). Regards, Rob. |
| Topic | Author | Date |
| quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: ASM variables, moving thru it | 01/01/70 00:00 | |
| RE: ASM variables, moving thru it | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables, Rob | 01/01/70 00:00 | |
| RE: quick question on ASM variables, Rob | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: data segment variables wont work? | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: data segment variables wont work? | 01/01/70 00:00 | |
| RE: Thanks!! | 01/01/70 00:00 | |
RE: Thanks!! | 01/01/70 00:00 |



