本文整理汇总了C++中read_word函数的典型用法代码示例。如果您正苦于以下问题:C++ read_word函数的具体用法?C++ read_word怎么用?C++ read_word使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_word函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: seekcompresszip
/* Seek zip->fp to compressed data
return:
==0 success
<0 error
*/
int seekcompresszip(ZIP* zip, struct zipent* ent) {
char buf[ZIPNAME];
long offset;
if (!zip->fp) {
if (!revivezip(zip))
return -1;
}
if (osd_fseek(zip->fp, ent->offset_lcl_hdr_frm_frst_disk, SEEK_SET)!=0) {
errormsg ("Seeking to header", ERROR_CORRUPT, zip->zip);
return -1;
}
if (osd_fread(zip->fp, buf, ZIPNAME)!=ZIPNAME) {
errormsg ("Reading header", ERROR_CORRUPT, zip->zip);
return -1;
}
{
UINT16 filename_length = read_word (buf+ZIPFNLN);
UINT16 extra_field_length = read_word (buf+ZIPXTRALN);
/* calculate offset to data and osd_fseek() there */
offset = ent->offset_lcl_hdr_frm_frst_disk + ZIPNAME + filename_length + extra_field_length;
if (osd_fseek(zip->fp, offset, SEEK_SET) != 0) {
errormsg ("Seeking to compressed data", ERROR_CORRUPT, zip->zip);
return -1;
}
}
return 0;
}
开发者ID:Ezio-PS,项目名称:mame2003-libretro,代码行数:40,代码来源:unzip.c
示例2: vbe_biosfn_restore_video_state
void vbe_biosfn_restore_video_state(uint16_t ES, uint16_t BX)
{
uint16_t enable, i;
enable = read_word(ES, BX);
BX += 2;
if (!(enable & VBE_DISPI_ENABLED)) {
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
outw(VBE_DISPI_IOPORT_DATA, enable);
} else {
outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
BX += 2;
outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
BX += 2;
outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
BX += 2;
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
outw(VBE_DISPI_IOPORT_DATA, enable);
for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
outw(VBE_DISPI_IOPORT_INDEX, i);
outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
BX += 2;
}
}
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:30,代码来源:vbe.c
示例3: read_fat_bs
void read_fat_bs(uint8_t* buf, struct fat_BS* bs) {
memcpy(bs->bootjmp,buf,3);
memcpy(bs->oem_name,buf+3,8);
bs->bytes_per_sector = read_halfword(buf, 11);
bs->sectors_per_cluster = read_byte(buf, 13);
bs->reserved_sector_count = read_halfword(buf, 14);
bs->table_count = read_byte(buf, 16);
bs->root_entry_count = read_halfword(buf, 17);
bs->total_sectors_16 = read_halfword(buf, 19);
bs->media_type = read_byte(buf, 21);
bs->table_size_16 = read_halfword(buf, 22);
bs->sectors_per_track = read_halfword(buf, 24);
bs->head_side_count = read_halfword(buf, 26);
bs->hidden_sector_count = read_word(buf, 28);
bs->total_sectors_32 = read_word(buf, 32);
if (bs->table_size_16==0) {
memcpy(&bs->ext,buf+36,sizeof(struct fat_extBS_32));
} else {
bs->ext.fat16.bios_drive_num = read_byte(buf,36);
bs->ext.fat16.reserved1 = read_byte(buf,37);
bs->ext.fat16.boot_signature = read_byte(buf,38);
bs->ext.fat16.volume_id = read_word(buf,39);
memcpy(&bs->ext.fat16.volume_label,buf+43,11);
memcpy(&bs->ext.fat16.fat_type_label,buf+54,8);
}
}
开发者ID:carld,项目名称:interim,代码行数:28,代码来源:fat.c
示例4: reset_registers
static void reset_registers(void) {
uint32_t vectortable = read_word(VECTOR_TABLE_OFFSET);
// R[0..12] = bits(32) UNKNOWN {nop}
SW(&sp_main,read_word(vectortable) & 0xfffffffc);
// sp_process = ((bits(30) UNKNOWN):'00')
SW(&sp_process, SR(&sp_process) & ~0x3);
CORE_reg_write(LR_REG, 0xFFFFFFFF);
uint32_t tmp = read_word(vectortable+4);
bool tbit = tmp & 0x1;
CORE_reg_write(PC_REG, tmp & 0xfffffffe);
if (! (tmp & 0x1) ) {
WARN("Reset vector %08x at %08x invalid\n", tmp, vectortable+4);
CORE_ERR_unpredictable("Thumb bit must be set for M-series\n");
}
// ASPR = bits(32) UNKNOWN {nop}
union ipsr_t ipsr = CORE_ipsr_read();
ipsr.bits.exception = 0;
CORE_ipsr_write(ipsr);
union epsr_t epsr = CORE_epsr_read();
epsr.bits.T = tbit;
epsr.bits.ICI_IT_top = 0;
epsr.bits.ICI_IT_bot = 0;
CORE_epsr_write(epsr);
}
开发者ID:inhee,项目名称:M-ulator,代码行数:32,代码来源:registers.c
示例5: elf_find_next_higher_section
Elf32_Shdr *
elf_find_next_higher_section(Elf32_Word offset)
{
Elf32_Shdr *section;
Elf32_Shdr *higher;
Elf32_Word sectionsize;
int numsections;
int i = 0;
section = (Elf32_Shdr *)FILE_OFFSET(read_word(elf_header->e_shoff));
sectionsize = read_half(elf_header->e_shentsize);
numsections = read_half(elf_header->e_shnum);
higher = NULL;
for (i=0;i<numsections;i++) {
if (read_word(section->sh_offset) >= offset) {
if (higher == NULL) {
higher = section;
} else if (read_word(section->sh_offset) < read_word(higher->sh_offset)) {
higher = section;
}
}
section = (Elf32_Shdr *)((char *)section + sectionsize);
}
return higher;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:29,代码来源:elf-dynstr-gc.c
示例6: enqueue_key
unsigned int enqueue_key(uint8_t scan_code, uint8_t ascii_code)
{
uint16_t buffer_start, buffer_end, buffer_head, buffer_tail, temp_tail;
#if BX_CPU < 2
buffer_start = 0x001E;
buffer_end = 0x003E;
#else
buffer_start = read_word(0x0040, 0x0080);
buffer_end = read_word(0x0040, 0x0082);
#endif
buffer_head = read_word(0x0040, 0x001A);
buffer_tail = read_word(0x0040, 0x001C);
temp_tail = buffer_tail;
buffer_tail += 2;
if (buffer_tail >= buffer_end)
buffer_tail = buffer_start;
if (buffer_tail == buffer_head)
return(0);
write_byte(0x0040, temp_tail, ascii_code);
write_byte(0x0040, temp_tail+1, scan_code);
write_word(0x0040, 0x001C, buffer_tail);
return(1);
}
开发者ID:Klanly,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:28,代码来源:keyboard.c
示例7: emu8k_detect
/* emu8k_detect:
* Locate the EMU8000. This tries to extract the base port from the E section
* of the BLASTER environment variable, and then does some test reads to check
* that there is an EMU8000 there.
*/
int emu8k_detect() {
char *envvar;
if (!(envvar=getenv("BLASTER"))) {
sprintf(allegro_error,"BLASTER environment variable not set");
return 0;
}
_emu8k_baseport=0;
while (*envvar) {
if (*envvar=='E') _emu8k_baseport=strtol(envvar+1,NULL,16);
while ((*envvar!=' ')&&(*envvar!=0)) envvar++;
if (*envvar) envvar++;
}
if (!_emu8k_baseport) {
sprintf(allegro_error,"BLASTER environment variable has no E section");
return 0;
}
sprintf(allegro_error,"AWE32 detection failed on port 0x%04x",_emu8k_baseport);
if ((read_word(7, 0,3)&0x000f)!=0x000c) return 0;
if ((read_word(1,29,1)&0x007e)!=0x0058) return 0;
if ((read_word(1,30,1)&0x0003)!=0x0003) return 0;
*allegro_error=0;
return 1;
}
开发者ID:Ringdingcoder,项目名称:d1x,代码行数:32,代码来源:emu8k.c
示例8: get_compressed_data_offset
static zip_error get_compressed_data_offset(zip_file *zip, UINT64 *offset)
{
file_error error;
UINT32 read_length;
/* make sure the file handle is open */
if (zip->file == nullptr)
{
int filerr = osd_open(zip->filename, OPEN_FLAG_READ, &zip->file, &zip->length);
if (filerr != FILERR_NONE)
return ZIPERR_FILE_ERROR;
}
/* now go read the fixed-sized part of the local file header */
error = osd_read(zip->file, zip->buffer, zip->header.local_header_offset, ZIPNAME, &read_length);
if (error != FILERR_NONE || read_length != ZIPNAME)
return (error == FILERR_NONE) ? ZIPERR_FILE_TRUNCATED : ZIPERR_FILE_ERROR;
/* compute the final offset */
*offset = zip->header.local_header_offset + ZIPNAME;
*offset += read_word(zip->buffer + ZIPFNLN);
*offset += read_word(zip->buffer + ZIPXTRALN);
return ZIPERR_NONE;
}
开发者ID:stengun,项目名称:mame,代码行数:25,代码来源:unzip.cpp
示例9: opcode_dict_unserialize
void opcode_dict_unserialize(opcode_dict_t od, reader_t r, void* dl_handle) {
long i,j,tot,typtot;
const char* name;
/* read dict header and check it against "DIC" */
name = read_string(r);
assert(!strcmp(name,"DIC"));
/* read number of arrays, check it against OpcodeTypeMax */
typtot = read_word(r);
assert(typtot==OpcodeTypeMax);
/* now for each array */
for(i=0;i<OpcodeTypeMax;i+=1) {
/* read number of records in array */
tot = read_word(r);
/* now for each record */
for(j=0;j<tot;j+=1) {
/* retrieve name */
typtot = read_word(r);
name = read_string(r);
assert(typtot == 1+strlen(name));
opcode_dict_add(od, i, name, opcode_stub_resolve(i,name,dl_handle));
}
/* read END OF RECORD */
typtot = read_word(r);
assert(typtot==0xFFFFFFFF);
}
}
开发者ID:bl0b,项目名称:tinyaml,代码行数:29,代码来源:opcode_dict.c
示例10: switch
RegExp::RegExp(char* expression) {
this->operations.reserve(64);
this->transducers.reserve(64);
this->expression = expression;
for (ui i = 0; i < strlen(expression); i++) {
switch(expression[i]) {
case '<': {
char* input = read_word(i);
char* output = read_word(++i);
i+=2;
ui weight = read_number(i);
Monoid monoid(input, output, weight);
this->transducers.push_back(new Transducer(monoid));
}
break;
case '|':
this->operations.push_back(UNION);
break;
case '*':
this->operations.push_back(STAR);
break;
case '.':
this->operations.push_back(CONCAT);
break;
}
}
}
开发者ID:denisMihaylov,项目名称:University,代码行数:28,代码来源:regular_exp.cpp
示例11: show_heap
void show_heap(void) {
// TODO: change the code, since i change the heap_tail to one byte after
void* p = heap_head;
DebugStr("-----------------\n");
DebugStr("heap_head = %x, heap size = %u\n",
p, (char*)heap_tail - (char*)heap_head);
DebugStr("-----------------\n");
DebugStr("%x\n", (char*)p + WSIZE);
DebugStr("%x\n", (char*)p + 2 * WSIZE);
DebugStr("-----------------\n");
p = (char*)p + 3 * WSIZE;
assert(p < heap_tail);
while (get_size(p) > 0) {
assert(p < heap_tail);
DebugStr("hdrp:%x val = ", p);
to_hex_str(*(size_t*)p, 1);
DebugStr("size = %u, ALLOC = %d, PREV_ALLOC = %d\n",
get_size(p), !!get_alloc(p), !!get_prev_alloc(p));
void *ftrp = (char*)p + get_size(p) - WSIZE;
DebugStr("ftrp:%x val = ", ftrp);
to_hex_str(*(size_t*)ftrp, 1);
if (!get_alloc(p)) { // if current block is not allocated, header = footer
assert(read_word(p) == read_word(ftrp));
}
DebugStr("-----------------\n");
p += get_size(p);
}
DebugStr("heap_tail = %x\n", p);
DebugStr("-----------------\n");
}
开发者ID:Guitang-Lan,项目名称:CSAPP,代码行数:30,代码来源:mm.c
示例12: loadCalibration
void EEPROM::loadCalibration(int16_t * xMin, int16_t * xMax, int16_t * yMin, int16_t * yMax)
{
*xMin = read_word(EEPROM_CAL_XMIN);
*xMax = read_word(EEPROM_CAL_XMAX);
*yMin = read_word(EEPROM_CAL_YMIN);
*yMax = read_word(EEPROM_CAL_YMAX);
}
开发者ID:WHCS-UCF,项目名称:AVR-Base-Station,代码行数:7,代码来源:eeprom.cpp
示例13: elf_find_section_named
Elf32_Shdr *
elf_find_section_named(char *name)
{
Elf32_Shdr *section;
Elf32_Shdr *strtab_section;
Elf32_Word sectionsize;
int numsections;
char *strtab;
int i = 0;
section = (Elf32_Shdr *)FILE_OFFSET(read_word(elf_header->e_shoff));
strtab_section = elf_find_section_num(read_half(elf_header->e_shstrndx));
strtab = (char *)FILE_OFFSET(read_word(strtab_section->sh_offset));
sectionsize = read_half(elf_header->e_shentsize);
numsections = read_half(elf_header->e_shnum);
for (i=0;i<numsections;i++) {
if (strcmp(&strtab[read_word(section->sh_name)], name) == 0) {
return section;
}
section = (Elf32_Shdr *)((char *)section + sectionsize);
}
return NULL;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:27,代码来源:elf-dynstr-gc.c
示例14: read_images
/*
* read_images: Reads the images from and mnist image db file and puts the
* images into and array of vectors.
*
* Parameters:
* - train: boolean value, read from training db if 0, test db if 1
*
* Return value:
* - array of vectors containing mnist images
*/
mnist_images_t read_images(uint32_t train)
{
// Set the filename based the mode (train or test)
char *full_path;
if (train) {
full_path = concat_fname(mnist_path, train_image_fname);
} else {
full_path = concat_fname(mnist_path, test_image_fname);
}
// Open the file for reading
char *mode = FILE_MODE;
FILE *fp = Fopen(full_path, mode);
// Read the header of the file
uint8_t header[IMAGE_HEADER_SIZE];
Fread(header, sizeof(uint8_t), IMAGE_HEADER_SIZE, fp);
// Extract size info from mnist db header
uint32_t num_images = read_word(header, NUM_ITEMS_OFFSET);
uint32_t rows = read_word(header, ROW_OFFSET);
uint32_t cols = read_word(header, COL_OFFSET);
uint32_t img_size = rows * cols;
// Create array of mnist image vectors
vector_t *mnist_data = (vector_t*) Calloc(num_images, sizeof(vector_t));
// Populate vectors with one image each
for (uint32_t i = 0; i < num_images; i++) {
mnist_data[i] = Vector((size_t) img_size);
uint8_t *image_bytes = (uint8_t*) Calloc(img_size, sizeof(uint8_t));
uint32_t actual_size;
// Read img_size bytes from the db file into the byte array
if ((actual_size = fread(image_bytes, sizeof(uint8_t), img_size, fp)) < img_size) {
Free(image_bytes);
for (uint32_t i = 0; i < num_images; i++) vector_destroy(mnist_data[i]);
return NULL;
}
// Move 8 bit data to 32 bit integer for more precision
uint32_t *vector_data = (uint32_t*) Calloc(img_size, sizeof(uint32_t));
for (uint32_t j = 0; j < img_size; j++) {
vector_data[j] = (uint32_t) image_bytes[j];
}
mnist_data[i]->data = vector_data;
Free(image_bytes);
}
// Create the mnist_images_t pointer and populate the struct it points to
mnist_images_t mnist_imgs = Mnist_images((size_t) num_images);
mnist_imgs->imgs = mnist_data;
Free(full_path);
Fclose(fp);
return mnist_imgs;
}
开发者ID:kkudrolli,项目名称:Team-SDK-545,代码行数:67,代码来源:mnist.c
示例15: print_bin
print_bin(){
if(dbg.flag != 0)puts("");
return;
printf(" |%04X %04X %04X %04X\n",
read_word(PC-2),
read_word(PC),
read_word(PC+2),
read_word(PC+4));
}
开发者ID:tatsui,项目名称:pdp11-run,代码行数:9,代码来源:print_disas.c
示例16: read_word
uint32_t PCI::pciCheckVendor(uint32_t bus, uint32_t slot)
{
uint32_t vendor, device;
/* check if device is valid */
if ((vendor = read_word(bus, slot, 0, 0)) != 0xFFFF)
{
device = read_word(bus, slot, 0, 2);
/* valid device */
} return (vendor);
}
开发者ID:imgits,项目名称:ShellcodeOS,代码行数:10,代码来源:pci.cpp
示例17: read_flash
static int
read_flash(Environ *e, Self *s, int offset, uByte *data, int len)
{
int actual = 0;
int width = s->meths->width;
int mask = width - 1;
int i;
DPRINTF(("read_flash: offset %#x, data %#x, len %d\n", offset, data, len));
if (offset & mask)
{
int n = width - (offset & mask);
DPRINTF(("read_flash: %d unaligned bytes at %#x\n", n, offset));
if (n > len)
n = len;
read_word(e, s, offset, s->buf);
for (i = 0; i < n; i++)
data[i] = s->buf[(offset & mask) + i];
data += n;
len -= n;
actual += n;
offset += n;
}
while (len >= width)
{
read_word(e, s, offset, data);
#if 0
DPRINTF(("read_flash: %d bytes at %#x, %#x %#x\n", width, offset, data[0], data[1]));
#endif
data += width;
len -= width;
actual += width;
offset += width;
}
if (len)
{
read_word(e, s, offset, s->buf);
DPRINTF(("read_flash: %d trailing bytes at %#x, %#x\n", len, offset, s->buf[0]));
for (i = 0; i < len; i++)
data[i] = s->buf[i];
actual += len;
}
DPRINTF(("read_flash: actual = %d\n", actual));
return actual;
}
开发者ID:cstrotm,项目名称:smartfirmware,代码行数:55,代码来源:gflash.c
示例18: thread_rollback
/*---------------------------------------------------------------------------*/
static void
thread_rollback(int fd)
{
#if INCLUDE_RAM
unsigned char *addr;
uint16_t size = 0;
unsigned char *thread_mem_start = (unsigned char *)&checkpoint_thread.thread.stack;
unsigned char *thread_mem_end = thread_mem_start + sizeof(checkpoint_thread.thread.stack);
unsigned char *coffee_mem_start = cfs_coffee_get_protected_mem(&size);
unsigned char *coffee_mem_end = coffee_mem_start + size;
#endif /* INCLUDE_RAM */
/*PRINTF("protected thread memory: %u, size=%u\n", (uint16_t) thread_mem_start, sizeof(checkpoint_thread.thread.stack));*/
/*PRINTF("protected coffee memory: %u, size=%u\n", (uint16_t) coffee_mem_start, size);*/
/* RAM */
#if INCLUDE_RAM
if (coffee_mem_start < thread_mem_start) {
read(fd, RAM_START, coffee_mem_start-RAM_START);
read(fd, coffee_mem_end, thread_mem_start-coffee_mem_end);
read(fd, thread_mem_end, RAM_END-thread_mem_end);
} else {
read(fd, RAM_START, thread_mem_start-RAM_START);
read(fd, thread_mem_end, coffee_mem_start-thread_mem_end);
read(fd, coffee_mem_end, RAM_END-coffee_mem_end);
}
#endif /* INCLUDE_RAM */
/* Timers */
#if INCLUDE_TIMERS
TACTL = read_word(fd);
TACCTL1 = read_word(fd);
TACCR1 = read_word(fd);
TAR = read_word(fd);
TBCTL = read_word(fd);
TBCCTL1 = read_word(fd);
TBCCR1 = read_word(fd);
TBR = read_word(fd);
#endif /* INCLUDE_TIMERS */
/* LEDs */
#if INCLUDE_LEDS
leds_arch_set(read_byte(fd));
#endif /* INCLUDE_LEDS */
/* UART DMA */
#if INCLUDE_UART_DMA
read_word(fd); /* DMA0SZ ignored */
uart1_reset_dma();
#endif /* INCLUDE_UART_DMA */
/* Radio */
/* ADC */
/* ... */
#if INCLUDE_PADDING
read_byte(fd);
#endif /* INCLUDE_PADDING */
}
开发者ID:kincki,项目名称:contiki,代码行数:61,代码来源:checkpoint-arch.c
示例19: are_anagrams
bool are_anagrams(const char *str1,const char *str2)
{
int cnt1[26]={0},cnt2[26]={0};
int i;
read_word(cnt1,str1);
read_word(cnt2,str2);
for(i=0;i<26;i++){
if(cnt1[i]!=cnt2[i])
return false;
}
return true;
}
开发者ID:Encore777,项目名称:DaiJiale-ProfessionalNotes,代码行数:12,代码来源:P224T14.c
示例20: read_user_entry
static int
read_user_entry(FILE *secrets_file, user_entry_t *user_entry)
{
int rc;
retry:
if (feof(secrets_file)) {
return -1;
}
rc = read_word(secrets_file, user_entry->name);
if ('#' == rc || -1 == rc) {
seek_eoln(secrets_file);
goto retry;
}
if ('\n' == rc) {
goto retry;
}
rc = read_word(secrets_file, user_entry->server);
if ('#' == rc || -1 == rc) {
seek_eoln(secrets_file);
goto retry;
}
if ('\n' == rc) {
goto retry;
}
rc = read_word(secrets_file, user_entry->secret);
if ('#' == rc || -1 == rc) {
seek_eoln(secrets_file);
goto retry;
}
if ('\n' == rc) {
goto retry;
}
rc = read_word(secrets_file, user_entry->addr);
if (-1 == rc) {
seek_eoln(secrets_file);
goto retry;
}
if ('\n' != rc) {
seek_eoln(secrets_file);
}
return 0;
}
开发者ID:fabn,项目名称:openvpn-otp,代码行数:52,代码来源:otp.c
注:本文中的read_word函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论