| UMBC | CMSC313 |
%define BUFSIZE 0X0F6000 ; This is 1,000,000 rounded up to the nearest
; multiple of 8192 which is the most efficient ; read size.
section .data
mode dd 0
flags dd 0
path db 'out',0
openMsg db 'Open error', 10, 0
bufsize dd BUFSIZE
section .bss
fd resd 1
buf resb BUFSIZE
section .text
global main ;must be declared for linker (ld)
extern printf
main: ;tell linker entry point
;; put your code here
open:
mov ebx, path
mov ecx, flags
mov edx, mode
mov eax, 5
int 80h
mov [ fd ], eax
cmp eax, 0
jg read
push openMsg
call printf
add esp, 4
jmp quit
read:
quit:
mov ebx,0 ;successful termination of program
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
This program will use subprogram, arrays, and system calls. You will have to open a file (which can have up to 1,000,000 bytes). This file can be any time of a file, text, binary, code, whatever. Then you will output 16 bytes per line where the first item on the line will be the offset into the file, followed by a colon. Then will come 16 bytes in hexadecimal characters, each one followed by a space. The will come a space, two colons and another space. Finally, display the ASCII character, if there is one. If not, display a period instead. For this project, that means if the byte is less than 32 or greater than 126, print the period. The program must terminate on a new line. Additionally, make the hex letters upcase.
You must design your program in such a way that it has at least two subprograms. Obviously, you will need an array of 1,000,000 bytes to use as a buffer. You must also use at least three system calls to make this work.
You must close the file as soon as possible. Good programming style dicates that files should only be opened the shortest amount of time possible.
[~/courses/umbc/CMSC313/spring04/proj2/C]$ proj2 Enter the name of the file to view: 313.txt 00000000: 48 65 72 65 20 69 73 20 74 68 65 20 66 69 72 73 :: Here.is.the.firs 00000010: 74 20 74 72 79 20 61 74 20 74 68 65 20 73 65 63 :: t.try.at.the.sec 00000020: 6F 6E 64 20 70 61 72 74 3A 0A 20 0A 23 31 35 20 :: ond.part:...#15. 00000030: 20 43 6F 6D 62 69 6E 61 74 69 6F 6E 61 6C 20 4C :: .Combinational.L 00000040: 6F 67 69 63 20 43 69 72 63 75 69 74 73 20 20 20 :: ogic.Circuits... 00000050: 20 20 20 4D 61 6E 6F 20 43 68 61 70 20 32 0A 20 :: ...Mano.Chap.2.. 00000060: 0A 23 31 36 20 20 28 43 6F 6E 74 69 6E 75 65 64 :: .#16..(Continued 00000070: 29 0A 20 0A 23 31 37 20 20 43 6F 6D 62 69 6E 61 :: )...#17..Combina 00000080: 74 69 6F 6E 61 6C 20 4C 6F 67 69 63 20 44 65 73 :: tional.Logic.Des 00000090: 69 67 6E 20 20 20 20 20 20 4D 61 6E 6F 20 43 68 :: ign......Mano.Ch 000000A0: 61 70 20 33 0A 20 0A 23 31 38 20 20 41 72 69 74 :: ap.3...#18..Arit 000000B0: 68 6D 65 74 69 63 20 46 75 6E 63 74 69 6F 6E 73 :: hmetic.Functions 000000C0: 20 61 6E 64 20 43 69 72 63 75 69 74 73 20 20 4D :: .and.Circuits..M 000000D0: 61 6E 6F 20 43 68 61 70 20 34 2C 20 43 68 61 70 :: ano.Chap.4,.Chap 000000E0: 20 35 20 20 20 20 48 6F 6D 65 77 6F 72 6B 20 31 :: .5....Homework.1 000000F0: 20 64 75 65 0A 20 0A 23 31 39 20 20 20 28 43 6F :: .due...#19...(Co 00000100: 6E 74 69 6E 75 65 64 29 0A 20 0A 23 32 30 20 20 :: ntinued)...#20..
;; Filename: 6789prj2.asm ;; Name: Ima Student ;; SSAN: 6789 ;; Date: 28 Feb 2004 ;; Course: CMSC313 ;; Description: (Your psuedocode goes here. Must be detailed) ;; Notes: (As needed, such has how to compile)