English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 08 November 2007, 20:09   #1
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
Please help

Hi,
I'm new to amiga stuff and I need to make some examples of programs in assembler for my school project. Can you give me a hint what do I need to do that? (do I need os, or is there a way how to get some free/opensource os, or can i do it without os)
I've downloaded WinUAE and got Kickstart1.3. I found some free os on Aminet but I cant boot them.
Thank you
raptor_13 is offline  
Old 08 November 2007, 20:15   #2
musashi5150
move.w #$4489,$dff07e
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 38
Posts: 2,302
Sounds interesting

What do these programs need to do? Do they have to be shown working or will sourcecode be enough?
musashi5150 is offline  
Old 08 November 2007, 22:13   #3
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
It should be only some small programs showing assembler. But I think I will have to show it work also.
raptor_13 is offline  
Old 11 November 2007, 19:43   #4
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
I would be thankful for any advice
raptor_13 is offline  
Old 11 November 2007, 20:39   #5
musashi5150
move.w #$4489,$dff07e
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 38
Posts: 2,302
I've made you a quick bootable ADF file for your school project. I've tried it on an Amiga1200 config and it works ok - won't work on Amiga500 config as the disk requires Kickstart2+ ROM.

What does this mean? Find an Amiga1200 Kickstart 3.0 / 3.1 ROM and use WinUAE with that The disk is in The Zone! for you.

Boot the disk with an A1200 config and wait for it to load
Open "Devpac" disk icon (double click)
Open "Devpac" drawer icon (double click)
Open "Devpac" program (double click)
Use the Right-Mouse menu to choose "Project->Load"
Choose the file "Flash.s"
Use the Right-Mouse menu to choose "Program->Run"
Once assembled, close the window that opened
Enjoy the result

I've tried to comment the code as throughly as possible... hope this helps you out

Last edited by musashi5150; 11 November 2007 at 20:45.
musashi5150 is offline  
Old 11 November 2007, 22:03   #6
Graham Humphrey
Moderator
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 33
Posts: 11,061
And just to pre-empt any "how do I access the Zone?" questions

http://eab.abime.net/faq.php?faq=vb_...ezone_faq_item
Graham Humphrey is offline  
Old 12 November 2007, 18:22   #7
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
Thank you both very much, guys. Especially to you, musashi5150. Hope I'll cope it now.
raptor_13 is offline  
Old 12 November 2007, 22:42   #8
musashi5150
move.w #$4489,$dff07e
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 38
Posts: 2,302
You're welcome
musashi5150 is offline  
Old 03 December 2007, 16:57   #9
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
Me again.I've got some problems with opening the libraries in devpac You've made for me(it's asking for Include3.1 disk). can u give me an advice again? i've spent some days looking for that disk and tryin to make my own but i was unsuccesful. now i don't know if the disk is really missin(i've found some post about devpac having included that disk) or i've only wrote the bad code(what doesn't make any sense to me according to compilators warning).
raptor_13 is offline  
Old 03 December 2007, 17:50   #10
musashi5150
move.w #$4489,$dff07e
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 38
Posts: 2,302
Yes, that disk doesn't have the "include" files. If you are running the code I wrote for you this isn't a problem as I'm not using them.

If you are running code from somewhere else then you will need to find them somewhere. I'm sure someone here can help you out with an include disk....
musashi5150 is offline  
Old 03 December 2007, 19:14   #11
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
Thanks
raptor_13 is offline  
Old 05 December 2007, 15:37   #12
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
Two more qestions:
1. how to make some kind of executable file(i've written the program and its assemblied without errors, i can run it from devpac, but i want to run it from OS)
2. ive written program that is printing Hello world message, but when i run it from devpac, the window with message shows only for a very short time, how to make the devpac wait for some users action
thanks
raptor_13 is offline  
Old 05 December 2007, 15:48   #13
musashi5150
move.w #$4489,$dff07e
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 38
Posts: 2,302
1) You need to choose the "Assemble to Disk" option from the menu and then set your output folder in "Assembler Options" or "Assembler Control" (can't remember which as I'm at work).

2) I don't know a way to pause Devpac output window. You could always just run your exe from the CLI window, then it won't close.

OR

You could make your program wait for a mouse click. I think the program I wrote for you has a mouse-pause routine in it...

musashi5150 is offline  
Old 05 December 2007, 18:38   #14
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
Thanks again... :-)
raptor_13 is offline  
Old 08 December 2007, 21:03   #15
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
I needed to print a number in decimal set, so i tried to make a subroutine to convert number to string, but it is not working, can you check it, pls? iread in instruction set that 'divu' sets a destination register as following: first 16 bits remainder, last 16 result, so i tried to isolate both using logical shift... but when i try to print the string, it allways print character zero



movem.l d1-d7/a0-a6,-(a7) ;saving regs, requires sum in d1
move.l #123,d2 ;moving sum to reg d2
move.l #0,d0 ;initiating counter
loop2: divu #10,d2 ;dividing the number by ten
move.l d2,d3 ;storing the metaresult
lsl #8,d2 ;getting new value
lsl #8,d2
lsr #8,d2 ;by shifting bits
lsr #8,d2
lsr #8,d3 ;getting remainder
lsr #8,d3
add.l #1,d0 ;adding 1 to counter
add.l #'0',d3 ;setting d3 as ascci of actual number
move.b d3,-(a7) ;saving the number
cmp #9,d2 ;is d2 greater than 9?
bgt loop2 ;if yes, loop
cmp #0,d2 ;we don't want to print zero
beq jump ;skip saving d2
add.l #1,d0 ;increment counter
move.b d2,-(a7) ;saving last remainder
jump: lea.l buffer2,a2 ;getting the address of buffer
move.l d0,d4 ;saving number of chars
sub.l #1,d0 ;decrement counter
loop3: move.b (a7)+,(a2)+ ;storing the number in buffer
dbra d0,loop3 ;condition to write all chars of sum
move.l d4,d0 ;moving number of chars to d0 as return value
movem.l (a7)+,d1-d7/a0-a6 ;restoring regs
rts
raptor_13 is offline  
Old 10 December 2007, 22:54   #16
flipper
Registered User
 
Join Date: Dec 2007
Location: newark england
Posts: 19
not sure what you are intending to do but ill tell you what i can

movem.l d1-d7/a0-a6,-(a7) ;saving regs, requires sum in d1
move.l #123,d2 ;moving sum to reg d2
move.l #0,d0 ;initiating counter

so far so good

loop2: divu #10,d2 ;dividing the number by ten

this gives us the result as 12 in reg d2 the remainder is not stored here but one of the processor flags will be set to tell you there was a remainder sorry amiga is down cant say which flags

move.l d2,d3 ;storing the metaresult

12 is now in d3

lsl #8,d2 ;getting new value

this is affectively dividing 12 by 2 8 times setting carry flag if there is an odd number to start with result in this case is zero

lsl #8,d2

still 0

lsr #8,d2 ;by shifting bits

multiplying by 2 8 times - still 0

lsr #8,d2


lsr #8,d3 ;getting remainder
lsr #8,d3

multiplying by 2 8 times overflow is set if overflowed
12 becomes very large

add.l #1,d0 ;adding 1 to counter

ok

add.l #'0',d3 ;setting d3 as ascci of actual number

does this compile??? #'0'

move.b d3,-(a7) ;saving the number

this will put 0 on stack d3 is very large

cmp #9,d2 ;is d2 greater than 9?
bgt loop2 ;if yes, loop

zero is not greater than nine

cmp #0,d2 ;we don't want to print zero
beq jump ;skip saving d2

we go to jump

add.l #1,d0 ;increment counter
move.b d2,-(a7) ;saving last remainder

this is missed

jump: lea.l buffer2,a2 ;getting the address of buffer

does your compiler allocate memory for you ???

move.l d0,d4 ;saving number of chars

count of 1 is in d4

sub.l #1,d0 ;decrement counter

zero in d0

loop3: move.b (a7)+,(a2)+ ;storing the number in buffer
dbra d0,loop3 ;condition to write all chars of sum

0 is stored in buffer2

move.l d4,d0 ;moving number of chars to d0 as return value

1 in d0

movem.l (a7)+,d1-d7/a0-a6 ;restoring regs
rts

hope this helps look for some 68000 assembler tutorials on web for list of all registers and settings after all commands.
flipper is offline  
Old 11 December 2007, 02:13   #17
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 43
Posts: 3,086
Quote:
Originally Posted by flipper
not sure what you are intending to do but ill tell you what i can
What raptor_13 is trying to do is convert a 16bit binary number to a decimal string.

Quote:
Originally Posted by raptor_13
I needed to print a number in decimal set, so i tried to make a subroutine to convert number to string, but it is not working, can you check it, pls? iread in instruction set that 'divu' sets a destination register as following: first 16 bits remainder, last 16 result, so i tried to isolate both using logical shift... but when i try to print the string, it allways print character zero
I've taken a look at your code, and it seems this code:
Code:
    movem.l    d1-d7/a0-a6,-(a7)    ;saving regs, requires sum in d1
    move.l    #123,d2            ;moving sum to reg d2
    move.l    #0,d0            ;initiating counter
