Вы находитесь на странице: 1из 18

emu8086 Assembler - Frequently Asked Questions

The Microprocessor Emulator and 8086 Interated Assembler


Please make sure you have the latest version of EMU8086
(if unsure click help -! check "or an update### from the menu)
The solutions may not work in previous versions of the emulator/assemler!
$eneral recommendation "or %indo&s '( users)
*# click "tart!
+# click #un!
,# type $e%plorer$
-# select from the menu $Tools$ &' $(ol)er *ptions$!
.# click $+iew$ ta!
6# select $"how hi))en files an) fol)ers$!
/# uncheck $,i)e e%tensions for known file types$!
To step forwar) press F8 key- to run forwar) press F0 or press an) hol) F8! To step
ackwar) press F6 key- to run ackwar) press an) hol) F6! The ma%imum numer of
steps&ack can e set in emu8086#ini! (or e%ample.
MA'IM1M23TE(324A567de"ault / y )efault it is set to 000 for a etter
performance!
or
MA'IM1M23TE(324A567*000 / this value shoul) not e over 10262!
Question)
3hy this co)e )oesn4t work5
org 100h
myArray dw 2, 12, 8, 52, 108
mov si, 0
mov ax, myArray[si]
ret
3olution)
There shoul) e a 6ump over the variales/array )eclaration.
org 100h
jmp code
myArray dw 2, 12, 8, 52, 108
code: mov si, 0
mov ax, myArray[si]
ret
(or the computer all ytes look the same- it cannot )etermine if it4s an instruction or a
variale! ,ere is an e%ample of M89 A:; . instruction that can e co)e) with simple
variale )eclarations.
org 100h
byte1 db 17
byte2 db 5
ret
3hen you run this pro7ram in emulator you can see that ytes */6 an) . are
actually assemle) into.
!"# A$, 5
This is very typical for 9on <eumann Architecture to keep )ata an) instructions in
the same memory- 8t4s even possile to write complete pro7ram y usin7 only =4
()efine yte) )irective!
org 100h
db 2%5 & j'mp(((
db & ) six bytes *orward +,eed to s-ip characters.
db 72 & ascii code o* /0/
db 101 & ascii code o* /e/
db 108 & ascii code o* /1/
db 108 & ascii code o* /1/
db 111 & ascii code o* /o/
db % & ascii code o* /2/ ) 3"4 *',ctio, pri,ts ',ti11 do11ar(
db 18 & mov 35, (((( ) 35 is word 6 two bytes
db 2 & 02 ) 1itt1e e,d
db 1 & 01 ) big e,d
db 180 & mov A0, ((((
db 7 & 07
db 205 & i,t (((
db %% & 21h ) %% is 21h +hexadecima1.
db 175 & ret ) stop the program(
8086 an) all other 8ntel4s microprocessors store the least si7nificant yte at a lower
a))ress! *0+h is the a))ress of 4>4 character 9 or *00h : + bytes (6mp
instruction)! The aove assemly co)e pro)uces i)entical machine co)e to this little
pro7ram.
org 100h
jmp code
msg db /0e11o2/
code: mov 35, o**set msg
mov A0, 7
i,t 21h
ret
8f you open the pro)uce) $#com$ file in any he% e)itor you can see he%a)ecimal
values- every yte takes two he%a)ecimal )i7its- for e%ample 01; 9 E4- etc!!!
memory win)ow of the emulator shows oth he?adecimal and decimal values!
(roblem)
The screen fonts are too small or too i75!!!
3olution)
The latest version of the emulator uses Terminal font y )efault an) it is
M"<*"/=">88 compatile!8t is also possile to set the screen font to Fi?edsys from
the options! (or other controls the font can e chan7e) from
c.?emu8086?emu8086!ini confi7uration file! 8t is well known that on some locali@e)
versions of 3in)ows AP the Terminal font may e shown si7nificantly smaller than in
ori7inal En7lish version! The latest version automatically chan7es )efault font to B0
unless it is set in emu8086!ini. FI'23MA::2F8<T37"alse! The (i%e)sys font is
reporte) to e shown eCually on all systems! 8t is reporte) that for small Terminal
font < an) 0 (@ero) look very alike!
"tartin7 from version D!00&Eeta&8 the inte7rate) assemler of emu8086 can e use)
from comman) line! The switch is @a followe) y a full path to assemly source co)e
files! The assemler will assemle all files that are in source fol)er into My4uild
)irectory!
(or e%ample.
emu8086 @a c)Aemu8086Ae?amples
Fote. any e%istin7 files in c.?emu8086?MyEuil)? su)irectory are to e overwritten!
The assemler )oes not print out the status an) error messa7es to console- instea) it
prints out everythin7 to this file.
c)Aemu8086AMy4uildA2emu80862lo#t?t
<o not run several instances of the assemler un)er the same path until GEF<'
appears in the file! Hou may see if emu8086 is runnin7 y pressin7 the >trl:=lt:<el
comination- or y 6ust openin7 an) reopenin7 2emu80862lo#t?t file in Fotepa) to
see if the file is written completely! This can e checke) automatically y another
pro7ram (the file must e opene) in share) mo)e)!
The assemler )oes not save files with e%tensions #com- #e?e- or #bin- instea) it uses
these e%tensions. #com2- #e?e2- or #bin2 (there is un)erline in the en))! 8f you4) like
to run the file for real 6ust rename #com2 to #com etc!
(or atch rename 6ust type.
ren B#com2 B#com
Theoretically it4s possile to make a hi7h level compiler that will use emu8086 as an
assemler to 7enerate the yte co)e! Maye even > or >:: compiler! The e%ample of
a asic compiler pro7ram written in pure 8086 co)e may e availale in the future!
To )isale little status win)ow in the lower ri7ht corner- set
3I:E<T2A33EM4:EC7true in emu8086!ini
(or the emulator physical )rive A) is this file c)Aemu8086AF:8((D20 (for E8*"
interrupts. 8FT B1h an) oot)!
(or <*" interrupts (8FT 0Bh) )rive A) is emulate) in this su)irectory.
c)Aemu8086AEdriEeAaA
assemler & the one who assemles- what ever in what ever- we 7enerally
refer to ytes an) machine co)e!
inte7rate) & not )isinte7rate)- i!e! all parts work to7ether an) supplement
each other!
compiler & the one who compiles ytes- it may use the assemler to make its
6o easier an) faster!
Question)
,ow )o 8 print a result of a sum of two numers5
3olution)
There are two 7eneral solutions to this task- small an) i7!
"hort "Macro Assembly" solution.
& it is a m'ch shorter so1'tio,, beca'se proced'res are hidde, i,side the i,c1'de *i1e(
i,c1'de 8em'808(i,c8
"9: 100h
!"# A5, 27
!"# ;5, 77
A33 A5, ;5
&,ow < wi11 pri,t the res'1t which is i, A5 register
=A$$ >9<?@A?B!
ret
3CD<?CA>9<?@A?B!
3CD<?CA>9<?@A?B!AB?4
e,d
(or more information aout macro )efinitions check out tutorial ;!
(source co)e of emu8086!inc is availale & click here to stu)y)
emu8086#inc is an open source lirary- you can )ismantle- mo)ify an) use its
proce)ures )irectly
in your co)e instea) of usin7 include )irectives an) tricky macro )efinitions!
The proce)ure the prints the simple numeric value can take several hun)re)s of lines-
you can use this lirary as a short&cut/ you can fin) actual assemly lan7ua7e co)e
that )oes the printin7
if you open emu8086#inc an) search for <E(8FEIP#8FTIFUM an)
<E(8FEIP#8FTIFUMIUF" insi)e of it-
they look e%actly as the first e%ample- the a)vanta7e of macros is that many
pro7rams can use it keepin7
their co)e relatively small!
Question)
,ow to calculate the numer of elements in array5
3olution) The followin7 co)e calculates the array si@e.
jmp start:
array db 17,15,%1,1,1,12%, 71
arrayAbyteAsiEe 6 2 ) o**set array
start:
!"# A5, arrayAbyteAsiEe
F is the location counter- it is use) y the assemler to calculate locations of laels
an) variales!
note. this solution may not work in ol)er versions of emu8086 inte7rate) assemler-
you can )ownloa) an up)ate here! the result is always in ytes! 8f you )eclare an
array of wor)s you nee) to )ivi)e the result y two- for e%ample.
jmp start:
array dw 12,2%,%1,15,17,F%1,17
arrayAbyteAsiEe 6 2 ) o**set array
start:
!"# A5, arrayAbyteAsiEe G 2
the remain)er is always @ero- ecause the numer of ytes is even!
Question)
,ow can 8 )o a far call- or is it not supporte) in the emulator5
mov bx,0h &set es:bx to poi,t to i,t 10h vector i, ivt
mov es,bx
mov bx,F0h
mov ah,0eh & set 'p i,t 10h params
mov a1, 1 & A4=<< code o* a *',,y *ace
p'sh*
ca11 es:[bx] & do a *ar ca11 to i,t10h vector + wro,g .
ret
e,d
3olution)
mov bx,0h & set es:bx to poi,t to i,t 10h vector i, ivt
mov es,bx
mov bx,F0h
mov ah,0eh & set 'p i,t 10h params
mov a1, 1 & A4=<< code o* a *',,y *ace(
p'sh*
ca11 *ar es:[bx] & do a *ar ca11 to i,t10h vector
ret
e,d
3ithout "ar prefi% the microprocessor sets a wor) value (0 ytes) that is pointe) y
es.JEAK to 8P re7ister/ with "ar prefi% microprocessor sets the wor) value that is
pointe) y es.JEAK to 8P re7ister- an) the wor) at es.JEA:0K is set to >" re7ister!
Question)
8s there another way to achieve the same result without usin7 << variales5
3olution)
<< )efinitions an) far 6umps are supporte) in the latest version- for e%ample.
jmp *ar addr
addr dd 12%5:512Fh
8f you are usin7 earlier version of emu8086 you can use a workaroun)- ecause
)oule wor)s are really two B6 it wor)s- an) wor)s are really two ytes or 8 its- it4s
possile to co)e without usin7 any other variales ut ytes! 8n other wor)s- you can
)efine two <3 values to make a <<!
(or e%ample.
ddvar dw 0
dw 0
Lon7 6umps are supporte) in the latest version (call "ar)! (or previous versions of
emu8086 there is another workaroun).
This co)e is compile) perfectly y all versions.
jmp 12%Fh:F57h
an) it is assemle) into yte seCuence.
CA 7 F5 %F 12
8t can e seen in memory win)ow an) in emulator -! debu!
Therefore- you can )efine in your co)e somethin7 similar to this co)e.
db 0CAh & 1o,g j'mp i,str'ctio, opcode(
o*t dw F57h & j'mp o**set
sg dw 12%Fh & j'mp segme,t
The aove co)e is assemle) into the same machine co)e- ut allows you to mo)ify
the 6ump values easily an) even replace them if reCuire)- for e%ampe.
mov cs:o*t, 100h
when e%ecute) the aove instruction mo)ifies the upper co)e into.
jmp 12%Fh:100h
this is 6ust a tiny e%ample of self&mo)ifyin7 co)e- it4s possile to )o anythin7 even
without usin7 << ()efine )oule wor)) an) se7ment overri)es- in fact it is possile to
use <E ()efine yte) only- ecause <3 ()efine wor)) is 6ust two <Es! it is important
to rememer that 8ntel architecture reCuires the little en) of the numer to e store)
at the lower a))ress- for e%ample the value *+,-h is comine) of two ytes an) it is
store) in the memory as ,-*+!
org 100h
mov ax, 0
mov es, ax
mov ax, es:[F0h]
mov wordAo**set, ax
mov ax, es:[F0hH2]
mov wordAsegme,t, ax
mov ah,0eh & set 'p parameters *or i,t 10h
mov a1,1 & A4=<< code o* a *',,y *ace(
& do same thi,gs as i,t does
p'sh*
p'sh cs
mov bx, rr
p'sh bx
opcode db 0CAh & jmp wordAsegme,t:wordAo**set
wordAo**set dw I
wordAsegme,t dw I
rr:
mov ax, 1 & ret'r, here
ret
e,d
Question)
8t woul) e very useful to have the option of invokin7 a <*" shell at the uil)
)irectory from the compile finishe) )ialo7ue!
3olution)
The latest version of emu8086 has e%ternal utton that allows to launch comman)
prompt or )eu7!e%e with preloa)e) e%ecutale an) it also allows to run e%ecutales
in real environment!
for previous versions of emu8086 you can )ownloa) Microsoft utility calle) comman)
prompt here- after the compilation click bro&se###- to open 5)Aemu8086AMy4uild
fol)er in file mana7er- then riht-click this fol)er an) select $open command
prompt here$ from the pop&up menu!
Question)
8s it possile to set a reak point5
Ans&er)
Hes- it4s possile to click the instruction line an) click 3et break point from =ebu
menu of the emulator!
8t is also possile to keep a lo7 similar to debu pro7ram- if you click 9ie& -! 6eep
=ebu :o!
The reak point is set to currently selecte) a))ress (se7ment.offset)!
The emulator will stop runnin7 when the physical a))ress of >".8P re7isters is
eCuivalent to reak point a))ress (note. several effective a))ress may represent the
same physical a))ress- for e%ample 0/00)**-A 7 0/*-)000AG
=nother way to set a reak point is to click debu -! stop on condition an) set
value of 8P re7ister! The easiest way to 7et 8P values is from the listin7 un)er L*>
column! To 7et listin7 click debu -! listin
8n a))ition it4s possile to the emulator to stop on co)ition A' 7 *+,-h an) to put
the follwoin7 lines in several places of your co)e.
M89 A'; *+,-h
M89 A'; 0
Question)
8 am aware that 8086 is limite) to 10-262 for positive an) to &10-268 for ne7ative! 8
am aware that this is the B6&it processor- that was use) in earlier computer systems-
ut even in 8&it =tari 0600 score counts in many 7ames went into the B00-000s- way
eyon) 10-000!
3olution)
,ere is the e%ample that calculates an) )isplays the sum of two B00&it values (10
)i7its)!
10 its can store values up to. D-0MD-M62-0M6 ecause +H,+ 7 -+0-06/+06 (this is
only B0 )ecimal )i7its)!
B00 its can hol) up to 1B )ecimal )i7its ecause +H*00 7
*+6/6.0600++8++0-0*-06/0,+0.,/6
(1B )ecimal )i7its 9 B00 inary )i7its 9 B00 its)
& this examp1e shows how to add h'ge ',pac-ed ;=3 ,'mbers +;=3 is bi,ary coded decima1.(
& this a11ows to over come the 1 bit a,d eve, %2 bit 1imitatio,(
& beca'se %2 digit decima1 va1'e ho1ds over 100 bitsJ
& the ,'mber o* digits i, ,'m1 a,d ,'m2 ca, be easi1y i,creased(
"9: 100h
& s-ip data:
K!> code
& the ,'mber o* digits i, ,'mbers:
& it/s importa,t to reserve 0 as most sig,i*ica,t digit, to avoid over*1ow(
& so i* yo' ,eed to operate with 250 digit va1'es, yo' ,eed to dec1are 1e, 6 251
1e, CLB %2
& every decima1 digit is stored i, a separate byte(
& *irst ,'mber is: F2%F5F12%12%F512%FF5%5177521
,'m1 3; 0,0,F,2,%,F,5,F,,1,2,%,,1,2,%,F,5,1,2,%,F,F,5,%,5,1,7,7,5,2,1
& seco,d ,'mber is: 712%788F777178112%51%1%7882F78
,'m2 3; 0,0,7,1,2,%,7,8,8,F,7,7,7,1,7,8,1,1,2,%,5,1,%,1,%,7,8,8,2,F,7,8
& we wi11 ca1c'1ate this:
& s'm 6 ,'m1 H ,'m2
& F2%F5F12%12%F512%FF5%5177521 H 712%788F777178112%51%1%7882F78 6
& 6 11%58%%F01%%215%58577%02017
s'm 3; 1e, d'p+0. & dec1are array to -eep the res'1t(
& yo' may chec- the res'1t o, paper, or c1ic- 4tart , the, 9',, the, type 8ca1c8 a,d hit e,ter -ey(
code: ,op & the e,try poi,t(
& digit poi,ter:
5"9 ;5, ;5
& set'p the 1oop:
!"# =5, 1e,
!"# ;5, 1e,)1 & poi,t to 1est sig,i*ica,t digit(
,extAdigit:
& add digits:
!"# A$, ,'m1[;5]
A3= A$, ,'m2[;5]
& this is a very 'se*'1 i,str'ctio, that
& adj'sts the va1'e o* additio,
& to be stri,g compatib1e
AAA
& AAA sta,ds *or A4=<< A33 A3KB4@(
& ))) a1gorithm behi,d AAA )))
& i* 1ow ,ibb1e o* A$ M 7 or AD 6 1 the,:
& A$ 6 A$ H
& A0 6 A0 H 1
& AD 6 1
& =D 6 1
& e1se
& AD 6 0
& =D 6 0
&
& i, both cases: c1ear the high ,ibb1e o* A$(
& ))) e,d o* AAA 1ogic )))
& store res'1t:
!"# s'm[;5], A$
& poi,t to ,ext digit:
3C= ;5
$""> ,extAdigit
& i,c1'de carry i, res'1t +i* a,y.:
A3= s'm[;5], 0
& pri,t o't the res'1t:
!"# =5, 1e,
& start pri,ti,g *rom most sig,i*ica,t digit:
!"# ;5, 0
pri,tAd:
!"# A$, s'm[;5]
& co,vert to A4=<< char:
"9 A$, %0h
!"# A0, 0Ch
<?@ 10h
<?= ;5
$""> pri,tAd
9C@
C?3
3ith some more )ili7ence it4s possile to make a pro7ram that inputs 000 )i7it values
an) prints out their sum!
Question)
84m makin7 an interrupt counter/ for that 8 am usin7 B phototransister an) s)k&86
oar) at colle7e! 8 am not havin7 this kit at home so 8 have a prolem to see the
output!
here is issue!. when li7ht on phototransister is on an) off pulse is 7enerate)- this
pulse comes 6ust like the harware) iterrupt! my pro7ram must to count these pulses
continuously/ for that 8 am usin7 80;;kit an) "<N&86kit at colle7e- ut at home 8
)on4t have this eCuempent at home! =m 8 ale to emulate the output of real system5
Perchanps- 8 have to )evelope 80;; )evice as an e%ternel )evice in emu8086/ ut
how can 8 pro7 this )evice in v5 8 am usin7 ports. 10h- 1Bh- 10h- an) 11h! 8 )ont
know v!!!
Ans&er)
Hou )on4t have to know v- ut you have to know any real pro7rammin7 lan7ua7e
apart from html/6avascript! the pro7rammin7 lan7ua7e must allow the pro7rammer to
have complete control over the file input/output operations- then you can 6ust open
the file c)Aemu8086#io in share) mo)e an) rea) values from it like from a real i/o
port! yte at offset 10h correspon)s to port 10h- wor) at offset 11h correspon)s to
port 11h! the operatin7 system automatically caches files that are accesse)
freCuently- this makes the interaction etween the emulator an) a virtual )evice 6ust
a little it slower than )irect memory&to&memory to communication! in fact- you can
create 80;; )evice in B6 it or even in 10 it assemly lan7ua7e!
Fote. the latest version supports har)ware interrupts. c)Aemu8086#h&- settin7 a
none&@ero value to any yte in that file tri77ers a har)ware interrupt! the emulator
must e runnin7 or step utton must e presse) to process the har)ware interrupt!
(or e%ample.
id1e:
,op
jmp id1e
Question)
8 want to know aout memory mo)els an) se7mentation an) memory consi)erations
in eme))e) systems!
Ans&er)
Hou may fin) these links helpful.
= feel for thin7s!
=)vance) Eme))e) A86 Pro7rammin7. Protection an) "e7mentation!
Eme))e) A86 Pro7rammin7. Protecte) Mo)e!
Micro Minis!
#8">y Eusiness!
8n search of a common =P8 for connecte) )evices!
Tamin7 the %86 east!
8ntel 8086 (amily =rchitecture!
Question)
3hat physical a))ress correspon)s to 34:10%Dh if 3467F30h
Ans&er)
7F30h N 10h H 10%Dh 6 753%Dh
an) it4s eCuivalent to effective a))ress. 753%h:000Dh
it4s possile to use emu8086 inte7rate) calculator to make these calculations (set
show result to he%)!
note. B0h 9 B6
Question)
8 woul) like to print out the assemly lan7ua7e pro7ram as
well as the correspon)in7 machine lan7ua7e co)e! ,ow can
8 )o so 5
3olution)
8t is not possile to print out the source co)e )irectly from
emu8086- ut you may click "ile &' e?port to >TM:### an)
print it from the rowser or even uploa) it to the server
preservin7 true co)e colors an) allowin7 others 6ust to copy
O paste it!
The correspon)in7 machine co)e can e opene) an) then
printe) out y clickin7 Eie& -! listin ri7ht after the
successful assemlin7/compilation or from the emulator4s
menu!
Question)
>an we use reakpoint int 01h with emu 80865
Ans&er)
8t is possile to overwrite the )efault stu a))ress for int 01h in interrupt vector tale
with a custom function! =n) it is possile to insert 55 yte to sustitute the first yte
of any instruction- however the easiest way to set a reak point is to click an
instruction an) then click debu -! set break point from the menu!
E)itor hints.
To repeat a successful te%t search press (1 key!
To cut a line press 5trl I D simultaneously!
(ree positionin7 of the te%t cursor can e turne) off from the options y
checkin7 con"ine caret to te?t!
6..,. an) -* are the same B6 it values in inary representation.
BBBBBBBBBBBBBBBB
as +.- an) -+ have the same inary co)e too. BBBBBBB0
Question)
8t is 7oo) that emu8086 supports virtual )evices for emulatin7 the io comman)s! Eut
how )oes the 8* work for real5 (*r. ,ow )o 8 7et the =))ress of a )evice e!7! the
serial port)
Ans&er)
8t is practically the same! The )evice conrollin7 is very simple! Hou may try searchin7
for $(5 (h=) Inside (5 Inter"acin$! The only prolem is the price! 8t4s 7oo) if you
can affor) to uy real )evices or a >PU workench an) e%periment with the real
thin7s! ,owever- for aca)emic an) e)ucational purpoces- the emulator is much
cheaper an) easier to use- plus you cannot nor urn nor shortcut it! Usin7 emu8086
technolo7y anyone can make free a))itional har)ware )evices! (ree har)ware easy &
in any pro7rammin7 lan7ua7e!
Question)
,ow )o 8 set the output screen to D0P0;- so 8 )ont have to resi@e it everytime it runs!
Ans&er)
mov ax, 0
i,t 10h
8t4s possile to chan7e the colours y clickin7 the $options$ utton! The latest version
uses yellow color to select lines of ytes when the instruction in )isassemle) list is
clicke)- it shows e%actly how many ytes the instruction takes! The yellow
ack7roun) is no lon7er recommen)e) to avoi) the confusion!
8nstea) of showin7 the offset the emulator shows the physical a))ress now! Hou can
easily calculate the offset even without the calculator- ecause the loa)in7 se7ment is
always 0200 (unless it4s a custom !in file)- so if physical a))ress is 02B00 then the
offset is B00 an) the se7ment is 200!
The file system emulation is still un)er7oin7 heavy checks- there are a few new ut
un)ocumente) interrupts! 8FT 0Bh/DEh an) 8FT 0Bh/D(h! These shoul) allow to 7et
the )irectory file list!
Question)
3hat is or *00h 5
Ans&er)
(irst of all- it4s a )irective which instructs the assemler to uil) a simple #com file!
unlike instructions- this )irective is not converte) into any machine co)e! com files
are compatile with <*" an) they can run in 3in)ows comman) prompt- an) it4s the
most tiny e%ecutale format that is availale!
Literally this )irective sets the location counter to 0;6 (B00h)! Location counter is
represente) in source co)e as )ollar! This is an e%ample of how location counter value
can e accesse). M89 A'; F the e%ecution of this instruction will make A' contain
the a))ress of instruction that put this a))ress in it!!!! ut usually- it4s not somethin7
to worry aout- 6ust rememer that or *00h must e the first line if you want to
make a tiny sin7le se7ment e%ecutale file! note. )ollar insi)e $Q$ or 4Q4 is not a
location counter- ut an =">88 character! Location counter has nothin7 to )o with
strin7 terminatin7 $Q$ that is historically use) y M"&<*" print functions!
Question)
3hat is or /c00h 5
Ans&er)
8t is very similar to or *00h! This )irective instructs the assemler to a)) /500h to
all a))resses of all variales that are )eclare) in your pro7ram! 8t operates e%actly
the same way as 8C$ *00h )irective- ut instea) of a))in7 *00h (or 0;6 ytes) it
a))s /500h!
(or e%ample if you write this co)e.
mov ax, var1
an) the a))ress of Ear* is *0h
without 8C$ *00h )irective assemler pro)uces the followin7 machine co)e.
mov ax, [10h]
however with 8C$ *00h )irective assemler automatically up)ates the machine co)e
to.
mov ax, [10hH100h]
an) it is eCuivalent to this co)e.
mov ax, [110h]
or /500h )irective must e use) ecause the computer loa)s oot recor)s into the
memory at a))ress 0000)/500!
8f pro7ram is not usin7 variale names an) only operates )irectly with numeric
a))ress values (such as J+00*hK or J0000)*+,+hK!!! etc- an) not Ear*- Ear+!!!) an)
it )oes not use any laels then there is no practical use for 8C$ )irective! 7enerally
it4s much more convenient to use names for specific memory locations (variales)- for
these cases 8C$ )irective can save a lot of time for the pro7rammer- y calculatin7
the correct offset automatically!
Fotes.
8C$ )irective )oes not loa) the pro7ram into specific memory area!
Misuse of 8C$ )irective can cause your pro7ram not to operate correctly!
The area where the oot mo)ule of the operatin7 system is loa)e) is )efine)
on har)ware level y the computer system/E8*" manufacture!
3hen #com files are loa)e) y <*"/prompt- they are loa)e) at any availale
se7ment- ut offset is always B00h (for e%ample B0>M.0B00)!
Question)
3here is a numeric Tale of *pco)es5
Ans&er)
= list of all 8086 >PU compatile instructions is pulishe) here (without numeric
opco)es)!
*nly those instructions that appear oth in Pentium
R
manuals an) in this reference
may e use) for 8086 microprocessor! (or a complete set of opco)es an) enco)in7
tales please check out.
The $reatest Cesources
IA-,+ Intel
J
Architecture 3o"t&are
=eEeloper Manuals
4asic Architecture)
8nstruction "et "ummary- B6&it Processors an) "e7mentation (BM28)- "ystem
Pro7rammin7 Sui)e
http.//)ownloa)!intel!com/)esi7n/PentiumD/manuals/0;166;B2!p)f

3ystem (rorammin $uide)


8086 Emulation- #eal&=))ress Mo)e.
http.//)ownloa)!intel!com/)esi7n/PentiumD/manuals/0;1668B2!p)f

Instruction 3et Ce"erence)


*nly B6 it instructions may run on the ori7inal 8086 microprocessor!
Part B- 8nstruction (ormat- 8nstructions from = to M.
http.//)ownloa)!intel!com/)esi7n/PentiumD/manuals/0;1666B2!p)f
Part 0- 8nstructions from F to T- *pco)e Map- 8nstruction (ormats an)
Enco)in7s.
http.//)ownloa)!intel!com/)esi7n/PentiumD/manuals/0;1662B2!p)f

AM=6-
J
Architecture (rorammer
Manuals
Application (rorammin)
*verview of the =M<6D =rchitecture.
Memory Mo)el an) Memory *r7ani@ation- #e7isters- 8nstruction "ummary.
http.//www!am)!com/us&
en/assets/contentItype/whiteIpapersIan)ItechI)ocs/0D;M0!p)f

3ystem (rorammin)
(i7ures- Tales- %86 an) =M<6D *peratin7 Mo)es- Memory Mo)el.
http.//www!am)!com/us&
en/assets/contentItype/whiteIpapersIan)ItechI)ocs/0D;M1!p)f

$eneral-(urpose Instructions and 3ystem Instructions)


*nly B6 it instructions are compatile with the ori7inal 8086 >PU!
8nstruction Eyte *r)er- Seneral&Purpose 8nstruction #eference- *pco)e an)
*peran) Enco)in7s-
http.//www!am)!com/us&
en/assets/contentItype/whiteIpapersIan)ItechI)ocs/0D;MD!p)f

<otes about I@8 port emulation "or c)Aemu8086#io


8t is not recommen)e) to use two nei7hourin7 B6 it ports- for e%ample port 0 an)
port B!
Every port has a yte len7th (8 it)- two yte port (B6 it wor)) is emulate) usin7 0
ytes or 0 yte ports!
3hen the emulator outputs the secon) wor) it overwrites the hi7h yte of the first
wor)!
& Dor examp1e:
!"# A$, %Fh
"B@ 25, A$
!"# A$, 12h
"B@ 2, A$
& is eO'va1e,t to:
!"# A5, 12%Fh
"B@ 25, A5
Question)
& < am tryi,g to compi1e the *o11owi,g:
org 25
mov dx, b'gi
ret
b'gi db 55
& @he variab1e Ab'giA is a byte whi1e 35 is
& a word b't the i,tegrated assemb1er does ,ot comp1ai,( PhyI
Ans&er)
To make the inte7rate) assemler to 7enerate more errors you may set.
3TCI5T23D<TA'7true
in this file.
5)Aemu8086Aemu8086#ini
Ey )efault it is set to false to enale co)in7 a little it faster without the necessity to
use $byte ptr$ an) $&ord ptr$ in places where it is clear without these lon7
constructions (i!e! when one of the operan)s is a re7ister)!
Fote. the settin7s in emu8086!ini )o not apply to fasm (flat assemler)! To use fasm
a)) K"asmK or any vali) "ormat )irective (vali) for emu8086 version D!00&Eeta&B;
an) aove)
(or )ifferences etween the inte7rate) assemler (M="M/T="M compatile) an)
(="M see "asm2compatibility#asm
(="M )oes not reCuire the o""set )irective! Ey )efault all te%tual laels are offsets
(even if )efine) with <E/<3)
To specify a variale L M must e put aroun) it!
To avoi) conflicts etween 8086 inte7rate) assemler an) fasm- it is recommen)e) to
place this )irective on top of all files that are )esi7ne) for flat assemler.
K"asmK
Question)
84ve installe) emu8086 on several computers in one of my electronics las! Everythin7
seems to work correctly when 8 am lo77e) onto any of the P>4s ut- when any of the
stu)ents lo7 on- the virtual )evice pro7rams controlle) y the e%ample ="M pro7rams
)o not respon)! e%/ usin7 LE<I)isplayItest!="M!
The la is set up with 3in)ows AP machines on a )omain! 8 have a)min privile7es ut
the stu)ents )o not! 8 trie) settin7 the security settin7 of 5)Aemu8086 so all users
have full privile7es ut it )i) not help! =re there other fol)ers that are in play when
the pro7ram is runnin75
3olution)
8n or)er for virtual )evices to work correctly- it is reCuire) to set #E=</3#8TE
privile7es for these files that are create) y the emulator in the root fol)er of the
)rive >.
5)Aemu8086#io
c)Aemu8086#h&
These files are are use) to communicate etween the virtual )evices an) the
emulator- an) it shoul) e allowe) for pro7rams that run un)er stu)ents4 lo7in to
create- rea) an) write to an) from these files freely!

Вам также может понравиться