How to start programming with assembly?

Anything QL Software or Programming Related.
g0blinish
ROM Dongle
Posts: 30
Joined: Mon Jun 22, 2015 11:54 am

Re: How to start programming with assembly?

Post by g0blinish »

Still wondering why Adder doesn't work on unregustered version.
Why not to transfer files to MDV?


Wimdev
ROM Dongle
Posts: 29
Joined: Fri Feb 28, 2014 4:40 am
Location: Livermore, CA

Re: How to start programming with assembly?

Post by Wimdev »

Try the attached asm.zip file. Unzip into a new directory, attach it as a folder to the first slot on your unregistered Qemulator. It should work. I tested it on my mac after de-registering my version. Not sure what the difference is with the zip on Dylwin's site, but apparently the qdos header info is intact on this one.

Wim
Attachments
asm.zip
adder assembler
(29.29 KiB) Downloaded 185 times


g0blinish
ROM Dongle
Posts: 30
Joined: Mon Jun 22, 2015 11:54 am

Re: How to start programming with assembly?

Post by g0blinish »

Wimdev

same error (((

maybe wrong settings?


g0blinish
ROM Dongle
Posts: 30
Joined: Mon Jun 22, 2015 11:54 am

Re: How to start programming with assembly?

Post by g0blinish »

well...
I attached assembler(asm20) and editor(QED). Here is text:

Code: Select all

UT_MTEXT equ $d0

         clr.l d0
         lea M9,a1
         move.l d2,(a1)
         lea M8,a1
         sub.l a0,a0
         move.w UT_MTEXT,a2
         jsr (a2)
         rts
M8
         dc.w M2-M1
M1       dc.b 'QDOS Version -  '
M9       ds.l 1
M2



     ds.l 1
M2

compilation:

Code: Select all

10 EXEC win2_asm20;'win2_a_s win2_hl'
how to launch binary?
I use BASIC:

Code: Select all

10 a=ALCHP(50)
20 LBYTES win2_hl,a
30 SEXEC win2_hl,a,50,4096
after I type exec win2_hl I got a trash message on screen and computer doesn't respond at pressing keys.

Any clue?


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: How to start programming with assembly?

Post by RWAP »

Refer to the QDOS/SMSQ Reference Manual - section 3.1

http://www.dilwyn.me.uk/docs/manuals/QD ... 20v4.3.pdf

This explains that an executable job has to have a standard header at the start:

Code: Select all

JMP.L	JOB_START
DC.W 	$4AFB
DC.W 	JOB_NAME_LENGTH
DC.B 	'Name of job' (word-aligned)
Then you can add your code

Code: Select all

JOB_START
         clr.l d0
         lea M9,a1
         move.l d2,(a1) 
         lea M8,a1
         sub.l a0,a0
         move.w UT_MTEXT,a2
         jsr (a2)
         rts
M8
         	dc.w M2-M1
M1       	dc.b 'QDOS Version -  '
M9       	ds.l 	1
M2 		ds.l	1
What are you trying to do with

Code: Select all

move.l d2,(a1)
d2 could contain anything at this point...


User avatar
janbredenbeek
Super Gold Card
Posts: 629
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands

Re: How to start programming with assembly?

Post by janbredenbeek »

The standard header is not really required - but recommended if you want your program to be identified by job control utilities such as in TK2.
He has forgotten the trap #1 (mt.inf) after the first clr.l d0. But that should not cause a crash - only garbage as QDOS version.
The real problem is that it ends with a RTS instruction, and because the stack will contain a zero longword the CPU will wander off to address 0 - on Minerva this will certainly cause a crash as Lau has deliberately put in an illegal opcode there, and on QDOS or SMSQ it won't be much better. The code should end with a MT.FRJOB trap like all executable jobs.
Also, M9 might not word aligned so doing a move.l d2,(a1) where a1 is odd will cause an address error. Putting a DS.L 1 at the end will not always get this right (the GST assembler has a bug in that). A DC.L 0 will do because this does a word alignment before assigning the address to the label.

Jan.


g0blinish
ROM Dongle
Posts: 30
Joined: Mon Jun 22, 2015 11:54 am

Re: How to start programming with assembly?

Post by g0blinish »

win2_a_s;3: Bad size or wrong operand(s)

Code: Select all

UT_MTEXT equ $d0

         BRA.S    js
         DC.W     $4AFB
         DC.W     4
         DC.B     ' hlw'

js
         clr.l d0


g0blinish
ROM Dongle
Posts: 30
Joined: Mon Jun 22, 2015 11:54 am

Re: How to start programming with assembly?

Post by g0blinish »

found one:
http://qlforum.co.uk/viewtopic.php?t=1449

program starts, no message (

Code: Select all

         JMP    J_S
         dc.w     0
         DC.W     $4AFB
         DC.W     6
         DC.B     'C_PROG'
J_S
         move.l #0,a0
         lea mess,a1
*         sub.l a0,a0
         move.w $d0,a2
         jsr (a2)
         rts
mess
         dc.w 12
M1       dc.b 'Hello World!',10


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: How to start programming with assembly?

Post by pjw »

g0blinish wrote:<>
how to launch binary?
I use BASIC:

Code: Select all

10 a=ALCHP(50)
20 LBYTES win2_hl,a
30 SEXEC win2_hl,a,50,4096
after I type exec win2_hl I got a trash message on screen and computer doesn't respond at pressing keys.

Any clue?
Lets not forget the simple solution: CALL. The code you need for this is:

Code: Select all

100 fnm$ = 'win2_hl_bin'
110 fl = FLEN(\ fnm$)
120 adr = ALCHP(fl)
130 LBYTES fnm$, adr
140 CALL adr
150 RECHP adr
160 :
As it stands, the code above requires either SMSQ/E or Qdos/Minerva with TK2.
It also presupposes a corrected version of your code (here packaged for assembly with QMAC):

Code: Select all

        filetype 0
        
        section code

UT_MTEXT equ $d0

         clr.l d0               sms.info
         trap #1                you forgot this!

         lea M9,a1
         move.l d2,(a1)         version

         lea M8,a1
         sub.l a0,a0
         move.w UT_MTEXT,a2
         jsr (a2)
         rts

M8
         dc.w M2-M1
M1       dc.b 'QDOS Version -  '
M9       ds.l 1
M2
*
        end


Per
dont be happy. worry
- ?
g0blinish
ROM Dongle
Posts: 30
Joined: Mon Jun 22, 2015 11:54 am

Re: How to start programming with assembly?

Post by g0blinish »

no, emulation stops.
QL2K emulator.


Post Reply