Search Results

Search found 28 results on 2 pages for 'msb'.

Page 1/2 | 1 2  | Next Page >

  • finding N contiguous zero bits in an integer to the left of the MSB from another

    - by James Morris
    First we find the MSB of the first integer, and then try to find a region of N contiguous zero bits within the second number which is to the left of the MSB from the first integer. Here is the C code for my solution: typedef unsigned int t; unsigned const t_bits = sizeof(t) * CHAR_BIT; _Bool test_fit_within_left_of_msb( unsigned width, t val1, t val2, unsigned* offset_result) { unsigned offbit = 0; unsigned msb = 0; t mask; t b; while(val1 >>= 1) ++msb; while(offbit + width < t_bits - msb) { mask = (((t)1 << width) - 1) << (t_bits - width - offbit); b = val2 & mask; if (!b) { *offset_result = offbit; return true; } if (offbit++) /* this conditional bothers me! */ b <<= offbit - 1; while(b <<= 1) offbit++; } return false; } Aside from faster ways of finding the MSB of the first integer, the commented test for a zero offbit seems a bit extraneous, but necessary to skip the highest bit of type t if it is set. I have also implemented similar algorithms but working to the right of the MSB of the first number, so they don't require this seemingly extra condition. How can I get rid of this extra condition, or even, are there far more optimal solutions?

    Read the article

  • Is TCP/IP encapsulation MSB or LSB?

    - by Justin
    Application data sent over TCP experiences multiple encapsulations: The application data is encapsulated within one or many TCP fragments The TCP fragment is encapsulated within one or many IP datagrams The IP datagram is encapsulated within one or many Ethernet frames It turns out Ethernet frames are sent most-significant byte first, and within each byte, most-significant bit first. What about the multiple encapsulations? Are they performed MSB first or LSB first?

    Read the article

  • Finding N contiguous zero bits in an integer to the left of the MSB position of another integer

    - by James Morris
    The problem is: given an integer val1 find the position of the highest bit set (Most Significant Bit) then, given a second integer val2 find a contiguous region of unset bits, with the minimum number of zero bits given by width to the left of the position (ie, in the higher bits). Here is the C code for my solution: typedef unsigned int t; unsigned const t_bits = sizeof(t) * CHAR_BIT; _Bool test_fit_within_left_of_msb( unsigned width, t val1, t val2, unsigned* offset_result) { unsigned offbit = 0; unsigned msb = 0; t mask; t b; while(val1 >>= 1) ++msb; while(offbit + width < t_bits - msb) { mask = (((t)1 << width) - 1) << (t_bits - width - offbit); b = val2 & mask; if (!b) { *offset_result = offbit; return true; } if (offbit++) /* this conditional bothers me! */ b <<= offbit - 1; while(b <<= 1) offbit++; } return false; } Aside from faster ways of finding the MSB of the first integer, the commented test for a zero offbit seems a bit extraneous, but necessary to skip the highest bit of type t if it is set. I have also implemented similar algorithms but working to the right of the MSB of the first number, so they don't require this seemingly extra condition. How can I get rid of this extra condition, or even, are there far more optimal solutions? Edit: Some background not strictly required. The offset result is a count of bits from the high bit, not from the low bit as maybe expected. This will be part of a wider algorithm which scans a 2D array for a 2D area of zero bits. Here, for testing, the algorithm has been simplified. val1 represents the first integer which does not have all bits set found in a row of the 2D array. From this the 2D version would scan down which is what val2 represents. Here's some output showing success and failure: t_bits:32 t_high: 10000000000000000000000000000000 ( 2147483648 ) --------- ----------------------------------- *** fit within left of msb test *** ----------------------------------- val1: 00000000000000000000000010000000 ( 128 ) val2: 01000001000100000000100100001001 ( 1091569929 ) msb: 7 offbit:0 + width: 8 = 8 mask: 11111111000000000000000000000000 ( 4278190080 ) b: 01000001000000000000000000000000 ( 1090519040 ) offbit:8 + width: 8 = 16 mask: 00000000111111110000000000000000 ( 16711680 ) b: 00000000000100000000000000000000 ( 1048576 ) offbit:12 + width: 8 = 20 mask: 00000000000011111111000000000000 ( 1044480 ) b: 00000000000000000000000000000000 ( 0 ) offbit:12 iters:10 ***** found room for width:8 at offset: 12 ***** ----------------------------------- *** fit within left of msb test *** ----------------------------------- val1: 00000000000000000000000001000000 ( 64 ) val2: 00010000000000001000010001000001 ( 268469313 ) msb: 6 offbit:0 + width: 13 = 13 mask: 11111111111110000000000000000000 ( 4294443008 ) b: 00010000000000000000000000000000 ( 268435456 ) offbit:4 + width: 13 = 17 mask: 00001111111111111000000000000000 ( 268402688 ) b: 00000000000000001000000000000000 ( 32768 ) ***** mask: 00001111111111111000000000000000 ( 268402688 ) offbit:17 iters:15 ***** no room found for width:13 ***** (iters is the count of iterations of the inner while loop)

    Read the article

  • How to propertly reference a namespace for Microsoft.Sdc.Tasks.XmlFile.GetValue

    - by æther
    Hi, i want to use MSBuild to insert a custom xml element into web.config. After looking up online, i found such solution: 1) Store element in the .build file in projectextensions <ProjectExtensions> <CustomElement name="CustomElementName"> ... </CustomElement> </ProjectExtensions> 2) Retrieve the element with GetValue <Target name="ModifyConfig"> <XmlFile.GetValue Path="$(MSBuildProjectFullPath)" XPath="Project/ProjectExtensions/CustomElement[@name='CustomElementName']"> <Output TaskParameter="Value" PropertyName="CustomElementProperty"/> </XmlFile.GetValue> </Target> This will not work as i need to reference a namespace the .build project is using for it to find the needed element (checked the .build file with XPath Visualizer). So, i look up for a further solution and come to this: <ItemGroup> <XmlNamespace Include="MSBuild"> <Prefix>msb</Prefix> <Uri>http://schemas.microsoft.com/developer/msbuild/2003</Uri> </XmlNamespace> </ItemGroup> <Target name="ModifyConfig"> <XmlFile.GetValue Path="$(MSBuildProjectFullPath)" Namespaces="$(XmlNamespace)" XPath="/msb:Project/msb:ProjectExtensions/msb:CustomElement[@name='CustomElementName']" > <Output TaskParameter="Value" PropertyName="CustomElementProperty"/> </XmlFile.GetValue> </Target> But for some reason namespace is not recognized - MSBuild reports the following error: C:...\mybuild.build(53,9): error : A task error has occured. C:...\mybuild.build(53,9): error : Message = Namespace prefix 'msb' is not defined. I tried some variations of referencing it differently but none work, and there is not much about propertly referencing those namespaces online also. Can you tell me what am i doing wrong and how to do it propertly?

    Read the article

  • Albacore msbuild task problem

    - by Dejan
    Just updated albacore to version 0.14 and ran into a major problem. My current environment is: Ruby 1.9.1 Rake 0.8.7 Albacore 0.1.4 The problem is that as of now all my rake build throw a funny little exception: undefined method 'push' for #<Enumerator:0x???????> So far I have traced the problem to albacore msbuild.rb line 38 and 26. To be honest I just don't have a clue why this is happening. As a little help here is the rake task that is turning my hear Grey :) desc "Build solution" msbuild :build => :prepareOutput do |msb| msb.properties :configuration => :Release msb.targets :Clean, :Build msb.solution = "../xxx/xxx/xxx.sln" end

    Read the article

  • UppercuT &ndash; Custom Extensions Now With PowerShell and Ruby

    - by Robz / Fervent Coder
    Arguably, one of the most powerful features of UppercuT (UC) is the ability to extend any step of the build process with a pre, post, or replace hook. This customization is done in a separate location from the build so you can upgrade without wondering if you broke the build. There is a hook before each step of the build has run. There is a hook after. And back to power again, there is a replacement hook. If you don’t like what the step is doing and/or you want to replace it’s entire functionality, you just drop a custom replacement extension and UppercuT will perform the custom step instead. Up until recently all custom hooks had to be written in NAnt. Now they are a little sweeter because you no longer need to use NAnt to extend UC if you don’t want to. You can use PowerShell. Or Ruby.   Let that sink in for a moment. You don’t have to even need to interact with NAnt at all now. Extension Points On the wiki, all of the extension points are shown. The basic idea is that you would put whatever customization you are doing in a separate folder named build.custom. Each step Let’s take a look at all we can customize: The start point is default.build. It calls build.custom/default.pre.build if it exists, then it runs build/default.build (normal tasks) OR build.custom/default.replace.build if it exists, and finally build.custom/default.post.build if it exists. Every step below runs with the same extension points but changes on the file name it is looking for. NOTE: If you include default.replace.build, nothing else will run because everything is called from default.build.    * policyChecks.step    * versionBuilder.step NOTE: If you include build.custom/versionBuilder.replace.step, the items below will not run.      - svn.step, tfs.step, or git.step (the custom tasks for these need to go in build.custom/versioners)    * generateBuildInfo.step    * compile.step    * environmentBuilder.step    * analyze.step NOTE: If you include build.custom/analyze.replace.step, the items below will not run.      - test.step (the custom tasks for this need to go in build.custom/analyzers) NOTE: If you include build.custom/analyzers/test.replace.step, the items below will not run.        + mbunit2.step, gallio.step, or nunit.step (the custom tasks for these need to go in build.custom/analyzers)      - ncover.step (the custom tasks for this need to go in build.custom/analyzers)      - ndepend.step (the custom tasks for this need to go in build.custom/analyzers)      - moma.step (the custom tasks for this need to go in build.custom/analyzers)    * package.step NOTE: If you include build.custom/package.replace.step, the items below will not run.      - deploymentBuilder.step Customize UppercuT Builds With PowerShell UppercuT can now be extended with PowerShell (PS). To customize any extension point with PS, just add .ps1 to the end of the file name and write your custom tasks in PowerShell. If you are not signing your scripts you will need to change a setting in the UppercuT.config file. This does impose a security risk, because this allows PS to now run any PS script. This setting stays that way on ANY machine that runs the build until manually changed by someone. I’m not responsible if you mess up your machine or anyone else’s by doing this. You’ve been warned. Now that you are fully aware of any security holes you may open and are okay with that, let’s move on. Let’s create a file called default.replace.build.ps1 in the build.custom folder. Open that file in notepad and let’s add this to it: write-host "hello - I'm a custom task written in Powershell!" Now, let’s run build.bat. You could get some PSake action going here. I won’t dive into that in this post though. Customize UppercuT Builds With Ruby If you want to customize any extension point with Ruby, just add .rb to the end of the file name and write your custom tasks in Ruby.  Let’s write a custom ruby task for UC. If you were thinking it would be the same as the one we just wrote for PS, you’d be right! In the build.custom folder, lets create a file called default.replace.build.rb. Open that file in notepad and let’s put this in there: puts "I'm a custom ruby task!" Now, let’s run build.bat again. That’s chunky bacon. UppercuT and Albacore.NET Just for fun, I wanted to see if I could replace the compile.step with a Rake task. Not just any rake task, Albacore’s msbuild task. Albacore is a suite of rake tasks brought about by Derick Bailey to make building .NET with Rake easier. It has quite a bit of support with developers that are using Rake to build code. In my build.custom folder, I drop a compile.replace.step.rb. I also put in a separate file that will contain my Albacore rake task and I call that compile.rb. What are the contents of compile.replace.step.rb? rake = 'rake' arguments= '-f ' + Dir.pwd + '/../build.custom/compile.rb' #puts "Calling #{rake} " + arguments system("#{rake} " + arguments) Since the custom extensions call ruby, we have to shell back out and call rake. That’s what we are doing here. We also realize that ruby is called from the build folder, so we need to back out and dive into the build.custom folder to find the file that is technically next to us. What are the contents of compile.rb? require 'rubygems' require 'fileutils' require 'albacore' task :default => [:compile] puts "Using Ruby to compile UppercuT with Albacore Tasks" desc 'Compile the source' msbuild :compile do |msb| msb.properties = { :configuration => :Release, :outputpath => '../../build_output/UppercuT' } msb.targets [:clean, :build] msb.verbosity = "quiet" msb.path_to_command = 'c:/Windows/Microsoft.NET/Framework/v3.5/MSBuild.exe' msb.solution = '../uppercut.sln' end We are using the msbuild task here. We change the output path to the build_output/UppercuT folder. The output path has “../../” because this is based on every project. We could grab the current directory and then point the task specifically to a folder if we have projects that are at different levels. We want the verbosity to be quiet so we set that as well. So what kind of output do you get for this? Let’s run build.bat custom_tasks_replace:      [echo] Running custom tasks instead of normal tasks if C:\code\uppercut\build\..\build.custom\compile.replace.step exists.      [exec] (in C:/code/uppercut/build)      [exec] Using Ruby to compile UppercuT with Albacore Tasks      [exec] Microsoft (R) Build Engine Version 3.5.30729.4926      [exec] [Microsoft .NET Framework, Version 2.0.50727.4927]      [exec] Copyright (C) Microsoft Corporation 2007. All rights reserved. If you think this is awesome, you’d be right!   With this knowledge you shall build.

    Read the article

  • My Automated NuGet Workflow

    - by Wes McClure
    When we develop libraries (whether internal or public), it helps to have a rapid ability to make changes and test them in a consuming application. Building Setup the library with automatic versioning and a nuspec Setup library assembly version to auto increment build and revision AssemblyInfo –> [assembly: AssemblyVersion("1.0.*")] This autoincrements build and revision based on time of build Major & Minor Major should be changed when you have breaking changes Minor should be changed once you have a solid new release During development I don’t increment these Create a nuspec, version this with the code nuspec - set version to <version>$version$</version> This uses the assembly’s version, which is auto-incrementing Make changes to code Run automated build (ruby/rake) run “rake nuget” nuget task builds nuget package and copies it to a local nuget feed I use an environment variable to point at this so I can change it on a machine level! The nuget command below assumes a nuspec is checked in called Library.nuspec next to the csproj file $projectSolution = 'src\\Library.sln' $nugetFeedPath = ENV["NuGetDevFeed"] msbuild :build => [:clean] do |msb| msb.properties :configuration => :Release msb.targets :Build msb.solution = $projectSolution end task :nuget => [:build] do sh "nuget pack src\\Library\\Library.csproj /OutputDirectory " + $nugetFeedPath end Setup the local nuget feed as a nuget package source (this is only required once per machine) Go to the consuming project Update the package Update-Package Library or Install-Package TLDR change library code run “rake nuget” run “Update-Package library” in the consuming application build/test! If you manually execute any of this process, especially copying files, you will find it a burden to develop the library and will find yourself dreading it, and even worse, making changes downstream instead of updating the shared library for everyone’s sake. Publishing Once you have a set of changes that you want to release, consider versioning and possibly increment the minor version if needed. Pick the package out of your local feed, and copy it to a public / shared feed! I have a script to do this where I can drop the package on a batch file Replace apikey with your nuget feed's apikey Take out the confirm(s) if you don't want them @ECHO off echo Upload %1? set /P anykey="Hit enter to continue " nuget push %1 apikey set /P anykey="Done " Note: helps to prune all the unnecessary versions during testing from your local feed once you are done and ready to publish TLDR consider version number run command to copy to public feed

    Read the article

  • Git pack file entry format

    - by Ben Collins
    My understanding of the Git pack file format is something like: Where the table is 32-bits wide, and the first three 32-bit words are the pack file header. The last row of 32 bits are the first 4 bytes of an entry. As I understand it, the size of the entry is specified by consecutive bytes with the MSB set, followed by compressed data. In the first byte whose MSB is not set, is the MSB part of the compressed data, or is it a gap? If it's part of the compressed data, how can you guarantee that when the data is compressed that bit won't be set?

    Read the article

  • issue with regex in C#

    - by Dilip
    my file is > A B C D unuse data <begin> Addd as ss 1 My name is 2323 33 text > </end> 34344 no need and my code is StringBuilder mSb = new StringBuilder(); StreamReader sr = new StreamReader(@"E:\check.txt"); String line; while (sr.ReadLine() != null) { mSb.AppendLine(sr.ReadLine()); } string matc = new Regex(@"(<begin>)(\n?.*)*</end>)?").Match(mSb.ToString()).ToString(); here it reading all file , but i just want till if i am removing ? from end , my program is crashing .. Thanks

    Read the article

  • displaying music current time & duration from AVFoundation

    - by msb
    I have a view-based iphone application that has a single play-pause button that plays an mp3 file. At the time of invoking my doPlayPauseButton() method, I 'd like to show the current time and total duration of this mp3 through the AVAudioPlayer instance I've created, called myAudioPlayer. I have placed two labels at the UI and i'm trying to assign the currentTime and duration properties to these label when the playing begins but my attempts have failed. Here's my play/pause loop, any help would be appreciated: -(IBAction) doPlayPauseButton:(UIButton *)theButton { if(myAudioPlayer.playing) { [myActivityIndicatorView stopAnimating]; myActivityIndicatorView.hidden = YES; //I think I need a myAudioPlayer.currentTime call of some sort for my labels. [myAudioPlayer pause]; [theButton setTitle:@"Play" forState:UIControlStateNormal]; [myTimer invalidate]; } else { [myActivityIndicatorView startAnimating]; myActivityIndicatorView.hidden = NO; myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(doTimer) userInfo:nil repeats:YES]; [myAudioPlayer play]; [theButton setTitle:@"Pause" forState:UIControlStateNormal];

    Read the article

  • Find most significant bit (left-most) that is set in a bit array

    - by Claudiu
    I have a bit array implementation where the 0th index is the MSB of the first byte in an array, the 8th index is the MSB of the second byte, etc... What's a fast way to find the first bit that is set in this bit array? All the related solutions I have looked up find the first least significant bit, but I need the first most significant one. So, given 0x00A1, I want 9.

    Read the article

  • Library Organization in .NET

    - by Greg Ros
    I've written a .NET bitwise operations library as part of my projects (stuff ranging from get MSB set to some more complicated bitwise transformations) and I mean to release it as free software. I'm a bit confused about a design aspect of the library, though. Many of the methods/transformations in the library come with different endianness. A simple example is a getBitAt method that regards index 0 as the least significant bit, or the most significant bit, depending on the version used. In practice, I've found that using separate functions for different endianness results in much more comprehensible and reusable code than assuming all operations are little-endian or something. I'm really stumped regarding how best to package the library. Should I have methods that have LE and BE versions take an enum parameter in their signature, e.g. Endianness.Little, Endianness.Big? Should I have different static classes with identically named methods? such as MSB.GetBit and LSB.GetBit On a much wider note, is there a standard I could use in cases like this? Some guide? Is my design issue trivial? I have a perfectionist bent, and I sometimes get stuck on tricky design issues like this... Note: I've sort of realized I'm using endianness somewhat colloquially to refer to the order/place value of digital component parts (be they bits, bytes, or words) in a larger whole, in any setting. I'm not talking about machine-level endianness or serial transmission endianness. Just about place-value semantics in general. So there isn't a context of targeting different machines/transmission techniques or something.

    Read the article

  • Contents changed(cleared?) when access the pointer returned by std::string::c_str()

    - by justamask
    string conf()     {         vector v;         //..         v = func(); //this function returns a vector         return v[1];     }     void test()     {         const char* p = conf().c_str();         // the string object will be alive as a auto var         // so the pointer should be valid till the end of this function,right?           // ... lots of steps, but none of them would access the pointer p         // when access p here, SOMETIMES the contents would change ... Why?         // the platform is solaris 64 bit         // compiler is sun workshop 12         // my code is compiled as  ELF 32-bit MSB relocatable SPARC32PLUS Version 1, V8+ Required         // but need to link with some shared lib which are ELF 32-bit MSB dynamic lib SPARC Version 1, dynamically linked, stripped     }

    Read the article

  • Is there any need for me to use wstring in the following case

    - by Yan Cheng CHEOK
    Currently, I am developing an app for a China customer. China customer are mostly switch to GB2312 language in their OS encoding. I need to write a text file, which will be encoded using GB2312. I use std::ofstream file I compile my application under MBCS mode, not unicode. I use the following code, to convert CString to std::string, and write it to file using ofstream std::string Utils::ToString(CString& cString) { /* Will not work correctly, if we are compiled under unicode mode. */ return (LPCTSTR)cString; } To my surprise. It just works. I thought I need to at least make use of wstring. I try to do some investigation. Here is the MBCS.txt generated. I try to print a single character named ? (its value is 0xBDC5) When I use CString to carry this character, its length is 2. When I use Utils::ToString to perform conversion to std::string, the returned string length is 2. I write to file using std::ofstream My question is : When I exam MBCS.txt using a hex editor, the value is displayed as BD (LSB) and C5 (MSB). But I am using little endian machine. Isn't hex editor should show me C5 (LSB) and BD (MSB)? I check from wikipedia. GB2312 seems doesn't specific endianness. It seems that using std::string + CString just work fine for my case. May I know in what case, the above methodology will not work? and when I should start to use wstring?

    Read the article

  • Implementing a bit shift using AND, NOT, ADD [closed]

    - by fdart17
    I'm implementing a 16-bit left bit shift by r bits, and I only have access to AND, NOT and ADD. There are 3 condition codes, negative, zero and positive, which are set when you use any of these operations. How I went about it was : (1) And the number with 1000 0000 0000 0000 to set condition codes to positive if the most significant bit is 1. (2) Add the number with itself. This shifts bits one to the left. (3) If the MSB was 1, add 1 to the result. (4) Loop threw (1)-(3) r times. I'm wondering if anyone has any hints to some more efficient methods? Thanks!

    Read the article

  • Problem in linking an nasm code

    - by Stefano
    I'm using a computer with an Intel Core 2 CPU and 2GB of RAM. The SO is Ubuntu 9.04. When I try to compile this code: ;programma per la simulazione di un terminale su PC, ottenuto utilizzando l'8250 ;in condizione di loopback , cioè Tx=Rx section .code64 section .data TXDATA EQU 03F8H ;TRASMETTITORE RXDATA EQU 03F8H ;RICEVITORE BAUDLSB EQU 03F8H ;DIVISORE DI BAUD RATE IN LSB BAUDMSB EQU 03F9H ;DIVISORE DI BAUD RATE IN MSB INTENABLE EQU 03F9H ;REGISTRO DI ABILITAZIONE DELL'INTERRUZIONE INTIDENTIF EQU 03FAH ;REGISTRO DI IDENTIFICAZIONE DELL'INTERRUZIONE LINECTRL EQU 03FBH ;REGISTRO DI CONTROLLO DELLA LINEA MODEMCTRL EQU 03FCH ;REGISTRO DI CONTROLLO DEL MODEM LINESTATUS EQU 03FDH ;REGISTRO DI STATO DELLA LINEA MODEMSTATUS EQU 03FEH ;REGISTRO DI STATO DEL MODEM BAUDRATEDIV DW 0060H ;DIVISOR: LOW=60, HIGH=00 -BAUD =9600 COUNTERCHAR DB 0 ;CHARACTER COUNTER ;DW 256 DUP (?) section .text global _start _start: ;PROGRAMMAZIONE 8250 MOV DX,LINECTRL MOV AL,80H ;BIT 7=1 PER INDIRIZZARE IL BAUD RATE OUT DX,AL MOV DX,BAUDLSB MOV AX,BAUDRATEDIV ;DEFINISCO FATTORE DI DIVISIONE OUT DX,AL MOV DX,BAUDMSB MOV AL,AH OUT DX,AL ;MSB MOV DX,LINECTRL MOV AL,00000011B ;8 BIT DATO, 1 STOP, PARITA' NO OUT DX,AL MOV DX,MODEMCTRL MOV AL,00010011B ;BIT 4=0 PER NO LOOPBACK OUT DX,AL MOV DX,INTENABLE XOR AL,AL ;DISABILITO TUTTI GLI INTERRUPTS OUT DX,AL CICLO: MOV DX,LINESTATUS IN AL,DX ;LEGGO IL REGISTRO DI STATO DELLA LINEA TEST AL,00011110B ;VERIFICO GLI ERRORI (4 TIPI) JNE ERRORI TEST AL,01H ;VERIFICO Rx PRONTO JNE LEGGOCHAR TEST AL,20H ;VERIFICO Tx VUOTO JE CICLO ;SE SI ARRIVA A QUESTO PUNTO ALLORA L'8250 è PRONTO PER TRASMETTERE UN NUOVO CARATTERE MOV AH,1 INT 80H JE CICLO ;SE SI ARRIVA A QUESTO PUNTO SIGNIFICA CHE ESISTE UN CARATTERE DA TASTIERA MOV AH,0 INT 80H ;Al CONTIENE IL CARATTERE DELLA TASTIERA MOV DX,3F8H OUT DX,AL JMP CICLO LEGGOCHAR: MOV AL,[COUNTERCHAR] INC AL CMP AL,15 JE FINE MOV [COUNTERCHAR],AL MOV DX,TXDATA IN AL,DX ;AL CONTIENE IL CARATTERE RICEVUTO AND AL,7FH ;POICHè VI SONO 7 BIT DI DATO ;VISUALIZZAZIONE DEL CARATTERE MOV BX,0 MOV AH,14 INT 80H POP AX CMP AL,0DH ;CONTROLLO SE RETURN JNE CICLO ;CAMBIO RIGA DI VISUALIZZAZIONE MOV AL,0AH MOV BX,0 MOV AH,14 ;INT 10H INT 80H JMP CICLO ;GESTIONE ERRORI ERRORI: MOV DX,3F8H IN AL,DX MOV AL,'?' MOV BX,0 MOV AH,14 INT 80H JMP CICLO FINE: XOR AH,AH MOV AL,03 INT 80H When I compile this code "NASM -f bin UARTLOOP.asm", the compiler can create the UARTLOOP.o file without any error. When I try to link the .o file with "ld UARTLOOP.o" it tells: UARTLOOP.o: In function `_start': UARTLOOP.asm:(.text+0xd): relocation truncated to fit: R_X86_64_16 against `.data' Have u got some ideas to solve this problem? Thx =)

    Read the article

  • elffile: ELF Specific File Identification Utility

    - by user9154181
    Solaris 11 has a new standard user level command, /usr/bin/elffile. elffile is a variant of the file utility that is focused exclusively on linker related files: ELF objects, archives, and runtime linker configuration files. All other files are simply identified as "non-ELF". The primary advantage of elffile over the existing file utility is in the area of archives — elffile examines the archive members and can produce a summary of the contents, or per-member details. The impetus to add elffile to Solaris came from the effort to extend the format of Solaris archives so that they could grow beyond their previous 32-bit file limits. That work introduced a new archive symbol table format. Now that there was more than one possible format, I thought it would be useful if the file utility could identify which format a given archive is using, leading me to extend the file utility: % cc -c ~/hello.c % ar r foo.a hello.o % file foo.a foo.a: current ar archive, 32-bit symbol table % ar r -S foo.a hello.o % file foo.a foo.a: current ar archive, 64-bit symbol table In turn, this caused me to think about all the things that I would like the file utility to be able to tell me about an archive. In particular, I'd like to be able to know what's inside without having to unpack it. The end result of that train of thought was elffile. Much of the discussion in this article is adapted from the PSARC case I filed for elffile in December 2010: PSARC 2010/432 elffile Why file Is No Good For Archives And Yet Should Not Be Fixed The standard /usr/bin/file utility is not very useful when applied to archives. When identifying an archive, a user typically wants to know 2 things: Is this an archive? Presupposing that the archive contains objects, which is by far the most common use for archives, what platform are the objects for? Are they for sparc or x86? 32 or 64-bit? Some confusing combination from varying platforms? The file utility provides a quick answer to question (1), as it identifies all archives as "current ar archive". It does nothing to answer the more interesting question (2). To answer that question, requires a multi-step process: Extract all archive members Use the file utility on the extracted files, examine the output for each file in turn, and compare the results to generate a suitable summary description. Remove the extracted files It should be easier and more efficient to answer such an obvious question. It would be reasonable to extend the file utility to examine archive contents in place and produce a description. However, there are several reasons why I decided not to do so: The correct design for this feature within the file utility would have file examine each archive member in turn, applying its full abilities to each member. This would be elegant, but also represents a rather dramatic redesign and re-implementation of file. Archives nearly always contain nothing but ELF objects for a single platform, so such generality in the file utility would be of little practical benefit. It is best to avoid adding new options to standard utilities for which other implementations of interest exist. In the case of the file utility, one concern is that we might add an option which later appears in the GNU version of file with a different and incompatible meaning. Indeed, there have been discussions about replacing the Solaris file with the GNU version in the past. This may or may not be desirable, and may or may not ever happen. Either way, I don't want to preclude it. Examining archive members is an O(n) operation, and can be relatively slow with large archives. The file utility is supposed to be a very fast operation. I decided that extending file in this way is overkill, and that an investment in the file utility for better archive support would not be worth the cost. A solution that is more narrowly focused on ELF and other linker related files is really all that we need. The necessary code for doing this already exists within libelf. All that is missing is a small user-level wrapper to make that functionality available at the command line. In that vein, I considered adding an option for this to the elfdump utility. I examined elfdump carefully, and even wrote a prototype implementation. The added code is small and simple, but the conceptual fit with the rest of elfdump is poor. The result complicates elfdump syntax and documentation, definite signs that this functionality does not belong there. And so, I added this functionality as a new user level command. The elffile Command The syntax for this new command is elffile [-s basic | detail | summary] filename... Please see the elffile(1) manpage for additional details. To demonstrate how output from elffile looks, I will use the following files: FileDescription configA runtime linker configuration file produced with crle dwarf.oAn ELF object /etc/passwdA text file mixed.aArchive containing a mixture of ELF and non-ELF members mixed_elf.aArchive containing ELF objects for different machines not_elf.aArchive containing no ELF objects same_elf.aArchive containing a collection of ELF objects for the same machine. This is the most common type of archive. The file utility identifies these files as follows: % file config dwarf.o /etc/passwd mixed.a mixed_elf.a not_elf.a same_elf.a config: Runtime Linking Configuration 64-bit MSB SPARCV9 dwarf.o: ELF 64-bit LSB relocatable AMD64 Version 1 /etc/passwd: ascii text mixed.a: current ar archive, 32-bit symbol table mixed_elf.a: current ar archive, 32-bit symbol table not_elf.a: current ar archive same_elf.a: current ar archive, 32-bit symbol table By default, elffile uses its "summary" output style. This output differs from the output from the file utility in 2 significant ways: Files that are not an ELF object, archive, or runtime linker configuration file are identified as "non-ELF", whereas the file utility attempts further identification for such files. When applied to an archive, the elffile output includes a description of the archive's contents, without requiring member extraction or other additional steps. Applying elffile to the above files: % elffile config dwarf.o /etc/passwd mixed.a mixed_elf.a not_elf.a same_elf.a config: Runtime Linking Configuration 64-bit MSB SPARCV9 dwarf.o: ELF 64-bit LSB relocatable AMD64 Version 1 /etc/passwd: non-ELF mixed.a: current ar archive, 32-bit symbol table, mixed ELF and non-ELF content mixed_elf.a: current ar archive, 32-bit symbol table, mixed ELF content not_elf.a: current ar archive, non-ELF content same_elf.a: current ar archive, 32-bit symbol table, ELF 64-bit LSB relocatable AMD64 Version 1 The output for same_elf.a is of particular interest: The vast majority of archives contain only ELF objects for a single platform, and in this case, the default output from elffile answers both of the questions about archives posed at the beginning of this discussion, in a single efficient step. This makes elffile considerably more useful than file, within the realm of linker-related files. elffile can produce output in two other styles, "basic", and "detail". The basic style produces output that is the same as that from 'file', for linker-related files. The detail style produces per-member identification of archive contents. This can be useful when the archive contents are not homogeneous ELF object, and more information is desired than the summary output provides: % elffile -s detail mixed.a mixed.a: current ar archive, 32-bit symbol table mixed.a(dwarf.o): ELF 32-bit LSB relocatable 80386 Version 1 mixed.a(main.c): non-ELF content mixed.a(main.o): ELF 64-bit LSB relocatable AMD64 Version 1 [SSE]

    Read the article

  • How would you communicate with aliens as a computer scientist?

    - by Pyrolistical
    Let's say aliens arrive on Earth and instead of just sending mathematicians and linguistic experts governments around the work decide to send an expert of major field. After a quick round of sorting you are paired up with an alien computer scientist. Given you don't understand each others language how would you using computer science to start the ground work of communication? eg. We know binary is universal, but not the way we write it. The symbols are not universal nor is the the direction we write it (MSB vs LSB and left vs right) Assume aliens are "similar" to us physically it won't impede visual communication.

    Read the article

  • How to correctly set the ORACLE_HOME variable on Ubuntu 9.x?

    - by nowarninglabel
    I have the same problem as listed here: http://stackoverflow.com/questions/52239/oracle-lost-sysdba-password although I did not lose the password, I entered it twice in the configure script originally, and then when I went to login (localhost:8080/apex, password not accepted. I don't have anything in the database, I just want to install and use Oracle-XE. I have tried apt-get removing it twice and reinstalling, but if I try to run /etc/init.d/oracle-xe configure again and I get "Oracle Database 10g Express Edition is already configured" despite the second time removing any folders I could find for Oracle XE. I tried running sqlplus "/ as sysdba" but all I get is: "Error 6 initializing SQL*Plus Message file sp1.msb not found SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory" I tried setting the variable via export. (also tried set). Tried: "export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlplus" and all the subdirectories of that. Same error every time. What is the ORACLE_HOME supposed to be set to? The only reference I have seen either just say general or say the above up to the version number then "/db_1". I do no thave a db_1. Let me know if need any clarification. Don't understand what I did wrong in this process.

    Read the article

  • [C#] Improving method to read signed 8-bit integers from hexadecimal.

    - by JYelton
    Scenario: I have a string of hexadecimal characters which encode 8-bit signed integers. Each two characters represent a byte which employ the leftmost (MSB) bit as the sign (rather than two's complement). I am converting these to signed ints within a loop and wondered if there's a better way to do it. There are too many conversions and I am sure there's a more efficient method that I am missing. Current Code: string strData = "FFC000407F"; // example input data, encodes: -127, -64, 0, 64, 127 int v; for (int x = 0; x < strData.Length/2; x++) { v = HexToInt(strData.Substring(x * 2, 2)); Console.WriteLine(v); // do stuff with v } private int HexToInt(string _hexData) { string strBinary = Convert.ToString(Convert.ToInt32(_hexData, 16), 2).PadLeft(_hexData.Length * 4, '0'); int i = Convert.ToInt32(strBinary.Substring(1, 7), 2); i = (strBinary.Substring(0, 1) == "0" ? i : -i); return i; } Question: Is there a more streamlined and direct approach to reading two hex characters and converting them to an int when they represent a signed int (-127 to 127) using the leftmost bit as the sign?

    Read the article

  • Improving method to read signed 8-bit integers from hexadecimal.

    - by JYelton
    Scenario: I have a string of hexadecimal characters which encode 8-bit signed integers. Each two characters represent a byte which employ the leftmost (MSB) bit as the sign (rather than two's complement). I am converting these to signed ints within a loop and wondered if there's a better way to do it. There are too many conversions and I am sure there's a more efficient method that I am missing. Current Code: string strData = "FFC000407F"; // example input data, encodes: -127, -64, 0, 64, 127 int v; for (int x = 0; x < strData.Length/2; x++) { v = HexToInt(strData.Substring(x * 2, 2)); Console.WriteLine(v); // do stuff with v } private int HexToInt(string _hexData) { string strBinary = Convert.ToString(Convert.ToInt32(_hexData, 16), 2).PadLeft(_hexData.Length * 4, '0'); int i = Convert.ToInt32(strBinary.Substring(1, 7), 2); i = (strBinary.Substring(0, 1) == "0" ? i : -i); return i; } Question: Is there a more streamlined and direct approach to reading two hex characters and converting them to an int when they represent a signed int (-127 to 127) using the leftmost bit as the sign?

    Read the article

  • Bit shift and pointer oddities in C, looking for explanations

    - by foo
    Hi all, I discovered something odd that I can't explain. If someone here can see what or why this is happening I'd like to know. What I'm doing is taking an unsigned short containing 12 bits aligned high like this: 1111 1111 1111 0000 I then want to shif the bits so that each byte in the short hold 7bits with the MSB as a pad. The result on what's presented above should look like this: 0111 1111 0111 1100 What I have done is this: unsigned short buf = 0xfff; //align high buf <<= 4; buf >>= 1; *((char*)&buf) >>= 1; This gives me something like looks like it's correct but the result of the last shift leaves the bit set like this: 0111 1111 1111 1100 Very odd. If I use an unsigned char as a temporary storage and shift that then it works, like this: unsigned short buf = 0xfff; buf <<= 4; buf >>= 1; tmp = *((char*)&buf); *((char*)&buf) = tmp >> 1; The result of this is: 0111 1111 0111 1100 Any ideas what is going on here?

    Read the article

  • C: 8x8 -> 16 bit multiply precision guaranteed by integer promotions?

    - by craig-blome
    I'm trying to figure out if the C Standard (C90, though I'm working off Derek Jones' annotated C99 book) guarantees that I will not lose precision multiplying two unsigned 8-bit values and storing to a 16-bit result. An example statement is as follows: unsigned char foo; unsigned int foo_u16 = foo * 10; Our Keil 8051 compiler (v7.50 at present) will generate a MUL AB instruction which stores the MSB in the B register and the LSB in the accumulator. If I cast foo to a unsigned int first: unsigned int foo_u16 = (unsigned int)foo * 10; then the compiler correctly decides I want a unsigned int there and generates an expensive call to a 16x16 bit integer multiply routine. I would like to argue beyond reasonable doubt that this defensive measure is not necessary. As I read the integer promotions described in 6.3.1.1, the effect of the first line shall be as if foo and 10 were promoted to unsigned int, the multiplication performed, and the result stored as unsigned int in foo_u16. If the compiler knows an instruction that does 8x8-16 bit multiplications without loss of precision, so much the better; but the precision is guaranteed. Am I reading this correctly? Best regards, Craig Blome

    Read the article

  • Store a signed long int (32bit) as 4 octets?

    - by Doori Bar
    I managed to get a unsigned long int octets-representation (BE) by reading IPv4 methods, and I managed to read about how signed integers are using the MSB as the sign indicator, which makes 00 00 00 00 to be 0, while 7F FF FF FF is 2147483647. But I can't manage how to do the same for signed long integers? #include <stdio.h> #include <string.h> int main (void) { unsigned long int intu32; unsigned char octets[4]; intu32 = 255; octets[3] = (intu32) & 255; octets[2] = (intu32 >> 8) & 255; octets[1] = (intu32 >> 16) & 255; octets[0] = (intu32 >> 24) & 255; printf("(%d)(%d)(%d)(%d)\n", octets[0], octets[1], octets[2], octets[3]); intu32 = (octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | octets[3]; printf("intu32:%lu\n", intu32); return 0; } Thanks in advance, Doori bar

    Read the article

1 2  | Next Page >