Ubuntu 20.04下配置 HAL 汇编开发环境教程

安装

环境:Ubuntu 20.04

安装包:linux64.hla.tar.gz

这里安装的是64位的,具体与linux.hla.tar.gz有什么不同,没研究过。

解压

可任选目录,本文在我的用户目录/home/nqw下解压。

$ tar -xvf linux64.hla.tar.gz

解压后会自动创建子目录/usr/hla,文件都保存在这个目录下。其中code文件夹是笔者自己添加的,用来保存以后编写的代码。

在这里插入图片描述

配置环境变量
$ gedit ~/.bashrc

在打开的文件末尾,添加如下内容,主要是配置hla的可执行文件路径、库路径、头文件路径等。

PATH=/home/nqw/usr/hla:$PATH
export PATH
hlalib=/home/nqw/usr/hla/hlalib
export hlalib
hlainc=/home/nqw/usr/hla/include
export hlainc
hlacode=/home/nqw/usr/hla/code
export hlacode

保存,退出。

执行如下指令生效。

$ source ~/.bashrc  
测试

检测hla版本,看是否安装成功。

$ hla -v

得到如下信息,表示安装成功。

$ hla -v
HLA (High Level Assembler)
Use '-license' to see licensing information.
Version 2.16 build 4409 (prototype)
ELF output
OBJ output using HLA Back Engine
-test active

HLA Lib Path:     /hla/usr/hla/hlalib/hlalib.a
HLA include path: /hla/usr/hla/include
HLA temp path:    
Files:

Nothing more to do!
Usage: hla options filename(s)

HLA (High Level Assembler - HLABE back end, LD linker)
Version 2.16 build 4409 (prototype)

  -?        Display help message.
  -license  Display license information.

案例

code文件夹下,创建文件hw.hla,并编辑如下内容。

program helloworld;
#include("stdlib.hhf")

begin helloworld;

stdout.put("Hello,world!!!", nl);

end helloworld;

编译

$ hla -v hw.hla

这个时候可能会报如下错误,提示找不到hlaparse

sh: 1: hlaparse: not found

网上关于这个的帖子较少,不过找到一个,大致意思好像是需要32位的链接器。

安装libc6-i386

$ sudo apt install libc6-i386

然后重新编译,基本就解决了。

nqw@ubuntu:~/usr/hla/code$ hla -v hw.hla 
HLA (High Level Assembler)
Use '-license' to see licensing information.
Version 2.16 build 4463 (prototype)
ELF output
OBJ output using HLA Back Engine
-test active

HLA Lib Path:     /home/nqw/usr/hla/hlalib/hlalib.a
HLA include path: /home/nqw/usr/hla/include
HLA temp path:    
Files:
1: hw.hla

Compiling 'hw.hla' to 'hw.o'
using command line:
[hlaparse -LINUX -level=high  -v -test "hw.hla"]

----------------------
HLA (High Level Assembler) Parser
use '-license' to view license information
Version 2.16 build 4463 (prototype)
-test active
File: hw.hla
Output Path: ""
hlainc Path: "/home/nqw/usr/hla/include"
hlaauxinc Path: ""
Compiler generating code for Linux OS
Back-end assembler: HLABE
Language Level: high

Assembling "hw.hla" to "hw.o"
HLAPARSE assembly complete, 48342 lines,   0.074 seconds,  652389 lines/second
------------
HLA Back Engine Object code formatter

HLABE compiling 'hw.hla' to 'hw.o'
Optimization passes: 3+2
----------------------
Linking via [ld  -melf_i386    -o "hw"    "hw.o" "/home/nqw/usr/hla/hlalib/hlalib.a"]

========================================
    HLA Compilation Complete
========================================

运行。

nqw@ubuntu:~/usr/hla/code$ ls
hw  hw.hla  hw.o
nqw@ubuntu:~/usr/hla/code$ ./hw 
Hello,world!!!

到这里,linux下hla的基本编程环境就配置好啦。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Rob月初

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值