Aug 7, 2008

Trying To Program In Assembly And Keep Getting Error

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Assembler and Delphi

free web hosting

Trying To Program In Assembly And Keep Getting Error

Angela
I am brand new at learning Assembly...and can't seem to get this proram to execute....

This is my code....

CODE
;;;;;%include  "NASMENV\lib\io.mac"
.STACK 100H
.DATA
char_prompt  db  "Please input a character: ",0
out_msg1        db  "The ASCII code of  ' ",0
out_msg2           db  "' in hex is  ",0
query_msg     db  "Do you want to quit (Y/N):  ",0

;  translation table: 4-bit binary to hex

hex-table       db   "012345789ABCDEF", 0

.CODE
    .STARTUP

read_char:

    PutStr    char_prompt; request a char. input
    GetCh    AL

    PutStr    out_msg1
    PutCh    AL
    PutStr    out_msg2
    mov    AH,AL    ; save input character in AH
    mov    EBX, hex_table; EBX = translation table
    shr    AL,4    ; move upper 4 bits to lower half
    xlatb        ; replace AL with hex digit
    PutCh    AL    ; write the first hex digit
    mov    AL,AH    ; restore input character to AL
    and    AL,0FH    ; mask off upper 4 bits
    xlatb            
    PutCh    AL    ; write the second hex digit
    nwln
    PutStr    query_msg; query user whether to terminate
    GetCh    AL    ; read response

    cmp    AL, 'Y'    ; if response is not 'Y'
    jne    read_char; read another character

done:
    .EXIT    


When I attempt to make...I get the below.... PLEASE HELP! This is driving me bonkers!

