PLEAC-MASD


Table of Contents
Foreword
1. Strings (10.5%)
2. Numbers (0.0%)
3. Dates and Times (0.0%)
4. Arrays (0.0%)
5. Hashes (0.0%)
6. Pattern Matching (0.0%)
7. File Access (0.0%)
8. File Contents (0.0%)
9. Directories (0.0%)
10. Subroutines (0.0%)
11. References and Records (0.0%)
12. Packages, Libraries, and Modules (0.0%)
13. Classes, Objects, and Ties (0.0%)
14. Database Access (0.0%)
15. User Interfaces (0.0%)
16. Process Management and Communication (0.0%)
17. Sockets (0.0%)
18. Internet Services (0.0%)
19. CGI Programming (0.0%)
20. Web Automation (0.0%)
A. Helpers

Foreword

Following the Perl Cookbook (by Tom Christiansen and Nathan Torkington, published by O'Reilly) spirit, the PLEAC Project aims to gather fans of programming, in order to implement the solutions in other programming languages.

In this document, you'll find an implementation of the Solutions of the Perl Cookbook in the MASD language.

The syntax is MASD and kasm compliant. It tries to be 39/40/48/49 compliant, but has only been tested on 48. I use masd_mod on emacs to edit, kasm to cross-assemble, sx to send, the 'saturn' UNIX emulator to test. % @@PLEAC@@_1.0 CODE % returns "\n" % two characters, \ and an n SAVE LC 00004 RES.STR LC 6E5C DAT0=C.4 A=R0.A LOAD GOVLNG PUSHA % $03A86 ENDCODE CODE % returns "Jon 'Maddog' Orwant" % literal single quotes SAVE LC 00026 RES.STR C=PC GOINA "STRING" A+C.A D1=A C=DAT1.16 DAT0=C.16 D0+16 D1+16 C=DAT1.16 DAT0=C.16 D0+16 D1+16 C=DAT1.6 DAT0=C.6 A=R0.A LOAD GOVLNG PUSHA % $03A86 *STRING $A4F6E60272D4164646F6767202F4277716E64755 % Jon 'Maddog' Orwant ENDCODE CODE % returns a newline character SAVE LC 00002 RES.STR LC 0A DAT0=C.2 A=R0.A LOAD GOVLNG PUSHA % $03A86 ENDCODE CODE % returns 'Jon "Maddog" Orwant' % literal double quotes SAVE LC 00026 RES.STR C=PC GOINA "STRING" A+C.A D1=A C=DAT1.16 DAT0=C.16 D0+16 D1+16 C=DAT1.16 DAT0=C.16 D0+16 D1+16 C=DAT1.6 DAT0=C.6 A=R0.A LOAD GOVLNG PUSHA % $03A86 *STRING $A4F6E60222D4164646F6762202F4277716E647 % Jon "Maddog" Orwant ENDCODE % @@PLEAC@@_1.1 CODE % level 2 : string % level 1 : offset (binary integer) % level 1 : count (binary integer) % returns the substring. % WARNING : no check done. SAVE GOSUB "VALUES" %(count) R1=C.A D1+5 GOSUB "VALUES" %(offset) D1+5 A=DAT1.A %(string) A+10.A A+C.A R2=A.A %@ where write C=R1.A RES.STR CD0EX D1=C C=R2.A D0=C C=R1.A GOSBVL MOVEDOWN %$0670C LOAD A=R0.A GOVLNG PUSHA % $03A86 *VALUES C=DAT1.A C=C+5.A D0=C A=DAT0.A A=A-6.A %length-1 LC 00005 ?A<C.A SKIPYES { LC 4 } % C=max(A,00004) P=C.0 D0+5 C=DAT0.WP % get datas P=0 C+C.A RTN ENDCODE