vscode-central-asm/examples/hello.s

71 lines
1.5 KiB
ArmAsm
Raw Permalink Normal View History

2024-11-08 22:11:29 +00:00
@@ text.start
.g hello
//Set HELLO variable to 1234
%% set var="HELLO",
%- to=1234,
%% set var="RC_SUCCESS",to=0
mov r1, %(HELLO)
ldr.eq r0, [r1]
nop
.l world
//Include other file
%% include member="myfile"
//Use the alloc macro
%* alloc size=r0, align=0x1000,
%- out=r1,
svc 0x7b
adr r2, .my_fd.def
%* nextrec "OK",fd=r2,
%- out=.my_fd.out.data
%* endprocess rc=%(RC_SUCCESS)
@@ rodata
.l value
//Defaults to dd(2)
dd 0x1234
dd 0x01'1, 0x02'1, 0xFFEE'2
.l value.other
dd "Hello, world!\0"
//File descriptor
@@ data
.l my_fd.def
%* filedesc ddname="HELLO",recfm="FB",lrecl=200
@@ bss
.l my_fd.out
//Array of 4 integers
ds int(4)
//Named array of characters with last label prepended. 200 bytes in length.
.. data
ds char(200)
///////////////////////////////////////////////////////////////////////////////
%% macro name="nextrec"
%% param name="ok",type="(OK,KO)"
%% kwparam name="fd",type="label|reg"
%% kwparam name="out",type="label|reg"
%% if val="ok",neq="OK"
%% abort msg="Error: param 'ok' of macro 'nextrec' must be OK"
%% endif
//Handle fd
%% if type="fd",is="label"
add r0, pc, %(fd)
%% elif val="fd",neq=r0
mov r0, %(fd)
%% endif
//Handle out
%% if type="out",is="label"
add r1, pc, %(out)
%% elif val="fd",neq=r0
mov r1, %(out)
%% endif
//Call the privileged service
svc 0x10
%% endmacro
///////////////////////////////////////////////////////////////////////////////