CASL assembly language learning

xiaoxiao2021-03-06  50

CASL assembly language 1. Processor Comet Description 1. Comet is a fixed-point computer for 16-bit, and the main memory capacity is 65536 bytes, and addressing 0000-FFFF (hexadecimal). 2. The 16-bit binary number of the word from left to right, ie

0123456789101112131415

..............

3. The 16 digits in one word can be:

Binary non-negative integer without symbols. At this time, the number of words represents is: 0-65535

Use the blended binary integersion with a complement indicated. At this point, a word represents the scope of: -32768-32767

Address constant. At this time, the address representing the address is written as a hexadecimal: 0000-ffff

Character data. At this time, the high 8 digits of the word should be zero, the low 8-bit ASCII code is encoded, ie

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

0 0 0 0 0 0 0 0 Character ASCII Coding

4. The Comet machine has 5 general register GR (16-bit), one instruction counter PC (16-bit) and a flag register FR (2). Their roles are:

The number of 5 general registers of GR (General Registers) is 0, 1, 2, 3, 4, respectively, respectively, respectively, respectively, respectively, respectively, respectively, respectively, GR0. These universal registers are used for arithmetic, logic, shift, etc., where GR1, GR2, GR3, and GR4 general registers are partially as an indeached register. In addition, GR4 also uses a stack pointer (SP), and the stack pointer is a register for storing the top address of the stack.

PC (Instruction Register) In the process of executing the instruction, the address of the first word of the instruction being executed in the PC is stored in the PC (one of the instructions comprises two words). When the instruction is executed, the contents of the PC are typically added 2, and the transfer command address is placed in the PC only when the transfer command is performed and the condition is established.

FR (Sign Register) At the end of the ADD, SUB, AND, OR, EOR, CPA, CPL, SLA, SRA, SLL, SRL, LEA, etc.,, based on the result of execution, the FR is set to 00, 01 or 10. It does not change due to the implementation of other instructions (see 7).

5. Comet control mode is sequential. The instruction consists of 32-bit binary, that is, double word length, which is constituted. 6. Symbol of the instruction

The GR generally refers to the registers of the registers to be specified, or GR0, GR1, GR2, GR3, GR4 can also be specified.

The XR is used to refer to the address register to be specified by numbers 1, 2, 3, 4.

SP Stack Pointer (No. 4 Register).

The ADR label (indicating the address corresponding to the label), is 10 encenters (-32768 <= ADR 65536; ADR as the address, with a value of 0-65536, and 32768-65536 can also be represented by negative 10) .

(X) Indicates the content in the X address, which means that the content in the general register is when X is a general register.

E represents a valid address. The rules that form valid address E are:

E = ADR [ (XR)] (16th of MOD 2)

[] Indicates that the portion surrounded by [] can be omitted (the following), and XR omitly indicates that the index register is not used.

7. Come has 23 instructions. The name, writing format, and its functions of the instructions are attached to the table 1. The instruction format is given in the form of assembly statements. Schedule 1:

Name Write Format Features Document Code Operating Number LDGR, ADR [x x] (E) -> GR Depreciation STGR, ADR [, XR] (GR) -> E Take Address * Leagr, ADR [, XR] E - > GR Add * Addgr, ADR [, XR] (GR) (E) -> GR subtraction * SUBGR, ADR [, XR] (GR) - (e) -> GR logic multiplied * Andgr, ADR [, XR] (GR) & (e) -> GR Logic plus * ORGR, ADR [, XR] (GR) | (E) -> GR Bright Add * EORGR, ADR [, XR] (GR) ^ (E) -> The GR arithmetic comparison CPAGR, ADR [, XR] (GR) and (E) are symbolic binary integers indicated by complement. If (GR)> (E), 00 -> FR If (GR) = (E), 01 -> FR If (Gr) <(E), 10-> FR logic compares CPLGR, ADR [, XR] ( Gr) and (e) are non-symbolic binary non-negative integers. If (GR)> (E), 00 -> FR If (GR) = (E), 01 -> FR If (GR) <(E), 10-> FR arithmetic left shift * Slagr, ADR [, XR] Put (GR) to the left or right. At an arithmetic shift, the 0th in the GR remains unchanged. The position on the right shift is set to 1 or 0 as the 0th, and the space out of the empty out is set to 0. At the time of logic shift, the 16 bits in the GR move together, and the space out is set to 0. Right shift * SRA logic left shift * SLL logic right shift * srl unconditional turn jmpadr [, xr] unconditional to the valid address E transfer, e-> PC is greater than or equal to the value of the JPZADR [, XR] according to the value of the FR to the valid address E Transfer, E-> PC; Do not transfer, the next instruction is performed, ie (PC) 2 -> PC is smaller than the transfer jmiadr [, XR] inequality JNZADR [, XR] instruction transfer time FR value JPZ00 or 01JMI10 is equal to Transfer pushadr [, xr] jnz00 or 10jze01 into Pushadr [, XR] (SP) -1 -> SP E -> (SP) Replenant Popgr ((sp)) -> GR (SP) 1 -> SP call Calladr [, XR] first form a valid address, then execute (SP) -1 -> SP (PC) 2 -> (SP) E -> PC Return RET ((sp)) -> PC (SP) 1 -> SP * These instructions are also based on the execution result (the value in the GR), the rule is:

