flat assembler
Message board for the users of flat assembler.
Index
> DOS > Simple Code not running |
Author |
|
revolution 13 May 2005, 08:21
Code: ; This probram adds two 8-bit words in the memory locations ;called NUM1 and NUM2. The result is stored in the memory location called ; RESULT. If there was a carry from teh addition it will be stored as 0000 ;0001 in the location CARRY. org 100h ;code starts at offset 100h use16 ;use 16-bit code jmp START NUM1 DB 15h ;First number is stored here NUM2 DB 20h ; Second number stored here RESULT DB ? ; Put sum here CARRY DB ? ; Put any carry here START: MOV AL, [NUM1] ; Get the first number ADD AL, [NUM2] ; Add it to 2nd number MOV [RESULT], AL ; Store the result RCL AL, 01 ; Rotate carry into LSB AND AL, 00000001B ; Mask out all but LSB MOV [CARRY], AL ; Store the carry result MOV AX, 4C00H INT 21h |
|||
13 May 2005, 08:21 |
|
Tomasz Grysztar 13 May 2005, 08:30
More literal conversion:
Code: FORMAT MZ SEGMENT _DATA ; CODE and DATA are reserved words in fasm, ; so other have to be used for segment names NUM1 DB 15h ;First number is stored here NUM2 DB 20h ; Second number stored here RESULT DB ? ; Put sum here CARRY DB ? ; Put any carry here SEGMENT _CODE START: MOV AX, _DATA ;Initialize data segment MOV DS, AX ; register ; register MOV AL, [NUM1] ; Get the first number ADD AL, [NUM2] ; Add it to 2nd number MOV [RESULT], AL ; Store the result RCL AL, 01 ; Rotate carry into LSB AND AL, 00000001B ; Mask out all but LSB MOV [CARRY], AL ; Store the carry result MOV AX, 4C00H INT 21h ENTRY _CODE:START |
|||
13 May 2005, 08:30 |
|
VG 13 May 2005, 08:48
Very thanks. But you didnot tell me what is the problem with my code. After all i have to depend on my book, for reference. Are all my code incapable of running on FASM?
|
|||
13 May 2005, 08:48 |
|
Tomasz Grysztar 13 May 2005, 08:54
Your book is for the different dialect of assembly language - that's why the translation was needed. You might try reading the fasm's Programmer's Manual (especially section 1.2) to see what the differencies are.
Also, your code is a DOS program, you should have posted in the DOS forum instead. |
|||
13 May 2005, 08:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.