home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
POWERMAG
/
POWER121.MSA
/
POWER_12.DK1_ASSEMBL3.PWR
< prev
next >
Wrap
Text File
|
1989-12-30
|
6KB
|
121 lines
***********************************************************************
* Assembly Language Programming *
* By *
* Chris Sharp *
***********************************************************************
Hi there, and welcome to the tutorial that doesn't try to teach you
how to pre-shift sprites, before you can print a line of text to
the screen!
The whole point of this tutorial really is to teach the absolute novice
how to program in assembly language. Absolutely no prior knowledge is
assumed.
As you probably know, Assembly language is the closest language to
machine code, which means that it can create the fastest programs,
which can be very important when programming a speed critical game
like space invaders, or a huge desktop publishing program, that needs
to run fast, in order to keep the users attention.
This time, I am going to show you how to write a very primitive
password entry system.
First of all, we have to decide what we want the program to do. In this
case, it is going to be the password protection system.
Once we know what we want the program to do, we have to decide how to
do it. Right then, the program I am going to write is going to ask for
3 letters or numbers to be entered, before the system exits to DOS.
The password program will be copied to an AUTO folder, and so will run
when the disk is inserted into the computer.
O.K. So, we know what the program is and what we want it to do. Now
all we have to do is program it! Which of course is easy (once you
know how, which is why I am trying to help you to learn)!
The program is below. I have commented every line, so it should be
pretty obvious what everything is doing.
I showed how to correct the stack in a previous issue of POWER, so if
you don't have that copy, you'd be wise to order it now, as a whole
column was given to show how to do this!
Ignore the semi-colon's in the listing. I typed this program in, and
then wrote the text to go with the program. I needed the semi-colons
when I was programming the password system, and have simply not
bothered to take them out.
Try typing in the program below, and running it.
***************************************************************************
start:
PEA mess(PC) Tell GEM where to find message in memory.
MOVE #9,-(A7) Ask for Function 9... Print a string.
TRAP #1 Call GEMDOS (Tell computer to do the instruction)
ADDQ.L #6,A7 Correct Stack
input:
BSR keypress Get the users keypress
CMP #'4',D0 is it the number '4' ?
BNE input If its not then branch to the label Input:
;if it is, then continue down the listing.
BSR keypress Get the second keypress
CMP #'5',D0 is it the number '5' ?
BNE input If its not, then go right back to the begining,
;where the user will have to enter the password
;all over again. However, if it is a 5, continue
;down the listing.
BSR keypress Get the third keypress.
CMP #'8',D0 is it an '8' ?
BNE input If it isn't, then go right back to the beginning,
;where the user has to enter the password all
;over again. If it is correct, then well done,
;the correct password has been entered!
BRA exit Correct password has been entered, so this
;command will take us to the exit procedure
;which will end this program, and return us
;to TOS.
keypress:
MOVE #8,-(A7) Call function 8, which is c_necin (get a keypress)
TRAP #1 Call GEMDOS to execute our command.
ADDQ.L #2,A7 tidy stack
RTS return from subroutine
exit:
Move.w #0,-(a7) call function 0.
TRAP #1 Call GEMDOS to execute our command.
mess DC.B "Please enter the password.If you make a mistake,start again.: ",0
*****************************************************************************
When you have got the program working, the best way to understand what is
happening is to modify lines of the program, assemble it, and then see
what happens. Only modify one line per go though, otherwise you won't know
which line had which effect!
If you can't understand the program, and you DO have the other copies of
POWER, with the tutorial parts 1 and 2, then write to me and I'll try to
sort out your problem. Remember to enclose a stamp and an envelope.
If you don't have the other copies of POWER, order them and read the
other tutorials first. If you still have no joy, write to me at the
following address -:
Chris Sharp
Supreme Software
4 Sunnycroft Lane
Dinas Powys
South Glamorgan
Wales
CF64 4QQ