A89: hello world


[Prev][Next][Index][Thread]

A89: hello world




Hi, can someone please help me understand this supposedly simple code?
Let me start by stating what I know or what I think I know:
***any help would be greatly appreciated***
-thanks-
Steven

line 1: This does a jump to the utility library in order to clear the screen
line 2: This pushes 2 onto the stack
line 3: 2 was pushed onto the stack because of the ti rom call FontSetSys:the
2 sets the font to normal size (?).  Is a7 used on all rom calls?
line 4: Because you pushed 2 onto the stack you must also pop the 2 off the
stack: Why does this have to be done?  and why can't you just add.w or add.b?
line 5: This pushes 4 onto the stack
line 6: This loads the address of string to the a0 register: what is the
"(pc)" for?
line 7: This pushes the address of the string to the stack: what happened to
the 4 that was pushed to the stack?
line 8: This pushes 0 onto the stack: what happened to the 4 and the address
of the string that was previously pushed onto the stack?
line 9: This pushes 0 onto the stack again: why is it pushed again?
line 10: This does the rom call DrawStrXY which displays the string: maybe i
think i know what is going on: the first thing that you need to do to call
this rom call is to push the address onto the stack then you must push the 2
coordinates onto the stack:0,0 and the rom call takes care of the rest?  But I
still don't know where the 4 comes in place.
line 11: It says restore the stack pointer...but where does the 10 come from:
i only count 4 then 0 then 0 again=4...i don't know how that works.  Why do
you even have to "restore" the stack...i remember with the z80 you didn't HAVE
to pop a register back after pushing it?
line 12: this does a jump to the utility library which basically does a loop
waiting for a key to be pressed.
line 13: returns to the shell when a key is pressed...What other return
statements are there?

_main:
    ; Execution will start here, at the _main label
  1  jsr      util::clr_scr          ; clear the screen
  2 move.w   #2,-(a7)               ; use font #2 (large font)
  3  jsr      tios::FontSetSys       ; set the font
  4  add.l    #2,a7                  ; clean up the stack
  5  move.w   #4,-(a7)               ; move the first param to the stack
  6  lea      string(pc),a0          ; move adress of string to the stack
  7  move.l   a0,-(a7)
  8  move.w   #0,-(a7)               ; push position
  9  move.w   #0,-(a7)               ; push position
 10 jsr      tios::DrawStrXY        ; call the DrawStrXY ROM function
 11 add.l    #10,a7                 ; restore the stack pointer
 12 jsr      util::idle_loop        ; library routine which waits until a key
                                    ; is pressed.
 13 rts

string:
    dc.b "Hello, World!",0
_comment:
    dc.b "Hello World example",0

    end


Follow-Ups: