home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / falcon / program / x_debug / tutorial / assemble.s < prev    next >
Text File  |  1993-01-02  |  1KB  |  71 lines

  1.  
  2. * (simple) assembly-language test program for X-Debug Tutorial
  3.  
  4. * assembled using Devpac 2
  5.  
  6.     opt    x+            Extended debug
  7.     
  8. start    move.l    #hellotx,a0
  9.     bsr    print
  10.     
  11.     move.l    #12345,d0
  12.     bsr    print_num
  13.  
  14.     clr.w    -(sp)
  15.     trap    #1
  16.         
  17.  
  18. * print the number d0.w in decimal, unsigned
  19. * leading zeros, just to make life easier
  20. * (not a terribly efficient algorithm)
  21.  
  22. print_num
  23.     subq.w    #6,sp                max 5 digits+null
  24.     move.l    sp,a0                use temp buffer on stack
  25.     
  26.     divu    #10000,d0
  27.     add.b    #'0',d0
  28.     move.b    d0,(a0)+
  29.     clr.w    d0
  30.     swap    d0                get remainder
  31.  
  32. thousands
  33.     divu    #1000,d0
  34.     add.b    #'0',d0
  35.     move.b    d0,(a0)+            and so on
  36.     clr.w    d0
  37.     swap    d0
  38.  
  39. hundreds
  40.     divu    #100,d0
  41.     add.b    #'0',d0
  42.     move.b    d0,(a0)+            and on
  43.     swap    d0
  44.     
  45. tens
  46.     divu    #10,d0
  47.     add.b    #'0',d0
  48.     move.b    d0,(a0)+
  49.     clr.w    d0
  50.     swap    d0
  51.  
  52. digits
  53.     add.b    #'0',d0
  54.     move.b    d0,(a0)+
  55.     clr.b    (a0)                null term it
  56.     move.l    sp,a0
  57.     bsr    print                and print it
  58.     addq.w    #6,sp
  59.     rts
  60.     
  61.  
  62. * print the message at a0
  63. print    move.l    a0,-(sp)
  64.     move.w    #9,-(sp)
  65.     trap    #1
  66.     addq.w    #6,sp
  67.     rts
  68.  
  69.     DATA
  70. hellotx    dc.b    'A simple program',13,10,0
  71.