Tải bản đầy đủ (.pdf) (5 trang)

cac lenh can thiet trong lap trinh asm

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (95.67 KB, 5 trang )

!"#$%"&$%'()(*$&+,(
(
&%$/01&2$.(&$(3-4563785(
(
(
• 3-45(7%192&+1&0%+((Microprocessor*without*Interlocked*Pipeline*Stages)*
* * *
o :;<#2&(=$ %/(> (?(#'&+,(
o (:;( %+@2 ,&+% ,(
o A",21( ,&%01&2$.,(
o 7,, +B#C'(D 2%+1&2E+,(
*
• 5',&+B(F"CC,(G$%( H0&6 I0&H0&(
( ( (
*
• 8+H%+,+.&"&2$.($G(.0B#+% ,(
( ( (
o J+K"/+12B "C((L#",+()MN(.$&"&2$.(
(
o !2&&C+<O./2".(#'&+($%/+%(
*
*
• IH+%"&2$.($G((3785((MIPS*Development*And*Runtime*Simulator)*
(
* * * *
*
*
3-45(7%1921&+1&0%+((32 *regi sters)*
( *
****$0*or*$zero** ** ‐*always*con tains*0.***
****$t0*‐*$t9*** * ‐*use*for *tem porary*storage*of*data*


****$s0*‐*$s7*** * ‐*use*to*hold*address*locations*in*mem ory**
****$a0*‐*$a3* * ‐*use*as*arguments*to *syst em*c alls*
****$v0 *and*$v1** * ‐*use*as*arguments *to*system*calls*
*
A",21(3-45(2.,&%01&2$.,(G$%(C"#(&$/"'(
(
7%2&9B +&21( L8 < &'H+N( ,&%0 1&2$.,(
"//((P&:QP&)QP&;* ****#$t 3*<‐* cont ents *of*$t1*+*contents *of*$t2*
(
"//2((P&:Q(P&)Q R* ****#$t3 *<‐*conte nts*of*$t1*+*5(
* * *
* 3+B$% '(711+,,( ,&%01&2$. ,(
( C=(( P&)QC"#+C* ** ***#*$t1*<‐*value*of*word*stored*at*memory*
* * * * * **************ad dress/location*specified*by*label((
*
* C=( P&)Q:LP,SN***********#*$t 1*<=* valu e*of*word*stored*at*memory*
* * * * * * ***ad dress*specified*by*base*ad dress*
* * * * * * **in*$s0*+*3***
****
* ,=(( P&)QC"#+C* * ***#*store*value*of*word*in*$t1*to*address/*
* * * * * *******location*in*m emory**specified *by*label%
%
* *(C=(and*,= (can* also*be*byte* or*halfword,*i.e.*C# ,*C 9Q(,#Q,9)*
* * *
* 4,+ 0/$<2.,&%01 &2$.,(
* C2((( (P&)Q(:(* ************#*$t1*<‐*3* *
* *
* C"((( P,) Q(C"# +C(***********#*$s1*<‐*address*c orresponding*to*label**
(
( B$E+QP&)QP&;* ***********#move*contents*of*$t2*to*$t1(

D2% +1&2E+,*< *tell* asse mbler*how*to*translate*program,*but*are*not*
instructions.*
*
* T&+K&(
( T@C$ #C(B"2.(
( ( Precede s*your*&+K&(,+@B+.&*(program*ins tructions),*and**
* * specifies*B"2.*as*a*globa l*symbol*(rec ogni zed*by*other**
* * files*in*a*mu lti‐fi le*projec t**
* *
T/"&"(
( Precede s*your*/"&"(,+@B+.&*(data*de clarations)*
*
(text*segment *can* come*before*data*seg men t,*or* vice* versa)*
*
( T",122((U, &%2. @V(
* * Defines* a*str ing*of*characters*(each*character*is*stored*as**
* * * a*1‐ byte*ascii*value)*
*
* T",122W(U,&%2.@V(
Defines* a*nu ll‐terminated*string*(ends*with*a*null*byte)( *
( (
( T#'&+(#SQ#)Q #;(
( ( Defines* and*initi alizes*subsequen t*bytes*in*memor y*
( (
( T9"CG(9SQ9)Q9 ;(
( ( Defines* and*initi alizes*subsequen t*hal f‐words*( 16‐bit**
* * values*–*alignment*forced*to*next*eve n*address*
*
( T=$ %/(=SQ= )Q=;(
( ( Defines* and*initi alizes*subseq uent*words*( 32‐bit*values)*

* * –*alignment *forced*to*next*word*address*(multiple *of*4)*
(
( ( T,H"1+(.(
( ( allo cates*n*bytes*of*space,*usually*initialized*to*0*
(
5X5F7! !(G0.1&2$.,( $E+%E2+=(*
( System*services*used*for*input/output*
(
J$=(&$(0,+(5X5 F7!!(,',&+B(,+%E21+,(
1.*Load*the*service*number*in*register*$v0 .*
2.*Load*argumen t*val ues,* if*an y,*in*$a0, *$a1, *or*$a2*
3.*Is sue*the*SYSCALL*instruction.*
4.*Retrieve*r etur n*values,*if*any,*from*resu lt*registers**
(
Y"#C+($G(F$BB$.C'(Z ,+/(5+%E21+,((
Service
$v0
Arguments
Result
print integer
1
$a0 = integer to print


print
string
4
$a0 = address of null-
terminated string to print


read
integer
5


$v0 contains
integer read
read
string
8
$a0=address of input buffer
$a1=max. # of chars. to read

exit (stop
execution)
10



print
character

11
$a0=character to print

read
character

12


$v0 contains
character read
open
file

13
$a0=address of null-terminated
string containing filename
$a1=flags
$a2=mode
$a0 contains
file descriptor
(- if error)
read
from file

14
$a0 = file descriptor
$a1=address of output buffer
$a2=max. # of chars to read
$a0 contains
# of chars. read
(0=EOF,- if error)
write
to file
15
$a0 = file descriptor
$a1=address of output buffer
$a2= # of chars to write
$a0 contains #

chars. written
(- if error)
close
file
16
$a0 = file descriptor

* *
Examples of Simple I/O for lab today
* *
#*H%2.&(".(2.& +@+% ((
( C2(PESQ)* #*load*service*number*in to*$v0( ( (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
( C2(P"SQR ( #* load*value*to*be*printed*i nto*$a0( ( ( ((((((((((((((((((((((((
( ,',1"CC* * (
*
#H%2.&("(.0CC<&+%B2."& +/(,&%2. @**
* C2(PESQ?(* #load*s ervice*number*in*$v0( ( ( ( ( (
( C"(P"SQH%$BH&[ ,&%2.@( ((
* * * #*load*a ddress*of*string*to*be*printe d*into*$a0*
* ,',1"CC((
(
* #*the*null‐termi nated*string* must*be* defined*in*data*segment*
* T/"&"(
(((((H%$BH&[,&%2 .@\((T",122W(UO.&+% ( "(E"C0+\( U* ( ( (
( (
#(%+"/(2.(".(2.&+@+%**
* C2(PESQR( #load*s ervice*number*in*$v0( ( ( ( ( (
( ,',1"CC* #the*value*entered*by*the*user*is*returned*in*$v0( (
( (
( B$E+(P&SQPES* #store*value*entered*into* another*register* *

*
#*%+"/(2.("(,&%2.@* *
* C2(PESQ]((( * ***#load*service*number*in * $v0*
C"(P"SQ".,=+%* ***#pu t*address* of*answe r*string*in* $a0* *
* C=(P")Q"C+.@&9* ***#put*length*of * string*in*$ a1* * * * *
,',1"CC* **#*string*is*stored*in*memory*at*the*answer%*lo cation*
*
#answe r*and*ale ngth*mu st*be*defined*in*da ta*segme nt*
*********T/"&" (
".,=+%\((T,H"1+ ( RS**#*allocate*sp ace*for*str i ng*to*be* stored*
* "C+.@&9\ ( ( T =$%/(RS***#length*of*string*to*be* entered(
*
#(&+%B2."&+(+K+10& 2$.($G(H%$@%"B *
C2(PESQ)S( #load*s ervice*number*in*$v0( ( ( (
( ,',1"CC* #should*alway s*be*the* f i nal*instructions*i n*your*pr ogram*
* (

×