dschmenk / PLASMA

Proto Language AsSeMbler for All (formerly Apple)
MIT License
189 stars 26 forks source link

Fix gets() so it creates a Pascal format string instead of a C format… #33

Closed BrianHoldsworth closed 6 years ago

BrianHoldsworth commented 6 years ago

Issue: The C PLVM gets() function doesn't return a Pascal string for use with other PLASMA functions like puts()

Sample Code:

include "inc/cmdsys.plh"
char[20] txt
puts("Enter something: ")
gets(txt); puts(@txt)
putln
done

Expected Behavior:

$ ./plvm GETS
Load module GETS
Enter something: test
test

Actual Behavior: puts() will output a gobbly-gook string that omits the first character and overruns the txt buffer.

Notes: Something is still off with the patch because the VM also outputs the warning "Eval stack pointer mismatch at end of execution = 1". I'm not sure if this is a problem with gets() or some other bug.

dschmenk commented 6 years ago

Ah, I was trying to replicate the Apple II version of gets() but I really screwed it up. I see a couple problems that need fixing. Never tried it on the C VM - I'll fix it later today.

BrianHoldsworth commented 6 years ago

Saw your fix and merged it. Thanks.