Pl EXOS 1.DOC

From Atari Wiki
Revision as of 00:25, 17 December 2023 by Olivier.jan (talk | contribs)
Jump to navigation Jump to search

                         -------------------------
                               EXERCISES   I

                         -------------------------


- Solutions to the exercises proposed in this file are present 
  in the file: CORRIG_1.DOC
                    ------------
  You just need to note the exercise number whose answer you want to know.




                            ------------------

No. 1:
------

Find the error (easy...)


     text

ab   move.b    #345,d0
     add.b     #1,d0
     jmp       ab

     end


No. 2:
------
What will the data register d3 contain?

     text

     move.l    #12,d3
     add.l     #4,d3
     add.l     d3,d3
     move.l    var,d2
     add.l     d2,d3

     data                ;data segment

var  dc.l      458

     end


No. 3:
------
What will the d5 register contain?
     

     text

     move      ici,d4
     add       #5,d4
     move      d4,la
     add       ici,la
     move      la,d5

     data 

ici  dc.w      10

     bss

la   ds.w      1

     end

No. 4:
-----
Find the value of a4 at the end of the program knowing that the label 'ad' is 
located at an address equal to $ff0 and it points to (dc.l) the number 45

Find the value of d5:

     text

     move.l    #ad,a4
     move.l    ad,d5
          
     data

ad   dc.l      45       ; it is assumed that here PC=$ff0

     end


No. 5:
-----
Find the value of d5 and a5 following this program.

     text

     move      #15,d5
     move.l    #zz,a5
     move.w    zz,d5    
     
     data

zz   dc.w      0

     end



-   I will now use the control operation instruction 'DBF' which allows the 
    execution of a loop and whose syntax is: 'DBF  Dn,loop'. This instruction 
    uses a data register Dn and a Destination Label. Each call, Dn is decremented by 1
    unit, if Dn equals -1, the program continues after the instruction that follows
    'DBF' otherwise the instruction performs a jump to the Destination address.

   example:
   --------
     text
     
     move.b    #1,d3        ;d3=1 from the beginning
     move.w    #99,d0       ;number of loops -1 (because we go until -1!)
                            
tgv  add.b     #1,d3        ;we add 1 to d3 until d0=-1, so
     dbf       d0,tgv       ;100 times in a row

     move.b    d3,var       ;then we put d3.b (=101) in var
                            ;NB: d0 equals -1 ...
     bss

var  ds.b      1

     end


No. 6:
-----
Find the value contained at the address out, the value of d0 and d5 at 
the end of this program.

     text

     move      #247,d0
     move      #3,d5

bbb  add       #8,d0
     move      d0,out
     dbf       d5,bbb

     bss

out  ds.b      2

     end


No. 7:
-----  
Find the BINARY value of the data register d1 at the end of this program.
NB:5438=%0001010100111110

     text

     move      #5391,d0
     add       #47,d0

     move      d0,dix
     move.b    in,d1

     bss

dix  ds.b      1
in   ds.w      47         

     data

nul  dc.w      5438

     end


No. 8:
-----
what will happen at 'gag'?

     text

     move.l    #gag,a2
     
gag  move.b    #100,d1
     jmp       (a2)

     end

No. 9:
-----
What will be the value of d3 after this program?

     text

     move.b    #12,lab
     move.b    #14,lac
     move.b    #15,lad

     move.l    #lab,a3
     move.b    #1,d1

fff  move.b    (a3)+,d3
     dbf       d1,fff

     add.b     (a3),-(a3)
     move.b    -(a3),d3
     add.b     (a3),d3

     bss

lab  ds.w      1
lac  ds.b      1
lad  ds.w      5

     end

     
No. 10:
------

What will be the values of d0,d1,d2,d3,a0 after this program?

     text

     move.b    #10,a
     move.b    #11,b
     move.b    #12,c
     move.b    #13,d
     move.b    #98,e

     move.l    #deb,a0
     move.b    (a0)+,d0
     move.b    (a0)+,d1
     move.b    (a0)+,d2
     move.b    (a0),d3
     move.b    -(a0),d4

     bss

