Page 4 of 7

Re: How to start programming with assembly?

Posted: Wed Jul 01, 2015 12:27 pm
by g0blinish
Still wondering why Adder doesn't work on unregustered version.
Why not to transfer files to MDV?

Re: How to start programming with assembly?

Posted: Wed Jul 01, 2015 4:00 pm
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

Re: How to start programming with assembly?

Posted: Wed Jul 01, 2015 5:42 pm
by g0blinish
Wimdev

same error (((

maybe wrong settings?

Re: How to start programming with assembly?

Posted: Mon Apr 30, 2018 2:42 pm
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?

Re: How to start programming with assembly?

Posted: Mon Apr 30, 2018 7:53 pm
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...

Re: How to start programming with assembly?

Posted: Mon Apr 30, 2018 11:39 pm
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.

Re: How to start programming with assembly?

Posted: Tue May 01, 2018 3:54 am
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

Re: How to start programming with assembly?

Posted: Tue May 01, 2018 3:54 am
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

Re: How to start programming with assembly?

Posted: Tue May 01, 2018 10:22 am
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

Re: How to start programming with assembly?

Posted: Tue May 01, 2018 12:19 pm
by g0blinish
no, emulation stops.
QL2K emulator.