<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="http://www.daniweb.com/js/rss.xsl"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community
			 - Assembly					</title>
		<link>http://www.daniweb.com/software-development/assembly/125</link>
		<description>Our Assembly forum is the place for Q&amp;A-style discussions related to machine language. Discuss all flavors including x86 assembly, MIPS assembly, RISC assembly, etc. Note that we also have a Computer Science forum within the Software Development category.</description>
		<language>en-US</language>
		<ttl>60</ttl>
		<!-- PubSubHubbub Discovery -->
		<link rel="hub" href="http://daniweb.superfeedr.com/" xmlns="http://www.w3.org/2005/Atom" />
		<link rel="self" href="http://www.daniweb.com/rss/pull/125" xmlns="http://www.w3.org/2005/Atom" />
		<!-- End Of PubSubHubbub Discovery -->
				<item>
			<title>What assembly language is friendly to beginners?</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/455224/what-assembly-language-is-friendly-to-beginners</link>
			<pubDate>Fri, 24 May 2013 07:58:14 +0000</pubDate>
			<description>I am have been programming in C++ for a few years now. Now I would like to also learn assembly language. I have tried NASM, but I dont like it, it works better on linux and my main development platform is windows. I have also tried FASM, its better but ...</description>
			<content:encoded><![CDATA[ <p>I am have been programming in C++ for a few years now. Now I would like to also learn assembly language.</p>

<p>I have tried NASM, but I dont like it, it works better on linux and my main development platform is windows.<br />
I have also tried FASM, its better but I couldnt find good documentation on it.<br />
I dont care for the syntex although I like the Intel syntex more e.g.</p>

<pre><code class="language-cpp">mov eax, 4
</code></pre>

<p>I want an assembler that is easy to learn, and have good documentation from which I can learn and that I can program bootloaders and other chipset based stuff like writing drivers for security cameras etc.</p>

<p>I am currently developing from an 64 bit cpu, so the assembler should support atleast 32 bit / 64 bit.<br />
My main platform is 64-bit windows 7.</p>

<p>Thanks...</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>MasterHacker110</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/455224/what-assembly-language-is-friendly-to-beginners</guid>
		</item>
				<item>
			<title>Assembly Beginner, question</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/454882/assembly-beginner-question</link>
			<pubDate>Sat, 18 May 2013 20:07:19 +0000</pubDate>
			<description>Howdy Friends; I have just started learning assembly, and am currently working with NASM, in Linux. I am not creating anything close to advanced, yet because I would like to know if I am on the right path with what I am learning. The code that is posted below is ...</description>
			<content:encoded><![CDATA[ <p>Howdy Friends;<br />
I have just started learning assembly, and am currently working with NASM, in Linux. I am not creating anything close to advanced, yet because I would like to know if I am on the right path with what I am learning. The code that is posted below is simply a hello world with two lines of output (but it doesn't work the way I intended). The output that I was hoping for was:</p>

<blockquote>
  <p>Howdy Folks!<br />
  Another line!</p>
</blockquote>

<p>However; I simlpy get:</p>

<blockquote>
  <p>Another line!</p>
</blockquote>

<p>Here is my code:</p>

<pre><code>SECTION .text
            global start
START:
            mov eax, 4          ;sys_write
            mov ebx, 1          ;output to screen
            mov ecx, string ;creates address for my string variable
            mov ecx, string2    ;creates address for another string
            mov edx, length ;creates address for my length variable
            mov edx, length2    ;creates address for another length
            int 80h             ;call the kernel
            mov eax, 1          ;sys_exit
            mov ebx, 0          ;no error exit
            int 80h             ;call the kernel
SECTION .data
string: db 'Howdy Folks!', 0Ah  ;output string
length: equ 12                      ;length of string
string2: db 'Another line!', 0Ah    ;output another string
length2: equ 13                 ;length of string2
</code></pre>

<p>Where did I go wrong?<br />
Did I accidentally overwrite string ('Howdy Folks') with the value of string2 ('Another Line!')?<br />
How can I go about fixing this?<br />
Also, are my comments appropriate with how the line actually functions?</p>

<p>For instance;</p>

<pre><code>int 80h             ;call the kernel
</code></pre>

<p>Does this line really call the kernel?<br />
If so what is it actually doing there?</p>

<p>Thanks for any help.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>pbj.codez</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/454882/assembly-beginner-question</guid>
		</item>
				<item>
			<title>Learning Raw Assembly</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/454763/learning-raw-assembly</link>
			<pubDate>Thu, 16 May 2013 16:41:59 +0000</pubDate>
			<description>Hello, I only have a basic knowledge of ASM because every tutorial I have found (including Narue's) is based on using some kind of high level library or another. However when I look through disassemblies of pretty much any program I notice that all such library calls are gone. My ...</description>
			<content:encoded><![CDATA[ <p>Hello, I only have a basic knowledge of ASM because every tutorial I have found (including Narue's) is based on using some kind of high level library or another. However when I look through disassemblies of pretty much any program I notice that all such library calls are gone. My questions are:</p>

<p>A) Did the assembler simply copy-paste the library code in (like a header file in c/c++)<br />
B) Where can I learn general assembly?<br />
C) I noticed that pretty much every tutorial uses different layout (IE: data:code: vs section data, etc) what are these and how can I know which one is correct?<br />
D) I always hear that you need to specialize your assembly code to your exact operating system, but then how come I can run certain programs across all the systems? What sort of sorcery is going on?!</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Labdabeta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/454763/learning-raw-assembly</guid>
		</item>
				<item>
			<title>MIPS project. Checksum of file.</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/454513/mips-project.-checksum-of-file</link>
			<pubDate>Mon, 13 May 2013 13:31:14 +0000</pubDate>
			<description>Hey guys, I wrote a program that reads a file and then displays its 8, 16 and 32 bit checksum as well as the XOR values. I've managed to do it and it works fine under windows(using qtspim) but on centos(using mars) I get the following errors: Line 7 column ...</description>
			<content:encoded><![CDATA[ <p>Hey guys, I wrote a program that reads a file and then displays its 8, 16 and 32 bit checksum as well as the XOR values. I've managed to do it and it works fine under windows(using qtspim) but on centos(using mars) I get the following errors:</p>

<p>Line 7 column five: "li": too many or incorrectly formatted operands. Expected li $t1, -100<br />
Line 94 column 23: "$t0" : operand is of incorrect type<br />
Line 97 column 23: "0xfffffffc" : operand is of incorrect type<br />
Line 289 column 23: "$t1": operand is of incorrect type</p>

<p>I need to get it working in mars.I'd be grateful for your help.</p>

<p>and below source code: ( I marked the error lines on the left )</p>

<p>my code:</p>

<p>.text<br />
main:</p>

<pre><code># extend data segment

    li      $v0, 9              # sbrk syscall
7 - li      $a0, 500000+4       # the the maximum data size (a multiple of 4) plus an extra word
    syscall
    bnez    $v0, store

    li      $v0, 4              # print error string
    la      $a0, memory_error
    syscall
    b       exit

store:
    sw      $v0, buffer         # store the file buffer address

# get input file name from user

get_filename:
    li      $v0, 4              # print prompt for input file
    la      $a0, prompt
    syscall

    li      $v0, 8              # read input filename
    la      $a0, filename
    li      $a1, 100
    syscall

# search for \n and replace it with terminating 0

    li      $t1, -1             # filename length (will be determined in the following loop)

search:
    lb      $t0, 0($a0)
    add     $a0, $a0, 1
    add     $t1, $t1, 1
    bne     $t0, 0x0a, search

    sb      $zero, -1($a0)

    beqz    $t1, exit           # exit if no filename was given

# open and read the file

    li      $v0, 13             # open file syscall
    la      $a0, filename
    li      $a1, 0              # flags
    li      $a2, 0              # mode (ignored)
    syscall
    bgez    $v0, read_file

    li      $v0, 4              # print error string
    la      $a0, open_error
    syscall
    b       exit

read_file:
    sw      $v0, descriptor

    li      $v0, 14             # read from file syscall
    lw      $a0, descriptor     # the file descriptor
    lw      $a1, buffer
    li      $a2, 500000         # max number of bytes to read
    syscall
    bgez    $v0, process

    li      $v0, 4              # print error string
    la      $a0, read_error
    syscall
    b       exit


process:
    srl     $s0, $v0, 1         # number of halfwords
    and     $t0, $v0, 0x1
    beqz    $t0, number_of_words
    add     $s0, $s0, 1         # round up (i.e. add 1) if the data size is not a multiple of 2

number_of_words:
    srl     $s1, $v0, 2         # number of words
    and     $t0, $v0, 0x3       # the remainder from division by 4 (number of effective data bytes in the last word)
    beqz    $t0, pad
    add     $s1, $s1, 1         # round up

# pad the data with 0s

pad:
    li      $t1, 4
    sub     $t0, $t1, $t0       # 4 minus the above remainder (specifies how many bytes to zero in a bit mask)
    sll     $t0, $t0, 3         # multiply by 8 to determine the number of zero bits to insert from the right 
    li      $t1, 0xffffffff     # initial value of the mask
94- srl     $t1, $t1, $t0       # insert zero bits and form actual bit mask (note: little endian order)

    add     $t2, $a1, $v0           # the address of the end of the data
97- and     $t2, $t2, 0xfffffffc    # the address (divisible by 4) that will be affected by the bit mask

    lw      $t0, ($t2)          # load the word that will contain the padding 0 bytes, note: this step can access (but not change) a whole extra word after the data when its size is a multiple of 4
    and     $t0, $t0, $t1       # zero the unused bytes (using the bit mask)
    sw      $t0, ($t2)          # store it

# modular sum

    # 8-bit checksum

    move    $t0, $v0            # number of bytes of the data (a counter)
    move    $t1, $a1            # the start address of the data
    li      $s2, 0              # clear the "accumulator"

sum8:
    lbu     $t2, ($t1)
    add     $t1, $t1, 1
    addu    $s2, $s2, $t2
    sub     $t0, $t0, 1
    bnez    $t0, sum8

    sll     $s2, $s2, 24        # sign extend byte to word (first align the sign bit of the byte to make use of arithmetic shifting)
    sra     $s2, $s2, 24        # insert the sign bit between bits 31-8

    # 16-bit checksum

    move    $t0, $s0
    move    $t1, $a1
    li      $s3, 0

sum16:
    lhu     $t2, ($t1)
    add     $t1, $t1, 2
    addu    $s3, $s3, $t2
    sub     $t0, $t0, 1
    bnez    $t0, sum16

    sll     $s3, $s3, 16        # sign extend halfword to word
    sra     $s3, $s3, 16

    # 32-bit checksum

    move    $t0, $s1
    move    $t1, $a1
    li      $s4, 0

sum32:
    lw      $t2, ($t1)
    add     $t1, $t1, 4
    addu    $s4, $s4, $t2
    sub     $t0, $t0, 1
    bnez    $t0, sum32

# parity check

    # 8-bit XOR value

    move    $t0, $v0
    move    $t1, $a1
    li      $s5, 0

xor8:
    lbu     $t2, ($t1)
    add     $t1, $t1, 1
    xor     $s5, $s5, $t2
    sub     $t0, $t0, 1
    bnez    $t0, xor8

    # 16-bit XOR value

    move    $t0, $s0
    move    $t1, $a1
    li      $s6, 0

xor16:
    lhu     $t2, ($t1)
    add     $t1, $t1, 2
    xor     $s6, $s6, $t2
    sub     $t0, $t0, 1
    bnez    $t0, xor16

    # 32-bit XOR value

    move    $t0, $s1
    move    $t1, $a1
    li      $s7, 0

xor32:
    lw      $t2, ($t1)
    add     $t1, $t1, 4
    xor     $s7, $s7, $t2
    sub     $t0, $t0, 1
    bnez    $t0, xor32


# report results to the user

    # 8-bit checksum

    li      $v0, 4              # print string
    la      $a0, checksum8
    syscall

    li      $v0, 1              # print int
    move    $a0, $s2
    syscall

    li      $v0, 4              # print string
    la      $a0, new_line
    syscall

    # 16-bit checksum

    li      $v0, 4              # print string
    la      $a0, checksum16
    syscall

    li      $v0, 1              # print int
    move    $a0, $s3
    syscall

    li      $v0, 4              # print string
    la      $a0, new_line
    syscall

    # 32-bit checksum

    li      $v0, 4              # print string
    la      $a0, checksum32
    syscall

    li      $v0, 1              # print int
    move    $a0, $s4
    syscall

    li      $v0, 4              # print string
    la      $a0, new_line
    syscall

    # 8-bit XOR value

    li      $v0, 4              # print string
    la      $a0, xor_value8
    syscall

    move    $a0, $s5            # the number to print
    li      $a1, 6              # start digit offset (6 implies a byte)
    jal     print_hex

    # 16-bit XOR value

    li      $v0, 4              # print string
    la      $a0, xor_value16
    syscall

    move    $a0, $s6            # the number to print
    li      $a1, 4              # type: halfword
    jal     print_hex

    # 32-bit XOR value

    li      $v0, 4              # print string
    la      $a0, xor_value32
    syscall

    move    $a0, $s7            # the number to print
    li      $a1, 0              # type: word
    jal     print_hex

close:
    li      $v0, 16             # close file syscall
    lw      $a0, descriptor     # the file descriptor
    syscall

    b       get_filename       # loop to process another file (or exit)

# exit the program

exit:
    li      $v0, 10
    syscall

# subroutine to print hexadecimal number

    # $a0 =&gt; number to print
    # $a1 =&gt; start digit: 0=word, 4=halfword, 6=byte

print_hex:
    la      $t0, hex            # address to store the string representation of a hexadecimal number
    li      $t1, 28             # shift count (to the right) of the most significant hexadecimal digit

hex_loop:
289 srl     $t2, $a0, $t1       # get a value of a hexadecimal digit
    and     $t2, $t2, 0xf       # mask unused bits
    bgtu    $t2, 9, letter

    add     $t2, $t2, 0x30      # a digit 0-9, add 0x30 to get actual ASCII code
    b       next_hex

letter:
    add     $t2, $t2, 0x57      # a letter a-f, add ('a'-10) to get actual ASCII code

next_hex:
    sb      $t2, ($t0)          # store the digit
    add     $t0, $t0, 1         # advance the pointer
    sub     $t1, $t1, 4         # update the shift count (to get another digit)
    bgez    $t1, hex_loop

    li      $v0, 4              # print string
    la      $a0, hex_prefix
    syscall

    li      $v0, 4              # print string
    la      $a0, hex
    add     $a0, $a0, $a1
    syscall

    jr      $ra


    .data
filename:       .space 16       # input filename

descriptor:     .word 0         # input file descriptor
buffer:         .word 0         # input file buffer address

prompt:         .asciiz "\nEnter the file name: "
memory_error:   .asciiz "Memory error (sbrk syscall failed)\n"
open_error:     .asciiz "Cannot open file\n"
read_error:     .asciiz "Cannot read file\n"

checksum8:      .asciiz "8-bit checksum:    "
checksum16:     .asciiz "16-bit checksum:   "
checksum32:     .asciiz "32-bit checksum:   "
xor_value8:     .asciiz "8-bit XOR value:   "
xor_value16:    .asciiz "16-bit XOR value:  "
xor_value32:    .asciiz "32-bit XOR value:  "
new_line:       .asciiz "\n"

hex_prefix:     .asciiz "0x"
hex:            .asciiz "????????\n"
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>ppajak</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/454513/mips-project.-checksum-of-file</guid>
		</item>
				<item>
			<title>Add new section to PE</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/454358/add-new-section-to-pe</link>
			<pubDate>Fri, 10 May 2013 21:19:42 +0000</pubDate>
			<description>Hello guys, can someone show me how to add new section to PE header in masm32?</description>
			<content:encoded><![CDATA[ <p>Hello guys,<br />
can someone show me how to add new section to PE header in masm32?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Rasool Ahmed</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/454358/add-new-section-to-pe</guid>
		</item>
				<item>
			<title>assembly program using tasm which request the user to enter name of file</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/454290/assembly-program-using-tasm-which-request-the-user-to-enter-name-of-file</link>
			<pubDate>Fri, 10 May 2013 03:08:28 +0000</pubDate>
			<description>hello guys,,,am facing a little problem around here.. I want to write a code in assembly language(tasm) which requests the user to enter the name of the file and then open that file...and count the number of words in it and display the results...</description>
			<content:encoded><![CDATA[ <p>hello guys,,,am facing a little problem around here..<br />
I want to write a code in assembly language(tasm) which requests the user to enter the name of the file and then open that file...and count the number of words in it and display the results...</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>shamsidini</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/454290/assembly-program-using-tasm-which-request-the-user-to-enter-name-of-file</guid>
		</item>
				<item>
			<title>Access violation at address 0000 when reading file</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453958/access-violation-at-address-0000-when-reading-file</link>
			<pubDate>Sun, 05 May 2013 18:34:33 +0000</pubDate>
			<description>Hello guys, I have problem with reading or writing files in C++ and MASM32. The problem is when calling the ReadFile or WriteFile the program give an exception saying &quot;Access violation at address 0000&quot;. This is the code in MASM32: LOCAL Kernel32:DWORD LOCAL CreateFileA:DWORD LOCAL GetFileSize:DWORD LOCAL ReadFile:DWORD LOCAL pBytesRead:DWORD ...</description>
			<content:encoded><![CDATA[ <p>Hello guys,<br />
I have problem with reading or writing files in C++ and MASM32. The problem is when calling the ReadFile or WriteFile the program give an exception saying "Access violation at address 0000".</p>

<p>This is the code in MASM32:</p>

<pre><code>    LOCAL   Kernel32:DWORD
    LOCAL   CreateFileA:DWORD
    LOCAL   GetFileSize:DWORD
    LOCAL   ReadFile:DWORD
    LOCAL   pBytesRead:DWORD
    LOCAL   BytesToRead:DWORD
    LOCAL   hFile:DWORD

    ;-----------------------------------------
    ;Getting Kernel Imagebase
    ;-----------------------------------------
    ;kernel32.dll = 2511EF2C
    PUSH    02511EF2Ch
    CALL    find_dll

    MOV Kernel32, EAX

    ;-----------------------------------------
    ;Find required APIs
    ;-----------------------------------------
    ;CreateFileA = 0CF2006EAh, GetFileSize = 06D61AB47h, ReadFile = 024EF6F37h, WriteFile = 0317EB0D7h

    PUSH    0CF2006EAh
    PUSH    Kernel32
    CALL    find_api

    MOV CreateFileA, EAX

    PUSH    06D61AB47h
    PUSH    Kernel32
    CALL    find_api

    MOV GetFileSize, EAX

    PUSH    024EF6F37h
    PUSH    Kernel32
    CALL    find_api

    MOV     ReadFile, EAX

    PUSH    NULL                                ; /hTemplateFile = NULL
    PUSH    FILE_ATTRIBUTE_NORMAL               ; |Attributes = FILE_ATTRIBUTE_NORMAL
    PUSH    OPEN_EXISTING                       ; |Mode = OPEN_EXISTING
    PUSH    0                                   ; |pSecurity = NULL
    PUSH    FILE_SHARE_READ + FILE_SHARE_WRITE  ; |ShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE
    PUSH    GENERIC_ALL             ; |Access = GENERIC_ALL
    PUSH    FileName                ; |FileName = "*.exe"
    CALL    CreateFileA     ; \CreateFileA

    MOV hFile,EAX

    PUSH    0                       ; /pFileSizeHigh = NULL
    PUSH    hFile                   ; |hFile
    CALL    GetFileSize     ; \GetFileSize

    CMP EAX, 0h
    JZ  Exit

    MOV BytesToRead, 10h

    PUSH    0           ; /pOverlapped = NULL
        PUSH    pBytesRead      ; |pBytesRead = ?
    PUSH    BytesToRead     ; |BytesToRead
    PUSH    OFFSET Buffer       ; |Buffer
    PUSH    hFile           ; |hFile
    CALL    ReadFile        ; \ReadFile
Exit:
</code></pre>

<p>When debug it in Ollydbg it stops right here:</p>

<pre><code>757F85EA   8907             MOV DWORD PTR DS:[EDI],EAX
EDI = 00000000
EAX = 00000055
</code></pre>

<p>And give me the error (described above) because EDI is 000000.</p>

<p>Why this error occurred and what is the solution to fix the problem?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Rasool Ahmed</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453958/access-violation-at-address-0000-when-reading-file</guid>
		</item>
				<item>
			<title>negative problem in read_int procedure x86_64</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453887/negative-problem-in-read_int-procedure-x86_64</link>
			<pubDate>Sat, 04 May 2013 05:42:28 +0000</pubDate>
			<description>I could not get c function calls to work inside of nasm so i wrote my own read integer procedure. Im sure its inefficient and could be greatly imporved but right now I'm interested in where the negative sign went. Any help is greatly apreiciated. ;---------------------------------------------------------; ;reads a 64 bit ...</description>
			<content:encoded><![CDATA[ <p>I could not get c function calls to work inside of nasm so i wrote my own read integer procedure.  Im sure its inefficient and could be greatly imporved but right now I'm interested in where the negative sign went.  Any help is greatly apreiciated.</p>

<pre><code>;---------------------------------------------------------;
;reads a 64 bit integer from the consol and returns in rax;
;---------------------------------------------------------;
read_int:
    push rbx    ;these registers are nonvolitile and must be saved
    push rdi
    push rsi

    mov rsi, sint   ;load string address
    mov rdi, rsi    ;duplicat address
    add rdi, 21 ;shift to end of string
    .purge:     ;sets all string contents to null
    mov byte[rsi], 0;set byte to 0
    inc rsi     ;move to next byte
    cmp rsi, rdi    ;check if at end of string
    je .end_purge   ;exit loop if at end
    jmp .purge  ;loop

    .end_purge:

    mov rax, 3  ;system call code for read_string
    mov rbx, 0  ;where to read from.  in this case std_in
    mov rcx, sint   ;where the place the resultant string
    mov rdx, 21 ;how many characters to read
    int 0x80    ;system call

    mov rcx, 0  ;set registers rax, rbx, and rcx to 0
    mov rax, 0
    mov rbx, 0

    mov rsi, sint       ;load address of string into rsi and rdi
    mov rdi, sint
    add rdi, 21     ;shift rdi to the end of the string
    mov bl, byte[rsi]   ;load the first character in the string

    cmp rbx, 43 ;if charachter is + sign continue
    je .convert
    cmp rbx, 45 ;if character is - sign continue
    je .convert 

    sub rbx, 48 ;shift character to its literal value
    cmp rbx, 0  ;test if it is a number greator than 0
    jl .endr1   ;if not exit procedure
    cmp rbx, 9  ;test if it is a number less than 9
    jg .endr1   ;if not exit procedure
    add rax, rbx    ;if it is a valid number add it to the result.
    dec rdi     ;if first char is an integer we can only read 18 more
                ;so we need to shif rdi closer to start of string
                ;this way it will exit once we have read 19 total numbers

    ;does the actual conversion from string to number
    .convert:
        inc rsi         ;increment rsi to point to next byte

        cmp rsi, rdi        ;check if we are at the end of the string
        je .endr1

        mov bl, byte[rsi]   ;load next byte
        sub rbx, 48

        cmp rbx, 0      ;if this is not a valid number end procedure
        jl .endr1
        cmp rbx, 9      
        jg .endr1       

        mov rdx, 10
        mul rdx         ;multiply rax by 10 to make room for new ones place
        add rax, rbx        ;add the new number to the result
    jmp .convert

    .endr1:
    mov bl, byte[sint]  ;get first byte of integer string if minus do -result
    cmp rbx, 45
    jne .endr2

    not rax     ;convert rax to a negative
    inc rax     ;increment to get back to origional magnitude


.endr2:
pop rsi     ;restore saved values
pop rdi
pop rbx
ret         ;return to caller

;-----------------------------------------;
;prints the integer in rax to standard out;
;-----------------------------------------;
print_int:
    push rbx    ;save these registers as they are nonvolitile
    push rdi
    push rsi

    mov rsi, sint   ;load address to store string
    mov r10, 10 ;load divisor
    mov rcx, 0  ;clear registers
    mov rdx, 0

    mov rdi, rsi    ;copy address
    add rdi, 21 ;shift to end of space
    .purge:     ;make all bytes null same as above
    mov byte[rsi], 0
    inc rsi
    cmp rsi, rdi
    je .end_purge
    jmp .purge

    .end_purge:
    mov rsi, sint   ;restore origional values
    mov rdi, 0

    cmp rax, 0  ;compair the number to 0 
    jg .convert ;if its positive skip to convert
    jl .neg     ;if its negative skip to neg

    mov byte[rsi], 48   ;if its 0 add literal 0 to string
    jmp .endp1      ;jump to print
    .neg:

    not rax     ;take negation to make positive
    inc rax     ;increment to restore magnitude

    mov byte[rsi], 45   ;add the - sign to print string
    inc rsi         ;increment pointer

    .convert:
        cmp rax, 0  ;see if we are out of integers to convert
        je .converts    ;if so create string with chars
        inc rcx     ;increment counter

        div r10     ;divide by 10 placeing remainder in rdx and quotient in rax
        add rdx, 48 ;convert remainder to its char value

        mov r8,  rdx    ;move to r8
        push r8     ;push onto the stack
        mov rdx, 0  ;set rdx to 0

    jmp .convert    ;loop
    .converts:
        cmp rcx, 0  ;see if we are out of characters to concat
        je .endp1   ;if so go to print
        dec rcx     ;decrement counter

        pop rbx         ;pop a char
        mov byte[rsi], bl   ;concat char to string
        inc rsi         ;adjust string pointer to next empty slot

    jmp .converts   ;loop


    .endp1:
    mov rax, 4  ;system call code for print_string
    mov rbx, 1  ;print to std_out
    mov rcx, sint   ;address of string to print
    mov rdx, 20 ;number of chars to print
    int 0x80    ;system call

    pop rsi     ;restore saved values
    pop rdi
    pop rbx
ret
</code></pre>

<p>I also included my print procedure to make it easier to test the read procedure should you decide to run it.</p>

<p>Thanks.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>DarkLightning7</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453887/negative-problem-in-read_int-procedure-x86_64</guid>
		</item>
				<item>
			<title>Calling c functions in x86_64 assembly, nasm</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453853/calling-c-functions-in-x86_64-assembly-nasm</link>
			<pubDate>Fri, 03 May 2013 15:01:37 +0000</pubDate>
			<description>So ive been teaching myself x86 over the last couple days now im trying to call c functions and am getting segmentation faults. if someone could explain how to call them properly that would be great. here is my code: print integer is just he control string %d as i ...</description>
			<content:encoded><![CDATA[ <p>So ive been teaching myself x86 over the last couple days now im trying to call c functions and am getting segmentation faults.  if someone could explain how to call them properly that would be great.</p>

<p>here is my code:<br />
print integer is just he control string %d as i am trying to read and wrint integers</p>

<pre><code>        lea rax, print_int
        push rax
        push 10
        push 0
        call fgets
        pop rax
        pop rax
        pop rax
</code></pre>

<p>on a seperate note here is my attempt to use atoi:</p>

<pre><code>        lea rax, x
        push rax
        call atoi
</code></pre>

<p>should i be adjusting the stack after calling functions?<br />
what is the proper push order for fgets atoi and printf?<br />
where do atoi and fgets place their results?<br />
do pop and push automaticly adjust the stack?</p>

<p>Thanks</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>DarkLightning7</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453853/calling-c-functions-in-x86_64-assembly-nasm</guid>
		</item>
				<item>
			<title>Changing spaces &quot; &quot; to underscore &quot;-&quot;</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453727/changing-spaces-to-underscore-</link>
			<pubDate>Thu, 02 May 2013 01:12:22 +0000</pubDate>
			<description>I'm writing a program in .asm which prompts the user to enter a sentence. I have no problems with this but one requirement of the program is to change the format of the sentence by replacing all the spaces (&quot; &quot;) with underscore characters (&quot;_&quot;). How do I go about ...</description>
			<content:encoded><![CDATA[ <p>I'm writing a program in .asm which prompts the user to enter a sentence. I have no problems with this but one requirement of the program is to change the format of the sentence by replacing all the spaces (" ") with underscore characters ("_"). How do I go about singling out the spaces and the changing them?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>patrickgormally</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453727/changing-spaces-to-underscore-</guid>
		</item>
				<item>
			<title>Assembly Language Pep 8 Stacks Help</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453520/assembly-language-pep-8-stacks-help</link>
			<pubDate>Sun, 28 Apr 2013 19:14:20 +0000</pubDate>
			<description> ;Dmitriy Potemkin 816 Assignment 3 BR main retVal: .Equate 2 printMes:STRO msg1,d CHARO '\n',i STRO msg2,d CHARO '\n',i STRO msg3,d CHARO '\n',i STRO msg4,d CHARO '\n',i DECI retVal,s RET0 ;******************************************************************* second procedure str1: .Equate 0 rett2: .Equate 3 max2: .Equate 5 sent2: .Equate 7 retVal2: .Equate 9 secPro: SUBSP 1,i ...</description>
			<content:encoded><![CDATA[ <pre><code>;Dmitriy Potemkin 816 Assignment 3
      BR      main        
retVal:  .Equate 2

printMes:STRO    msg1,d      
         CHARO   '\n',i
         STRO    msg2,d      
         CHARO   '\n',i     
         STRO    msg3,d      
         CHARO   '\n',i
         STRO    msg4,d
         CHARO   '\n',i  
         DECI   retVal,s
         RET0
;*******************************************************************  second procedure
str1:    .Equate 0
rett2:   .Equate 3
max2:    .Equate 5
sent2:   .Equate 7
retVal2: .Equate 9

secPro:  SUBSP   1,i
         LDA     rett2,s
         CPA     1,i
         BREQ    c1
         LDA     rett2,s
         CPA     2,i
         BREQ    c2
         LDA     rett2,s
         CPA     3,i
         BREQ    c3
         LDA     rett2,s
         CPA     4,i
         BREQ    c4


c1:      STRO    msgIn,d
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i      ;This part is present in every procedure, just to see what has been passed to the procedure.
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i
while:   CHARI   str1,s
         LDBYTEA str1,s
         CPA     sent2,s
         BREQ    ender
         LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         LDA     retVal2,s   ;Here we check if the number of chars entered is at the max or more, if yes then it returns the maximum number.
         CPA     max2,s
         BRGE    ender
         br      while

c2:      STRO    msgIn,d
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i
while1:  CHARI   str1,s
         LDBYTEA str1,s
         STA     str1,s
         LDBYTEA str1,s
         CPA     sent2,s
         BREQ    ender
         LDBYTEA str1,s
         CPA     'a',i
         BREQ    ca
         CPA     'e',i
         BREQ    ce
         CPA     'i',i
         BREQ    ci
         CPA     'o',i
         BREQ    co
         CPA     'u',i
         BREQ    cu
ca:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
ce:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
ci:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
co:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
cu:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         LDA     retVal2,s
         CPA     max2,s
         BRGE    ender
         br      while1

c3:      STRO    msgIn,d
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i 
while3:  CHARI   str1,s
         LDBYTEA str1,s
         STA     str1,s
         LDBYTEA str1,s
         CPA     sent2,s
         BREQ    ender
         LDA     str1,s
         CPA     'a',i
         BREQ    while3
         LDA     str1,s
         CPA     'e',i
         BREQ    while3
         LDA     str1,s
         CPA     'i',i
         BREQ    while3
         LDA     str1,s
         CPA     'o',i
         BREQ    while3
         LDA     str1,s
         CPA     'u',i
         BREQ    while3
         LDA     retVal2,s
         adda    1,i
         STA     retVal2,s
         LDA     retVal2,s
         CPA     max2,s
         BRGE    ender
         br      while3

c4:      STRO    msgIn,d          
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i
while4:  CHARI   str1,s      
         LDBYTEA str1,s
         CPA     'z',i
         BRGT    ender
         LDBYTEA str1,s
         CPA     'A',i
         BRLT    ender
         LDA     retVal2,s
         adda    1,i
         STA     retVal2,s
         LDA     retVal2,s
         CPA     max2,s
         BRGE    ender
         br      while4


ender:   CHARO   'E',i       ;prints out end and returns to main procedure where the number of chars is printed
         CHARO   'n',i
         CHARO   'd',i
         CHARO   '\n',i
         RET1    



;*******************************************************************  main
sent1:   .EQUATE 0
max1:    .Equate 1
returned:.Equate 3
junk:    .Equate 5

main:    subsp   5,i
         STRO    msgEnd,d
         CHARI   sent1,s
         CHARI   junk,s
         STRO    msgLim,d
         DECI    max1,s
         subsp   2,i ;for return value and parameters only.
         CALL    printMes
         addsp   2,i
         LDA     -2,s
         STA     returned,s

         LDA     returned,s
         STA     -7,s

         LDA     max1,s
         STA     -5,s

         LDBYTEA sent1,s
         STBYTEA -3,s

         subsp   7,i
         CALL    secPro
         addsp   7,i

         LDA     -1,s
         STA     returned,s
         DECO    returned,s

         addsp   5,i


         STOP     

msgTotal:.ASCII  "The total number of Chars is. \x00"           
msgIn:   .ASCII  "Input your sentence. \x00"
msgEnd:  .ASCII  "Enter the sentinel character to use. \x00"
msgLim:  .ASCII  "Enter the max amount of characters to use. \x00"
msg1:    .ASCII  "1. Total number of characters\x00"     
msg2:    .ASCII  "2. Number of vowels\x00"    
msg3:    .ASCII  "3. Number of consonents\x00"   
msg4:    .ASCII  "4. Number of non-alphabetic characters\x00"   

         .END      
</code></pre>

<p>This program is supposed to take in a sentinel character and a maximum number of characters and then choose one of 4 options (counting the vowels, consonents, etc.). Whenever it starts counting though in "secPro:" it enters an endless loop where it compares the input character to god knows what (the value in the accumulator is odd). Please help.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Dmitriy78</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453520/assembly-language-pep-8-stacks-help</guid>
		</item>
				<item>
			<title>Help with Power function in MIPS</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453321/help-with-power-function-in-mips</link>
			<pubDate>Thu, 25 Apr 2013 16:20:47 +0000</pubDate>
			<description>Hi I am fairly new at programming, I am working on a final project for my assembly language class where I am calculating college savings, this is the formula I believe I will end up using, fv= pv(1+(r/n))^nt, but I am in desperate need of help in writing that in ...</description>
			<content:encoded><![CDATA[ <p>Hi I am fairly new at programming, I am working on a final project for my assembly language class where I am calculating college savings, this is the formula I believe I will end up using, fv= pv(1+(r/n))^nt, but I am in desperate need of help in writing that in to code in regards to the base * power. I have seen codes for other simulators but my professor requires us to use PCSpim. If anyone has any tips I would truly appreciate it.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>globueno</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453321/help-with-power-function-in-mips</guid>
		</item>
				<item>
			<title>problem - MIPS GCD</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453261/problem-mips-gcd</link>
			<pubDate>Thu, 25 Apr 2013 01:41:34 +0000</pubDate>
			<description>pretty new to programming in assembly but my assignment is to write a GCD program but my program works sometimes and sometimes it doesn't work. if i put the smaller number first then the larger number i don't get the correct GCD but if i do the opposite i get ...</description>
			<content:encoded><![CDATA[ <p>pretty new to programming in assembly but my assignment is to write a GCD program but my program works sometimes and sometimes it doesn't work. if i put the smaller number first then the larger number i don't get the correct GCD but if i do the opposite i get the right answer<br />
example:<br />
if i enter 209 then 2585 it says the GCD is 209, which is incorrect<br />
but, if i enter 2585 then 209 it says the GCD is 11 which is correct<br />
looking for some guidance on to why my program is working one way and not the other<br />
here is my code:</p>

<pre><code># Lab 2 - GCD
#
    .data
A:  .word 0
B:  .word 0
Prompt: .asciiz "Type integer for A, press ENTER. Type integer for B, press ENTER \n"
Result: .asciiz "\nThe GCD is "

    .globl main
    .text

main:
    li $v0,4        # syscall to print String
    la $a0,Prompt       # load address of Prompt
    syscall         # print Prompt String

    li $v0,5        # syscall to read integer
    syscall         # read first intger
    move $a0,$v0        # move integer in $v0 to $a0

    li $v0,5        # syscall to read integer
    syscall         # read next integer
    move $a1,$v0        # move integer in $v0 to $a1

baseCase:
    bne $a1,$zero,recCase   # if $a1 != 0 branch to recCase
    li $v0,4        # syscall to print String
    la $a0,Result       # load address of Result
    syscall         # print result String

    lw $a0,A        # load A
    li $v0,1        # syscall to print integer
    syscall         # print A

    li $v0,10       # terminate prog running
    syscall         # return control to system

recCase:
    sub $sp,$sp,12      # push stack
    sw $ra,0($sp)       # save return address
    sw $a0,4($sp)       # save registers
    sw $a1,8($sp)       
    move $t0,$a1        # move $a1 to $t0
    rem $a1,$a0,$a1     # $a1 =  A%B
    sw $t0,A        # store A for output
    jal baseCase        # jump to baseCase

    lw $ra,0($sp)       # load main
    addi $sp,$sp,12     # 
    jr $ra          # return to main
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>newGains</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453261/problem-mips-gcd</guid>
		</item>
				<item>
			<title>Encryption Decryption</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453256/encryption-decryption</link>
			<pubDate>Wed, 24 Apr 2013 23:55:53 +0000</pubDate>
			<description>Would this decryption decrypt this encryption? encryption: push eax and eax,0xAA not al mov edx,eax pop eax and eax,0x55 xor ecx,edx xor ecx,eax rol cl,1 rol cl,1 mov eax,ecx sub al,0x20 decryption: add al, 0x20 mov eax, ecx ror cl, 1 ror cl, 1 xor ecx, eax xor ecx, edx ...</description>
			<content:encoded><![CDATA[ <p>Would this decryption decrypt this encryption?</p>

<p>encryption:<br />
push eax<br />
and eax,0xAA<br />
not al<br />
mov edx,eax<br />
pop eax<br />
and eax,0x55<br />
xor ecx,edx<br />
xor ecx,eax<br />
rol cl,1<br />
rol cl,1<br />
mov eax,ecx<br />
sub al,0x20</p>

<p>decryption:</p>

<p>add al, 0x20<br />
mov eax, ecx<br />
ror cl, 1<br />
ror cl, 1<br />
xor ecx, eax<br />
xor ecx, edx<br />
and eax, 0x55<br />
pop eax<br />
mov edx, eax<br />
not al<br />
and eax, 0xAA<br />
push eax</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>RYAnn191</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453256/encryption-decryption</guid>
		</item>
				<item>
			<title>how you can make menu in assembly</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453208/how-you-can-make-menu-in-assembly</link>
			<pubDate>Wed, 24 Apr 2013 13:13:07 +0000</pubDate>
			<description>please help me in my project how you can make menu in assembly ??</description>
			<content:encoded><![CDATA[ <p>please help me in my project<br />
how you can make menu in assembly ??</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>isra sweileh</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453208/how-you-can-make-menu-in-assembly</guid>
		</item>
				<item>
			<title>Neat 512 byte programs</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/453013/neat-512-byte-programs</link>
			<pubDate>Mon, 22 Apr 2013 09:59:22 +0000</pubDate>
			<description>Has anyone made some really cool (or not so cool) 512-byte programs in assembly? I used to hear about people taking part in competitions where they'd try and make, say, a bootloader (or a program like a calculator, for example) and pack-in as many features as they could, the only ...</description>
			<content:encoded><![CDATA[ <p>Has anyone made some really cool (or not so cool) 512-byte programs in assembly? I used to hear about people taking part in competitions where they'd try and make, say, a bootloader (or a program like a calculator, for example) and pack-in as many features as they could, the only constraints being that it must be bootable (ie. stuck onto a floppy as its boot sector) and must only occupy the 512-byte boot sector - ie. can't load code from files on the disk and run it.</p>

<p>I just thought that I'd put it out there. Anyone made something along these lines? Just curious to see what people may or may not have done.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Assembly GUy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/453013/neat-512-byte-programs</guid>
		</item>
				<item>
			<title>do Intel and AND use the same instrctuions set</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/452852/do-intel-and-and-use-the-same-instrctuions-set</link>
			<pubDate>Fri, 19 Apr 2013 16:12:44 +0000</pubDate>
			<description>If I write an asembly program to a one CPU, will it also run on the other brand? What CPU is faster?Intel or amd (let's say both are 2Ghz processors. )</description>
			<content:encoded><![CDATA[ <p>If I write an asembly program to a one CPU, will it also run on the other brand?</p>

<p>What CPU is faster?Intel or amd (let's say both are 2Ghz processors. )</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>silvercats</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/452852/do-intel-and-and-use-the-same-instrctuions-set</guid>
		</item>
				<item>
			<title>include dll procedures into body of programs</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/452416/include-dll-procedures-into-body-of-programs</link>
			<pubDate>Sun, 14 Apr 2013 05:21:23 +0000</pubDate>
			<description>Hi all, I'm programming a shell code for stack buffer overflow vulnerabilities, I have learned about it and read alot of this vulnerability and finally I have the ability to exploit it and make the shells. This is my code: ;+-+-+-+-+[ FileName: shellcode.asm ]+-+-+-+-+-+ .386 .model flat, stdcall option casemap:none ...</description>
			<content:encoded><![CDATA[ <p>Hi all,<br />
I'm programming a shell code for stack buffer overflow vulnerabilities, I have learned about it and read alot of this vulnerability and finally I have the ability to exploit it and make the shells.<br />
This is my code:</p>

<pre><code>;+-+-+-+-+[ FileName: shellcode.asm ]+-+-+-+-+-+
.386
.model flat, stdcall
option casemap:none

;+-+-+-+-+ Include Files +-+-+-+-+-+
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

;+-+-+-+-+ Include Libraries +-+-+-+-+
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.code
main:

;|=--------------=[ shell code section ]=---------------=|
    push 0 ; OK button
    jmp _caption
_rCaption:
    jmp _msg
_rMsg:
    push 0 ; hWnd
    call DWORD PTR DS:[402034h] ; &amp;lt;=&amp;gt; call MessageBox

    push 0
    call DWORD PTR DS:[402014h] ; &amp;lt;=&amp;gt; call ExitProcess

;|=--------------=[ shell data section ]=---------------=|
_caption:
    call _rCaption ; &amp;lt;=&amp;gt; push offset caption
    caption db "ha ha",0
_msg:
    call _rMsg ; &amp;lt;=&amp;gt; push offset msg
    msg db "You have been hacked!",0

end main
</code></pre>

<p>Now as you can see the routines above (messagebox, and exitprocess) are static, so I must know the address of the procedures inside the target program and put it into the shell and assemble it again!! :(</p>

<p>Is there any way to make the shell dynamically, my point is how to &lt;b&gt;include the dll procedures inside the body of programs?&lt;/b&gt;</p>

<p>The reason of my question is to make the shell works in any program that have the stack buffer overflow vulnerability and maybe to make virus do the same way.</p>

<p>Note: I don't accept the solution that make the shell takes the addresses from import data section of the target program, this is can work for the example above but don't work with shells that have different dll procedures.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Rasool Ahmed</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/452416/include-dll-procedures-into-body-of-programs</guid>
		</item>
				<item>
			<title>Problem with Windows program (MASM32 x86 Intel)</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/452324/problem-with-windows-program-masm32-x86-intel</link>
			<pubDate>Fri, 12 Apr 2013 22:44:03 +0000</pubDate>
			<description>So, When I assemble this code, I get no errors. It flies through the build. However, when I go to execute this code, it does not display the window. I am unsure of why. I have tried invoking messageboxes at the start or WinMain, but it seems it's not getting ...</description>
			<content:encoded><![CDATA[ <p>So, When I assemble this code, I get no errors. It flies through the build. However, when I go to execute this code, it does not display the window. I am unsure of why. I have tried invoking messageboxes at the start or WinMain, but it seems it's not getting called, because the MessageBox does not show up. However, I am actually calling the WinMain function. But it seems to not be running.</p>

<p>Any help would be great,<br />
Thanks!</p>

<pre><code>.386
.model flat, stdcall
option casemap :none 

include \masm32\include\windows.inc 
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

WinMain PROTO :HINSTANCE, :HINSTANCE, :LPSTR, :DWORD
WinProc PROTO :HWND, :UINT, :WPARAM, :LPARAM

.data
    ClassName   db "MAIN_CLASS", 0
    MainTitle   db "A Window in Assembly!", 0
    ErrorText   db "Fatal Error, the program will now close...", 0
    ErrorTitle  db "Fatal Error", 0

.data?
    hInstance   HINSTANCE ?

.code
start:
    WinProc PROC hWnd:HWND, message:UINT, wParam:WPARAM, lParam:LPARAM
            cmp message, WM_DESTROY
            je DO_DESTROY

            cmp message, WM_CLOSE
            je DO_CLOSE

            jmp DO_DEFAULT

            DO_DESTROY:

            invoke PostQuitMessage, 0
            jmp DO_END

            DO_CLOSE:

            invoke DestroyWindow, addr hWnd
            jmp DO_END

            DO_DEFAULT:

            invoke DefWindowProc, hWnd, message, wParam, lParam
            ret
            jmp DO_STOP

            DO_END:

            xor eax, eax
            ret

            DO_STOP:

    WinProc ENDP

    WinMain PROC hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:DWORD
            local wc:WNDCLASSEX
            local msg:MSG
            local hWnd:HWND

            mov  wc.cbSize, SIZEOF WNDCLASSEX
            mov  wc.style, 0
            mov  wc.lpfnWndProc, offset WinProc
            mov  wc.cbClsExtra, NULL
            mov  wc.cbWndExtra, NULL
            push hInstance
            pop  wc.hInstance
            mov  wc.hbrBackground, COLOR_WINDOW + 1
            mov  wc.lpszMenuName, NULL
            mov  wc.lpszClassName, offset ClassName
            invoke LoadIcon, NULL, IDI_APPLICATION
            mov wc.hIcon, eax
            mov wc.hIconSm, eax
            invoke LoadCursor, NULL, IDC_ARROW
            mov wc.hCursor, eax
            invoke RegisterClassEx, addr wc
            cmp eax, 0
            je SHOW_ERROR

            invoke CreateWindowEx,
                WS_EX_CLIENTEDGE,
                addr ClassName,
                addr MainTitle,
                WS_OVERLAPPEDWINDOW,
                50,
                50,
                600,
                300,
                NULL,
                NULL,
                hInst,
                NULL
            mov hWnd, eax

            cmp hWnd, NULL
            je SHOW_ERROR

            invoke ShowWindow, hWnd, CmdShow
            invoke UpdateWindow, hWnd

            message_loop:

            invoke GetMessage, addr msg, addr hWnd, 0, 0
            cmp eax, 0
            je message_loop_end
            invoke TranslateMessage, addr msg
            invoke DispatchMessage, addr msg
            jmp message_loop

            message_loop_end:

            mov eax, msg.wParam
            ret

            jmp STOP

            SHOW_ERROR:

            invoke MessageBox, NULL, addr ErrorText, addr ErrorTitle, MB_OK
            jmp RET_ZERO

            RET_ZERO:

            mov eax, 0
            ret

            STOP:
    WinMain ENDP

    invoke GetModuleHandle, NULL
    mov hInstance, eax
    invoke WinMain, hInstance, NULL, NULL, 0
    invoke ExitProcess, eax
end start
</code></pre>

<p>Thanks again!</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Echo89</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/452324/problem-with-windows-program-masm32-x86-intel</guid>
		</item>
				<item>
			<title>KeBugCheck question</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/451273/kebugcheck-question</link>
			<pubDate>Sat, 30 Mar 2013 12:35:12 +0000</pubDate>
			<description> Does KeBugCheck only work in a driver ? Andy [code] start: xor eax,eax or esi, 300h add eax, 220h nop cmp [eax], esi pop esi pop ebx jnz short done xor ecx, ecx push ecx ; BugCheckParameter4 push ecx ; BugCheckParameter3 push ecx ; BugCheckParameter2 push ecx ; BugCheckParameter1 push ...</description>
			<content:encoded><![CDATA[ <pre><code>Does KeBugCheck only work in a driver ?

Andy

[code]
start:

xor     eax,eax
or      esi, 300h
add     eax, 220h
nop

cmp     [eax], esi
pop     esi
pop     ebx
jnz     short done
xor     ecx, ecx
push    ecx             ; BugCheckParameter4
push    ecx             ; BugCheckParameter3
push    ecx             ; BugCheckParameter2
push    ecx             ; BugCheckParameter1
push    0E2h            ; BugCheckCode MANUALLY_INITIATED_CRASH
mov     [eax], ecx
call    KeBugCheckEx    ;ds:__imp__KeBugCheckEx@20

[/code]
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Fix_It</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/451273/kebugcheck-question</guid>
		</item>
				<item>
			<title>Assembly Game Code Help</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/451154/assembly-game-code-help</link>
			<pubDate>Thu, 28 Mar 2013 16:26:05 +0000</pubDate>
			<description>I am a beginner at Assembly. I am trying to make a DDR like game. Can someone please help me call the audio (SONG1 PROC) properly in the play window alongside with the graphics? The graphics are messed up whenever I try to call the audio. I cannot post the ...</description>
			<content:encoded><![CDATA[ <p>I am a beginner at Assembly. I am trying to make a DDR like game. Can someone please help me call the audio (SONG1 PROC) properly in the play window alongside with the graphics? The graphics are messed up whenever I try to call the audio. I cannot post the code since it's 1000+ lines. I'm not allowed to post asm file either so I posted it as txt. I run it with MASM. Thank you.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>digifort</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/451154/assembly-game-code-help</guid>
		</item>
				<item>
			<title>8085</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/451007/8085</link>
			<pubDate>Tue, 26 Mar 2013 15:12:51 +0000</pubDate>
			<description>`LDA C031 MVI B, A LDA C032H ADD B STA C033H HLT` Okay so I made a program that add two numbers in 8085 AL but I keep getting 0A on C033 whatever I put in C031 AND C032. Help, please? Thanks!</description>
			<content:encoded><![CDATA[ <p><code>LDA C031
MVI B, A
LDA C032H
ADD B
STA C033H
HLT</code></p>

<p>Okay so I made a program that add two numbers in 8085 AL but I keep getting 0A on C033 whatever I put in C031 AND C032. Help, please? Thanks!</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Daigan</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/451007/8085</guid>
		</item>
				<item>
			<title>Assembly language, longest common subsequence</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/450662/assembly-language-longest-common-subsequence</link>
			<pubDate>Thu, 21 Mar 2013 18:28:05 +0000</pubDate>
			<description>I have done this chunk of code that I want to ''translate'' in assembly language. It calculates the lenght of the longest common subsequence. Can someone help me to translate this in PEP/8 assembly language ? The rest of my program is functionning quite good, but I cant find a ...</description>
			<content:encoded><![CDATA[ <p>I have done this chunk of code that I want to ''translate'' in assembly language. It calculates the lenght of the longest common subsequence.</p>

<p>Can someone help me to translate this in PEP/8 assembly language ? The rest of my program is functionning quite good, but  I cant find a way to populate my matrix. Its a multidimension and variable length matrix, and I find this very complex. I know there is no such thing in assembly because multi dimension arrays are in fact one dimension arrays. I am quite lost.</p>

<p>To simplify I can say that no string will be more that 100 characters.</p>

<p>Thanks for any insight.</p>

<pre><code>public static void LCS() {

    matrix = new int[String1Lenght + 1][String2Lenght + 1];
    for (int i = String1Lenght - 1; i &gt;= 0; i--) {
        for (int j = String2Lenght - 1; j &gt;= 0; j--) {
            if (String1Array[i] == String2Array[j]) {
                matrix[i][j] = matrix[i + 1][j + 1] + 1;

            } else {
                matrix[i][j] = max(matrix[i + 1][j], matrix[i][j + 1]);

            }
        }
    }
    int i = 0, j = 0;
    while (i &lt; String1Lenght &amp;&amp; j &lt; String2Lenght) {
        if (String1Array[i] == String2Array[j]) {
            i++;
            j++;
        } else if (matrix[i + 1][j] &gt;= matrix[i][j + 1]) {
            i++;
        } else {
            j++;
        }
    }

    System.out.print(j);
    System.out.println("");
}
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>nacedo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/450662/assembly-language-longest-common-subsequence</guid>
		</item>
				<item>
			<title>In need of help here. </title>
			<link>http://www.daniweb.com/software-development/assembly/threads/450288/in-need-of-help-here.-</link>
			<pubDate>Sun, 17 Mar 2013 15:41:33 +0000</pubDate>
			<description>Okay, I'm a newbie in this matter, and my lecturer seems to punish my class for not coming early to class. He asks us to write this assembly languange program, by using the information from internet. I really need your help about this question. Question 1. Initialize the grade listed ...</description>
			<content:encoded><![CDATA[ <p>Okay, I'm a newbie in this matter, and my lecturer seems to punish my class for not coming early to class. He asks us to write this assembly languange program, by using the information from internet. I really need your help about this question.<br />
Question 1.<br />
Initialize the grade listed below in the data segment.<br />
Grades: 55h, 6Eh, 69h, 4Bh, 4Ch, 20h, 42h, 4Dh, 49h, 03h, E6h<br />
Question 2.<br />
Write an assembly program, to sum up all the data, the result should be placed in the memory as "SUM_add".</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>mohdshafiqanas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/450288/in-need-of-help-here.-</guid>
		</item>
				<item>
			<title>Help Me PLEASE :(</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/450226/help-me-please-</link>
			<pubDate>Sat, 16 Mar 2013 15:21:43 +0000</pubDate>
			<description> Somebody help. This is for my special project and to be submitted on monday. It's 11:09pm (saturday) here. i have a problem with my codes. its about when you input a CAPITAL LETTER the output should be in lowercase and vice versa. and also my problem is i dont know ...</description>
			<content:encoded><![CDATA[ <pre><code>Somebody help. This is for my special project and to be submitted on monday. It's 11:09pm (saturday) here. i have a problem with my codes. its about when you input a CAPITAL LETTER the output should be in lowercase and vice versa. and also my problem is i dont know to code the " INVALID INPUT" when the input characters have spaces and numbers. that's all. hope someone will help :( i need to pass my subject :(

Here's my code....

DIS MACRO STR
MOV AH,09H
LEA DX,STR
INT 21H
ENDM
DATA SEGMENT
MSG1 DB "INPUT A CHARACTER : $"
MSG2 DB "CONVERTED CHARACTER IS : $"
STR1 DB 20 DUP('$')
LINE DB 10,13,'$'
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA,CS:CODE

START:
MOV AX,DATA
MOV DS,AX
DIS MSG1
MOV AH,0AH
LEA DX,STR1
INT 21H
DIS LINE
MOV CH,00
MOV CL,BYTE PTR[STR1+1]
LEA SI,STR1+2

L1: MOV AH,BYTE PTR[SI]
    CMP AH,'A'
    JL L4
    CMP AH,'Z'
    JG L2
    ADD BYTE PTR[SI],32
    JMP L3

 L2:CMP AH,'a'
    JL L4
    CMP AH,'z'
    JG L4
    SUB BYTE PTR[SI],32

 L3:INC SI
    LOOP L1
    DIS MSG2
    DIS STR1+2

L4:MOV AH,4CH
INT 21H
CODE ENDS
END START

;------
;OUTPUT
;------

ENTER YOUR CHARACTER : JiNeSh
CONVERTED CHARACTER IS : jInEsh
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>trebla21</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/450226/help-me-please-</guid>
		</item>
				<item>
			<title>If high level data structures aren&#039;t so prevalent in Assembly, why use?</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/449891/if-high-level-data-structures-arent-so-prevalent-in-assembly-why-use</link>
			<pubDate>Tue, 12 Mar 2013 19:28:18 +0000</pubDate>
			<description>In Assembly there's not going to be much insight on linked lists, B trees, arrays, etc. In fact those don't even exist at the bit level. Sure, they help solve some problems from all the way up to your compiled language syntax, but such symbols don't exist in machine code, ...</description>
			<content:encoded><![CDATA[ <p>In Assembly there's not going to be much insight on linked lists, B trees, arrays, etc.</p>

<p>In fact those don't even exist at the bit level.</p>

<p>Sure, they help solve some problems from all the way up to your compiled language syntax, but such symbols don't exist in machine code, which is logically simple, just, and basic in bulk of operations in the bit level(i.e. move this here, add this using two's complement, return this, compare that, do this <strong>if</strong> that, etc.).</p>

<p>So if we realize that the closer we get to the architecture the lesser the abstraction gets, and that our higher level data structures convert back to basic just machine instructions once they've solved some of our problems, why not just go bare basics and accomplish the implementation of these high level data structures more confined to the architecture itself, since, ultimately, that is what happens to our linguistics after we press F9?</p>

<p>If I were to right now develop a kernel keeping in tune with the underlying architecture, rather than being secure that my linked library invoking driver called subroutines and APIs right underneath my symbols are translated perfectly in to executable format images and/or specific file extensions I would expect to worry about the <strong><em>chip's implementation</em></strong>, not the behavior of APIs, drivers, and other platform handling modules and services, hence, I'd worry more about how <em>my code is working directly</em>, and I'd focus more on the bare basics of programming.</p>

<p>That is operating system development, as the only <em>thing</em> beneath me is mostly going to be hardware.</p>

<p>If I were to continue on being abstracted of the hardware by dozens of services, driver invoking libraries and APIs, and other combination of tools, utility software, compiling and linking software, and perfectly designated methods to invoke one thing on to the other, I'd eventually become so abstracted from the actual implementation of the architecture by the operating system as a whole, and eventually wouldn't know <em>what</em> I'd be writing code for due to such bloating abstraction from what code is really doing.</p>

<p>For example, I am not setting a pixel on the window system's client area on a GUI with my code I am calling a method through a binded language with a compatible language compiled library that will invoke a driver that will access a service that have a kernel handle everything for me ever so precisely through an executable image. How am I doing the full work though?</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Clan Onion</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/449891/if-high-level-data-structures-arent-so-prevalent-in-assembly-why-use</guid>
		</item>
				<item>
			<title>Pep8 convert a 3-bit binary number to a decimal number</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/449428/pep8-convert-a-3-bit-binary-number-to-a-decimal-number</link>
			<pubDate>Thu, 07 Mar 2013 03:28:40 +0000</pubDate>
			<description>Write a program in object code that will convert a 3-bit binary number to a decimal number,For example, if input is 101, output should be 5; if input is 011, output should be 3. that is what I have to do,this is what I have so far but its not ...</description>
			<content:encoded><![CDATA[ <p>Write a program in object code that will convert a 3-bit binary number to a decimal number,For example, if input is 101, output should be 5; if input is 011, output should be 3. that is what I have to do,this is what I have so far but its not working, Can someone point out what is wrong or what need to be changed</p>

<p>49 00 30<br />
D1 00 30<br />
1C<br />
F1 00 33<br />
51 00 33<br />
zz</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>goha1414</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/449428/pep8-convert-a-3-bit-binary-number-to-a-decimal-number</guid>
		</item>
				<item>
			<title>Tips for a Beginner Learner</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/449329/tips-for-a-beginner-learner</link>
			<pubDate>Tue, 05 Mar 2013 23:26:51 +0000</pubDate>
			<description>Hey guys i was just wondering if any of you have good links to sources that i can learn assembly from all i want to know is what the CMP PUSH EAX... means. basically i just want a reference to help me understand assembly language like in OllyDBG. Thanks.</description>
			<content:encoded><![CDATA[ <p>Hey guys<br />
i was just wondering if any of you have good links to sources that i can learn assembly from<br />
all i want to know is what the CMP PUSH EAX... means.</p>

<p>basically i just want a reference to help me understand assembly language like in OllyDBG.</p>

<p>Thanks.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>evilguyme</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/449329/tips-for-a-beginner-learner</guid>
		</item>
				<item>
			<title>Advice for Learning [Beginner]</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/449328/advice-for-learning-beginner</link>
			<pubDate>Tue, 05 Mar 2013 23:02:42 +0000</pubDate>
			<description>hey guys im just trying to learn software hacking and i realised a major part is memory editing. that out of the way, i just wanted to ask if anyone knows a simple book or something of the sort to help me learn. basically i just want to figure out ...</description>
			<content:encoded><![CDATA[ <p>hey guys<br />
im just trying to learn software hacking and i realised a major part is memory editing.<br />
that out of the way, i just wanted to ask if anyone knows a simple book or something of the sort to help me learn.</p>

<p>basically i just want to figure out what all the PUSH MOV EAX stuff means and how to manipulate this and change these to edit certain values.</p>

<p>well basically are there any guides out there that teach you to read assembly language like the one in memory view of Cheat Enging or OllyDBG and preferably related more to hacking software.</p>

<p>Thanks.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>evilguyme</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/449328/advice-for-learning-beginner</guid>
		</item>
				<item>
			<title>Willing to pay for help on assembly assignement</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/448966/willing-to-pay-for-help-on-assembly-assignement</link>
			<pubDate>Thu, 28 Feb 2013 22:02:34 +0000</pubDate>
			<description>Hi, I'm a student at a university and I'm having trouble with an assignment. Mainly because I am very new to assembly language. If you have any experience using NASM x86 assembly language, please contact me through private messages I am willing to pay well.</description>
			<content:encoded><![CDATA[ <p>Hi,</p>

<p>I'm a student at a university and I'm having trouble with an assignment. Mainly because I am very new to assembly language.</p>

<p>If you have any experience using NASM x86 assembly language, please contact me through private messages</p>

<p>I am willing to pay well.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>meatyking</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/448966/willing-to-pay-for-help-on-assembly-assignement</guid>
		</item>
				<item>
			<title>Clock with 7 segment using 8051</title>
			<link>http://www.daniweb.com/software-development/assembly/threads/448772/clock-with-7-segment-using-8051</link>
			<pubDate>Tue, 26 Feb 2013 18:38:37 +0000</pubDate>
			<description>Hi everyone, i'm trying to code a Clock with 2 7segment (commun anode) with 8051 microcontroller in assembly language. i use only two 7 segment led because i want just minutes and secondes for hours i will see later. So i tried to code and when i run it, it's ...</description>
			<content:encoded><![CDATA[ <p>Hi everyone,<br />
i'm trying to code a Clock with 2 7segment (commun anode) with 8051 microcontroller in assembly language.<br />
i use only two 7 segment led because i want just minutes and secondes for hours i will see later.<br />
So i tried to code and when i run it, it's counting from 0 to 9 and after it restarts at 0 to 9<br />
but it never counts after 9, i want it to count from 0 to 59.<br />
i used port2 and port3 in 8051 and simulate in Keil and Proteus<br />
So please can anyone check my code...<br />
Thank you<br />
code:</p>

<pre><code> org 0000h
Home:
mov r0,#00h
mov a,r0
lcall TT
mov p2,a
mov r1,#00h
mov a,r1
lcall TT
mov p3,a 
lcall delay

SEC1:
inc r0
mov a,r0
cjne a,#01h,L1
mov r0,#00h
sjmp SEC2

L1:
lcall TT
mov p2,a
lcall delay
sjmp SEC1

SEC2:
inc r1
mov a,r1
cjne a,#0ah,L2
mov r1,#00h
sjmp Home
L2:
lcall TT
mov p3,a
lcall delay
sjmp SEC2

TT:
cjne a,#01h,M1
mov a,#0F9h;1
ret
M1:
cjne a,#02h,M2
mov a,#0a4h;2
ret
M2:
cjne a,#03h,M3
mov a,#0b0h;3
ret
M3:
cjne a,#04h,M4
mov a,#099h;4
ret
M4:
cjne a,#05h,M5
mov a,#012h;5
ret
M5:
cjne a,#06h,M6
mov a,#082h;6
ret
M6:
cjne a,#07h,M7
mov a,#0f8h;7
ret
M7:
cjne a,#08h,M8
mov a,#080h;8
ret
M8:
cjne a,#09h,M9
mov a,#090h;9
ret
M9:
cjne a,#00h,M1
mov a,#0c0h;0
ret
M10:



delay: 
mov r2,#04h
mov r3,#080h
mov r4,#0ffh
djnz r4,$
djnz r3,$-2
djnz r2,$-4
ret
end
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/software-development/assembly/125">Assembly</category>
			<dc:creator>Neversleepin</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/software-development/assembly/threads/448772/clock-with-7-segment-using-8051</guid>
		</item>
			</channel>
</rss>