If the 0th bit in GR is 0 and the remaining is not all 0, the FR is set to 00; if the 16 bits of the GR are all 0, the FR is set to 01; if the 0th bit in GR is 1, Then FR is set 10. Second, assembly language CASL Description Comet assembly language is CASL, and its grammar rules are described below. 1. Type and writing format of the instruction

CasL consists of four pseudo-instructions (START, END, DS, DC), 3 macro (IN, OUT, EXIT), and 23 symbolic commands (commands in Comet).

Each instruction of CASL is written in one line (up to 72 characters), and its writing format is shown in Schedule 2.

Schedule 2:

Number command code operand [label] start [label] blank end blank [label] DC constant [label] in the DS area [label] INALABEL, NLABEL [label] Outalabel, NLabel [label] EXIT blank [label] symbol instruction Referring to the Schedule 2, the CASL is constructed by the reference numeral (default), the instruction code, the operand (the default) 4 column, and the writing rules of each column are as follows:

The label bar starts from the first character, up to 6 characters position.

When the instruction column is in a wireless, at least one blank is started after the label is started from the second character position.

There is at least one blank after the operating number column instruction code, and then to 72 characters. Can't continue to the next line.

There is a semicolon (;) in the note column, thereafter, the end is finally treated (except for the semicolon in the string in the DC instruction). In addition, in the case where the first character position is a semicolon or only blank before the semicolon, the row is all as an annotation process, and any character can be written in the annotation column.

Label's general reference numeral, the label is up to 6 characters, and the beginning must be English uppercase letters, which will be English letters or numbers.

Do not write characters in the column indicated by blank.

2. Pseudo-Directive

(1) [label] Start [label]

Indicates the beginning of the program, that is, the beginning of the program must be written.

The label in the operand is the label defined in this program, which indicates the startup address of the program. In the case of omitting, the program starts to be implemented.

The label in the label bar can enter the entry of the program as other programs.

(2) END

Represents the termination of the program, must be written in the end of the program.

(3) [label] DC constant

Used to specify and store constants. Four of constant divided constants, hexadecimal constants, address constants, and string constants.

The label in the label field is the address of the first word representing the stored address of the designated decimal constant, hexadecimal constant, address constant, or represents the first word of the storage area representing the specified string constant.

Decimal constant: DC N

Use n to specify a decimal (-32768

The decimal number of 32768-65535 can also be expressed with a negative decimal constant.

Hexadecimal constant: DC #h

Use H to specify a 4-bit hexadecimal number (0000 - fff), and store the binary number of H in one word (must be written in front of the H).

Address constant: DC Label

The address corresponding to the label is used as binary storage of one word. If Label is not defined in the program, the assembly will reserve the definition of the address and processed by the operating system.

String constant: DC 'string'

Convert each character from the left into character data from the left start in the string (see Limet 3), and sequentially store the character data in a continuous word.

In the string, the character strings are not allowed, the length of the string cannot be zero (ie, the string).

(4) [Label] DS area

The address of the first word used to retain the stored area of ​​the specified word.

When the number of words in the area is zero, the storage area does not exist, but the labels in the label column are still valid, that is, the address of the next word.

3. Macro

The macro is a instruction string of the specified function based on the information defined in advance defined instruction string and the operation.

There is a macro such as input, output, and end programs in CASL, without defining input, output symbol instructions, which is done by the operating system. When a macro appears in the program, the CASL generates instruction strings of the calling operating system, but the number of words generated in the form is uncertain.

When the macro is executed, the content of the GR remains unchanged and the content of FR is uncertain.

(1) [label] in Alabel NLabel

Macro Ins, enter a record from the input device, information (character) in the record is sequentially stored in the form of the character data in the form of the label, and the input character is stored in the binary form in the label. For the word NLabel. The separation symbol between the records is not input.

(2) [label] OUT Alabel NLabel

Macro OUT, the character data stored in the area starting from the label Alabel, which is output as a record to the output device, and the output of the character is determined by the contents of the word NLABEL. When outputting, to record the interval symbols, the output is automatically inserted by the operating system.

(3) [label] exit

Macro exit, indicating the termination of the program execution, control returns the operating system.

(4) Symbol instructions, see Last section 7.

(5) Directive word, relative location

The relative position of the assembled instruction word and the area is determined by the assembler, and the generated instruction word, the area occupies the continuous area of ​​the main memory.

转载请注明原文地址:https://www.9cbs.com/read-54641.html

New Post(0)