0

I am really new to Assembly programming. Its been 2 weeks since our lecturer starting teaching assembly programming using FASM. He gave us the above question to solve using memory addressing and I am really stuck. He only taught us the mov instructions until now and dint go into much details. So, i am wondering if anyone can help me solve this problem.

Since, he told us to retrieve from the memory. So, i used a variable to store it in the memory. This is what i tried so far

 #fasm#

org 100h

mov ah,2 
var db 67  
mov bh, [var]
mov dl,bh

int 21h
int 20h
Melissa
  • 41
  • 9
  • @JoseManuelAbarcaRodríguez:- I have edited and added the missing part. Thats all i have. – Melissa Jun 18 '15 at 19:06
  • Melissa, your little program works fine, when I run it I see "C" on screen, what is the problem? I'm using EMU8086. – Jose Manuel Abarca Rodríguez Jun 18 '15 at 19:07
  • 1
    Yeah, accidentally. The `var db 67` gets executed as `inc bx` which is harmless and a single byte opcode. It's not a good practice to put data in the middle of code though :) – Jester Jun 18 '15 at 19:24
  • @JoseManuelAbarcaRodríguez:- Thank you for that. My lecturer told us to solve the same question first one using the data from the memory and the second time he asked us to reference the memory address of the variable using a register. I think the one i used is addressing the memory, how can i get the data from the memory and print it on the screen? Thank u so much – Melissa Jun 18 '15 at 19:27
  • @Jester:- Write a program that gets the character 'C' from memory then prints it on screen Write a program that get the character 'C' from memory, but this time, reference the memory address using a register – Melissa Jun 18 '15 at 19:29
  • @JoseManuelAbarcaRodríguez:- Thank you very much for your help. Can you suggest me a good book for assembly programming using fasm assembler for a beginner like me? My lecturer doesn't explain the things in detail and a good reference book/tutorials can help me lot. Thank you – Melissa Jun 18 '15 at 19:42
  • StackOverflow is better than anybook : use google like this = "stackoverflow assembly print string" (for example), and you will find what you want to learn. Everything you need is already here, just like this question you asked today. Another example : "stackoverflow assembly how to write to file". – Jose Manuel Abarca Rodríguez Jun 18 '15 at 19:44
  • @JoseManuelAbarcaRodríguez:- Thank you Jose. I am also following the online manual of flat assembler. Its really helping me a lot. – Melissa Jun 18 '15 at 19:48

3 Answers3

0

That's pretty much it, except you don't want your data in the middle of code. Put it after the code, such as:

org 100h

mov ah,2 
mov bh, [var]
mov dl,bh

int 21h
int 20h
var db 67  
Jester
  • 56,577
  • 4
  • 81
  • 125
  • :- Thank you for that. My lecturer told us to solve the same question first one using the data from the memory and the second time he asked us to reference the memory address of the variable using a register. I think the one i used is addressing the memory, how can i get the data from the memory and print it on the screen? Thank u so much – Melissa Jun 18 '15 at 19:26
  • 1
    This one used the data. I believe your lecturer wants something like `lea bx, [var]; mov dl, [bx]` for addressing. – Jester Jun 18 '15 at 19:29
0

This is what @Jester means:

org 100h

mov ah,2 
;mov bh, [var]
lea si, [var]  ;"SI" REFERENCES THE VARIABLE. LEA = LOAD EFFECTIVE ADDRESS.
mov dl,[si]    ;GET THE DATA THROUGH THE MEMORY REFERENCE.

int 21h
int 20h
var db 67      ;JESTER IS RIGHT: VARIABLES AT THE BOTTOM.
0
org 100h

mov ah,2 
mov dl,[var]

int 21h
int 20h
var db 67
NoName
  • 1
  • 2