CPSC 355 Lecture Notes - Lecture 30: File Descriptor, Assembly Language, Standard Streams

229 views5 pages

Document Summary

Eg: opening an existing file called myfile. bin. Cpsc 355 - lecture 30 nov 25th. // error handling code (cid:862)(cid:373)yfile. bi(cid:374)(cid:863) w0, -100 x1, pn x1, x1, :lo12:pn w2, 0 w3, 0 x8, 56. string mov adrp add mov mov mov svc cmp b. ge. Reading from a file: equivalent c function: long n_read = read(int fd, void *buf, unsigned long n); Previously set by openat( ), or 0 for stdin. Buf: buffer where the bytes read will be stored. 1 is returned on error: eg: assembly code to read in 8 bytes buf_size = 8 alloc = -(16 + buf_size) & -16 dealloc = - alloc buf_s = 16 main: stp mov add mov mov svc. Writing to a file: equivalent c function: w0, w19 x1, x29, buf_s x2, 8 x8, 63. // n_read is in x0 long n_written = write(int fd, void *buf, unsigned long n); Previously set by openat( ), or -1 for stdout.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents