machine language code

All 680x0 related coding posts in this section please.

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

machine language code

Postby charles » Tue May 09, 2017 11:33 pm

its been a while..
im curious about machine language code once again .
I have a small bit of code I wish to read and decipher .
but
its in machine language ..(&H60006...etc etc etc )

my question is how to identify the commands so to exactily figure out what the machine code is computating?

charles
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
Ragstaff
Atari Super Hero
Atari Super Hero
Posts: 610
Joined: Mon Oct 20, 2003 3:39 am
Location: Melbourne Australia
Contact:

Re: machine language code

Postby Ragstaff » Wed May 10, 2017 5:44 am

Here's a page of 68k opcodes.
68kOpcodes.png


You will also need a memory map of the ST, there's some nice ones on the Wiki but it's down at the moment.

Of course, I'm being a little obtuse here Charles. I think you need to do more background reading on how a CPU works before posting a question like this. And perhaps at least do a "hello world" and a few things in assembler before moving on to reading machine code directly from memory.
You do not have the required permissions to view the files attached to this post.

User avatar
Greenious
Hardware Guru
Hardware Guru
Posts: 1161
Joined: Sat Apr 24, 2004 5:39 pm
Location: Sweden

Re: machine language code

Postby Greenious » Wed May 10, 2017 6:56 am

Reading/writing machine code on a 8 bit CPU is hardcore. Doing it on a 16 bit CPU requires serious autism. :-D

Problem is, an 8 bit CPU only got that many possible opcodes for instructions (2^8=256), with a 16 bit CPU like the 68k, you got thousands with all the possible iterations of adressing modes and whatnot. In theory as many as 2^16=65536. With 32-bit...

But it was common for the better coders on C64 and other 8-bit computers to write directly in machine code, since an assembler would use up way to much of that valuable ram... (nowadays with emulators and PC-based development tools for the 8-bit CPU's, most do it in assembler I think)

If you got devpac, you can always put the code in dc.b statements, compile it and look at it through the debugger.

Or use a debugger and type the opcodes into memory directly.
Updated my guides as of june 28th, 2016. Check'em out and feedback!
viewtopic.php?t=5040

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Wed May 10, 2017 10:41 am

thats how I used to do it greenious !!
thanks ,,haven't coded in five years .unpractised and dull,,was unfamiliar...and even back then didn't perform too much asm.

I tried breifily loading the statements into tt-digger
but nothng came clear ...
question would you simply type
&H60080000 &H41FA &HFFF62228
&H44A10 &H6754B2BC &HFFFFFFF &H62407003

or separate each code on its own line in st digger?
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
Greenious
Hardware Guru
Hardware Guru
Posts: 1161
Joined: Sat Apr 24, 2004 5:39 pm
Location: Sweden

Re: machine language code

Postby Greenious » Wed May 10, 2017 7:47 pm

I would do dc.w statments in Devpack, like this:

dc.w $H600, $8000, $H600, $8000, $H600, $8000

compile and load it up in the debugger. Haven't used digger so I wouldn't know how to do...

Remember, everything needs to be word aligned. The numbers you use are off. 9 hexnumbers are a longword and a nibble... 5 hexnumbers a word and a nibble,
Updated my guides as of june 28th, 2016. Check'em out and feedback!
viewtopic.php?t=5040

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Wed May 10, 2017 11:42 pm

oh don't you rush me greenious ,,,
you can be certain I will post my results
its a small 50-100 statement code segment so hold on to your hat
will return shortly .....thank you!
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Thu May 11, 2017 2:02 am

CODE LAUNCH PARTY DID NOT LEAVE THE GROUND ....DEVPAK JUST SENT A BUCH OF ERROR REPORTS
INCLUDED IS THE MACHINE CODE AT HAND .......

ITS A REATTEMPT AT DEVPAC AFTER FEW YEARS SO SIT BACK AND RELAX WHILE I READ RAGSTAFFS NIG HANDY LITTLE CHART.......

Code: Select all

&H60080000 &H41FA &HFFF62228
&H44A10 &H6754B2BC &HFFFFFFF &H62407003
&HE389E209 &H8810007 &HB07C0003 &H67084A01
&H670408C1 &H71401 &HE09AE089 &H51C8FFE2
&H8020017 &H670408C2 &HF0802 &H1F6706
&H820080 &H80002142 &H47000 &H4E75217C
&HFFFFFFF7 &H470FF &H4E75B2BC &HFFFFFFF7
&H62167003 &H1401EE9A &HE08951C8 &HFFF8E89A
&H2820FFF &HFFFF60CE &H217C0FFF &HFFFF0004
&H70FF4E75
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Thu May 11, 2017 2:04 am

I KNOW 4E75 IS RTS OR RTE FFFF0004 THE MIDI ACIA?
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2257
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: machine language code

Postby lp » Thu May 11, 2017 6:50 am

Digger can display instruction mnemonics, no need for all the hex. lol First step might be reading digger manual.

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Thu May 11, 2017 10:39 am

I know , its hex im trying to convert back to asm
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
BenOVR
Atariator
Atariator
Posts: 25
Joined: Wed Nov 02, 2016 7:54 pm
Contact:

Re: machine language code

Postby BenOVR » Thu May 11, 2017 11:50 am

Code: Select all

Start:
             bra.s    L01000A                       ; 6008
             ori.b    #$0,d0                        ; 0000-0000
             lea      $fffe(pc),a0                  ; 41FA-FFF6
L01000A:
             move.l   $4(a0),d1                     ; 2228-0004
             tst.b    (a0)                          ; 4A10
             beq.s    L010066                       ; 6754
             cmp.l    #$fffffff,d1                  ; B2BC-0FFFFFFF
             bhi.s    L01005A                       ; 6240
             moveq    #$3,d0                        ; 7003
L01001C:
             lsl.l    #1,d1                         ; E389
             lsr.b    #1,d1                         ; E209
             bclr     #$7,d1                        ; 0881-0007
             cmp.w    #$3,d0                        ; B07C-0003
             beq.s    L010032                       ; 6708
             tst.b    d1                            ; 4A01
             beq.s    L010032                       ; 6704
             bset     #$7,d1                        ; 08C1-0007
L010032:
             move.b   d1,d2                         ; 1401
             ror.l    #8,d2                         ; E09A
             lsr.l    #8,d1                         ; E089
             dbf      d0,L01001C                    ; 51C8-FFE2
             btst     #$17,d2                       ; 0802-0017
             beq.s    L010046                       ; 6704
             bset     #$f,d2                        ; 08C2-000F
L010046:
             btst     #$1f,d2                       ; 0802-001F
             beq.s    L010052                       ; 6706
             ori.l    #$808000,d2                   ; 0082-00808000
L010052:
             move.l   d2,$4(a0)                     ; 2142-0004
             moveq    #$0,d0                        ; 7000
             rts                                    ; 4E75
L01005A:
             move.l   #-$9,$4(a0)                   ; 217C-FFFFFFF7-0004
             moveq    #-$1,d0                       ; 70FF
             rts                                    ; 4E75
L010066:
             cmp.l    #-$9,d1                       ; B2BC-FFFFFFF7
             bhi.s    L010084                       ; 6216
             moveq    #$3,d0                        ; 7003
L010070:
             move.b   d1,d2                         ; 1401
             ror.l    #7,d2                         ; EE9A
             lsr.l    #8,d1                         ; E089
             dbf      d0,L010070                    ; 51C8-FFF8
             ror.l    #4,d2                         ; E89A
             andi.l   #$fffffff,d2                  ; 0282-0FFFFFFF
             bra.s    L010052                       ; 60CE
L010084:
             move.l   #$fffffff,$4(a0)              ; 217C-0FFFFFFF-0004
             moveq    #-$1,d0                       ; 70FF
             rts                                    ; 4E75
Last edited by BenOVR on Thu May 11, 2017 12:13 pm, edited 2 times in total.

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2257
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: machine language code

Postby lp » Thu May 11, 2017 12:12 pm

charles wrote:I know , its hex im trying to convert back to asm


No, you don't know. instruction mnemonics = asm as you call it
Digger can easily output the listing above that someone else has so graciously done for you.

User avatar
BenOVR
Atariator
Atariator
Posts: 25
Joined: Wed Nov 02, 2016 7:54 pm
Contact:

Re: machine language code

Postby BenOVR » Thu May 11, 2017 12:21 pm

Basically you can use any assembler/disassembler to do it.
Just transform the hexa data to a form your assembler understand. Assemble the thing. Then use the disassembler to get the assembler listing.

For instance I used vasm to assemble to binary the hexa sequence after converting it to the proper motorola syntax (dc.l $60080000 ...). Then I used sourcer68 my own disassembler to get the listing.

On the Atari I would have use GENST and MONST as they are the tool I know the best. And for such a simple thing to disassemble monst would have done the work just fine.

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Thu May 11, 2017 10:59 pm

thanks benovr
here is what happened last night for the hour or so I had to try:

yes i was off to a rough start ,,,

forgot to indent or "tab" the devpak listing so I received errors
and forgot that
hex &hxx under devpak
is $XX

sooner or later !!!
...first time after five years , stuff doesn't come back quickily


im not sure if anybody here knows what this is ,
but the source code just calls it a vlq ,,
short for variable length quanity
I know in basic I can write one that's about five or six lines of code

was curious..(and still am ) at what all these extra command/functions are
within this chunky packed code...

this is wiki on v.l.q.
https://en.wikipedia.org/wiki/Variable-length_quantity
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Thu May 11, 2017 11:06 pm

o.t.
who did the art for the gfa basic on your avatar lonny?
cool!!
that's how signals are transported to satellite..in little packets
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Thu May 11, 2017 11:15 pm

benovr
the code ,
I have a question
the statement
dbf d0,L010070 ; 51C8-FFF8

appears to me I would enter in devpak as two dc.w statements
do I type in ?
DC.W $51c8,$FFF8
or
is it a long
DC.L $51c8fff8

different in appearance than a code like
ror.l #7,d2 ; EE9A

which would be
dc.w $ee9a
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: machine language code

Postby charles » Fri May 12, 2017 12:12 am

nemonics are really drifting ,,, easily identifying the way they forged is difficult
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
BenOVR
Atariator
Atariator
Posts: 25
Joined: Wed Nov 02, 2016 7:54 pm
Contact:

Re: machine language code

Postby BenOVR » Fri May 12, 2017 12:15 am

As M68k memory order is big endian

Code: Select all

   dc.b $51,$C8,$FF,$F8
   dc.w $51C8,$FFF8
   dc.l $51C8FFF8

are exactly the same byte sequence in memory.
My disassembler splits the opcode to help understand how it's encoded.

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2930
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: machine language code

Postby AtariZoll » Fri May 12, 2017 8:42 am

charles wrote:I know , its hex im trying to convert back to asm

Well, this sentence describes perfectly this really pointless thread :D
I think Charles, that you should get some Altair prehistoric computer, from seventies of previous century + where binary/hex input was the only way.

With some more modern computer, and it includes those released years before Atari ST people using assemblers for that task. Furthermore, assembler does much more - it calculates addresses, makes relocation table, checks for errors. Then there is lot of options - so many things. Of course we can not go in all it here, that's long story.

I do frequently some simple code changes/patches in game adaptations - like unlimited lives, inserting code for exiting from game, saving gamestate and like. In such cases I usually use direct machine code, just because all it is in my head, and there are some 10 instructions involved.
Like:

Code: Select all

  lea  address,a1
  lea  rdLoc+gamex-rmdc.w,a0
  move.w  #$4EF8,(a1)+
  move.w  a0,(a1)

$4EF8 is short jump in lowest 32KB space.

But if there is need for something what I don't know, instead of looking is some tables for machine code, I just use mnemonics this way:

Code: Select all

   lea  patch(pc),a0
   lea  dest,a1
   moveq  #4,d1   * for 10 bytes
 .cop  move.w (a0)+,(a1)+
   dbf  d1,.cop
 * continuing launch here ,,,,
.....
......
patch  clr,l  d0
   move.l  #value,d1
   rts
There is way to stop global warming.


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 1 guest