![]() |
POKE STRING and @string$ - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: POKE STRING and @string$ (/showthread.php?tid=229) Pages:
1
2
|
POKE STRING and @string$ - LCD - 06-01-2010 Just converted the Proportional text routine to a SUB, so it won't crash at exit, but I ran into some problems. I remember, I asked about it, but the thread was closed then, but you promised to look at this: POKE and PEEK STRING do not work, and something else: @a$ does not return the correct adress of the string stored in a$. It returns a adress, but peeking memory in emulator reveals that the text stored in string is not at the adress. Testing @variable reveals that the adress of normal ubyte variables is correct. Is this a bug or "feature"? If it is a feature, how to find out the adress of a string stored in Variable? Re: POKE STRING and @string$ - boriel - 06-02-2010 LCD Wrote:Is this a bug or "feature"? If it is a feature, how to find out the adress of a string stored in Variable?Strings are just pointers to memory blocks (chars), so: Code: DIM a$; Re: POKE STRING and @string$ - LCD - 06-02-2010 I was expecting, it was a pointer, but I ran into the problem in a sub: Code: SUB test(a$ as string) Code: SUB test(a$ as string) Re: POKE STRING and @string$ - boriel - 06-02-2010 LCD Wrote:I was expecting, it was a pointer, but I ran into the problem in a sub:Not sure, but @parameter should work too. I will investigate it further, as you might catched a bug. @parameter addresses are not in a fixed ram position (the global variables memory block) but in the stack (which is a dynamic one). So, will have a look... Re: POKE STRING and @string$ - LCD - 09-03-2012 BUMP! Are POKE and PEEK STRING supposed to work? This would be great for direct string manipulation. I ask because they do not work. POKE [type] address,value suggest that it should accept any type (Okay, I have not tried floats and doubles yet, and POKE ULONG address,PEEK (ULONG,address) was not working in previous versions, crashing the emulator), so this is something that needs further testing. Re: POKE STRING and @string$ - boriel - 09-03-2012 LCD Wrote:BUMP!Nope, the don't. In fact, the problem here is most of you are thinking in C/Asm and not in "High level" language (such as BASIC). You can use memcpy (it's in the library) already for that. Memcpy(Destiny, @varname + 2, len(varname)) will copy an entire string starting at Destiny memory address. Re: POKE STRING and @string$ - LCD - 09-03-2012 boriel Wrote:LCD Wrote:BUMP!Nope, the don't. In fact, the problem here is most of you are thinking in C/Asm and not in "High level" language (such as BASIC). You can use memcpy (it's in the library) already for that. Memcpy(Destiny, @varname + 2, len(varname)) will copy an entire string starting at Destiny memory address. Yes, that is true. Thanks for clearing this. Re: POKE STRING and @string$ - LCD - 09-04-2012 By the way: <!-- m --><a class="postlink" href="http://www.freebasic-portal.de/befehlsreferenz/poke-476.html">http://www.freebasic-portal.de/befehlsr ... e-476.html</a><!-- m --> (german) FreeBasic supports POKE/PEEK String Re: POKE STRING and @string$ - nitrofurano - 06-02-2013 btw, it's missing a description about memcopy (or memcpy) at <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Library">http://www.boriel.com/wiki/en/index.php ... IC:Library</a><!-- m --> based on that, i'm trying to create a new subroutine, which attempts to do a memcopy from paged memory (128k) (far still incomplete and accurate, because, besides it doesn't work fine yet, it doesn't copy a group of bytes splitted into different neighbour pages) Code: sub memcpypagedtodisplay(tdest as ulong, tpadr as ulong, tleng as ulong): Re: POKE STRING and @string$ - LCD - 06-02-2013 nitrofurano Wrote:btw, it's missing a description about memcopy (or memcpy) at <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Library">http://www.boriel.com/wiki/en/index.php ... IC:Library</a><!-- m -->Is this not a little bit offtopic? Anyway, Memcopy is not optimal, it can be replaced with much faster and shorter ASM routine. I made one and it is on my HDD, but I do not remember which one was working and which not. Code: sub CopyMem(src as Uinteger,des as Uinteger,length as Uinteger,bank as ubyte) Code: sub CopyMem(src as Uinteger,des as Uinteger,length as Uinteger) Re: POKE STRING and @string$ - boriel - 06-03-2013 LCD Wrote:At the moment I'm "tera-busy" (not mega, neither giganitrofurano Wrote:btw, it's missing a description about memcopy (or memcpy) at <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Library">http://www.boriel.com/wiki/en/index.php ... IC:Library</a><!-- m -->Is this not a little bit offtopic? ![]() This idea is *very* interesting, and this routine may go in the library/ package, bundled with the compiler. :roll: Re: POKE STRING and @string$ - LCD - 06-03-2013 boriel Wrote:At the moment I'm "tera-busy" (not mega, neither gigaCool. Thanks! Looking forward for the refactored Compiler. Re: POKE STRING and @string$ - LCD - 06-03-2013 While we are there. How about this? Code: sub FillMem(mem as Uinteger,size as Uinteger,byt as Ubyte) Edit: replacing Code: ld d,(ix+5) Code: ld de,hl Code: sub FillMem(mem as Uinteger,size as Uinteger,byt as Ubyte) Re: POKE STRING and @string$ - nitrofurano - 06-04-2013 thanks, but when testing Code: sub cpymempaged(src as Uinteger,des as Uinteger,length as Uinteger,bank as ubyte): i got from terminal: Code: memcopytest.bas:5: Error: Syntax error. Unexpected token 'IX' [IX] (btw, sorry about the offtopic... :S ) Re: POKE STRING and @string$ - LCD - 06-04-2013 nitrofurano Wrote:thanks, but when testingOkay, so I do now know which one was not working... LD registerpair,(IX+offset) is invalid. Then this should work: Code: sub cpymempaged(src as Uinteger,des as Uinteger,length as Uinteger,bank as ubyte) |