Microprocessor Simulator 0 Help



Download 481.92 Kb.
Page16/18
Date23.05.2017
Size481.92 Kb.
#18906
1   ...   10   11   12   13   14   15   16   17   18

Other Instructions


Detailed Instruction Set
  1. Miscellaneous Instructions - CLI and STI control the (I) Flag


AssemblerMachine CodeExplanationHALT 00Stop the program.
00 is the machine instruction for HALT.
The program will cease to run if it encounters a HALT instruction.
Continuous running is cancelled by this command.
You can have several halt commands in one program.
There should be only one END and code after END is ignored.NOPFFDo nothing for one clock cycle.
FF is the machine instruction for NOP.
The program will do nothing for one clock cycle.
The program then continues as normal.
NOP is used to introduce time delays to allow slow electronics to keep up with the CPU. These are also called WAIT STATES. CLOFEClose all the peripheral windows.
FE is the machine code for CLO.
It applies to this simulator only, and is used to close peripheral windows.
This makes it easier to write demonstration programs without the screen getting too cluttered. ORG 30NONECode Origin. Generate code starting from this address.
To generate code from a starting address other than zero use ORG.
This is useful to place procedures, interrupts or data tables at particular addresses in memory.
ORG is an assembler directive and no code is generated.DB 8484Define a byte.
Store the byte (84) in the next free RAM location.
Use DB to create data tables containing bytes of data.
Use BD to define an Interrupt Vector.DB "Hello"48, 65, 6C, 6C, 6FDefine a string.
Store the ASCII codes of the text in quotes in the next free RAM locations.
Use DB to store text strings.
The stored ASCII codes do not include an end-of-string marker.
Use DB 00 for this.CLIFDClear the I flag
If the I flag is cleared, hardware interrupts are ignored.
This is the default state for the simulator.
Resetting the CPU will also clear the I flag.
The timer that generates hardware interrupts will do nothing. STIFCSet the I flag
If the I flag is set, the simulator will generate INT 02 at regular time intervals.
It is necessary to have an interrupt vector stored at address 02 that points to interrupt handler code stored elsewhere.
The interval between timer interrupts can be set using the slider in the Configuration Tab.
If interrupts occur faster than the processor can handle them, a simulated system crash will follow.
Adjust the CPU clock speed and the timer interval to prevent this – or cause it if you want to see what happens.It is possible to program the simulator using pure machine codes. Here is a simple example.
; ===== NORMAL CODE =====

MOV AL,0


INC AL

END


; ===== NORMAL CODE =====

Here is the same program in pure machine code apart from the required END keyword. This should run exactly as the program above.


; ===== PURE MACHINE CODE =====

DB D0 ; MOV

DB 00 ; AL

DB 00 ; 0

DB A4 ; INC

DB 00 ; AL

END

; ===== PURE MACHINE CODE =====



This is an interesting exercise but rather defeats the whole point of using an assembler. If you have a dog, why bark yourself? Manually calculating jump distances might be a useful learning exercise, especially for negative jumps.
  • List File


Contents
  1. The List File


In the list file, your original program is shown.


Numbers in square blackets such as [1C] are the addresses at which the machine codes were generated.
The machine codes are shown.
  • Here is a typical line.


MOV CL,C0 ; [10] D0 02 C0 ; Video ram base address

The command is to move C0 into the AL register.


The machine code was generated at address [10].
The machine codes are D0 00 C0.
The programmer's comment is reproduced.
  • Negative Numbers


Contents
  1. Negative NumbersDecHexDecHexDecHexDecHexDecHexDecHexDecHexDecHex-12880-12781-12682-12583-12484-12385-12286-12187-12088-11989-1188A-1178B-1168C-1158D-1148E-1138F-11290-11191-11092-10993-10894-10795-10696-10597-10498-10399-1029A-1019B-1009C-0999D-0989E-0979F-096A0-095A1-094A2-093A3-092A4-091A5-090A6-089A7-088A8-087A9-086AA-085AB-084AC-083AD-082AE-081AF-080B0-079B1-078B2-077B3-076B4-075B5-074B6-073B7-072B8-071B9-070BA-069BB-068BC-067BD-066BE-065BF-064C0-063C1-062C2-061C3-060C4-059C5-058C6-057C7-056C8-055C9-054CA-053CB-052CC-051CD-050CE-049CF-048D0-047D1-046D2-045D3-044D4-043D5-042D6-041D7-040D8-039D9-038DA-037DB-036DC-035DD-034DE-033DF-032E0-031E1-030E2-029E3-028E4-027E5-026E6-025E7-024E8-023E9-022EA-021EB-020EC-019ED-018EE-017EF-016F0-015F1-014F2-013F3-012F4-011F5-010F6-009F7-008F8-007F9-006FA-005FB-004FC-003FD-002FE-001FFPositive NumbersDecHexDecHexDecHexDecHexDecHexDecHexDecHexDecHex+00000+00101+00202+00303+00404+00505+00606+00707+00808+00909+0100A+0110B+0120C+0130D+0140E+0150F+01610+01711+01812+01913+02014+02115+02216+02317+02418+02518+0261A+0271B+0281C+0291D+0301E+0311F+03220+03321+03422+03523+03624+03725+03826+03927+04028+04129+0422A+0432B+0442C+0452D+0462E+0472F+04830+04931+05032+05133+05234+05335+05436+05537+05638+05739+0583A+0593B+0603C+0613D+0623E+0633F+06440+06541+06642+06743+06844+06945+07046+07147+07248+07349+0744A+0754B+0764C+0774D+0784E+0794F+08050+08151+08252+08353+08454+08555+08656+08757+08858+08959+0905A+0915B+0925C+0935D+0945E+0955F+09660+09761+09863+09963+10064+10165+10266+10367+10468+10569+1066A+1076B+1086C+1096D+1106E+1116F+11270+11371+11472+11573+11674+11775+11876+11977+12078+12179+1227A+1237B+1247C+1257D+1267E+1277F 

  2. Two's complement


The numbers work as follows.

The leftmost bit in an eight bit byte is the sign bit.


1 0 1 0 1 0 1 0

^

^ The sign bit has a value of -128 decimal or -80 hexadecimal.



The other seven bits are treated as a normal positive number between 0 and 127. This is true whether the overall number is positive or negative. For example to store -1 the binary is
1 1 1 1 1 1 1 1 - 128d + 127d = -1d

^

^ -128d



To store 127 decimal, the binary is
0 1 1 1 1 1 1 1 0 + 127d = 127d

^

^ The sign bit is zero.



16 and 32 bit machines also use the leftmost bit as the sign bit. The negative numbers work in exactly the same way but much bigger niumbers can be stored. In a 16 bit machine, the sign bit is worth -32768. In a 32 bit machine, the sign bit is worth -2147483648 (2000 million approximately).
1   ...   10   11   12   13   14   15   16   17   18




The database is protected by copyright ©ininet.org 2024
send message

    Main page