deb  ds.b      1
a    ds.b      1
b    ds.b      1
c    ds.b      1
d    ds.b      1
e    ds.b      1
f    ds.l      4

     end

No. 11:
------
Find the value of a4 and d0,d1 after this program.

     text

     move.b    #3,d0
     move.l    #pil,a4

rrr  move.b    -(a4),d1
     add.b     #4,d1
     dbf       d0,rrr

     data

     dc.b      1,2,3,4,5,6,7,8,9
pil  dc.w      245     

     end

No. 12:
------
Find out what is in 'out' and the value of d2.

     text

a    equ       3
b    equ       5

     move.b    a,d2
     add.b     b,d2

     move.l    #g,a5
     move.b    d2,(a5)    
     move.b    d2,-(a5)
     move.b    (a5)+,d2
     move.b    (a5),d2

     bss

out  ds.b      1
g    ds.b      4

     end

No. 13:
------
Find the value of d1,d2,d3,d4 and a0.

     text

     move.l    #out,a0
     move.w    #2,d3
     move.w    (a0),d1
     move.w    -4(a0),d2
     move.w    -4(a0,d3),d3
     move.w    -(a0),d4
     data

     dc.l      1
     dc.w      12
     dc.w      2356
out  dc.b      15

     end 

No. 14:
------
What are the different values taken by a0 during this program?
What is the final value contained in 'res'?

     text
     
     move.l    #a,a5
     move.l    #2,d2

ttt  move.b    #1,(a5)+
     dbf       d2,ttt
     move.b    #5,(a5)

     move.l    #vec,a1
     move.b    #3,d0
     move.b    #0,d2

cde  move.l    0(a1,d2),a0
     add.l     #4,d2
     move.b    (a0),res
     dbf       d0,cde

     data

vec  dc.l      a,b,c,d

     bss

a    ds.b      1
b    ds.b      1
c    ds.b      1
d    ds.b      1
res  ds.b      1

     end

No. 15:
------
Find the value pointed by ret, at the end of this program.

     text

     move.l    #5,a
     move.l    #a,a0

     move.l    (a0)+,d2
     move.l    d2,ret

     bss

a    ds.l      2
ret  ds.l      1
     
     end

No. 16:
-----
Find the value of d0 and a0 after this program.

     text

     move.b    #3,d1
     move.b    #a,a0

mno  move.b    1(a0,d1),d0
     add.b     #14,d0
     add.b     a,d0
     dbf       d1,mno

     data

a    dc.b      0,5,6,7,8,9

     end
     
No. 17: 
------
Find the value of d3 after this program.

     text

     move.l    #a,a0
     move.b    #5,(a0)+
     move.b    #6,(a0)+

     move.b    -(a0),d2
     move.l    #a,a0
     move.b    1(a0),d3
     add.b     d2,d3

     bss

a    ds.w      1     
     ds.b      1 

     end

No. 18:
------
Find out what happens at 'stp', what does 'res' contain?
   
     text

     move.w    #5,d3
     add.b     #6,d2
     add.b     d2,d3
     move.l    #ad,a0

stp  jmp       10(a0)
 
ad   move.l    #5,res
     move.b    d3,res 

     bss

res  ds.b      1

     end

No. 19:
------
Now some quick questions:

a) If I write 'MOVE.W #0,d0', what will happen at the level of the CCR?
   And if I write afterwards 'ADD.W #-2,d0'?

b) Can we place a BYTE at an odd address?

c) How many digits is an L-M encoded in HEXADECIMAL?

d) Can we use the PC to store a digit as with a data or address register?
   (I remind you that it is a register).
   If yes, how?

e) The directive 'END' ends the program and allows the return to the DESKTOP,
   True or False? Argue.

f) A macro instruction is a subroutine called by the Linker every
   time it encounters its name in the object code.
   True or False? Explain.

g) You can use any addressing mode for the operands of the
   68000 instructions.
   True or False? 


                           -----------------


When you are finished with these exercises, look at the solutions
in the CORRIG_1.DOC file then go back to the courses.
Good luck!   ------------




PIECHOCKI Laurent
8,impasse Bellevue
57980 TENTELING


Back to ASM_Tutorial