0 Members and 4 Guests are viewing this topic.
I really want this to be possible:Code: [Select]"Up"->Str1"Down"->Str1I'd love to see that
"Up"->Str1"Down"->Str1
"Up"->Str1"Down"->Str2If CONDITIONStr1->AElseStr2->AEnd
Repeat getKey->KEndIf K=4("Up")->PElseIf K=1("Down")->PElse("Neither")->PEndDisp P
If you are going to use a string more than once, it is a good idea to give it a name, though. If you inline the string each time, the data will be added again and again. (Well, unless Quigibo made it check for duplicates, but I think that would be a waste of processing time)
;getkey stuff here cp 4 jq nz,lb1 ld de,P_Address ld hl,str1 ld (de), hllb1:...data_section:str1: db "Up", 0
{====______}
{=========_}
;getKey stuff here ld hl,($8700) ;$8700 = K ld a,l ;K=4 check sub 4 or h ld hl,$01 jr z,$+3 dec l ld a,h ;Standard If statement code or l jp z,EndIf ld hl,string ;If statement contents ld ($870A),hl ;$870A = PEndIf: ;Other stuffstring: .db "Up", 0
You can always use a variable as a pointer to a string, and change that variable. For example, P is used as a pointer in the following program:Code: [Select]Repeat getKey->KEndIf K=4("Up")->PElseIf K=1("Down")->PElse("Neither")->PEndDisp P("String") tells Axe to insert the string data at the end of the program and return a pointer to it. The parentheses are important because it tells Axe that it is an expression and needs to return the pointer, instead of it being a simple data definition (in which case no code is generated)
Quote from: calc84maniacYou can always use a variable as a pointer to a string, and change that variable. For example, P is used as a pointer in the following program:Code: [Select]Repeat getKey->KEndIf K=4("Up")->PElseIf K=1("Down")->PElse("Neither")->PEndDisp P("String") tells Axe to insert the string data at the end of the program and return a pointer to it. The parentheses are important because it tells Axe that it is an expression and needs to return the pointer, instead of it being a simple data definition (in which case no code is generated)Thanks, didn't know that. I don't understand how the parentheses work, though...