loop2:    divu    #10,d2            ;dividing the number by ten
    move.l    d2,d3            ;storing the metaresult
    lsl    #8,d2            ;getting new value
    lsl    #8,d2
    lsr    #8,d2            ;by shifting bits
    lsr    #8,d2
    lsr    #8,d3            ;getting remainder
    lsr    #8,d3
    add.l    #1,d0            ;adding 1 to counter
    add.l    #'0',d3            ;setting d3 as ascci of actual number
    move.b    d3,-(a7)        ;saving the number
    cmp    #9,d2            ;is d2 greater than 9?
    bgt    loop2            ;if yes, loop
    cmp    #0,d2            ;we don't want to print zero
    beq    jump            ;skip saving d2
    add.l    #1,d0            ;increment counter
    move.b    d2,-(a7)        ;saving last remainder
jump:    lea.l    buffer2,a2        ;getting the address of buffer
    move.l    d0,d4            ;saving number of chars
    sub.l    #1,d0            ;decrement counter
loop3:    move.b    (a7)+,(a2)+        ;storing the number in buffer
    dbra    d0,loop3        ;condition to write all chars of sum
    move.l    d4,d0            ;moving number of chars to d0 as return value
    movem.l    (a7)+,d1-d7/a0-a6    ;restoring regs
    rts
should be more like this:
Code:
    movem.l d1-a6,-(a7)      ;saving regs, requires sum in d1

    move.l  #123,d2          ;moving sum to reg d2
    move.l  #-1,d0           ;initiating counter, setting it to -1 will
                             ;cause d0 to contain the length of the resulting
                             ;string without the end of string marker, in dbra
                             ;format. in this case it will thus contain 2.

    lea.l   buffer2,a2       ;get buffer address, we don't need to write to the
                             ;stack first!
    add.l   #6,a2            ;String size (5 numbers+1 end of string marker)
                             ;This is enough, because the largest number is
                             ;65535, as we are using sixteen bits.
    move.b  #0,-(a2)         ;End of string.

loop2:
    divu    #10,d2           ;dividing the number by ten
    move.l  d2,d3            ;storing the metaresult

    and.l   #$ffff,d2        ;This gets rid of the remainder.
    swap.w  d3               ;And this moves the remainder to the bottom
                             ;sixteen bits. As only eight of those bits
                             ;are used, the other bits don't have to be cleared.

    add.l   #1,d0            ;increment counter
    add.b   #'0',d3          ;add ascii value of '0' to d3 to get actual number
    move.b  d3,-(a2)         ;write digit to buffer
    cmp     #0,d2            ;are there any numbers left?
    bne     loop2            ;if yes, loop

;At this point, a2 points to the start of the string.
;And d0 contains the string length (excluding the end of string marker) minus
;one, so it's in dbra format.
;Also, remember that the string doesn't necessarily starts at the beginning of the buffer!
;This means that you shouldn't save and restore a2, if you just want the start of the string.

    movem.l (a7)+,d1-a6    ;restoring regs
    rts
This is tested code, so it works (I wouldn't dare to post it otherwise) And if you have any more questions about assembler programming, please ask them, but do post them in Coders Heaven.

Last edited by Thorham; 11 December 2007 at 02:30.
Thorham is offline  
Old 11 December 2007, 15:24   #18
DamienD
Global Moderator

DamienD's Avatar
 
Join Date: Aug 2005
Location: London / Sydney
Age: 43
Posts: 16,293
Quote:
Originally Posted by Thorham View Post
And if you have any more questions about assembler programming, please ask them, but do post them in Coders Heaven.
Thread moved accordingly
DamienD is offline  
Old 12 December 2007, 00:03   #19
raptor_13
Registered User
 
Join Date: Nov 2007
Location: Slovakia
Posts: 23
ok, thank you guys for help, ill take a look at it again
raptor_13 is offline  
Old 12 December 2007, 17:14   #20
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 46
Posts: 3,644
The code can be made somewhat simpler :
Code:
    move.l  d2,-(a7)         ;save regs (d2's enough)
    move.l  #123,d2          ;moving sum to reg d2
    lea     buffer2+6,a2     ;get (end of) buffer address
    clr.b   -(a2)            ;End of string.
    moveq   #-1,d0           ;initiate counter
loop2:
    divu    #10,d2           ;dividing the number by ten
    swap    d2               ;get the remainder
    add.b   #'0',d2          ;add ascii value of '0' to d2 to get actual number
    move.b  d2,-(a2)         ;write digit to buffer
    addq.l  #1,d0            ;increment counter
    clr.w   d2               ;clear the remainder
    swap    d2               ;get the rest of the number
    tst.l   d2               ;are there any numbers left?
    bne     loop2            ;if yes, loop
    move.l  (a7)+,d2         ;restoring regs
    rts
Now you have a2 pointing on the string, and d0 containing the number of digits, ready for a dbf loop.
Also note that I can't prevent myself from optimizing all code I find

Alternatively, you can use the OS to print a number for you. See dos.library/VPrintF.
meynaf is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:57.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.08847 seconds with 14 queries