TITLE "stringtest.a String test program" ; Extracted from the second example distributed with the Jun. 28, 2018 notes. ; Here, this code is used as an example to demonstrate how a large file can ; be broken into multiple pieces for separate assembly and possible reuse. ; This test program serves as a stand-in for any application program that ; uses the string functions. USE "hawk.h" USE "monitor.h" USE "strings.h" SUBTITLE "main() a main program" ; activation record structure ;RETAD = 0 BUFFER = 4 ARSIZE = BUFFER + BUFLEN S MAIN INT MAIN ; activation record structure MAIN: STORES R1,R2 ; -- save RA LEA R3,R2,BUFFER ; -- parameter dst LEA R4,ASTRING ; -- parameter src ADDI R2,R2,ARSIZE LIL R1,STRCPY JSRS R1,R1 ; strcpy( buffer, astring ) ADDI R2,R2,-ARSIZE ; -- parameter buffer already in R3 ADDI R2,R2,ARSIZE LIL R1,PUTS JSRS R1,R1 ; puts( buffer ) ADDI R2,R2,-ARSIZE LIS R3,' ' ; -- parameter ADDI R2,R2,ARSIZE LIL R1,PUTCHAR JSRS R1,R1 ; putchar( ' ' ) ADDI R2,R2,-ARSIZE LEA R3,R2,BUFFER ; -- parameter dst ADDI R2,R2,ARSIZE LIL R1,STRLEN JSRS R1,R1 ; temp = strlen( buffer ) ADDI R2,R2,-ARSIZE ; -- parameter temp already in R3 LIS R4,0 ; -- parameter ADDI R2,R2,ARSIZE LIL R1,PUTDEC JSRS R1,R1 ; putdec( temp, 0 ) ADDI R2,R2,-ARSIZE LOADS R1,R2 ; -- restore RA JUMPS R1 ; test data ASTRING:ASCII "this is a string",0 ITSLEN = . - ASTRING BUFLEN = ((ITSLEN + 3) >> 2) << 4 ; buflen rounded up