Using Metaprogramming Tools of the Common Lisp Language for the Development of Emulator Systems

А. А. Chaplygin
{"title":"Using Metaprogramming Tools of the Common Lisp Language for the Development of Emulator Systems","authors":"А. А. Chaplygin","doi":"10.21869/2223-1536-2023-13-3-135-145","DOIUrl":null,"url":null,"abstract":"The purpose of research is to analyze and use metaprogramming in the Common Lisp language when designing and implementing emulators that simulate computer system hardware. The metaprogramming, the macro tools of the Common Lisp language and the use of macros for metaprogramming are considered.Methods. The Lisp language is characterized by its use of uniform S-expressions to represent data and programs. Thus, data can be part of a program and vice versa: a program can be data. Common Lisp macro tools allow you to directly modify the abstract syntax tree of a program, and thus it is possible to create new syntactic constructs to solve a given problem. When implementing emulator functions, macro tools of the Common Lisp language can be used to generate functions, where the common part of the functions is included in the macro, and the differences between the functions are specified in the parameters when calling the macros. Examples of this macros are: bit status register macros, generation of ariphmetic commands, comparation commands, memory commands. Using that you can significantly reduce the size of the program.Results. As a result of computer modeling, a simulator of the NES architecture (MOS 6502 processor) was developed and implemented in the conventional object-orientied C# programming language and in the Common Lisp metaprogramming language. As a result, the simulator written in a language with metaprogramming support turned out to be more than 2 times smaller than the simulator written in C#.Conclusion. The use of metaprogramming (using the example of creating emulators) can significantly reduce the size of a program, simplify and improve the program architecture, reduce the number of errors and improve the quality of programs. The use of domain specific languages lets reduce code size even more.","PeriodicalId":166124,"journal":{"name":"Proceedings of the Southwest State University. Series: IT Management, Computer Science, Computer Engineering. Medical Equipment Engineering","volume":"3 2","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-01-27","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the Southwest State University. Series: IT Management, Computer Science, Computer Engineering. Medical Equipment Engineering","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.21869/2223-1536-2023-13-3-135-145","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

The purpose of research is to analyze and use metaprogramming in the Common Lisp language when designing and implementing emulators that simulate computer system hardware. The metaprogramming, the macro tools of the Common Lisp language and the use of macros for metaprogramming are considered.Methods. The Lisp language is characterized by its use of uniform S-expressions to represent data and programs. Thus, data can be part of a program and vice versa: a program can be data. Common Lisp macro tools allow you to directly modify the abstract syntax tree of a program, and thus it is possible to create new syntactic constructs to solve a given problem. When implementing emulator functions, macro tools of the Common Lisp language can be used to generate functions, where the common part of the functions is included in the macro, and the differences between the functions are specified in the parameters when calling the macros. Examples of this macros are: bit status register macros, generation of ariphmetic commands, comparation commands, memory commands. Using that you can significantly reduce the size of the program.Results. As a result of computer modeling, a simulator of the NES architecture (MOS 6502 processor) was developed and implemented in the conventional object-orientied C# programming language and in the Common Lisp metaprogramming language. As a result, the simulator written in a language with metaprogramming support turned out to be more than 2 times smaller than the simulator written in C#.Conclusion. The use of metaprogramming (using the example of creating emulators) can significantly reduce the size of a program, simplify and improve the program architecture, reduce the number of errors and improve the quality of programs. The use of domain specific languages lets reduce code size even more.
使用通用 Lisp 语言的元编程工具开发仿真器系统
研究目的是在设计和实施模拟计算机系统硬件的仿真器时,分析和使用 Common Lisp 语言中的元编程。研究考虑了元编程、Common Lisp 语言的宏工具以及宏在元编程中的使用。Lisp 语言的特点是使用统一的 S 表达式来表示数据和程序。因此,数据可以是程序的一部分,反之亦然:程序可以是数据。常用的 Lisp 宏工具可以直接修改程序的抽象语法树,因此可以创建新的语法结构来解决给定的问题。在实现仿真器函数时,可以使用 Common Lisp 语言的宏工具来生成函数,函数的共同部分包含在宏中,函数之间的差异则在调用宏时在参数中指定。这种宏的例子有:位状态寄存器宏、生成非线性命令、比较命令和内存命令。使用这些宏可以大大减少程序的大小。作为计算机建模的结果,开发了一个 NES 架构(MOS 6502 处理器)模拟器,并用传统的面向对象的 C# 编程语言和 Common Lisp 元编程语言实现了该模拟器。结果,用支持元编程的语言编写的模拟器比用 C# 语言编写的模拟器小 2 倍多。使用元编程(以创建模拟器为例)可以大大缩小程序的规模,简化和改进程序结构,减少错误数量,提高程序质量。使用特定领域语言可以进一步减少代码量。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信