0% found this document useful (0 votes)
3 views

Assembly_Lecture_07_2023

The document provides an overview of assembly language addressing modes, specifically SHORT, NEAR, and FAR addresses, along with their respective limitations. It details various conditional jump instructions based on both signed and unsigned data, as well as special arithmetic tests. Additionally, the document explains the CALL and RET instructions for procedure control and the methods for passing parameters by value and by reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assembly_Lecture_07_2023

The document provides an overview of assembly language addressing modes, specifically SHORT, NEAR, and FAR addresses, along with their respective limitations. It details various conditional jump instructions based on both signed and unsigned data, as well as special arithmetic tests. Additionally, the document explains the CALL and RET instructions for procedure control and the methods for passing parameters by value and by reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Mansoura University

Faculty of Computers and Information


Department of Computer Science
First Semester: 2020-2021

[CS214P] Assembly Language: Chapter 7


Grade: Third Year (Computer Science)

Sara El-Metwally, Ph.D.


Faculty of Computers and Information,
Mansoura University,
Egypt.
SHORT, NEAR and FAR addresses

➢ Short Address: limited to a distance of -128


(80H) to 127 (7FH) ( 1 byte long, same
segment).

➢ NEAR Address: limited to a distance of -


32768 (8000H) to 32767 (7FFFH) (2 bytes
long, same segment)

➢ FAR address: (4 bytes long, another


segment)
SHORT addresses
NEAR addresses
SHORT, NEAR and FAR addresses

Instruction SHORT NEAR FAR


JMP yes yes Yes
Jnnn yes Yes (.386+) No
LOOP yes no No
CALL N/A yes Yes
Backward & Forward JMP

Backward JUMP Forward JUMP


LOOP

➢ LOOPE/LOOPZ (loop while equal/zero)


continue looping as long as CX is not zero
and the zero condition is set. Implicitly
decrement CX by 1.

➢ LOOPNE/LOOPNZ (loop while not equal/ not


zero) continue looping as long as CX is not
zero and the zero condition is not set.
CMP

[label: ] CMP R/M, R/M/I

➢ Only compare numeric data. CMPS for


string comparing.
➢ The result affects AF, CF,OF, PF,SF, ZF
Conditional JUMP Instructions
o Jumps Based on Unsigned Data

Symbol Description Flags


Tested
JE/JZ Jump Equal or Jump Zero. ZF
JNE/JNZ Jump Not Equal or Jump Not Zero. ZF
JA/JNBE Jump Above or Jump Not CF, ZF
Below/Equal.
JAE/JNB Jump Above/Equal or Jump Not CF
Below.
JB/JNAE Jump Below or Jump Not CF
Above/Equal
JBE/JNA Jump Below/Equal or Jump Not AF, CF
Above
Conditional JUMP Instructions
o Jumps Based on signed Data

Symbol Description Flags


Tested
JE/JZ Jump Equal or Jump Zero. ZF
JNE/JNZ Jump Not Equal or Jump Not Zero. ZF
JG/JNLE Jump Greater or Jump Not OF, SF,
Less/Equal. ZF
JGE/JNL Jump Greater/Equal or Jump Not OF, SF
Less.
JL/JNGE Jump Less or Jump Not OF, SF
Greater/Equal
JLE/JNG Jump Less/Equal or Jump Not OF, SF,
Greater ZF
Conditional JUMP Instructions
o Special Arithmetic Test.

Symbol Description Flags


Tested
JCXZ Jump if CX is Zero None
JC Jump Carry (same as JB) CF
JNC Jump No Carry CF
JO Jump Overflow OF
JNO Jump No Overflow OF
JP/JPE Jump Parity or Jump Parity Even PF
Conditional JUMP Instructions
o Special Arithmetic Test.

Symbol Description Flags


Tested
JNP/JPO Jump No Parity or Jump Parity PF
Odd.
JS Jump Sign (negative) SF
JNS Jump No Sign (positive) SF
CALL

[label: ] CALL Proc-name


[label: ] RET[n] [immediate]

➢ Purpose of call instruction to transfer


control to a called procedure.
➢ RET, returns from the called procedure.
➢ RETN for near returns.
➢ RETF for far returns.
CALL
CALL
0000 SP=64 = 0040H
0000 SP Dec by 2
0003
0006

0008

000B
STACK

000C
000D
CALL
0000 SP=003EH
0000
0003 003E 0003
0006 003C 000B

0008

000B
STACK

000C
000D
CALL
0000 SP=003EH
0000
0003 003E 0003
0006 003C 000B

0008

000B
STACK

000C
000D
CALL
0000 SP=003EH
0000
0003 003E 0003
0006 003C 000B

0008

000B
STACK

000C
000D
CALL
0000 SP=003EH
0000
0003 003E 0003
0006 003C

0008

000B
STACK

000C
000D
Passing Parameters
o Passing Parameters by Value.
Passing Parameters
o Passing Parameters by Value.
MULTIPLICAND
MULTIPLIER
Return Address SP

MULTIPLICAND BP + 6
MULTIPLIER BP + 4
Return Address BP + 2
BP value SP
BP
Passing Parameters
o Passing Parameters by Reference.
Passing Parameters
o Passing Parameters by Reference.

Address MULTIPLICAND BP + 6
Address MULTIPLIER BP + 4
Return Address BP + 2
BP value SP
BP
Passing Parameters
o A common practice for a called procedure:
BOOLEN OPERATIONS

You might also like