Tuesday, February 26, 2008

Quiz 1 - 4 plus Appendices A and B

We will have a double-weight one-hour quiz at the beginning of our meeting on Tuesday, March 4. Topics:

  • integer representation and other Appendix A topics that we covered
  • assembly "by hand," i.e., what would the result in a machine-language listing be? and what does machine language in a given listing mean?
  • all topics discussed in architecture, memory organization, registers, etc.
  • basic assembly language statements for arithmetic and logic
You should understand all of the program examples in Appendix B and Chapters 1 to 4. In the exercises, you should be able to answer all of the following readily:

  • A-1 to A-8, A-11, A-12, A-13
  • 1-1, 1-3, 1-4
  • 2-1, 2-2, 2-4, 2-7, 2-8, 2-9
  • 3-3, 3-4, 3-78, 3-12, 3-15, 3-16
  • 4 all
There are a few topics we haven't discussed even a little, such as floating-point representation and some Pentium internals. Don't worry about those.

You may have all the hand-written notes you like, provided that you produced them yourself. Keep in mind that a passing grade is 65, and that passing averages on both programs and quizzes are required to pass the course.

Tuesday, February 19, 2008

skeleton program

I have found it convenient to have known-good code on file. Here's a very simple program that can serve as a starting place for your work (click for text version):


; skeleton assembly-language program SKEL.ASM
; for use with NASM and Dandamudi macros
;
; References:
; NASM at http://nasm.sourcegorge.net
; macros at http://www.scs.carleton.ca/~sivarama
; (see ASM book on this site)
;
; to assemble on Linux:
;
; nasm -f elf skel.asm
; ld -s -o skel skel.o io.o
;
; (files io.mac and io.o are assumed available)
;
; to run:
;
; ./skel
;
; input: any
; output: messages on screen
;
%include "io.mac"

.DATA
; -------------
; initialized data
;
; ascii 10 and 9 produce whitespace
; with CR and HT
;
strBegin db 10, 9, 'Skeleton program ---', 10, 0
strPrompt db 10, 9, 'Press a key: ', 0
strEnd db 10, 9, 'Program ending.', 10, 10, 0

.UDATA
; -------------
; uninitialized data
;
byteResponse resb 1

.CODE
.STARTUP

PutStr strBegin ; welcome message
PutStr strPrompt ; ask user for response

GetCh [byteResponse] ; get response
; but don't do anything with it

PutStr strEnd ; end program
.EXIT

Sample .bashrc

Check this sample .bashrc file for how many things are done. It will be executed (interpreted, actually, because it's a script) every time you log on if you put it in your home directory.

many, many instructions

For more information about NASM instructions:
  • Appendix E of the textbook names and describes "selected instructions," including the flags affected
  • Appendix B of current (v2) NASM instructions only lists the instructions that it assembles for each IA-32-type CPU,
    but without descriptions
  • old NASM docs have an Appendix B that includes descriptions of the actions of the instructions;
    no flags information there, though
  • Intel docs have more details than you can imagine about every instruction — there are hundreds more than we will ever use...