QUOTE
J:\NASMENV\ASM\Hex2Char>make
MAKE Version 5.2 Copyright © 1987, 2000 Borland
/NASMENV/NASM/nasm-0.98.39/nasm -o hex2char.obj -f obj -l hex2char.lst -
P /NASMENV/lib/io.mac hex2char.asm
J:\NASMENV\lib\io.mac:7: warning: redefining multi-line macro `.STACK'
J:\NASMENV\lib\io.mac:15: warning: redefining multi-line macro `.DATA'
J:\NASMENV\lib\io.mac:21: warning: redefining multi-line macro `.UDATA'
J:\NASMENV\lib\io.mac:27: warning: redefining multi-line macro `.CODE'
J:\NASMENV\lib\io.mac:35: warning: redefining multi-line macro `.STARTUP'
J:\NASMENV\lib\io.mac:49: warning: redefining multi-line macro `.EXIT'
J:\NASMENV\lib\io.mac:57: warning: redefining multi-line macro `nwln'
J:\NASMENV\lib\io.mac:64: warning: redefining multi-line macro `PutCh'
J:\NASMENV\lib\io.mac:74: warning: redefining multi-line macro `PutStr'
J:\NASMENV\lib\io.mac:84: warning: redefining multi-line macro `GetStr'
J:\NASMENV\lib\io.mac:99: warning: redefining multi-line macro `GetCh'
J:\NASMENV\lib\io.mac:120: warning: redefining multi-line macro `PutInt'
J:\NASMENV\lib\io.mac:130: warning: redefining multi-line macro `GetInt'
J:\NASMENV\lib\io.mac:143: warning: redefining multi-line macro `PutLInt'
J:\NASMENV\lib\io.mac:152: warning: redefining multi-line macro `GetLInt'
hex2char.asm:18: error: parser: instruction expected

** error 1 ** deleting hex2char.obj

 

 

 


Reply

ghostrider
QUOTE
hex-table db "012345789ABCDEF", 0


EBX is a 32-bit variable. This means it can hold a total of 32 bits / 8 bits per byte or a total of 4 bytes. The value you are trying to put in there is 17 bytes. Perhaps you are supposed to be putting the location of hex_table in EBX? I'm not familiar with some of the instructions you are using so I couldn't tell you. Post back and I can try and help you out more. I've been using assembly for 3 years.

Reply

Angela
Hi Ghostrider! smile.gif Thanks soooooo much for responding. I can't imagine anyone who would take this course because they want to. I am currently enrolled in the course because I have toooo...a tutor...I definitely need... anyway... I believe I am moving the hex_table into EBX...see a copy of the code below.... Any and all help is greatly appreciated...Thanks...

mov EBX, hex_table; EBX = translation table





QUOTE(Angela @ Nov 14 2006, 11:47 PM) *

I am brand new at learning Assembly...and can't seem to get this proram to execute....

This is my code....

CODE
;;;;;%include  "NASMENV\lib\io.mac"
.STACK 100H
.DATA
char_prompt  db  "Please input a character: ",0
out_msg1        db  "The ASCII code of  ' ",0
out_msg2           db  "' in hex is  ",0
query_msg     db  "Do you want to quit (Y/N):  ",0

;  translation table: 4-bit binary to hex

hex-table       db   "012345789ABCDEF", 0

.CODE
    .STARTUP

read_char:

    PutStr    char_prompt; request a char. input
    GetCh    AL

    PutStr    out_msg1
    PutCh    AL
    PutStr    out_msg2
    mov    AH,AL; save input character in AH
    mov    EBX, hex_table; EBX = translation table
    shr    AL,4; move upper 4 bits to lower half
    xlatb    ; replace AL with hex digit
    PutCh    AL; write the first hex digit
    mov    AL,AH; restore input character to AL
    and    AL,0FH; mask off upper 4 bits
    xlatb            
    PutCh    AL; write the second hex digit
    nwln
    PutStr    query_msg; query user whether to terminate
    GetCh    AL; read response

    cmp    AL, 'Y'; if response is not 'Y'
    jne    read_char; read another character

done:
    .EXIT    


When I attempt to make...I get the below.... PLEASE HELP! This is driving me bonkers!

 

 

 


Reply

ghostrider
I'm sorry I can't elorborate on this more, but I found this on the internet. It explains the xlatb function. You need to put the address of the table in EBX, not the table itself.
CODE

lea EBX, hex-table
;lea stands for load effective address.  


Here is what I found on the internet:
QUOTE
Description
Locates a byte entry in a table in memory, using the contents of the AL register as a table index, then copies the contents of the table entry back into the AL register. The index in the AL register is treated as an unsigned integer. The XLAT and XLATB instructions get the base address of the table in memory from either the DS:EBX or the DS:BX registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). (The DS segment may be overridden with a segment override prefix.)

At the assembly-code level, two forms of this instruction are allowed: the "explicit-operand" form and the "no-operand" form. The explicit-operand form (specified with the XLAT mnemonic) allows the base address of the table to be specified explicitly with a symbol. This explicit-operands form is provided to allow documentation; however, note that the documentation provided by this form can be misleading. That is, the symbol does not have to specify the correct base address. The base address is always specified by the DS:(E)BX registers, which must be loaded correctly before the XLAT instruction is executed.

The no-operands form (XLATB) provides a "short form" of the XLAT instructions. Here also the processor assumes that the DS:(E)BX registers contain the base address of the table.


Hope this helps.

Reply

Angela
Hi Ghostrider! Any help is elaboration is better than none...I will try this..and I'll let you know how it turns out. Thanks again soooo much for your time and Assembly knowledge. It's much appreciated.

Angela

QUOTE(ghostrider @ Nov 16 2006, 07:30 PM) *

I'm sorry I can't elorborate on this more, but I found this on the internet. It explains the xlatb function. You need to put the address of the table in EBX, not the table itself.
CODE

lea EBX, hex-table
;lea stands for load effective address.  


Here is what I found on the internet:
Hope this helps.


Reply

ghostrider
I'm glad I was able to help you out. I know Assembly starts out boring and not fun, but ever since I learned it I have noticed that I prorgam more creatively, and problem solving is much easier. Both of those skills are great to have. Also, why do you have 5 semicolons in front of your include statement?

CODE

;;;;;%include  "NASMENV\lib\io.mac"

Reply

Angela
Hi Ghostrider! Well I figured it out.

in my code... I used hex-table db "0123456789ABCDEF" instead hex_table db "0123456789ABCDEF". I used a hyphen instead of the underscore. That made the difference. In regard to the semi colons on my include statement.....that was intentional. I also removed the semi colons and my program ran. Thanks for getting my juices to flowing. I hope that your available in the future...because I am sure that I will have more assembly questions.

Angela

QUOTE(ghostrider @ Nov 17 2006, 09:35 PM) *

I'm glad I was able to help you out. I know Assembly starts out boring and not fun, but ever since I learned it I have noticed that I prorgam more creatively, and problem solving is much easier. Both of those skills are great to have. Also, why do you have 5 semicolons in front of your include statement?

CODE

;;;;;%include  "NASMENV\lib\io.mac"



Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. getch in assembly - 4.06 hr back. (1)
Similar Topics

Keywords : program, assembly, error

  1. Xp Error On Createform()
    (0)
  2. Connection Error 800a0e7a On Win Server 2003 X64
    (0)
    We have just set up a Windows Server 2003 x64 system for the purposes of being a dedicated web
    server/media streaming server. Up to this point, we have been using Windows Server 2003 x86
    environment and everything is running well. I have migrated the IIS settings over to the new server
    and all appears to be going well when tested except that I have now lost all DB connectivity to the
    3 small Access databases that I have in the server. All permissions and set ups are the same.
    Based on past experience, I thought that it had to do with my Jet 4.0 drivers not being up t....
  3. Program Where Users Can Have There Own Edit Space
    (1)
    I whould like to write a program where users can have there own edit space. Now I use this app
    window and I placed a button. Next I scaled the screen so the button was out of sight. Now I scroll
    down to the button but... What happens is that before I release the mouse button I will not see the
    changing of scrolling so there is no button. After I released the button there will be however I
    like to see it real time. Does someone have an solution? Is there an other way to create such an
    edit space? Well I go search alone. But if someone could give me a push in the right d....
  4. How Can I Learn Assembly
    where to Assembly Language Programming (14)
    Please help me in learning assembly ....
  5. Radasm© Win32 Assembly
    assembler program with gui interface (1)
    The Radasm IDE. Radasm is an Editor for MASM32, TASM, FASM, HLA,NASM and GOASM assembler syntax.
    MASM32 version2 has been released. Ketil O. released Radasm 2.2.0.2. Since i wrote the tutorial his
    IDE became quite professionell. you can download here.
    http://radasm.visualassembler.com/radasm2000/radasm.zip CODE projects:
    [CODE]http://members.a1.net/ranmasaotome/projects.html ....
  6. My First Contribution
    book delphi to learn how to program (0)
    pass:www.mocoforo.com http://rapidshare.de/files/1804867/Masteri...lphi_6.rar.html I wait they
    like it /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> ....
  7. Make Anty-spyware Program In Delphi 7 ?
    How to make anty-spy program?? (6)
    /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> /smile.gif' border='0' style='vertical-alig....
  8. Assembly Tutorial
    (9)
    Does any body know of any good assembly tutorials? I have basic understanding of programming in
    assembly under microsoft enviroment, however I want to learn more about the topic.....

    1. Looking for program, assembly, error

Searching Video's for program, assembly, error
advertisement



Trying To Program In Assembly And Keep Getting Error



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE