Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,804 members, 7,810,094 topics. Date: Friday, 26 April 2024 at 08:35 PM

Any Assembly Language Programmer Here? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Any Assembly Language Programmer Here? (4258 Views)

Any Female Python Programmer Here?? / Who And Know Who Is The Youngest Programmer Here / Female Programmer Here: Please Help (c Language) (2) (3) (4)

(1) (Reply) (Go Down)

Any Assembly Language Programmer Here? by Javanian: 11:35pm On Oct 13, 2014
Please are there any Assembly Language Programmers here? undecided Preferably the x86 family, but any would do.
Re: Any Assembly Language Programmer Here? by Jasi7(m): 11:53pm On Oct 13, 2014
Javanian:
Please are there any Assembly Language Programmers here? undecided Preferably the x86 family, but any would do.

I need ur help bro on a question pls
Re: Any Assembly Language Programmer Here? by soldierdollar(m): 8:40am On Oct 14, 2014
I program microcontrollers with assembly language
Re: Any Assembly Language Programmer Here? by Javanian: 1:14pm On Oct 14, 2014
soldierdollar:
I program microcontrollers with assembly language

Cool. Please can i ask you some questions? I'm having difficulty grasping some of it.
Re: Any Assembly Language Programmer Here? by Javanian: 1:15pm On Oct 14, 2014
Jasi7:


I need ur help bro on a question pls

I'm all ears boss.
Re: Any Assembly Language Programmer Here? by soldierdollar(m): 1:49pm On Oct 14, 2014
Javanian:


Cool. Please can i ask you some questions? I'm having difficulty grasping some of it.

go ahead
Re: Any Assembly Language Programmer Here? by Javanian: 2:07pm On Oct 14, 2014

nodata segment
db ?
nodata ends
text segment
assume cs:text, ds:nodata
mov ax, seg nodata
mov ds, ax
inc bx
mov cx, bx
push bx


This is a code snippet culled from a program. I didn't paste the complete code. Please at line 9, what is the value of bx before and after 'inc bx' is called? Does it mean the bx register is given some default value by the operating system or is it by the programmer?
Re: Any Assembly Language Programmer Here? by CodeHouse: 2:47pm On Oct 14, 2014
Javanian:

nodata segment
db ?
nodata ends
text segment
assume cs:text, ds:nodata
mov ax, seg nodata
mov ds, ax
inc bx
mov cx, bx
push bx


This is a code snippet culled from a program. I didn't paste the complete code. Please at line 9, what is the value of bx before and after 'inc bx' is called? Does it mean the bx register is given some default value by the operating system or is it by the programmer?


From my rusty knowledge of AL, The inc instruction will increase any operand by 1..depending on if you got the complete code or not where bx register was assigned a value somewhere
Re: Any Assembly Language Programmer Here? by Javanian: 2:52pm On Oct 14, 2014
CodeHouse:



From my rusty knowledge of AL, The inc instruction will increase any operand by 1..depending on if you got the complete code or not where bx register was assigned a value somewhere

I know exactly what Inc does. The issue is that in the code nothing is assigned to bx before it is incremented but yet the code still works.
Re: Any Assembly Language Programmer Here? by CodeHouse: 3:09pm On Oct 14, 2014
Javanian:


I know exactly what Inc does. The issue is that in the code nothing is assigned to bx before it is incremented but yet the code still works.

I expected it to run when I saw your code, assume it to be default increament on the 32-bit register since the syntax for inc is:

INC operand
Thesame way INC [Count] will run to cause increament in the count variable

1 Like

Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 3:27pm On Oct 14, 2014
If the code worked as u expected it to then the os definitely must have initialized the bx register to 0 though its usually advised to initialize ur registers (general purpose registers) before using them to avoid undefined behaviour.
Check this link for a brief info [url]stackoverflow.com/questions/9147455/what-is-default-register-state-when-program-launches-asm-linux[/url]

1 Like

Re: Any Assembly Language Programmer Here? by Javanian: 9:35pm On Oct 14, 2014
CodeHouse:


I expected it to run when I saw your code, assume it to be default increament on the 32-bit register since the syntax for inc is:

INC operand
Thesame way INC [Count] will run to cause increament in the count variable

Thanks.

BlueMagnificent:
If the code worked as u expected it to then the os definitely must have initialized the bx register to 0 though its usually advised to initialize ur registers (general purpose registers) before using them to avoid undefined behaviour.
Check this link for a brief info [url]stackoverflow.com/questions/9147455/what-is-default-register-state-when-program-launches-asm-linux[/url]

Thanks for this, it really helped.

Another question.

How can i check the values of all my registers at run time? How can i print to console?

e.g

mov ax, 6
mov cx, 5
mov bx, 6
add ax, bx

How can i display the values of all this registers to console?

I know how to use

mov dl, 'x'
mov ah, 02h
int 21h

to print characters

and also how to use

lea dx, string
mov ah, 09h
int 21h

to print strings, but i can't get them to print values of my registers.
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 11:31pm On Oct 14, 2014
Javanian:


Another question.
How can i check the values of all my registers at run time? How can i print to console?

e.g

mov ax, 6
mov cx, 5
mov bx, 6
add ax, bx

How can i display the values of all this registers to console?

I know how to use

mov dl, 'x'
mov ah, 02h
int 21h

to print characters

and also how to use

lea dx, string
mov ah, 09h
int 21h

to print strings, but i can't get them to print values of my registers.

That seems to be really difficult to do using dos-asm api but if you are working with win32 asm all u have to do is call the console output routine after pushing the value of the intended register unto the stack as parameter
Re: Any Assembly Language Programmer Here? by Javanian: 4:06am On Oct 15, 2014
BlueMagnificent:


That seems to be really difficult to do using dos-asm api but if you are working with win32 asm all u have to do is call the console output routine after pushing the value of the intended register unto the stack as parameter

I am using masm32. How can i do this?

1 Like

Re: Any Assembly Language Programmer Here? by tsleazy(m): 8:21am On Oct 15, 2014
Javanian:


I know exactly what Inc does. The issue is that in the code nothing is assigned to bx before it is incremented but yet the code still works.
That awkward moment, i may have already seen you in Uniben....physical science...lol
Re: Any Assembly Language Programmer Here? by Javanian: 9:20am On Oct 15, 2014
tsleazy:
that awkward moment, that may have already seen you in Uniben....physical science...lol

cool
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 9:33am On Oct 15, 2014
Javanian:


I am using masm32. How can i do this?

I'm trying to get my rusty asm head running lol...

Try and see if this works:

invoke StdOut, eax


assuming the value is store in eax. eax is the 32 bit equivalent of ax (actually ax is the lower order word of eax).
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 10:00am On Oct 15, 2014
BlueMagnificent:


I'm trying to get my rusty asm head running lol...

Try and see if this works:

invoke StdOut, eax


assuming the value is store in eax. eax is the 32 bit equivalent of ax (actually ax is the lower order word of eax).

the code above is not correct, my bad grin

first in ur .data? section

stringValue dd 5 dup(?)



then in the .code section

invoke dwtoa, eax, addr stringValue
invoke StdOut, addr stringValue
Re: Any Assembly Language Programmer Here? by Javanian: 1:16pm On Oct 15, 2014
Thanks but i am getting an 'undefiened symbol' compile assemble time error for both 'dwtoa' and 'StdOut'. Aren't they supposed to be declared somewhere?
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 2:36pm On Oct 15, 2014
Javanian:
Thanks but i am getting an 'undefiened symbol' compile assemble time error for both 'dwtoa' and 'StdOut'. Aren't they supposed to be declared somewhere?

include this file to the asm file:
\masm32\include\masm32rt.inc
Re: Any Assembly Language Programmer Here? by Javanian: 3:03pm On Oct 15, 2014
BlueMagnificent:


include this file to the asm file:
\masm32\include\masm32rt.inc

please how? Sorry if my questions are too many or too silly. Assembly language is just one hell of a language.
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 3:30pm On Oct 15, 2014
Javanian:


please how? Sorry if my questions are too many or too silly. Assembly language is just one hell of a language.

it sure is one hell of a language grin

I believe you are using masm32 that is Microsoft Macro Assembler for windows 32. What I mean by the above post is to include the file named "masw32rt.inc". This file should be in the include folder of ur masm32 installation. To include a file in asm simply type:
include filename
at the beginning of ur code. For example:
include masm32rt.inc
you might have to include the file path:
include \masm32\include\masm32rt.inc
Re: Any Assembly Language Programmer Here? by Javanian: 4:20pm On Oct 15, 2014
Yeah i am using Microsoft Assembler. I have included the file and i am getting another error but i think this one has to do with the structure of my code before invoking dwtoa and StdOut. Please can i get a simple code snippet that prints out the value of any register? Lets say cx register, a code i would be able to assemble and run so i can see where i went wrong.
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 6:42pm On Oct 15, 2014
Javanian:
Yeah i am using Microsoft Assembler. I have included the file and i am getting another error but i think this one has to do with the structure of my code before invoking dwtoa and StdOut. Please can i get a simple code snippet that prints out the value of any register? Lets say cx register, a code i would be able to assemble and run so i can see where i went wrong.

Sorry for the delay, I was away from my system. The below code works on my system, it should work for you too


include masm32rt.inc

.data?
stringValue dd 5 dup(?)
.code

main:
mov ebx, 12
invoke dwtoa, ebx, addr stringValue
invoke StdOut, addr stringValue

invoke ExitProcess, eax

end main

Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 6:45pm On Oct 15, 2014
Follow this link for a guide on how to setup Masm32 with visual studio (VS 2010)
http://scriptbucket./2011/10/19/setting-up-visual-studio-10-for-masm32-programming/
Re: Any Assembly Language Programmer Here? by Javanian: 9:35pm On Oct 15, 2014
Thanks, i actually already used visual studio. It works now, Words cannot express my gratitude. You have been immensely helpful. Thanks a lot.
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 10:11pm On Oct 15, 2014
Javanian:
Thanks, i actually already used visual studio. It works now, Words cannot express my gratitude. You have been immensely helpful. Thanks a lot.

You are welcomed smiley
Re: Any Assembly Language Programmer Here? by Nobody: 6:25am On May 30, 2017
BlueMagnificent:


You are welcomed smiley

Hey.
Sorry to disturb. This is an old thred but do you still use Assembly?
Re: Any Assembly Language Programmer Here? by BlueMagnificent(m): 11:22am On May 30, 2017
Gaara101:


Hey.
Sorry to disturb. This is an old thred but do you still use Assembly?

I rarely use it currently, but can help out if that's what you mean smiley
Re: Any Assembly Language Programmer Here? by SIXFEETUNDER: 12:46pm On Jan 20
Kek

(1) (Reply)

Learn Microcontroller PLC Ladder Logic Programming With Ldmicro Free On Youtube / My Journey To Getting A Remote Job / Mtn Api For Selling Mobile Applications That Is Of Nigerian Origin

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 36
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.