This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
amiga:development_environments:basic:amos_professional:extension_development [2024/03/18 13:14] – Topaz | amiga:development_environments:basic:amos_professional:extension_development [2024/03/18 21:15] (current) – Topaz | ||
---|---|---|---|
Line 66: | Line 66: | ||
When you want to demand string space, you apply for it with `L_Demande`. | When you want to demand string space, you apply for it with `L_Demande`. | ||
- | The requested length goes into D3. It does not have to be even. You get the base address in both A0 and A1. | + | The requested length goes into D3. It has to be even. You get the base address in both A0 and A1. |
This is an AMOS string, so the first two bytes are the size of the string as a word. Then the string comes after. | This is an AMOS string, so the first two bytes are the size of the string as a word. Then the string comes after. | ||
- | Then, you have to eventually hand `HiChaine(A5)` (be sure to preserve A5) the ending address of the string, rounded up to the nearest 2. I'm guessing you're now setting the end of the string area in memory manually. | + | Then, you have to eventually hand `HiChaine(A5)` (be sure to preserve A5) the ending address of the string. |
Make sure you don't try to allocate a zero width string with this! It will fail hard. | Make sure you don't try to allocate a zero width string with this! It will fail hard. | ||
Line 109: | Line 109: | ||
```asm | ```asm | ||
; D4 contains your string length | ; D4 contains your string length | ||
- | MOVE.L | + | MOVE.L D4,D3 |
AND.W #$FFFE,D3 | AND.W #$FFFE,D3 | ||
- | ADDQ #2,D3 | + | ADDQ #2,D3 ; round up to the nearest 2 |
Rjsr L_Demande ; string is in A0/A1 | Rjsr L_Demande ; string is in A0/A1 | ||
LEA 2(A0, | LEA 2(A0, | ||
MOVE.L A1, | MOVE.L A1, | ||
+ | MOVE.L A0,A1 ; put A1 back | ||
+ | MOVE.W D4,(A0)+ ; put length of string at start of memory | ||
+ | .stringstuff | ||
+ | MOVE.B (A2)+,(A0)+ | ||
+ | BNE .stringstuff ; copy until null terminator | ||
``` | ``` | ||