(1) ASCII: American Standard Code for Information Interchange
Byte: Smallest addressable unit of memory.
Disassemble: Translate machine code to symbolic ("Assembler")
Double Word: 32 bits (4 bytes).
Downward compatible: (This disagrees with the text) You should (for example) be able to run a program generated on a 386 on an 8086 if you write the code the right way. He probably means that code generated on the 8086 will run on the 80386.
Hexadecimal: Base 16.
Instruction Mnemonic: Shorthand words that translate into assembly code, whose names remind us of what they do. For example, MOV means "Move" or "copy" from one location to another.
Instruction Set: The instructions that can be used to cause the CPU to perform different operations, such as copying data from one location to another, adding numbers, and so on. Some mnemonics may translate into different instructions ("op codes") depending on how they are used. For example, MOV translates into about 36 different OP codes.
Machine instruction: Ultimately, a binary code that makes sense to the processor.
Microcode: Code that is hard-wired into the CPU that causes it to translate OP codes into hardware signals. For example, the instruction ADD AX,10 causes the number 10 to be routed to the adder circuit, and then back to the AX register which means that certain gates or circuits must be opened (or closed) to allow the values to be sent to the proper location. Usually designed by engineers.
Octal: Base 8
Offset: The second set of 4 hex digits in a memory address are called the offset. (The first 4 are called the segment.) The address 1A30:1C00 translates to the address 1A300 + 1C00, which is a 20-bit address. In an instruction such as MOV [120],AX 120 indicates an offset in the DS register. (DS:0120) The segment registers are DS (Data Segment), CS (Code Segment), SS (Stack Segment) and ES (Extra Segment). All segments together occupy 64k total in the small memory model, in the huge memory model, each segment has 64k of space reserved.
Operand: That which is needed by an instruction for it to be able to execute. In the instruction MOV AX,10 both AX and 10 are operands. There are a different number of operands for different instructions. For example, while MOV and ADD both have 2 operands, PUSH and POP each have only one.
Program Entry Point: The first line of code in the program that is executed.
2's complement: Used for storing a negative number. Obtained by "flipping" (reversing) all the bits and adding one.
(2) You can use the features of the operating system in your code to save work (which can be done easily by the operating system). Since the interrupts (such as INT 21) are DOS-specific, the programs we are writing wouldn't run, say, under UNIX on the same machine. (The compiler is also o/s-specific.)
(3) No.
(4) Yes.
(5) Communications, encryption.
(6) One line of high-level language code translates into many lines of machine code, where in assembler, one line of code is exactly equal to one machine instruction.
a = b + c + d; in c would be as follows in assembler: MOV AX, B ADD AX, C ADD AX, D MOV A, AX
(7) Assembler. (See above)
(9) 58 59h = 0101 1000 0101 1001b
(10) 16
(11) (a) -128
(b) 127
(12) The first byte. (05, in this case)
(13) There are restrictions imposed by the language that keep you from all the features of the operating system.
When you first start up your computer, it looks at the ROM BIOS and copies its contents into RAM (programs can only execute from RAM). This little program then begins to execute, and it loads stuff from the disk drive into RAM. In DOS, it uses config.sys and autoexec.bat to find out how the remainder of the operating system should be loaded.
A comment is preceded by a ;
title Hello World Program
; dosseg ; comment this out, it's obsolete
.model small
.stack 100h This is where the stack starts (256 bytes --
100 thru 0)
.data now begins the data segment
; hello_message is a label
hello_message db 'Hello, world!',0dh,0ah,'$'
; 0d = \r
; 0a = \n
; the $ makes it stop
.code ; now begins the code segment
main proc
mov ax,@data ; puts segment address of data (.data) into ax.
mov ds, ax ; move ax into ds, so that ds now points to the data
; The above 2 steps are required for any program that wants to
; use .data
mov ah,9 ; Get ready for a dos call! "Hey dos, look at dx and
; start printing until you find a $
mov dx, offset hello_message ; move the address of hello_message
; into dx, which will be inspected by DOS
int 21h
mov ax,4c00h ; another message to dos. This makes it look into al.
; which will contain 00. (Another way of making it stop.)
int 21h
; The above 3 lines are required for normal termination of
; the program.
main endp ; end of the procedure
; there could be other stuff here.
end main ; end of main
tasm /zi /l tlink /v
The /zi and /v Put stuff in it for the turbo debugger
Guess what? If you're using another Borland language, such as C++ or Delphi or Pascal, you can compile your program so that you can use the turbo debugger on your program. In Delphi, you do this by checking off the "Include TDW Debug Info" on the linker page of your compiler options. You should be very careful about where you put the breakpoints, or you will end up stepping through way too much code. One of the advantages of debugging tricky Delphi code that way, is that you might get more detailed error messages than you did from the Delphi debugger. For example, say that you were using a unit that turned off the stack checking option, regardless of what your compiler options said in the project options, this turns off stack checking for the whole thing, so a stack overflow would just cause a gpf. But in TDW, you would see the stack overflow error code. (This happens to me, which is how I know.)
Some of the DOS calls are listed on page 116 and appendix G, starting on page 570.
The computer has a lot of components, including the motherboard, which contains the CPU, memory, I/O ports, keyboard port, mouse port, disk controller, bus.
There's also (some) disk drive(s) (usually minimum 1 FDD and 1 HDD, and possibly a CD), CRT, keyboard, mouse, network connection
The CPU registers
AX, BX, CX, DX are data registers.
CS, DS, SS, EX are segment registers
SI, DI and BP are index registers
IP instruction pointer
SP stack pointer
Flags register.
The Flags register :
Bit 11 - overflow 10 - direction 9 - interrupt 8 - trap 7 - sign 6 - zero 5 - not used 4 - auxiliary carry 3 - not used 2 - parity 1 - not used 0 - carry These bits may be affected as a result of various operations.
CX (count register)
MOV CX,10 ; decimal 10
BEG-OF-LOOP:
LOOP BEG-OF-LOOP ; will repeat the loop 10 times.
The LOOP instruction (Pascal code, sorry C folks)
Dec(CX)
If CX <> 0 then {so if cx=0 before the loop starts,}
goto :beg-of-loop {it will go 65000 times!!}
else
Do not alter your counter register during a loop, because bad stuff might happen.
DX is also used as an i/o pointer. mov dx 1 add dx,10 mov loc,dx with input/output instructions (i.e., dos calls) it points to i/o ports 255 through 65535
DI is a memory pointer (usually destination) mov DI, 100 For example, mov [DI], 20 The 20 goes to location 100. (Actually DS:DI)
SI is used as a memory pointer (usually source) mov di, 1000 mov ax, [si] mov [di],ax effectively copies contents of location pointed to from si to 1000.MOV AX,[DS][SI]
Third week's lab assignment: (too long to transcribe here)
Fourth week's lab assignment: Look at the size of hello.exe (dir hello.exe will show it) Write a C or C++ program to do the same thing and look at its size. Do exercises 3.1, 3.2, 3.6 at end of ch3 (1,2,6)
Third week's reading assignment: Read the pages 46-59 and 66-69 of chapter 3, and do review questions 1a-g, 2, 10-12, 15,16
Fourth week's reading assignment: Read pages 60-end of chapter 3, and do review questions 3, 5-8, 18, 19
[back to the main csc220 page] [To the downloadable files] [To Maggie's homepage]