Micro Assembly Language (M.A.L)

Diddy19

Su@mi
Micro Assembly Language (M.A.L)

Kam nevoje per ndihme...

Me eshte caktuar nje projekt (detyre shtepie) per kursin e arkitektures se kompjuterave i cili me kerkon te implementoj instruksionin IDIV (dmth pjesetimin e numrave te plote relative ) ne Micro Assembly Language,dmth ne micro-kod por me kusht qe te mos mbeshtetet ne zbritjet e njepasnjeshme ,po tek shifter-i.

Meqenese nuk kam informacion te bollshem mbi Micro Assembly Language,do me ndihmonit shume edhe me pak informacion mbi menyren se si mund ta ndertoj programin;kerkoj thjesht te di nga duhet t'ia nis ,ku mund te mbeshtetetm apo çfare duhet te kem parasysh...Thnx in advance! /pf/images/graemlins/smile.gif
 

ludwig

Primus registratum
Re: Micro Assembly Language (M.A.L)

Une di si te perdore idiv ne assembler por nuk kuptoje c'fare kerkon te thuash me zbritjet e njepasnjeshme dhe shift. Po te sqarohesh edhe mund te te ndihmoje.

shendet
 

ludwig

Primus registratum
Re: Micro Assembly Language (M.A.L)

Ketu ke nje pjese nga nje tutorial per assembler nqs te ben pune:
---------------------------------------------------

Division operates in the same way as multiplication. Word
division operates on the DX:AX pair and byte division operates on
the AH:AL pair. There are two instructions, DIV for unsigned
division and IDIV for signed division. After the division:

byte AL = quotient, AH = remainder
word AX = quotient, DX = remainder

Both DIV and IDIV operate on BOTH registers. For bytes, they
consider AH:AL a single number. This means that AH must be set
correctly before the division or you will get an incorrect
answer. For words, they consider DX:AX a single number. This
means that DX must be set correctly before the division, or the
result will be incorrect. Why did Intel include AH and DX in the
division? Wouldn't it have been easier to use just AH (or AX for
word division) and put the quotient and remainder in the same
place? These instructions are actually designed for dividing a
long number (4 or 8 bytes). How it works is pretty slick; you'll
find out about it later in the book.

How do you set AH and DX correctly? For unsigned numbers, that's
easy. Make them 0:

mov al, variable
mov ah, 0
div cl ; unsigned byte division

For signed division, set AH or DX to 0 (0000h) if it is a
positive number and set them to -1 (FFFFh) if the number is
negative. This is just standard sign extension that was covered
in the chapter on numbers. Fortunately for us, Intel has provided
instructions which do the sign extension for us. CBW (convert
byte to word) correctly extends the signed number in AL through
AH:AL. CWD (convert word to double) correctly extends the signed
number in AX through DX:AX. The code is

mov ax, variable5
cwd
idiv bx ; signed word division

Of course with these two instructions you can convert a byte to a
double word.

mov al, variable6
cbw
cwd
idiv bx ; signed word division

first converting to a word, then to a double word.
--------------------------------------------
Ketu flitet per 16 bit. Per ta kaluar ne 32 nuk eshte e veshtire.
 

Diddy19

Su@mi
Re: Micro Assembly Language (M.A.L)

Hmmm,me duket se po flasim per dy gjuhe komplet te ndryshme....

Ketu poshte po te jap nje shembull,nje miniprogram qe numeron numrin e bit-eve te barabarte me 1 kur jepet nje numer binar me 32 bit...gjithe kjo sa per te kriju nje ide rreth asaj per te cilen une po kerkoj ndihme...

contabit.mal

OPC=nr.me 32 bit
TOS=jep numrin e biteve 1.Sa here qe gjen nje bit te barabarte me 1,regjistri TOS rritet me 1 (njesi)....

.label inizio 0x00
.default goto fine

inizio TOS=0;goto conta0

conta0 Z=OPC;if(Z)goto fine;else goto conta1

OPC=OPC

conta1 N=OPC;if(N)goto INC;else goto conta2

conta2 H=OPC;goto conta3 //kopjon ne H vleren e OPC-se

conta3 OPC=OPC+H;goto conta0

INC TOS=TOS+1;goto conta2
fine goto fine
 
Top