Possibly the first thing is to write our assembler sourcecode...
10DIM code% 64 20P% = code% 30[ OPT 2 40 ADD R0, PC, #4 50 SWI "OS_Write0" 60 MOVS PC, R14 70 EQUS "Hello world!" + CHR$13 + CHR$10 + CHR$0 80 ALIGN 90] 100CALL code%I use "
ADD R0, PC, #4
" instead of an ADR
so it'll assemble in
one pass. Note that we only need to add '4' (not '8') because the pipeline has already advanced
PC to the next instruction, so that plus four is the offset we want.
Once we've run our program and checked that it works (!!! of course it works, it's only a ten line program!), we need to find our code address. This is easy:
>PRINT ~code% 8FFC >Let's take a quick peek at the program...
>*MemoryI 8FFC +1C 00008FFC : E28F0004 : ..â : ADR a1,&00009008 00009000 : EF000002 : ...ï : SWI "OS_Write0" 00009004 : E1B0F00E : .ð°á : MOVS pc,lr 00009008 : 6C6C6548 : Hell : STCVSTL cp5,c6,[ip],#-&120 0000900C : 6F77206F : o wo : SWIVS &77206F 00009010 : 21646C72 : rld! : DCD &21646C72 00009014 : 00000A0D : .... : ANDEQ a1,a1,sp,LSL #20 >If you don't fancy trying to pull the information directly from that, then you can get a byte dump... Please pay careful attention to the byte order.
>*Memory B 8FFC +1C Address : 0C 0D 0E 0F 00 01 02 03 04 05 06 07 08 09 0A 0B : ASCII Data 00008FFC : 04 00 8F E2 02 00 00 EF 0E F0 B0 E1 48 65 6C 6C : ..â...ï.ð°áHell 0000900C : 6F 20 77 6F 72 6C 64 21 0D 0A 00 00 : o world!.... >That's all you need.
Here's the program. We must output byte-by-byte because we do not have a 'writeword' command.
; How sad can a person get? ; open file filewrite("<Teletext$Temp>.helloworld") ; ADD R0, PC, #4 (or "ADR R0, <location-that's-two-words-on-from-here>") filewritebyte(&04) filewritebyte(&00) filewritebyte(&8F) filewritebyte(&E2) ; SWI "OS_Write0" filewritebyte(&02) filewritebyte(&00) filewritebyte(&00) filewritebyte(&EF) ; MOVS PC, R14 filewritebyte(&0E) filewritebyte(&F0) filewritebyte(&B0) filewritebyte(&E1) ; String to output filewritestring("Hello world!") filewritebyte(13) filewritebyte(10) filewritebyte(0) filewritebyte(0) ; close file, set it to absolute fileclose() filetype("<Teletext$Temp>.helloworld", &FF8) ; Now run it! oscall("%Filer_Run <Teletext$Temp>.helloworld") ; done! terminate()