CSCI2510 Computer Organization Tutorial 02: MASM Basic .

2y ago
7 Views
2 Downloads
644.19 KB
16 Pages
Last View : 30d ago
Last Download : 3m ago
Upload by : Shaun Edmunds
Transcription

CSCI2510 Computer OrganizationTutorial 02: MASM BasicStructs and OperationsBentian Jiangbtjiang@cse.cuhk.edu.hk

Review You can use the video demo for tuto 1 to revisit howto setup basic MASM environment and how to seeregister windows step by step:– http://www.cse.cuhk.edu.hk/ mcyang/csci2510.html Please create a new file for each program. If youwant to have two assembly file in one project, pleaseexclude all assembly file until only one included, andrebuild it.– [Right Click] the .asm file [Exclude From Project].– You can include it again in [Project] [Show All Files]CSCI2510 Tut02: MASM Basic Structs and Operations2

Program structureCSCI2510 Tut02: MASM Basic Structs and Operations3

Assembler Directives Telling the assembler what to do:– Option, configuration, syntax etc .386– Use 80386 instruction set (intel 1985’s architecture, mostcommon supported) .model flat– Memory model of the assembly program– Only flat model is supported under Win32 program (.model) stdcall– Function calling convention, parameter passed from right toleft (stack)CSCI2510 Tut02: MASM Basic Structs and Operations4

Includes Files casemap:none– The assembly is case insensitive– i.e. Label label IAbEl include windows.inc include kerner32.inc– Include the files, which handles the system calls– E.g. invoke ExitProcess, 0 (valid after include files) include user32.inc– Graphical User Interface (GUI) elements in windowsCSCI2510 Tut02: MASM Basic Structs and Operations5

Data Segment & Datatypes “.data” is also assembly directives– Declare and apply some memory space in primary memory(e.g. RAM) Datatypes: integer DB, DW, DWORD, DQ– SINGLEBYTE DB, 8-bits– TWOBYTE DW, 16-bits– FOURBYTE DWORD, 32-bits– EIGHTBYTE DQ, 64-bitsCSCI2510 Tut02: MASM Basic Structs and Operations6

Data Segment & DatatypesCSCI2510 Tut02: MASM Basic Structs and Operations7

Code Segment “.code” is also assembly directives– State the following segment is the program assembly code start:– Label that indicates where should the program begins– End function with “end start” Comment in masm: “;”– It will directly comment the whole lineCSCI2510 Tut02: MASM Basic Structs and Operations8

I/O (Console) C style function to input/output information– crt printf: print like a C program (like printf() in C)– crt scanf: read the input (like scanf() in C)– console application Example:CSCI2510 Tut02: MASM Basic Structs and Operations9

I/O (Console) Download the new library:– In Blackboard - CSCI2510 - course content - msvcrt.zip Open VS community, click [New] [Project] [VisualC ] [Windows Desktop] [Windows DesktopWizard] [Console application] only choose [Emptyproject].CSCI2510 Tut02: MASM Basic Structs and Operations10

I/O (Console) Configure the project setting like the previous program– Left the Subsystem be [Console] instead of [Windows] In the [Project] [Property], add the newly downloaded libraryto [Linker] [General] [Additional Library Directories]– e.g. D:\csci2510\libCSCI2510 Tut02: MASM Basic Structs and Operations11

Reference for Programming ex1.386.model flat, stdcalloption casemap:noneinclude windows.incinclude kernel32.incinclude msvcrt.incincludelib msvcrt.lib.dataAPrompt db "CSCI2510 Tutorial 2", 10, 0.codestart:invoke crt printf, addr APromptinvoke ExitProcess, NULLend start; press Ctrl F5 to prevent instant quit after program executionCSCI2510 Tut02: MASM Basic Structs and Operations12

Hints for HW1 For question 1, you can find corresponding conceptsin lecture 01, please answer the questions in yourown words. For question 2, you can find corresponding conceptsin lecture 02. For question 3, you can find corresponding conceptsin lecture 03.CSCI2510 Tut02: MASM Basic Structs and Operations13

Extended ASCII for HW1 Q2CSCI2510 Tut02: MASM Basic Structs and Operations14

Hint for Q2 Example to translate a 16-bits word into string ofcharacters:– E641h, find the corresponding hex in extended ASCII table E6h 230 E6h µ 41h 65 41h A So the result is “µA”. You can find how to interpret a word in other methodsin slide of lecture 02.CSCI2510 Tut02: MASM Basic Structs and Operations15

Summary Reference for programming exercise 1 Hints for HW1 Q1-Q3CSCI2510 Tut02: MASM Basic Structs and Operations16

option casemap:none include windows.inc include kernel32.inc include msvcrt.inc includelib msvcrt.lib .data APrompt db "CSCI2510 Tutorial 2", 10, 0 .code start: invoke crt_printf, addr APrompt invoke ExitProcess, NULL end start; press Ctrl F5 to prevent instant quit after program execution CSCI2510 Tut

Related Documents:

Tutorial 09:Associative mapping in MASM Yuhong LIANG yhliang@cse.cuhk.edu.hk. Outline LRU Algorithm First-In-First-Out Algorithm CSCI2510 Tut09: Associative mapping implementation 2. LRU Algorithm . jmp check. LRU Algorithm CSCI2510 Tut09: Associative mapping in MASM 10 4 3 2 1

Tutorial Process The AVID tutorial process has been divided into three partsÑ before the tutorial, during the tutorial and after the tutorial. These three parts provide a framework for the 10 steps that need to take place to create effective, rigorous and collaborative tutorials. Read and note the key components of each step of the tutorial .

Tutorial Process The AVID tutorial process has been divided into three partsÑ before the tutorial, during the tutorial and after the tutorial. These three parts provide a framework for the 10 steps that need to take place to create effective, rigorous and collaborative tutorials. Read and note the key components of each step of the tutorial .

Tutorial 1: Basic Concepts 10 Tutorial 1: Basic Concepts The goal of this tutorial is to provide you with a quick but successful experience creating and streaming a presentation using Wirecast. This tutorial requires that you open the tutorial document in Wirecast. To do this, select Create Document for Tutorial from the Help menu in Wirecast.

Tutorial 16: Urban Planning In this tutorial Introduction Urban Planning tools Zoning Masterplanning Download items Tutorial data Tutorial pdf This tutorial describes how CityEngine can be used for typical urban planning tasks. Introduction This tutorial describes how CityEngine can be used to work for typical urban .

Tutorial 1: Basic Concepts 10 Tutorial 1: Basic Concepts The goal of this tutorial is to provide you with a quick but successful experience creating and streaming a presentation using Wirecast. This tutorial requires that you open the tutorial document in Wirecast. To do this, select Create Document for Tutorial from the Help menu in Wirecast.

CSC418: Computer Graphics Tutorial 1 MichaelTao September20,2012 Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 1 / 31. Plan for Today (and next Week) Event-DrivenProgramming . OpenGL 4.3 Programmable Pipeline Diagram Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 19 / 31.

teaching 1, and Royal Colleges noting a reduction in the anatomy knowledge base of applicants, this is clearly an area of concern. Indeed, there was a 7‐fold increase in the number of medical claims made due to deficiencies in anatomy knowledge between 1995 and 2007.