Lecture Computer organization and assembly language: Chapter 19 - Dr. Safdar Hussain Bouk

pptx
Số trang Lecture Computer organization and assembly language: Chapter 19 - Dr. Safdar Hussain Bouk 16 Cỡ tệp Lecture Computer organization and assembly language: Chapter 19 - Dr. Safdar Hussain Bouk 292 KB Lượt tải Lecture Computer organization and assembly language: Chapter 19 - Dr. Safdar Hussain Bouk 0 Lượt đọc Lecture Computer organization and assembly language: Chapter 19 - Dr. Safdar Hussain Bouk 0
Đánh giá Lecture Computer organization and assembly language: Chapter 19 - Dr. Safdar Hussain Bouk
5 ( 22 lượt)
Nhấn vào bên dưới để tải tài liệu
Để tải xuống xem đầy đủ hãy nhấn vào bên trên
Chủ đề liên quan

Nội dung

CSC 221 Computer Organization and Assembly Language Lecture 19: I/O and Conditional Jumps in Assembly Lecture 18: Review Program Components I/O Instructions StdIn proc lpszBuffer:DWORD,bLen:DWORD • Description Include \masm32\include\masm32.inc includelib \masm32\lib\masm32.lib – StdIn receives text input from the console and places it in the buffer required as a parameter. – The function terminates when Enter is pressed. • Parameters invoke StdIn, addr buffer, 100 – 1. lpszBuffer The buffer to receive the text input from the console. – 2. bLen The length of the buffer. Source: C:\masm32\help\masmlib.chm Lecture 18: Review (cont.) StdOut proc lpszText:DWORD Include \masm32\include\masm32.inc includelib \masm32\lib\masm32.lib • Description: StdOut will display a zero terminated string at the current position in the console. invoke StdOut, addr message1 • Parameter – lpszText : A zero terminates string. • Return Value – There is no return value. Source: C:\masm32\help\masmlib.chm I/O Instructions: Example .data message1 BYTE "Type your name: ", 0 message2 BYTE "Your name is ", 0 .data? buffer BYTE 100 dup(?) .code start: invoke invoke invoke invoke invoke invoke end start StdOut, addr message1 StdIn, addr buffer, 100 StdOut, addr message2 StdOut, addr buffer StdIn, addr buffer, 100 ExitProcess, 0 Conditional Jump (Jcond) Instructions • A conditional jump instruction branches to a label when specific register or flag conditions are met. • Examples: – – – – – JB, JC jump to a label if the Carry flag is set JE, JZ jump to a label if the Zero flag is set JS jumps to a label if the Sign flag is set JNE, JNZ jump to a label if the Zero flag is clear JECXZ jumps to a label if ECX equals 0 Jcond Ranges • Prior to the 386: – jump must be within –128 to +127 bytes from current location counter. • IA-32 processors: – 32-bit offset permits jump anywhere in memory. Jumps Based on Specific Flags Jumps Based on Equality Jumps Based on Unsigned Comparisons Jumps Based on Signed Comparisons Lecture Outline ASSEMBLY LANGUAGE IMPLEMENTATION • I/O Instructions • Jumps Based On . . . – – – – Specific flags Equality Unsigned comparisons Signed Comparisons LET’S ENJOY ASSEMBLY Summary Assembly Language Implementation: • I/O Instructions – StdIn • invoke StdIn, addr buffer, 100 – StdOut • invoke StdOut, addr message1 Summary • Assembly Language Implementation: • Conditional Jump Instructions – Jumps Based on Specific Flags – JZ, JNZ, JC, JNC, …… – Jumps Based on Equality – JE, JNE, JCXZ, ….. – Jumps Based on Unsigned Comparison – JA, JB, JAE, JBE, ….. – Jumps Based on Signed Comparison – JG, JL, JGE, JLE, …. Reference Most of the Slides are taken from Presentation: Chapter 6 Assembly Language for Intel-Based Computers, 4th Edition Kip R. Irvine (c) Pearson Education, 2002. All rights reserved. You may modify and copy this slide show for your personal use, or for use in the classroom, as long as this copyright statement, the author's name, and the title are not changed.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.