A Solution
Notes
- I will probably never find out how many lines of code the previous solution will generate.
- The code should not be hard to generate,
- But I also don't feel that we would gain anything from generating it.
- So I have a partial solution
- Take a look at lib.cpp
- This has a memory leak
- I just call fdopen (see man fdopen)
- Also, I ran up hard against the 16 byte stack alignment rule
- So here is a solution
mov r12, rsp and rsp, -16 call GetString mov rsp, r12
- I moved on to build a GET_WORD function
- I needed STRLEN and STRCPY
- There are standard library implementations of these
- But they are quite easy to write, so I wrote them.
- Note that they are both leaf routines
- I could, and probably should have written STRDUP, but I built that into GET_WORD
- This reads in a maximum size word.
- How could this be avoided? (yuck in assembly)
- Everything should be fairly straight forward from here.
- Gaze upon preList.asm.
- I needed STRLEN and STRCPY
- I abstracted these out into a library
- And added any string functions I need (strcmp) to complete the list task.