hey everybody
i have problem in my code, everything is fine until i want to print 'hello world' , i get an error(in the image_ here is my code: Transcript clear. ggg := FileStream fileNamed: 'c:\MyData\test.txt'. x :=1. stream := FileStream fileNamed: 'c:\MyData\test24.txt'. [ggg atEnd] whileFalse: [ string:=ggg nextLine. y:=string. Transcript cr; show: string,x. len:=string size. value:=string findString: 'pop' startingAt: 0. value == 1 ifTrue: [ Transcript show:'aaaaaa'. con:=string findString: 'local' startingAt: 3. con==5 ifTrue: [ rem:=string last: len-10. Transcript show:rem. t:= '@',rem. stream nextPutAll:t;cr. stream nextPutAll: 'D=A';cr. stream nextPutAll: '@LCL'; cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'D=A+D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'A=M-1';cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'A=A-D';cr. stream nextPutAll: 'D=D+A';cr. stream nextPutAll: 'A=D-A';cr. stream nextPutAll: 'M=D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'M=M-1';cr ]. con:=string findString: 'argument' startingAt: 3. con==5 ifTrue: [ rem:=string last: len-14. Transcript show:'cccc'. t:= '@',rem. stream nextPutAll:t;cr. stream nextPutAll: 'D=A';cr. stream nextPutAll: '@ARG'; cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'D=A+D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'A=M-1';cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'A=A-D';cr. stream nextPutAll: 'D=D+A';cr. stream nextPutAll: 'A=D-A';cr. stream nextPutAll: 'M=D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'M=M-1';cr ]. con:=string findString: 'this' startingAt: 3. con==5 ifTrue: [ rem:=string last: len-10. Transcript show:'cccc'. t:= '@',rem. stream nextPutAll:t;cr. stream nextPutAll: 'D=A';cr. stream nextPutAll: '@THIS'; cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'D=A+D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'A=M-1';cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'A=A-D';cr. stream nextPutAll: 'D=D+A';cr. stream nextPutAll: 'A=D-A';cr. stream nextPutAll: 'M=D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'M=M-1';cr ]. con:=string findString: 'that' startingAt: 3. con==5 ifTrue: [ rem:=string last: len-10. Transcript show:'cccc'. t:= '@',rem. stream nextPutAll:t;cr. stream nextPutAll: 'D=A';cr. stream nextPutAll: '@THAT'; cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'D=A+D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'A=M-1';cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'A=A-D';cr. stream nextPutAll: 'D=D+A';cr. stream nextPutAll: 'A=D-A';cr. stream nextPutAll: 'M=D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'M=M-1';cr ]. con:=string findString: 'static' startingAt: 3. con==5 ifTrue: [ rem:=string last: len-12. Transcript show:'cccc'. t:= '@',rem. stream nextPutAll:t;cr. stream nextPutAll: 'D=A';cr. stream nextPutAll: '@STATIC'; cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'D=A+D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'A=M-1';cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'A=A-D';cr. stream nextPutAll: 'D=D+A';cr. stream nextPutAll: 'A=D-A';cr. stream nextPutAll: 'M=D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'M=M-1';cr ]. con:=string findString: 'pointer' startingAt: 3. con==5 ifTrue: [ rem:=string last: len-13. Transcript show:'cccc'. t:= '@',rem. stream nextPutAll:t;cr. stream nextPutAll: 'D=A';cr. stream nextPutAll: '@PTR'; cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'D=A+D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'A=M-1';cr. stream nextPutAll: 'A=M';cr. stream nextPutAll: 'A=A-D';cr. stream nextPutAll: 'D=D+A';cr. stream nextPutAll: 'A=D-A';cr. stream nextPutAll: 'M=D';cr. stream nextPutAll: '@SP';cr. stream nextPutAll: 'M=M-1';cr ] ]. Transcript show:string. Transcript show:len. value2:=y findString: 'push' startingAt: 0. Transcript show:value2. con2:=y findString: 'constant' startingAt: 4. con2==6 ifTrue: [ rem:=y last:len-14. Transcript show:rem ]. con2:=y findString: 'local' startingAt: 3. Transcript show:'hello world'. ///not working make errors like the image ]. stream close. ggg close. |
Free forum by Nabble | Edit this page |