Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- : make-string ( -- s )
- s" foo" ;
- : append-print ( s s -- )
- append type cr ;
- make-string s" bar" append-print
- $ gforth prob1.fs -e bye
- gforth(41572,0x7fff79cc2310) malloc: *** error for object 0x103a551a0: pointer being realloc'd was not allocated
- *** set a breakpoint in malloc_error_break to debug
- Abort trap: 6.
- variable foo
- s" foo" foo !
- foo s" bar " append type cr
- $ gforth prob2.fs
- foo��^C
- in file included from *OS command line*:-1
- prob2.fs:4: User interrupt
- foo s" bar " append >>>type<<< cr
- Backtrace:
- $10C7C2E90 write-file
- see append
- : append
- >l >l >l >l @local0 @local1 @local3 + dup >l resize throw >l @local4 @local0 @local3 + @local5
- move @local0 @local1 lp+!# 48 ; ok
- : make-string ( -- s )
- s" foo" ;
- : append-print
- s+ type cr ;
- make-string s" bar" append-print
- $ gforth b.fs -e bye
- foobar
- : append { addr1 u1 addr2 u2 -- addr u }
- addr1 u1 u2 + dup { u } resize throw { addr }
- addr2 addr u1 + u2 move
- addr u ;
- : s+ { addr1 u1 addr2 u2 -- addr u }
- u1 u2 + allocate throw { addr }
- addr1 addr u1 move
- addr2 addr u1 + u2 move
- addr u1 u2 +
- ;
- : astring S" foo" ;
- CREATE buffer 100 ALLOT space for 100 chars
- Put the first string in `buffer and append the second string.
- Also print the second string
- : append-print ( s s -- )
- type cr 2swap
- buffer $!
- buffer $+! ;
- astring s" bar" append-print
- bar OK answer
- buffer $@ TYPE
- foobar OK answer
Add Comment
Please, Sign In to add comment